diff options
author | H Hartley Sweeten <hartleys@visionengravers.com> | 2012-05-17 01:18:52 (GMT) |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-05-17 02:19:06 (GMT) |
commit | 64255031bde68bd0f7ec934b83842619d513cf91 (patch) | |
tree | 9a217b39afe078045ff0740a2b2b4502e4d056fc /drivers/staging/comedi/drivers.c | |
parent | d896e0e4f45e925b2bf9a800ca85e613d68e2888 (diff) | |
download | linux-fsl-qoriq-64255031bde68bd0f7ec934b83842619d513cf91.tar.xz |
staging: comedi: Add helper macro for comedi usb driver boilerplate
Introduce the module_comedi_usb_driver macro, and the
associated register/unregister functions, which is a
convenience macro for comedi usb 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 usb
driver. By using this macro it is possible to eliminate
a few lines of boilerplate code per comedi usb driver.
Also, when registering the usb 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/drivers.c')
-rw-r--r-- | drivers/staging/comedi/drivers.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index 3a82950..1c3d638 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -1016,3 +1016,30 @@ void comedi_usb_auto_unconfig(struct usb_interface *intf) comedi_auto_unconfig(&intf->dev); } EXPORT_SYMBOL_GPL(comedi_usb_auto_unconfig); + +int comedi_usb_driver_register(struct comedi_driver *comedi_driver, + struct usb_driver *usb_driver) +{ + int ret; + + ret = comedi_driver_register(comedi_driver); + if (ret < 0) + return ret; + + ret = usb_register(usb_driver); + if (ret < 0) { + comedi_driver_unregister(comedi_driver); + return ret; + } + + return 0; +} +EXPORT_SYMBOL_GPL(comedi_usb_driver_register); + +void comedi_usb_driver_unregister(struct comedi_driver *comedi_driver, + struct usb_driver *usb_driver) +{ + usb_deregister(usb_driver); + comedi_driver_unregister(comedi_driver); +} +EXPORT_SYMBOL_GPL(comedi_usb_driver_unregister); |