diff options
author | Greg KH <gregkh@linuxfoundation.org> | 2012-02-24 18:38:14 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-02-28 14:21:48 -0500 |
commit | d1cddb4a8e9b09c33158acae05c48069d74fa4d0 (patch) | |
tree | e1ab740cc4a6905ef0a520dd79ecdbac041585a1 /include/linux/usb/serial.h | |
parent | 03892d5fefbe7d4df68466bd4cfda86fac84ebd8 (diff) |
USB: create module_usb_serial_driver macro
Now that Alan Stern has cleaned up the usb serial driver registration,
we have the ability to create a module_usb_serial_driver macro to make
things a bit simpler, like the other *_driver macros created.
But, as we need two functions here, we can't reuse the existing
module_driver() macro, so we need to roll our own.
Here's a patch implementing module_usb_serial_driver() and it converts
the pl2303 driver to use it, showing a nice cleanup.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/usb/serial.h')
-rw-r--r-- | include/linux/usb/serial.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h index 34c06a723dcc..7b1db841e2a8 100644 --- a/include/linux/usb/serial.h +++ b/include/linux/usb/serial.h | |||
@@ -406,5 +406,33 @@ do { \ | |||
406 | } \ | 406 | } \ |
407 | } while (0) | 407 | } while (0) |
408 | 408 | ||
409 | /* | ||
410 | * module_usb_serial_driver() - Helper macro for registering a USB Serial driver | ||
411 | * @__usb_driver: usb_driver struct to register | ||
412 | * @__serial_drivers: list of usb_serial drivers to register | ||
413 | * | ||
414 | * Helper macro for USB serial drivers which do not do anything special | ||
415 | * in module init/exit. This eliminates a lot of boilerplate. Each | ||
416 | * module may only use this macro once, and calling it replaces | ||
417 | * module_init() and module_exit() | ||
418 | * | ||
419 | * Note, we can't use the generic module_driver() call here, due to the | ||
420 | * two parameters in the usb_serial_* functions, so we roll our own here | ||
421 | * :( | ||
422 | */ | ||
423 | #define module_usb_serial_driver(__usb_driver, __serial_drivers) \ | ||
424 | static int __init usb_serial_driver_init(void) \ | ||
425 | { \ | ||
426 | return usb_serial_register_drivers(&(__usb_driver), \ | ||
427 | (__serial_drivers)); \ | ||
428 | } \ | ||
429 | module_init(usb_serial_driver_init); \ | ||
430 | static void __exit usb_serial_driver_exit(void) \ | ||
431 | { \ | ||
432 | return usb_serial_deregister_drivers(&(__usb_driver), \ | ||
433 | (__serial_drivers)); \ | ||
434 | } \ | ||
435 | module_exit(usb_serial_driver_exit); | ||
436 | |||
409 | #endif /* __LINUX_USB_SERIAL_H */ | 437 | #endif /* __LINUX_USB_SERIAL_H */ |
410 | 438 | ||