| 1 |
[PATCH] usb: print message when device is rejected due to insufficient power
|
| 2 |
|
| 3 |
2.6.16 introduces USB power budgeting in the Linux kernel, and since then, a
|
| 4 |
fair number of users have observed that some of their devices no longer work in
|
| 5 |
unpowered hubs (this is not a bug, the devices claim that they need more than
|
| 6 |
100mA).
|
| 7 |
|
| 8 |
The very least we can do is print an informational message to the kernel log
|
| 9 |
when this happens, otherwise it is not at all clear why the device was not
|
| 10 |
accepted.
|
| 11 |
|
| 12 |
Signed-off-by: Daniel Drake <dsd@gentoo.org>
|
| 13 |
|
| 14 |
Index: linux/drivers/usb/core/hub.c
|
| 15 |
===================================================================
|
| 16 |
--- linux.orig/drivers/usb/core/hub.c
|
| 17 |
+++ linux/drivers/usb/core/hub.c
|
| 18 |
@@ -1171,6 +1171,7 @@ static int choose_configuration(struct u
|
| 19 |
u16 devstatus;
|
| 20 |
int bus_powered;
|
| 21 |
int num_configs;
|
| 22 |
+ int insufficient_power = 0;
|
| 23 |
struct usb_host_config *c, *best;
|
| 24 |
|
| 25 |
/* If this fails, assume the device is bus-powered */
|
| 26 |
@@ -1218,8 +1219,10 @@ static int choose_configuration(struct u
|
| 27 |
*/
|
| 28 |
|
| 29 |
/* Rule out configs that draw too much bus current */
|
| 30 |
- if (c->desc.bMaxPower * 2 > udev->bus_mA)
|
| 31 |
+ if (c->desc.bMaxPower * 2 > udev->bus_mA) {
|
| 32 |
+ insufficient_power++;
|
| 33 |
continue;
|
| 34 |
+ }
|
| 35 |
|
| 36 |
/* If the first config's first interface is COMM/2/0xff
|
| 37 |
* (MSFT RNDIS), rule it out unless Linux has host-side
|
| 38 |
@@ -1253,6 +1256,11 @@ static int choose_configuration(struct u
|
| 39 |
best = c;
|
| 40 |
}
|
| 41 |
|
| 42 |
+ if (insufficient_power > 0)
|
| 43 |
+ dev_info(&udev->dev, "rejected %d configuration%s "
|
| 44 |
+ "due to insufficient available bus power\n",
|
| 45 |
+ insufficient_power, plural(insufficient_power));
|
| 46 |
+
|
| 47 |
if (best) {
|
| 48 |
i = best->desc.bConfigurationValue;
|
| 49 |
dev_info(&udev->dev,
|