diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2008-03-03 15:15:43 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-04-25 00:16:32 -0400 |
commit | 3eb14915a300f539f271e3716f2421bb0697ed48 (patch) | |
tree | 99a834182c6135f03df9d632a4607e51904e3304 /drivers | |
parent | 3bb1af5243d41af9518728445e9c9bd30dd47237 (diff) |
USB: reorganize code in hub.c
This patch (as1045) reorganizes some code in the hub driver.
hub_port_status() is moved earlier in the file, and a new hub_stop()
routine is created to do the work currently in hub_preset() (i.e.,
disconnect all child devices and quiesce the hub).
There are no functional changes.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/core/hub.c | 58 |
1 files changed, 32 insertions, 26 deletions
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index a42db75c2336..087e3bb70e09 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c | |||
@@ -333,6 +333,27 @@ static int get_port_status(struct usb_device *hdev, int port1, | |||
333 | return status; | 333 | return status; |
334 | } | 334 | } |
335 | 335 | ||
336 | static int hub_port_status(struct usb_hub *hub, int port1, | ||
337 | u16 *status, u16 *change) | ||
338 | { | ||
339 | int ret; | ||
340 | |||
341 | mutex_lock(&hub->status_mutex); | ||
342 | ret = get_port_status(hub->hdev, port1, &hub->status->port); | ||
343 | if (ret < 4) { | ||
344 | dev_err(hub->intfdev, | ||
345 | "%s failed (err = %d)\n", __func__, ret); | ||
346 | if (ret >= 0) | ||
347 | ret = -EIO; | ||
348 | } else { | ||
349 | *status = le16_to_cpu(hub->status->port.wPortStatus); | ||
350 | *change = le16_to_cpu(hub->status->port.wPortChange); | ||
351 | ret = 0; | ||
352 | } | ||
353 | mutex_unlock(&hub->status_mutex); | ||
354 | return ret; | ||
355 | } | ||
356 | |||
336 | static void kick_khubd(struct usb_hub *hub) | 357 | static void kick_khubd(struct usb_hub *hub) |
337 | { | 358 | { |
338 | unsigned long flags; | 359 | unsigned long flags; |
@@ -610,9 +631,8 @@ static void hub_port_logical_disconnect(struct usb_hub *hub, int port1) | |||
610 | } | 631 | } |
611 | 632 | ||
612 | /* caller has locked the hub device */ | 633 | /* caller has locked the hub device */ |
613 | static int hub_pre_reset(struct usb_interface *intf) | 634 | static void hub_stop(struct usb_hub *hub) |
614 | { | 635 | { |
615 | struct usb_hub *hub = usb_get_intfdata(intf); | ||
616 | struct usb_device *hdev = hub->hdev; | 636 | struct usb_device *hdev = hub->hdev; |
617 | int i; | 637 | int i; |
618 | 638 | ||
@@ -622,6 +642,14 @@ static int hub_pre_reset(struct usb_interface *intf) | |||
622 | usb_disconnect(&hdev->children[i]); | 642 | usb_disconnect(&hdev->children[i]); |
623 | } | 643 | } |
624 | hub_quiesce(hub); | 644 | hub_quiesce(hub); |
645 | } | ||
646 | |||
647 | /* caller has locked the hub device */ | ||
648 | static int hub_pre_reset(struct usb_interface *intf) | ||
649 | { | ||
650 | struct usb_hub *hub = usb_get_intfdata(intf); | ||
651 | |||
652 | hub_stop(hub); | ||
625 | return 0; | 653 | return 0; |
626 | } | 654 | } |
627 | 655 | ||
@@ -910,7 +938,7 @@ static void hub_disconnect(struct usb_interface *intf) | |||
910 | 938 | ||
911 | /* Disconnect all children and quiesce the hub */ | 939 | /* Disconnect all children and quiesce the hub */ |
912 | hub->error = 0; | 940 | hub->error = 0; |
913 | hub_pre_reset(intf); | 941 | hub_stop(hub); |
914 | 942 | ||
915 | usb_set_intfdata (intf, NULL); | 943 | usb_set_intfdata (intf, NULL); |
916 | 944 | ||
@@ -1510,28 +1538,6 @@ out_authorized: | |||
1510 | } | 1538 | } |
1511 | 1539 | ||
1512 | 1540 | ||
1513 | static int hub_port_status(struct usb_hub *hub, int port1, | ||
1514 | u16 *status, u16 *change) | ||
1515 | { | ||
1516 | int ret; | ||
1517 | |||
1518 | mutex_lock(&hub->status_mutex); | ||
1519 | ret = get_port_status(hub->hdev, port1, &hub->status->port); | ||
1520 | if (ret < 4) { | ||
1521 | dev_err (hub->intfdev, | ||
1522 | "%s failed (err = %d)\n", __FUNCTION__, ret); | ||
1523 | if (ret >= 0) | ||
1524 | ret = -EIO; | ||
1525 | } else { | ||
1526 | *status = le16_to_cpu(hub->status->port.wPortStatus); | ||
1527 | *change = le16_to_cpu(hub->status->port.wPortChange); | ||
1528 | ret = 0; | ||
1529 | } | ||
1530 | mutex_unlock(&hub->status_mutex); | ||
1531 | return ret; | ||
1532 | } | ||
1533 | |||
1534 | |||
1535 | /* Returns 1 if @hub is a WUSB root hub, 0 otherwise */ | 1541 | /* Returns 1 if @hub is a WUSB root hub, 0 otherwise */ |
1536 | static unsigned hub_is_wusb(struct usb_hub *hub) | 1542 | static unsigned hub_is_wusb(struct usb_hub *hub) |
1537 | { | 1543 | { |
@@ -2726,7 +2732,7 @@ static void hub_events(void) | |||
2726 | /* If the hub has died, clean up after it */ | 2732 | /* If the hub has died, clean up after it */ |
2727 | if (hdev->state == USB_STATE_NOTATTACHED) { | 2733 | if (hdev->state == USB_STATE_NOTATTACHED) { |
2728 | hub->error = -ENODEV; | 2734 | hub->error = -ENODEV; |
2729 | hub_pre_reset(intf); | 2735 | hub_stop(hub); |
2730 | goto loop; | 2736 | goto loop; |
2731 | } | 2737 | } |
2732 | 2738 | ||