Greg:
This patch removes the hub_set_power_budget routine, which was used by a
couple of HCDs to indicate that the root hub was running on battery power.
In its place is a new field added to struct usb_hcd, which HCDs can set
before the root hub is registered. Special-case code in the hub driver
knows to look at this field when configuring a root hub.
Alan Stern
Signed-off-by: Alan Stern <[EMAIL PROTECTED]>
diff -u a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h
--- a/drivers/usb/core/hcd.h Fri Apr 22 22:07:45 2005
+++ b/drivers/usb/core/hcd.h Sat Apr 23 14:52:22 2005
@@ -87,6 +87,7 @@
void __iomem *regs; /* device memory/io */
u64 rsrc_start; /* memory/io resource start */
u64 rsrc_len; /* memory/io resource length */
+ unsigned power_budget; /* in mA, 0 = no limit */
#define HCD_BUFFER_POOLS 4
struct dma_pool *pool [HCD_BUFFER_POOLS];
diff -u a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
--- a/drivers/usb/core/hub.c Fri Apr 22 13:24:46 2005
+++ b/drivers/usb/core/hub.c Sat Apr 23 11:04:25 2005
@@ -644,15 +644,21 @@
message = "can't get hub status";
goto fail;
}
- cpu_to_le16s(&hubstatus);
- if ((hubstatus & (1 << USB_DEVICE_SELF_POWERED)) == 0) {
+ le16_to_cpus(&hubstatus);
+ if (hdev == hdev->bus->root_hub) {
+ struct usb_hcd *hcd =
+ container_of(hdev->bus, struct usb_hcd, self);
+
+ hub->power_budget = min(500u, hcd->power_budget) / 2;
+ } else if ((hubstatus & (1 << USB_DEVICE_SELF_POWERED)) == 0) {
dev_dbg(hub_dev, "hub controller current requirement: %dmA\n",
hub->descriptor->bHubContrCurrent);
hub->power_budget = (501 - hub->descriptor->bHubContrCurrent)
/ 2;
+ }
+ if (hub->power_budget)
dev_dbg(hub_dev, "%dmA bus power budget for children\n",
hub->power_budget * 2);
- }
ret = hub_hub_status(hub, &hubstatus, &hubchange);
diff -u a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h
--- a/drivers/usb/core/hub.h Fri Apr 22 21:57:48 2005
+++ b/drivers/usb/core/hub.h Sat Apr 23 11:04:25 2005
@@ -224,15 +224,4 @@
struct work_struct leds;
};
-/* use this for low-powered root hubs */
-static inline void
-hub_set_power_budget (struct usb_device *hubdev, unsigned mA)
-{
- struct usb_hub *hub;
-
- hub = (struct usb_hub *)
- usb_get_intfdata (hubdev->actconfig->interface[0]);
- hub->power_budget = min(mA,(unsigned)500)/2;
-}
-
#endif /* __LINUX_HUB_H */
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel