From: Greg Kroah-Hartman <gregkh@suse.de>
To: linux-usb@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
Alan Stern <stern@rowland.harvard.edu>,
Greg Kroah-Hartman <gregkh@suse.de>
Subject: [PATCH 2/6] USB: reorganize code in hub.c
Date: Mon, 10 Mar 2008 17:59:08 -0700 [thread overview]
Message-ID: <1205197152-18146-2-git-send-email-gregkh@suse.de> (raw)
In-Reply-To: <20080311004239.GD17890@suse.de>
From: Alan Stern <stern@rowland.harvard.edu>
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>
---
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 acd4658..98c39fb 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -334,6 +334,27 @@ static int get_port_status(struct usb_device *hdev, int port1,
return status;
}
+static int hub_port_status(struct usb_hub *hub, int port1,
+ u16 *status, u16 *change)
+{
+ int ret;
+
+ mutex_lock(&hub->status_mutex);
+ ret = get_port_status(hub->hdev, port1, &hub->status->port);
+ if (ret < 4) {
+ dev_err(hub->intfdev,
+ "%s failed (err = %d)\n", __func__, ret);
+ if (ret >= 0)
+ ret = -EIO;
+ } else {
+ *status = le16_to_cpu(hub->status->port.wPortStatus);
+ *change = le16_to_cpu(hub->status->port.wPortChange);
+ ret = 0;
+ }
+ mutex_unlock(&hub->status_mutex);
+ return ret;
+}
+
static void kick_khubd(struct usb_hub *hub)
{
unsigned long flags;
@@ -611,9 +632,8 @@ static void hub_port_logical_disconnect(struct usb_hub *hub, int port1)
}
/* caller has locked the hub device */
-static int hub_pre_reset(struct usb_interface *intf)
+static void hub_stop(struct usb_hub *hub)
{
- struct usb_hub *hub = usb_get_intfdata(intf);
struct usb_device *hdev = hub->hdev;
int i;
@@ -623,6 +643,14 @@ static int hub_pre_reset(struct usb_interface *intf)
usb_disconnect(&hdev->children[i]);
}
hub_quiesce(hub);
+}
+
+/* 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);
return 0;
}
@@ -911,7 +939,7 @@ static void hub_disconnect(struct usb_interface *intf)
/* Disconnect all children and quiesce the hub */
hub->error = 0;
- hub_pre_reset(intf);
+ hub_stop(hub);
usb_set_intfdata (intf, NULL);
@@ -1511,28 +1539,6 @@ out_authorized:
}
-static int hub_port_status(struct usb_hub *hub, int port1,
- u16 *status, u16 *change)
-{
- int ret;
-
- mutex_lock(&hub->status_mutex);
- ret = get_port_status(hub->hdev, port1, &hub->status->port);
- if (ret < 4) {
- dev_err (hub->intfdev,
- "%s failed (err = %d)\n", __FUNCTION__, ret);
- if (ret >= 0)
- ret = -EIO;
- } else {
- *status = le16_to_cpu(hub->status->port.wPortStatus);
- *change = le16_to_cpu(hub->status->port.wPortChange);
- ret = 0;
- }
- mutex_unlock(&hub->status_mutex);
- return ret;
-}
-
-
/* Returns 1 if @hub is a WUSB root hub, 0 otherwise */
static unsigned hub_is_wusb(struct usb_hub *hub)
{
@@ -2727,7 +2733,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_pre_reset(intf);
+ hub_stop(hub);
goto loop;
}
--
1.5.4.3
next prev parent reply other threads:[~2008-03-11 0:59 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-11 0:42 [GIT PATCH] USB suspend persistance for 2.6.25-rc5 git Greg KH
2008-03-11 0:59 ` [PATCH 1/6] USB: EHCI: carry out port handover during each root-hub resume Greg Kroah-Hartman
2008-03-11 0:59 ` Greg Kroah-Hartman [this message]
2008-03-11 0:59 ` [PATCH 3/6] USB: make USB-PERSIST work after every system sleep Greg Kroah-Hartman
2008-03-11 0:59 ` [PATCH 4/6] USB: remove CONFIG_USB_PERSIST setting Greg Kroah-Hartman
2008-03-11 0:59 ` [PATCH 5/6] USB: check serial-number string after device reset Greg Kroah-Hartman
2008-03-11 0:59 ` [PATCH 6/6] USB: enable USB-PERSIST by default Greg Kroah-Hartman
2008-03-19 17:05 ` Mark Lord
2008-03-19 21:35 ` Alan Stern
2008-03-20 14:17 ` Mark Lord
2008-03-11 10:27 ` [GIT PATCH] USB suspend persistance for 2.6.25-rc5 git Pavel Machek
2008-03-11 15:28 ` Greg KH
2008-03-11 16:18 ` Linus Torvalds
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1205197152-18146-2-git-send-email-gregkh@suse.de \
--to=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome