aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKrzysztof Mazur <krzysiek@podlesie.net>2013-08-22 08:49:40 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-08-23 13:47:17 -0400
commit3bbc47d8b07abad56780a8e214520259808c4f8b (patch)
tree6a7bf12ca876302c8ecf200c1ec1c9e476ebe3bf
parente58547eb9561a8a72d46e2d411090a614d33ac0e (diff)
usb: don't use bNbrPorts after initialization
After successful initialization hub->descriptor->bNbrPorts and hub->hdev->maxchild are equal, but using hub->hdev->maxchild is preferred because that value is explicitly used for initialization of hub->ports[]. Signed-off-by: Krzysztof Mazur <krzysiek@podlesie.net> Acked-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/usb/core/hub.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 79ec4a7640cd..5d859fc07610 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -451,7 +451,7 @@ static void led_work (struct work_struct *work)
451 if (hdev->state != USB_STATE_CONFIGURED || hub->quiescing) 451 if (hdev->state != USB_STATE_CONFIGURED || hub->quiescing)
452 return; 452 return;
453 453
454 for (i = 0; i < hub->descriptor->bNbrPorts; i++) { 454 for (i = 0; i < hdev->maxchild; i++) {
455 unsigned selector, mode; 455 unsigned selector, mode;
456 456
457 /* 30%-50% duty cycle */ 457 /* 30%-50% duty cycle */
@@ -500,7 +500,7 @@ static void led_work (struct work_struct *work)
500 } 500 }
501 if (!changed && blinkenlights) { 501 if (!changed && blinkenlights) {
502 cursor++; 502 cursor++;
503 cursor %= hub->descriptor->bNbrPorts; 503 cursor %= hdev->maxchild;
504 set_port_led(hub, cursor + 1, HUB_LED_GREEN); 504 set_port_led(hub, cursor + 1, HUB_LED_GREEN);
505 hub->indicator[cursor] = INDICATOR_CYCLE; 505 hub->indicator[cursor] = INDICATOR_CYCLE;
506 changed++; 506 changed++;
@@ -830,7 +830,7 @@ static unsigned hub_power_on(struct usb_hub *hub, bool do_delay)
830 else 830 else
831 dev_dbg(hub->intfdev, "trying to enable port power on " 831 dev_dbg(hub->intfdev, "trying to enable port power on "
832 "non-switchable hub\n"); 832 "non-switchable hub\n");
833 for (port1 = 1; port1 <= hub->descriptor->bNbrPorts; port1++) 833 for (port1 = 1; port1 <= hub->hdev->maxchild; port1++)
834 if (hub->ports[port1 - 1]->power_is_on) 834 if (hub->ports[port1 - 1]->power_is_on)
835 set_port_feature(hub->hdev, port1, USB_PORT_FEAT_POWER); 835 set_port_feature(hub->hdev, port1, USB_PORT_FEAT_POWER);
836 else 836 else
@@ -4648,9 +4648,7 @@ static void hub_events(void)
4648 hub_dev = hub->intfdev; 4648 hub_dev = hub->intfdev;
4649 intf = to_usb_interface(hub_dev); 4649 intf = to_usb_interface(hub_dev);
4650 dev_dbg(hub_dev, "state %d ports %d chg %04x evt %04x\n", 4650 dev_dbg(hub_dev, "state %d ports %d chg %04x evt %04x\n",
4651 hdev->state, hub->descriptor 4651 hdev->state, hdev->maxchild,
4652 ? hub->descriptor->bNbrPorts
4653 : 0,
4654 /* NOTE: expects max 15 ports... */ 4652 /* NOTE: expects max 15 ports... */
4655 (u16) hub->change_bits[0], 4653 (u16) hub->change_bits[0],
4656 (u16) hub->event_bits[0]); 4654 (u16) hub->event_bits[0]);
@@ -4695,7 +4693,7 @@ static void hub_events(void)
4695 } 4693 }
4696 4694
4697 /* deal with port status changes */ 4695 /* deal with port status changes */
4698 for (i = 1; i <= hub->descriptor->bNbrPorts; i++) { 4696 for (i = 1; i <= hdev->maxchild; i++) {
4699 if (test_bit(i, hub->busy_bits)) 4697 if (test_bit(i, hub->busy_bits))
4700 continue; 4698 continue;
4701 connect_change = test_bit(i, hub->change_bits); 4699 connect_change = test_bit(i, hub->change_bits);