From: Greg Kroah-Hartman <gregkh@xxxxxxx> 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@xxxxxxxxxx> for other busses (i2c and spi). Cc: Lars-Peter Clausen <lars@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxx> --- I'm going through the tree and converting all drivers to this format, it ends up saving about 10-20 lines a driver, which is nice win overall. 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 d3d0c13..5d258c3 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 *, extern void usb_deregister(struct usb_driver *); +/** + * module_usb_driver() - Helper macro for registering a USB driver + * @__usb_driver: usb_driver struct + * + * Helper macro for USB 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_usb_driver(__usb_driver) \ + module_driver(__usb_driver, usb_register, \ + usb_deregister) + extern int usb_register_device_driver(struct usb_device_driver *, struct module *); extern void usb_deregister_device_driver(struct usb_device_driver *); -- 1.7.7.3 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html