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

[PATCH] USB: Suspend update for dummy_hcd

This patch fixes a few minor errors in the port suspend/resume handling
code of the dummy_hcd driver.  There are a couple of other small changes
too, such as removing a BUG_ON().  Please apply.
Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 2a7b57bd
......@@ -770,7 +770,8 @@ usb_gadget_unregister_driver (struct usb_gadget_driver *driver)
spin_lock_irqsave (&dum->lock, flags);
stop_activity (dum, driver);
dum->port_status &= ~USB_PORT_STAT_CONNECTION;
dum->port_status &= ~(USB_PORT_STAT_CONNECTION | USB_PORT_STAT_ENABLE |
USB_PORT_STAT_LOW_SPEED | USB_PORT_STAT_HIGH_SPEED);
dum->port_status |= (1 << USB_PORT_FEAT_C_CONNECTION);
spin_unlock_irqrestore (&dum->lock, flags);
......@@ -815,8 +816,8 @@ static int dummy_urb_enqueue (
struct dummy *dum;
unsigned long flags;
/* patch to usb_sg_init() is in 2.5.60 */
BUG_ON (!urb->transfer_buffer && urb->transfer_buffer_length);
if (!urb->transfer_buffer && urb->transfer_buffer_length)
return -EINVAL;
dum = container_of (hcd, struct dummy, hcd);
spin_lock_irqsave (&dum->lock, flags);
......@@ -1102,10 +1103,10 @@ static void dummy_timer (unsigned long _dum)
ep = find_endpoint(dum, address);
if (!ep) {
/* set_configuration() disagreement */
dev_err (hardware,
dev_dbg (hardware,
"no ep configured for urb %p\n",
urb);
maybe_set_status (urb, -ETIMEDOUT);
maybe_set_status (urb, -EPROTO);
goto return_urb;
}
......@@ -1409,9 +1410,12 @@ static int dummy_hub_control (
case ClearPortFeature:
switch (wValue) {
case USB_PORT_FEAT_SUSPEND:
/* 20msec resume signaling */
dum->resuming = 1;
dum->re_timeout = jiffies + ((HZ * 20)/1000);
if (dum->port_status & (1 << USB_PORT_FEAT_SUSPEND)) {
/* 20msec resume signaling */
dum->resuming = 1;
dum->re_timeout = jiffies +
msecs_to_jiffies(20);
}
break;
case USB_PORT_FEAT_POWER:
dum->port_status = 0;
......@@ -1440,7 +1444,7 @@ static int dummy_hub_control (
dum->port_status &= ~(1 << USB_PORT_FEAT_SUSPEND);
dum->resuming = 0;
dum->re_timeout = 0;
if (dum->driver->resume) {
if (dum->driver && dum->driver->resume) {
spin_unlock (&dum->lock);
dum->driver->resume (&dum->gadget);
spin_lock (&dum->lock);
......@@ -1481,11 +1485,15 @@ static int dummy_hub_control (
case SetPortFeature:
switch (wValue) {
case USB_PORT_FEAT_SUSPEND:
dum->port_status |= (1 << USB_PORT_FEAT_SUSPEND);
if (dum->driver->suspend) {
spin_unlock (&dum->lock);
dum->driver->suspend (&dum->gadget);
spin_lock (&dum->lock);
if ((dum->port_status & (1 << USB_PORT_FEAT_SUSPEND))
== 0) {
dum->port_status |=
(1 << USB_PORT_FEAT_SUSPEND);
if (dum->driver && dum->driver->suspend) {
spin_unlock (&dum->lock);
dum->driver->suspend (&dum->gadget);
spin_lock (&dum->lock);
}
}
break;
case USB_PORT_FEAT_RESET:
......@@ -1502,7 +1510,7 @@ static int dummy_hub_control (
/* FIXME test that code path! */
}
/* 50msec reset signaling */
dum->re_timeout = jiffies + ((HZ * 50)/1000);
dum->re_timeout = jiffies + msecs_to_jiffies(50);
/* FALLTHROUGH */
default:
dum->port_status |= (1 << wValue);
......@@ -1790,4 +1798,3 @@ static void __exit cleanup (void)
the_controller = 0;
}
module_exit (cleanup);
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