diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2008-04-28 11:07:31 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-07-21 18:15:52 -0400 |
commit | 4330354f7660828d97834598633054b413f6264d (patch) | |
tree | 807426b75086e3e4e2670ef60577e366f3eed843 | |
parent | f2835219ed5e29ec959a0e635af4339d6174b2a7 (diff) |
USB: combine hub_quiesce and hub_stop
This patch (as1083) combines hub_quiesce() and hub_stop() into a
single routine. There's no point keeping them separate since they are
usually called together.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/usb/core/hub.c | 63 |
1 files changed, 32 insertions, 31 deletions
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 4c629a036aed..e678ed8bd8c2 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c | |||
@@ -538,19 +538,6 @@ static void hub_power_on(struct usb_hub *hub) | |||
538 | msleep(max(pgood_delay, (unsigned) 100)); | 538 | msleep(max(pgood_delay, (unsigned) 100)); |
539 | } | 539 | } |
540 | 540 | ||
541 | static void hub_quiesce(struct usb_hub *hub) | ||
542 | { | ||
543 | /* (nonblocking) khubd and related activity won't re-trigger */ | ||
544 | hub->quiescing = 1; | ||
545 | |||
546 | /* (blocking) stop khubd and related activity */ | ||
547 | usb_kill_urb(hub->urb); | ||
548 | if (hub->has_indicators) | ||
549 | cancel_delayed_work_sync(&hub->leds); | ||
550 | if (hub->tt.hub) | ||
551 | cancel_work_sync(&hub->tt.kevent); | ||
552 | } | ||
553 | |||
554 | static int hub_hub_status(struct usb_hub *hub, | 541 | static int hub_hub_status(struct usb_hub *hub, |
555 | u16 *status, u16 *change) | 542 | u16 *status, u16 *change) |
556 | { | 543 | { |
@@ -609,20 +596,6 @@ static void hub_port_logical_disconnect(struct usb_hub *hub, int port1) | |||
609 | kick_khubd(hub); | 596 | kick_khubd(hub); |
610 | } | 597 | } |
611 | 598 | ||
612 | /* caller has locked the hub device */ | ||
613 | static void hub_stop(struct usb_hub *hub) | ||
614 | { | ||
615 | struct usb_device *hdev = hub->hdev; | ||
616 | int i; | ||
617 | |||
618 | /* Disconnect all the children */ | ||
619 | for (i = 0; i < hdev->maxchild; ++i) { | ||
620 | if (hdev->children[i]) | ||
621 | usb_disconnect(&hdev->children[i]); | ||
622 | } | ||
623 | hub_quiesce(hub); | ||
624 | } | ||
625 | |||
626 | enum hub_activation_type { | 599 | enum hub_activation_type { |
627 | HUB_INIT, HUB_POST_RESET, HUB_RESUME, HUB_RESET_RESUME | 600 | HUB_INIT, HUB_POST_RESET, HUB_RESUME, HUB_RESET_RESUME |
628 | }; | 601 | }; |
@@ -732,12 +705,40 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) | |||
732 | kick_khubd(hub); | 705 | kick_khubd(hub); |
733 | } | 706 | } |
734 | 707 | ||
708 | enum hub_quiescing_type { | ||
709 | HUB_DISCONNECT, HUB_PRE_RESET, HUB_SUSPEND | ||
710 | }; | ||
711 | |||
712 | static void hub_quiesce(struct usb_hub *hub, enum hub_quiescing_type type) | ||
713 | { | ||
714 | struct usb_device *hdev = hub->hdev; | ||
715 | int i; | ||
716 | |||
717 | /* khubd and related activity won't re-trigger */ | ||
718 | hub->quiescing = 1; | ||
719 | |||
720 | if (type != HUB_SUSPEND) { | ||
721 | /* Disconnect all the children */ | ||
722 | for (i = 0; i < hdev->maxchild; ++i) { | ||
723 | if (hdev->children[i]) | ||
724 | usb_disconnect(&hdev->children[i]); | ||
725 | } | ||
726 | } | ||
727 | |||
728 | /* Stop khubd and related activity */ | ||
729 | usb_kill_urb(hub->urb); | ||
730 | if (hub->has_indicators) | ||
731 | cancel_delayed_work_sync(&hub->leds); | ||
732 | if (hub->tt.hub) | ||
733 | cancel_work_sync(&hub->tt.kevent); | ||
734 | } | ||
735 | |||
735 | /* caller has locked the hub device */ | 736 | /* caller has locked the hub device */ |
736 | static int hub_pre_reset(struct usb_interface *intf) | 737 | static int hub_pre_reset(struct usb_interface *intf) |
737 | { | 738 | { |
738 | struct usb_hub *hub = usb_get_intfdata(intf); | 739 | struct usb_hub *hub = usb_get_intfdata(intf); |
739 | 740 | ||
740 | hub_stop(hub); | 741 | hub_quiesce(hub, HUB_PRE_RESET); |
741 | return 0; | 742 | return 0; |
742 | } | 743 | } |
743 | 744 | ||
@@ -1024,7 +1025,7 @@ static void hub_disconnect(struct usb_interface *intf) | |||
1024 | 1025 | ||
1025 | /* Disconnect all children and quiesce the hub */ | 1026 | /* Disconnect all children and quiesce the hub */ |
1026 | hub->error = 0; | 1027 | hub->error = 0; |
1027 | hub_stop(hub); | 1028 | hub_quiesce(hub, HUB_DISCONNECT); |
1028 | 1029 | ||
1029 | usb_set_intfdata (intf, NULL); | 1030 | usb_set_intfdata (intf, NULL); |
1030 | 1031 | ||
@@ -2167,7 +2168,7 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg) | |||
2167 | dev_dbg(&intf->dev, "%s\n", __func__); | 2168 | dev_dbg(&intf->dev, "%s\n", __func__); |
2168 | 2169 | ||
2169 | /* stop khubd and related activity */ | 2170 | /* stop khubd and related activity */ |
2170 | hub_quiesce(hub); | 2171 | hub_quiesce(hub, HUB_SUSPEND); |
2171 | return 0; | 2172 | return 0; |
2172 | } | 2173 | } |
2173 | 2174 | ||
@@ -2914,7 +2915,7 @@ static void hub_events(void) | |||
2914 | /* If the hub has died, clean up after it */ | 2915 | /* If the hub has died, clean up after it */ |
2915 | if (hdev->state == USB_STATE_NOTATTACHED) { | 2916 | if (hdev->state == USB_STATE_NOTATTACHED) { |
2916 | hub->error = -ENODEV; | 2917 | hub->error = -ENODEV; |
2917 | hub_stop(hub); | 2918 | hub_quiesce(hub, HUB_DISCONNECT); |
2918 | goto loop; | 2919 | goto loop; |
2919 | } | 2920 | } |
2920 | 2921 | ||