diff options
| author | Alan Stern <stern@rowland.harvard.edu> | 2012-02-23 14:55:59 -0500 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-02-24 15:39:17 -0500 |
| commit | 765e0ba62613fb90f09c1b5926750df0aa56f349 (patch) | |
| tree | a283130f8c0e4b70978e24012fbeafe4001b5dea /include/linux/usb | |
| parent | c69263c66e5b2a5d0c7e5a41c189b1846ae1de92 (diff) | |
usb-serial: new API for driver registration
This patch (as1522) adds two new routines to the usb-serial core, for
registering and unregistering serial drivers. Instead of registering
the usb_driver and usb_serial_drivers separately, with error checking
for each one, the drivers can all be registered and unregistered by a
single function call. This reduces duplicated code.
More importantly, the new core routines change the order in which the
drivers are registered. Currently the usb-serial drivers are all
registered first and the usb_driver is done last, which leaves a
window for problems. A udev script may quickly add a new dynamic-ID
for a usb-serial driver, causing the corresponding usb_driver to be
probed. If the usb_driver hasn't been registered yet then an oops
will occur.
The new routine prevents such problems by registering the usb_driver
first. To insure that it gets probed properly for already-attached
serial devices, we call driver_attach() after all the usb-serial
drivers have been registered.
Along with adding the new routines, the patch modifies the "generic"
serial driver to use them. Further patches will similarly modify all
the other in-tree USB serial drivers.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/usb')
| -rw-r--r-- | include/linux/usb/serial.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h index 10cb74d2ad1..8c8dbf9c5b8 100644 --- a/include/linux/usb/serial.h +++ b/include/linux/usb/serial.h | |||
| @@ -300,8 +300,17 @@ struct usb_serial_driver { | |||
| 300 | #define to_usb_serial_driver(d) \ | 300 | #define to_usb_serial_driver(d) \ |
| 301 | container_of(d, struct usb_serial_driver, driver) | 301 | container_of(d, struct usb_serial_driver, driver) |
| 302 | 302 | ||
| 303 | /* | ||
| 304 | * These two routines are kept only for backward compatibility. | ||
| 305 | * Don't use them; call usb_serial_{de}register_drivers() instead. | ||
| 306 | */ | ||
| 303 | extern int usb_serial_register(struct usb_serial_driver *driver); | 307 | extern int usb_serial_register(struct usb_serial_driver *driver); |
| 304 | extern void usb_serial_deregister(struct usb_serial_driver *driver); | 308 | extern void usb_serial_deregister(struct usb_serial_driver *driver); |
| 309 | |||
| 310 | extern int usb_serial_register_drivers(struct usb_driver *udriver, | ||
| 311 | struct usb_serial_driver * const serial_drivers[]); | ||
| 312 | extern void usb_serial_deregister_drivers(struct usb_driver *udriver, | ||
| 313 | struct usb_serial_driver * const serial_drivers[]); | ||
| 305 | extern void usb_serial_port_softint(struct usb_serial_port *port); | 314 | extern void usb_serial_port_softint(struct usb_serial_port *port); |
| 306 | 315 | ||
| 307 | extern int usb_serial_probe(struct usb_interface *iface, | 316 | extern int usb_serial_probe(struct usb_interface *iface, |
