ChangeSet 1.1587.3.22, 2004/04/30 22:19:00-07:00, david-b@pacbell.net [PATCH] USB: reject urb submissions to suspended devices This patch rejects URB submissions to suspended devices, so that they don't get hardware-specific fault reports. Instead, they get the same code (-EHOSTUNREACH) for all HCDs. It also fixes a minor problem with colliding declarations of the symbol USB_STATE_SUSPENDED. drivers/usb/core/hcd-pci.c | 6 +++--- drivers/usb/core/hcd.h | 2 +- drivers/usb/core/urb.c | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff -Nru a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c --- a/drivers/usb/core/hcd-pci.c Fri May 14 15:30:58 2004 +++ b/drivers/usb/core/hcd-pci.c Fri May 14 15:30:58 2004 @@ -293,7 +293,7 @@ case USB_STATE_HALT: dev_dbg (hcd->self.controller, "halted; hcd not suspended\n"); break; - case USB_STATE_SUSPENDED: + case HCD_STATE_SUSPENDED: dev_dbg (hcd->self.controller, "hcd already suspended\n"); break; default: @@ -310,7 +310,7 @@ "suspend fail, retval %d\n", retval); else - hcd->state = USB_STATE_SUSPENDED; + hcd->state = HCD_STATE_SUSPENDED; } pci_set_power_state (dev, state); @@ -333,7 +333,7 @@ dev_dbg (hcd->self.controller, "resume from state D%d\n", dev->current_state); - if (hcd->state != USB_STATE_SUSPENDED) { + if (hcd->state != HCD_STATE_SUSPENDED) { dev_dbg (hcd->self.controller, "can't resume, not suspended!\n"); return -EL3HLT; diff -Nru a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h --- a/drivers/usb/core/hcd.h Fri May 14 15:30:58 2004 +++ b/drivers/usb/core/hcd.h Fri May 14 15:30:58 2004 @@ -96,7 +96,7 @@ # define USB_STATE_RUNNING (__ACTIVE) # define USB_STATE_QUIESCING (__SUSPEND|__TRANSIENT|__ACTIVE) # define USB_STATE_RESUMING (__SUSPEND|__TRANSIENT) -# define USB_STATE_SUSPENDED (__SUSPEND) +# define HCD_STATE_SUSPENDED (__SUSPEND) #define HCD_IS_RUNNING(state) ((state) & __ACTIVE) #define HCD_IS_SUSPENDED(state) ((state) & __SUSPEND) diff -Nru a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c --- a/drivers/usb/core/urb.c Fri May 14 15:30:58 2004 +++ b/drivers/usb/core/urb.c Fri May 14 15:30:58 2004 @@ -237,6 +237,8 @@ (dev->state < USB_STATE_DEFAULT) || (!dev->bus) || (dev->devnum <= 0)) return -ENODEV; + if (dev->state == USB_STATE_SUSPENDED) + return -EHOSTUNREACH; if (!(op = dev->bus->op) || !op->submit_urb) return -ENODEV;