Skip to content

Commit

Permalink
USB: Avoid PM error messages during resume if a device was disconnected
Browse files Browse the repository at this point in the history
Currently if a laptop is suspended e.g. while docked and then resumed after
undocking it, the following errors get generated because the USB hub in the
docking station and the devices connected to it are no longer available:
pm_op(): usb_dev_resume+0x0/0x10 returns -19
PM: Device 1-2 failed to resume: error -19
pm_op(): usb_dev_resume+0x0/0x10 returns -19
PM: Device 1-2.2 failed to resume: error -19
pm_op(): usb_dev_resume+0x0/0x10 returns -19
PM: Device 1-2.3 failed to resume: error -19

As the removal of USB devices while a system is suspended is a relatively
common use case and in most cases not an error, just return success on
-ENODEV. The user gets informed anyway as the USB subsystem generates
regular disconnect messages for the devices shortly afterwards:
usb 1-2: USB disconnect, address 3
usb 1-2.2: USB disconnect, address 4
usblp0: removed
usb 1-2.3: USB disconnect, address 5

Signed-off-by: Frans Pop <elendil@planet.nl>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Frans Pop authored and Greg Kroah-Hartman committed Jun 16, 2009
1 parent 453f775 commit 23a54e5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion drivers/usb/core/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -1750,6 +1750,7 @@ int usb_suspend(struct device *dev, pm_message_t msg)
int usb_resume(struct device *dev, pm_message_t msg)
{
struct usb_device *udev;
int status;

udev = to_usb_device(dev);

Expand All @@ -1759,7 +1760,14 @@ int usb_resume(struct device *dev, pm_message_t msg)
*/
if (udev->skip_sys_resume)
return 0;
return usb_external_resume_device(udev, msg);
status = usb_external_resume_device(udev, msg);

/* Avoid PM error messages for devices disconnected while suspended
* as we'll display regular disconnect messages just a bit later.
*/
if (status == -ENODEV)
return 0;
return status;
}

#endif /* CONFIG_PM */
Expand Down

0 comments on commit 23a54e5

Please sign in to comment.