]> err.no Git - linux-2.6/commitdiff
[PATCH] usbcore: Remove hub_set_power_budget
authorAlan Stern <stern@rowland.harvard.edu>
Mon, 25 Apr 2005 15:18:32 +0000 (11:18 -0400)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 27 Jun 2005 21:43:48 +0000 (14:43 -0700)
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.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Acked-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/core/hcd.h
drivers/usb/core/hub.c
drivers/usb/core/hub.h

index ac5752778e3985d12ec182bd4f85a90425556910..3837f68bb7b377062221fd9bfcd3381ce91da6da 100644 (file)
@@ -87,6 +87,7 @@ struct usb_hcd {      /* usb_bus.hcpriv points to this */
        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];
index 6d1a330d577b5ba5b1cfbab4a03bbe2a067fa76f..63ee3d97b6a968571bc1b706bd3e0cc4169f885c 100644 (file)
@@ -643,15 +643,21 @@ static int hub_configure(struct usb_hub *hub,
                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);
index d114b847d56f84e9ba0b1fb1b754283e02618eed..53bf5649621ef366485c4346e754cfc9f60ab893 100644 (file)
@@ -224,15 +224,4 @@ struct usb_hub {
        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 */