All of lore.kernel.org
 help / color / mirror / Atom feed
* proper place for devfs_register_chrdev with pci_module_init
@ 2004-02-04 20:23 Oliver Dain
  2004-02-04 21:30 ` Richard B. Johnson
  0 siblings, 1 reply; 7+ messages in thread
From: Oliver Dain @ 2004-02-04 20:23 UTC (permalink / raw)
  To: linux-kernel

I'm writing a char driver for a PCI card.  Looking at examples of such things I've found that most have a module_init like this:

int foo_init(void)
{
	/* stuff... */
	devfs_register_chrdev(...);
	/* more stuff... */
	pci_module_init(...);
}

This seems strange to me.  The devfs_register_chrdev call will register the module and cause it to be held in memory even if the associated PCI device isn't present on the system.  It seems like a better way to do this is to have the init method just call pci_module_init(...) and then in that method, after the PCI device has been initialized, call devfs_register_chrdev to associate the driver with the device.  That way the kernel can unload the module if no such device is present, but if the device is present (or if one appears via hotplug) the module will be loaded and can then register itself.  Will this work?  Is there a reason people don't do this?

I'm not subscribed to the LKML so please CC me on any responses.

Thanks,
Oliver

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2004-02-05 15:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-04 20:23 proper place for devfs_register_chrdev with pci_module_init Oliver Dain
2004-02-04 21:30 ` Richard B. Johnson
2004-02-04 21:48   ` odain2
2004-02-04 22:29     ` Richard B. Johnson
2004-02-04 23:34       ` Greg KH
2004-02-05 12:42         ` Richard B. Johnson
2004-02-05 15:27           ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.