-
Alan Stern authored
On Fri, 27 Feb 2004, Greg KH wrote: > On Wed, Feb 25, 2004 at 10:05:37AM -0500, Alan Stern wrote: > > > Why would anyone want to do this, you ask? Well the USB subsystem does it > > already. Each USB device can have several configurations, only one of > > which is active at any time. Corresponding to each configuration is a set > > of struct devices, and they (together with their embedded kobjects) are > > allocated and initialized when the USB device is first detected. The > > struct devices are add()'ed and del()'ed as configurations are activated > > and deactivated, leading to just the sort of call sequence shown above. > > Then we need to fix this. The driver model does not support repeated device_add(), device_del(), device_add(), device_del(), ... calls for the same device. But that's what happens to an interface's embedded struct device when we change configurations. Accordingly, this patch changes the device_add()/device_del() calls for interfaces to device_register()/device_unregister(). When the interface is unregistered the new code waits for the release method to run, so that it will be safe to re-register the interface should the former configuration be reinstated. Greg, please check this out to make sure I haven't made some dumb mistake. It works on my system and it fixes a memory leak in the USB system.
aa36bfd2