diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2011-11-17 17:38:33 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-11-17 17:38:33 -0500 |
commit | f3a6a4b6cfc80e57bf16bb12f9425bec1a5731a9 (patch) | |
tree | 5771513ef737b88392b1484c632fbc33d3d83fce /include/linux/usb.h | |
parent | ae6ae6fec3f7d6919e0146996df37b665c75f662 (diff) |
USB: Add helper macro for usb_driver boilerplate
This patch introduces the module_usb_driver macro which is a convenience
macro for USB driver modules similar to module_platform_driver. It is
intended to be used by drivers which init/exit section does nothing but
register/unregister the USB driver. By using this macro it is possible
to eliminate a few lines of boilerplate code per USB driver.
Based on work done by Lars-Peter Clausen <lars@metafoo.de> for other
busses (i2c and spi).
Cc: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'include/linux/usb.h')
-rw-r--r-- | include/linux/usb.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/include/linux/usb.h b/include/linux/usb.h index d3d0c1374334..5d258c3180ae 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h | |||
@@ -953,6 +953,18 @@ extern int usb_register_driver(struct usb_driver *, struct module *, | |||
953 | 953 | ||
954 | extern void usb_deregister(struct usb_driver *); | 954 | extern void usb_deregister(struct usb_driver *); |
955 | 955 | ||
956 | /** | ||
957 | * module_usb_driver() - Helper macro for registering a USB driver | ||
958 | * @__usb_driver: usb_driver struct | ||
959 | * | ||
960 | * Helper macro for USB drivers which do not do anything special in module | ||
961 | * init/exit. This eliminates a lot of boilerplate. Each module may only | ||
962 | * use this macro once, and calling it replaces module_init() and module_exit() | ||
963 | */ | ||
964 | #define module_usb_driver(__usb_driver) \ | ||
965 | module_driver(__usb_driver, usb_register, \ | ||
966 | usb_deregister) | ||
967 | |||
956 | extern int usb_register_device_driver(struct usb_device_driver *, | 968 | extern int usb_register_device_driver(struct usb_device_driver *, |
957 | struct module *); | 969 | struct module *); |
958 | extern void usb_deregister_device_driver(struct usb_device_driver *); | 970 | extern void usb_deregister_device_driver(struct usb_device_driver *); |