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) ...@@ -770,7 +770,8 @@ usb_gadget_unregister_driver (struct usb_gadget_driver *driver)
spin_lock_irqsave (&dum->lock, flags); spin_lock_irqsave (&dum->lock, flags);
stop_activity (dum, driver); 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); dum->port_status |= (1 << USB_PORT_FEAT_C_CONNECTION);
spin_unlock_irqrestore (&dum->lock, flags); spin_unlock_irqrestore (&dum->lock, flags);
...@@ -815,8 +816,8 @@ static int dummy_urb_enqueue ( ...@@ -815,8 +816,8 @@ static int dummy_urb_enqueue (
struct dummy *dum; struct dummy *dum;
unsigned long flags; unsigned long flags;
/* patch to usb_sg_init() is in 2.5.60 */ if (!urb->transfer_buffer && urb->transfer_buffer_length)
BUG_ON (!urb->transfer_buffer && urb->transfer_buffer_length); return -EINVAL;
dum = container_of (hcd, struct dummy, hcd); dum = container_of (hcd, struct dummy, hcd);
spin_lock_irqsave (&dum->lock, flags); spin_lock_irqsave (&dum->lock, flags);
...@@ -1102,10 +1103,10 @@ static void dummy_timer (unsigned long _dum) ...@@ -1102,10 +1103,10 @@ static void dummy_timer (unsigned long _dum)
ep = find_endpoint(dum, address); ep = find_endpoint(dum, address);
if (!ep) { if (!ep) {
/* set_configuration() disagreement */ /* set_configuration() disagreement */
dev_err (hardware, dev_dbg (hardware,
"no ep configured for urb %p\n", "no ep configured for urb %p\n",
urb); urb);
maybe_set_status (urb, -ETIMEDOUT); maybe_set_status (urb, -EPROTO);
goto return_urb; goto return_urb;
} }
...@@ -1409,9 +1410,12 @@ static int dummy_hub_control ( ...@@ -1409,9 +1410,12 @@ static int dummy_hub_control (
case ClearPortFeature: case ClearPortFeature:
switch (wValue) { switch (wValue) {
case USB_PORT_FEAT_SUSPEND: case USB_PORT_FEAT_SUSPEND:
/* 20msec resume signaling */ if (dum->port_status & (1 << USB_PORT_FEAT_SUSPEND)) {
dum->resuming = 1; /* 20msec resume signaling */
dum->re_timeout = jiffies + ((HZ * 20)/1000); dum->resuming = 1;
dum->re_timeout = jiffies +
msecs_to_jiffies(20);
}
break; break;
case USB_PORT_FEAT_POWER: case USB_PORT_FEAT_POWER:
dum->port_status = 0; dum->port_status = 0;
...@@ -1440,7 +1444,7 @@ static int dummy_hub_control ( ...@@ -1440,7 +1444,7 @@ static int dummy_hub_control (
dum->port_status &= ~(1 << USB_PORT_FEAT_SUSPEND); dum->port_status &= ~(1 << USB_PORT_FEAT_SUSPEND);
dum->resuming = 0; dum->resuming = 0;
dum->re_timeout = 0; dum->re_timeout = 0;
if (dum->driver->resume) { if (dum->driver && dum->driver->resume) {
spin_unlock (&dum->lock); spin_unlock (&dum->lock);
dum->driver->resume (&dum->gadget); dum->driver->resume (&dum->gadget);
spin_lock (&dum->lock); spin_lock (&dum->lock);
...@@ -1481,11 +1485,15 @@ static int dummy_hub_control ( ...@@ -1481,11 +1485,15 @@ static int dummy_hub_control (
case SetPortFeature: case SetPortFeature:
switch (wValue) { switch (wValue) {
case USB_PORT_FEAT_SUSPEND: case USB_PORT_FEAT_SUSPEND:
dum->port_status |= (1 << USB_PORT_FEAT_SUSPEND); if ((dum->port_status & (1 << USB_PORT_FEAT_SUSPEND))
if (dum->driver->suspend) { == 0) {
spin_unlock (&dum->lock); dum->port_status |=
dum->driver->suspend (&dum->gadget); (1 << USB_PORT_FEAT_SUSPEND);
spin_lock (&dum->lock); if (dum->driver && dum->driver->suspend) {
spin_unlock (&dum->lock);
dum->driver->suspend (&dum->gadget);
spin_lock (&dum->lock);
}
} }
break; break;
case USB_PORT_FEAT_RESET: case USB_PORT_FEAT_RESET:
...@@ -1502,7 +1510,7 @@ static int dummy_hub_control ( ...@@ -1502,7 +1510,7 @@ static int dummy_hub_control (
/* FIXME test that code path! */ /* FIXME test that code path! */
} }
/* 50msec reset signaling */ /* 50msec reset signaling */
dum->re_timeout = jiffies + ((HZ * 50)/1000); dum->re_timeout = jiffies + msecs_to_jiffies(50);
/* FALLTHROUGH */ /* FALLTHROUGH */
default: default:
dum->port_status |= (1 << wValue); dum->port_status |= (1 << wValue);
...@@ -1790,4 +1798,3 @@ static void __exit cleanup (void) ...@@ -1790,4 +1798,3 @@ static void __exit cleanup (void)
the_controller = 0; the_controller = 0;
} }
module_exit (cleanup); 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