[PATCH] Only treat lasting over-current conditions as errors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On a laptop I see these errors on (most) resumes:
    hub 3-0:1.0: over-current change on port 1
    hub 3-0:1.0: over-current change on port 2

Since over-current conditions can disappear quite quickly it's better to
downgrade that message to debug level, recheck for an over-current
condition a little later and only treat an over-current condition as an
error if it still exists when it's rechecked.

Signed-off-by: Paul Bolle <pebolle@xxxxxxxxxx>
---
This seems to do the trick. Note that this patch took some (educated)
guesswork about the kernel's USB API, so a review would appreciated.

Also note that hub over-current changes are currently handled rather
differently. Is there a reason to treat these events differently?

 drivers/usb/core/hub.c |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index d041c68..2309600 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -3412,12 +3412,27 @@ static void hub_events(void)
                        }
                        
                        if (portchange & USB_PORT_STAT_C_OVERCURRENT) {
-                               dev_err (hub_dev,
+                               u16 status;
+                               u16 unused;
+
+                               dev_dbg (hub_dev,
                                        "over-current change on port %d\n",
                                        i);
                                clear_port_feature(hdev, i,
                                        USB_PORT_FEAT_C_OVER_CURRENT);
-                               hub_power_on(hub, true);
+                               msleep(100);    /* Cool down */
+
+                               ret = hub_port_status(hub, i, &status,
+                                               &unused);
+                               if (ret < 0)
+                                       continue;
+
+                               if (status & USB_PORT_STAT_OVERCURRENT) {
+                                       dev_err (hub_dev,
+                                               "over-current condition on port "
+                                               "%d\n", i);
+                                       hub_power_on(hub, true);
+                               }
                        }
 
                        if (portchange & USB_PORT_STAT_C_RESET) {
-- 
1.7.4.1

--
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


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux