• Alan Stern's avatar
    [PATCH] USB: Mark devices as NOTATTACHED as soon as possible · 63eee2ca
    Alan Stern authored
    This patch implements something we've been lacking for a long time: a way
    to mark devices as USB_STATE_NOTATTACHED as soon as we know that they're
    gone.  The usb_device->state member is no longer protected by the
    ->serialize semaphore; instead there's a new private spinlock.  Usbcore
    routines should no longer set ->state directly; instead they should use
    the new utility routine usb_set_device_state().  There are protections
    against changing states while devices are being added or removed.
    
    	Change assignments to udev->state into calls of
    	usb_set_device_state().
    
    	Add new private device_state_lock to the hub driver, along
    	with usb_set_device_state() and recursively_mark_NOTATTACHED().
    
    	Acquire the new spinlock while adding or removing children[]
    	pointers.
    
    	When disabling a port that has a child device, mark the child
    	as NOTATTACHED.
    
    You mentioned once having tried to do something like this and running into
    trouble.  Take a good look and let me know if you see any difficulties
    here.
    Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
    Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
    63eee2ca
usb.h 1.14 KB