• Alan Stern's avatar
    [PATCH] USB: Superficial improvements to hub_port_debounce() · f4692b3e
    Alan Stern authored
    Since my previous suggestions for changes to hub_port_debounce()
    encountered so much resistance, this patch makes some fairly superficial
    improvements to the code while leaving the logic of the algorithm almost
    completely intact.  The only behavioral change is that it actually
    requests the port status at the start, rather than assuming the status is
    not CONNECTED.  Changes include:
    
    	Vastly improved comments that are now unambiguous and accurately
    	descriptive of the code.
    
    	Local variables changed to more sensible names.  The stability
    	period is now reported in milliseconds rather than a meaningless
    	poll count.
    
    	The sleep interval is moved from the start of the loop to the
    	end, so that the first time through we read the port status
    	immediately.
    
    	If the connection has not stabilized after the total timeout
    	expires, -ETIMEDOUT is returned rather than whatever the
    	current connect status happens to be.
    
    	If the connection does stabilize then the port status is returned
    	so that hub_port_connect_change() will have an up-to-date value
    	for the status rather than relying on the pre-debounce value.
    
    The changes I wanted to make but other people were worried about are
    included as comments.  A later (small) patch will uncomment them for
    testing.
    Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
    Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
    f4692b3e
hub.c 51.3 KB