[PATCHv2 3/8] staging: comedi: das08: Use module_comedi_{pci_, }driver

Greg Kroah-Hartman gregkh at linuxfoundation.org
Tue Jun 5 03:35:40 UTC 2012


On Thu, May 24, 2012 at 06:06:01PM +0100, Ian Abbott wrote:
> On 2012-05-24 17:36, H Hartley Sweeten wrote:
> >On Thursday, May 24, 2012 9:27 AM, Ian Abbott wrote:
> >>If PCI boards are supported, use the module_comedi_pci_driver() macro to
> >>register the module as a comedi driver and a PCI driver.  Otherwise, if
> >>ISA (or PC/104) boards are supported, use the module_comedi_driver()
> >>macro to register the module as a comedi driver.  Otherwise, this is
> >>only a helper module for an external comedi driver (das08_cs).
> >>
> >>Signed-off-by: Ian Abbott<abbotti at mev.co.uk>
> >>---
> >
> ><snip>
> >
> >>+#else /* DO_COMEDI_DRIVER_REGISTER */
> >>+static int __init das08_init(void)
> >>+{
> >>+	return 0;
> >>  }
> >>
> >>-static void __exit driver_das08_cleanup_module(void)
> >>+static void __exit das08_exit(void)
> >>  {
> >>-#if IS_ENABLED(CONFIG_COMEDI_DAS08_PCI)
> >>-	pci_unregister_driver(&driver_das08_pci_driver);
> >>-#endif
> >>-#ifdef DO_COMEDI_DRIVER_REGISTER
> >>-	comedi_driver_unregister(&driver_das08);
> >>-#endif
> >>  }
> >>
> >>-module_init(driver_das08_init_module);
> >>-module_exit(driver_das08_cleanup_module);
> >>+module_init(das08_init);
> >>+module_exit(das08_exit);
> >>+#endif /* DO_COMEDI_DRIVER_REGISTER */
> >
> >When this file is only compiled to be used as a helper library
> >are the module_init/module_exit stubs even needed?
> 
> They used to be.  I wasn't aware things had changed.  The comments
> in <linux/init.h> suggest they're required:
> 
> /* Each module must use one module_init(). */
> #define module_init(initfn)	\
> ...
> /* This is only required if you want to be unloadable. */
> #define module_exit(exitfn)	\
> ...
> 
> >Take a look at the drivers/gpio/gpio-generic.c driver for an
> >example.
> 
> Hmm. :-\

Odd, I thought Ian was correct here, so I'll apply his patch, but if you
all test and find out it's not needed anymore, a follow-on one to remove
these lines is fine.

thanks,

greg k-h



More information about the devel mailing list