[PATCH] USB: Superficial improvements to hub_port_debounce()
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: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Showing
Please register or sign in to comment