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 15:15:52 -0700 |
commit | 4330354f7660828d97834598633054b413f6264d (patch) | |
tree | 807426b75086e3e4e2670ef60577e366f3eed843 /drivers/usb/core | |
parent | f2835219ed5e29ec959a0e635af4339d6174b2a7 (diff) | |
download | op-kernel-dev-4330354f7660828d97834598633054b413f6264d.zip op-kernel-dev-4330354f7660828d97834598633054b413f6264d.tar.gz |
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>
Diffstat (limited to 'drivers/usb/core')
-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 4c629a0..e678ed8 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) msleep(max(pgood_delay, (unsigned) 100)); } -static void hub_quiesce(struct usb_hub *hub) -{ - /* (nonblocking) khubd and related activity won't re-trigger */ - hub->quiescing = 1; - - /* (blocking) stop khubd and related activity */ - usb_kill_urb(hub->urb); - if (hub->has_indicators) - cancel_delayed_work_sync(&hub->leds); - if (hub->tt.hub) - cancel_work_sync(&hub->tt.kevent); -} - static int hub_hub_status(struct usb_hub *hub, u16 *status, u16 *change) { @@ -609,20 +596,6 @@ static void hub_port_logical_disconnect(struct usb_hub *hub, int port1) kick_khubd(hub); } -/* caller has locked the hub device */ -static void hub_stop(struct usb_hub *hub) -{ - struct usb_device *hdev = hub->hdev; - int i; - - /* Disconnect all the children */ - for (i = 0; i < hdev->maxchild; ++i) { - if (hdev->children[i]) - usb_disconnect(&hdev->children[i]); - } - hub_quiesce(hub); -} - enum hub_activation_type { HUB_INIT, HUB_POST_RESET, HUB_RESUME, HUB_RESET_RESUME }; @@ -732,12 +705,40 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) kick_khubd(hub); } +enum hub_quiescing_type { + HUB_DISCONNECT, HUB_PRE_RESET, HUB_SUSPEND +}; + +static void hub_quiesce(struct usb_hub *hub, enum hub_quiescing_type type) +{ + struct usb_device *hdev = hub->hdev; + int i; + + /* khubd and related activity won't re-trigger */ + hub->quiescing = 1; + + if (type != HUB_SUSPEND) { + /* Disconnect all the children */ + for (i = 0; i < hdev->maxchild; ++i) { + if (hdev->children[i]) + usb_disconnect(&hdev->children[i]); + } + } + + /* Stop khubd and related activity */ + usb_kill_urb(hub->urb); + if (hub->has_indicators) + cancel_delayed_work_sync(&hub->leds); + if (hub->tt.hub) + cancel_work_sync(&hub->tt.kevent); +} + /* caller has locked the hub device */ static int hub_pre_reset(struct usb_interface *intf) { struct usb_hub *hub = usb_get_intfdata(intf); - hub_stop(hub); + hub_quiesce(hub, HUB_PRE_RESET); return 0; } @@ -1024,7 +1025,7 @@ static void hub_disconnect(struct usb_interface *intf) /* Disconnect all children and quiesce the hub */ hub->error = 0; - hub_stop(hub); + hub_quiesce(hub, HUB_DISCONNECT); usb_set_intfdata (intf, NULL); @@ -2167,7 +2168,7 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg) dev_dbg(&intf->dev, "%s\n", __func__); /* stop khubd and related activity */ - hub_quiesce(hub); + hub_quiesce(hub, HUB_SUSPEND); return 0; } @@ -2914,7 +2915,7 @@ static void hub_events(void) /* If the hub has died, clean up after it */ if (hdev->state == USB_STATE_NOTATTACHED) { hub->error = -ENODEV; - hub_stop(hub); + hub_quiesce(hub, HUB_DISCONNECT); goto loop; } |