On Fri, 24 Feb 2012, Greg KH wrote: > On Thu, Feb 23, 2012 at 02:55:34PM -0500, Alan Stern wrote: > > Greg: > > > > This series of patches adds a new, simpler API to the usb-serial core > > for registering drivers, and changes all the existing drivers to use > > it. Instead of making separate calls to register the usb_driver and > > one or more usb_serial drivers, everything can be done with a single > > function call. Likewise for deregistration. > > > > In addition, the order of registration is changed; the new routine will > > register the usb_driver first. Currently each of the serial drivers > > registers its usb_driver last, which leaves a window for a bug: If a > > new dynamic-ID is added to the usb_serial driver before its usb_driver > > is registered (say by a udev script), it causes an oops. > > > > This doesn't seem to be a very serious problem; so far there has been > > only one complaint about it. For that reason, and because this is a > > somewhat lengthy set of changes, I'm not going to submit it for the > > stable kernels. > > > > I have been able to test this only with the pl2303 driver. All the > > other drivers are merely compile-tested. > > I'm trying to remember why the ordering was set up this way, there was a > good reason (good enough that we had to fix drivers that were doing it > backwards.) But I can't remember it at the moment. It has to do with binding of pre-existing devices. If you don't take proper care when first registering the usb_driver, the core will try to bind that driver to all the pre-existing serial devices it matches. But the bindings will fail, because usb-serial won't be able to find the appropriate usb_serial drivers. As a result, the devices won't get bound at all. My patch takes care of this. Initially it sets the usb_driver's id_table to NULL, so that there won't be any doomed binding attempts. Then after all the usb_serial drivers have been registered, it calls driver_attach() to force the bindings to take place. Now that all the drivers have been registered, the bindings will succeed. > Worse case, we have to switch it back, or fix it up somehow differently, > this patch series will make it easier to do so in the future, so I'll go > queue it up. Thanks for doing this work, it's much appreciated. You're welcome. Overall, it removes a lot of lines of duplicated code from the source tree. Alan Stern -- 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