summaryrefslogtreecommitdiff
path: root/drivers/staging/comedi/comedidev.h
diff options
context:
space:
mode:
authorH Hartley Sweeten <hartleys@visionengravers.com>2012-05-11 23:15:39 (GMT)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-05-14 20:48:47 (GMT)
commitd4899c6ff86ea9836c89250cb2127aa64765b35a (patch)
treec77672087fe5d0cde437e64c2bfb08f80b036d96 /drivers/staging/comedi/comedidev.h
parent5a81b4a0b673bf34823191a83318377c0e66e713 (diff)
downloadlinux-fsl-qoriq-d4899c6ff86ea9836c89250cb2127aa64765b35a.tar.xz
staging: comedi: Add helper macro for comedi pci driver boilerplate
Introduce the module_comedi_pci_driver macro, and the associated register/unregister functions, which is a convenience macro for comedi pci driver modules similar to module_platform_driver. It is intended to be used by drivers where the init/exit section does nothing but register/unregister the comedi driver and associated pci driver. By using this macro it is possible to eliminate a few lines of boilerplate code per comedi pci driver. Add a check to make sure that the pci_driver->name is set. Once all the comedi pci drivers have been fixed this will be removed. Also, when registering the pci driver check for failure and unregister the comedi driver. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Cc: Mori Hess <fmhess@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/comedi/comedidev.h')
-rw-r--r--drivers/staging/comedi/comedidev.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h
index 8828609..92a1199 100644
--- a/drivers/staging/comedi/comedidev.h
+++ b/drivers/staging/comedi/comedidev.h
@@ -310,6 +310,25 @@ int comedi_driver_unregister(struct comedi_driver *);
module_driver(__comedi_driver, comedi_driver_register, \
comedi_driver_unregister)
+struct pci_driver;
+
+int comedi_pci_driver_register(struct comedi_driver *, struct pci_driver *);
+void comedi_pci_driver_unregister(struct comedi_driver *, struct pci_driver *);
+
+/**
+ * module_comedi_pci_driver() - Helper macro for registering a comedi PCI driver
+ * @__comedi_driver: comedi_driver struct
+ * @__pci_driver: pci_driver struct
+ *
+ * Helper macro for comedi PCI drivers which do not do anything special
+ * in module init/exit. This eliminates a lot of boilerplate. Each
+ * module may only use this macro once, and calling it replaces
+ * module_init() and module_exit()
+ */
+#define module_comedi_pci_driver(__comedi_driver, __pci_driver) \
+ module_driver(__comedi_driver, comedi_pci_driver_register, \
+ comedi_pci_driver_unregister, &(__pci_driver))
+
void init_polling(void);
void cleanup_polling(void);
void start_polling(struct comedi_device *);