On Tue, May 08, 2012 at 03:33:09PM -0400, Alan Stern wrote: > On Tue, 8 May 2012, Greg Kroah-Hartman wrote: > > > This reworks the usb_serial_register_drivers() and > > usb_serial_deregister_drivers() to not need a pointer to a struct > > usb_driver anymore. The usb_driver structure is created dynamically and > > registered and unregistered as needed. > > > > > > Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> > > > > --- > > drivers/usb/serial/generic.c | 9 ++------- > > drivers/usb/serial/usb-serial.c | 30 ++++++++++++++++++------------ > > include/linux/usb/serial.h | 27 +++++++++++++++++++-------- > > 3 files changed, 39 insertions(+), 27 deletions(-) > > > > Untested, but I think this will work. It makes the usb-serial drivers > > smaller, which is always nice, I'll follow-on with a patch for what is > > needed to convert the individual drivers. > > Yes, this is the next logical step. > > > Any objections? > > Just that you ought to update a few of the comments to match the new > code better. > > Oh, and one more thing. The old usb_serial_register() routine still > contains a test for !driver->usb_driver which is now unnecessary. You > could remove it. Ah, nice catch. > > diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c > > index d1840ae..dd5e7ca 100644 > > --- a/drivers/usb/serial/usb-serial.c > > +++ b/drivers/usb/serial/usb-serial.c > > @@ -1364,18 +1364,21 @@ static void usb_serial_deregister(struct usb_serial_driver *device) > > > > /** > > * usb_serial_register_drivers - register drivers for a usb-serial module > > - * @udriver: usb_driver used for matching devices/interfaces > > * @serial_drivers: NULL-terminated array of pointers to drivers to be registered > > + * @name: name of the usb_driver for this set of @serial_drivers > > + * @id_table: list of all devices this @serial_drivers set binds to > > * > > - * Registers @udriver and all the drivers in the @serial_drivers array. > > + * Registers all the drivers in the @serial_drivers array, and a struct usb_driver > > + * with the name @name. > > * Automatically fills in the .no_dynamic_id and PM fields in @udriver and > > * the .usb_driver field in each serial driver. > > The last two lines should mention that the usb_driver structure is > allocated dynamically and filled in with @name, @id_table, and the > usb-serial core method pointers (in addition to the part about the > .usb_driver field in each serial driver). Will fix up. > > @@ -1412,7 +1417,7 @@ int usb_serial_register_drivers(struct usb_driver *udriver, > > } > > > > /* Now restore udriver's id_table and look for matches */ > > This comment and the one earlier about saving off the id_table are now > out of date. The field doesn't get saved any more; we just avoid > filling it in until the right time. Will fix up. > > - udriver->id_table = saved_id_table; > > + udriver->id_table = id_table; > > rc = driver_attach(&udriver->drvwrap.driver); > > return 0; > > > > @@ -1426,17 +1431,18 @@ EXPORT_SYMBOL_GPL(usb_serial_register_drivers); > > > > /** > > * usb_serial_deregister_drivers - deregister drivers for a usb-serial module > > - * @udriver: usb_driver to unregister > > * @serial_drivers: NULL-terminated array of pointers to drivers to be deregistered > > * > > - * Deregisters @udriver and all the drivers in the @serial_drivers array. > > + * Deregisters all the drivers in the @serial_drivers array. > > Also dregisters and deallocates the corresponding usb_driver structure. Will fix up. > > @@ -396,8 +395,8 @@ do { \ > > > > /* > > * module_usb_serial_driver() - Helper macro for registering a USB Serial driver > > - * @__usb_driver: usb_driver struct to register > > * @__serial_drivers: list of usb_serial drivers to register > > + * @__ids: all device ids that @__serial_drivers bind to > > Missing a line for @__name: Ah, good catch. This macro went through a zillion different variations, I was trying to embed KBUILD_MODNAME into it automagically for a while before giving up on that, which is why I forgot the @name usage. Thanks for reviewing, I'll fix these up, clean up the other usb-serial drivers, and test it before sending it out again. greg k-h -- 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