Commit 4330354f authored by Alan Stern's avatar Alan Stern Committed by Greg Kroah-Hartman

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: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent f2835219
...@@ -538,19 +538,6 @@ static void hub_power_on(struct usb_hub *hub) ...@@ -538,19 +538,6 @@ static void hub_power_on(struct usb_hub *hub)
msleep(max(pgood_delay, (unsigned) 100)); 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, static int hub_hub_status(struct usb_hub *hub,
u16 *status, u16 *change) u16 *status, u16 *change)
{ {
...@@ -609,20 +596,6 @@ static void hub_port_logical_disconnect(struct usb_hub *hub, int port1) ...@@ -609,20 +596,6 @@ static void hub_port_logical_disconnect(struct usb_hub *hub, int port1)
kick_khubd(hub); 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 { enum hub_activation_type {
HUB_INIT, HUB_POST_RESET, HUB_RESUME, HUB_RESET_RESUME 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) ...@@ -732,12 +705,40 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
kick_khubd(hub); 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 */ /* caller has locked the hub device */
static int hub_pre_reset(struct usb_interface *intf) static int hub_pre_reset(struct usb_interface *intf)
{ {
struct usb_hub *hub = usb_get_intfdata(intf); struct usb_hub *hub = usb_get_intfdata(intf);
hub_stop(hub); hub_quiesce(hub, HUB_PRE_RESET);
return 0; return 0;
} }
...@@ -1024,7 +1025,7 @@ static void hub_disconnect(struct usb_interface *intf) ...@@ -1024,7 +1025,7 @@ static void hub_disconnect(struct usb_interface *intf)
/* Disconnect all children and quiesce the hub */ /* Disconnect all children and quiesce the hub */
hub->error = 0; hub->error = 0;
hub_stop(hub); hub_quiesce(hub, HUB_DISCONNECT);
usb_set_intfdata (intf, NULL); usb_set_intfdata (intf, NULL);
...@@ -2167,7 +2168,7 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg) ...@@ -2167,7 +2168,7 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg)
dev_dbg(&intf->dev, "%s\n", __func__); dev_dbg(&intf->dev, "%s\n", __func__);
/* stop khubd and related activity */ /* stop khubd and related activity */
hub_quiesce(hub); hub_quiesce(hub, HUB_SUSPEND);
return 0; return 0;
} }
...@@ -2914,7 +2915,7 @@ static void hub_events(void) ...@@ -2914,7 +2915,7 @@ static void hub_events(void)
/* If the hub has died, clean up after it */ /* If the hub has died, clean up after it */
if (hdev->state == USB_STATE_NOTATTACHED) { if (hdev->state == USB_STATE_NOTATTACHED) {
hub->error = -ENODEV; hub->error = -ENODEV;
hub_stop(hub); hub_quiesce(hub, HUB_DISCONNECT);
goto loop; goto loop;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment