public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Frans Pop <elendil@planet.nl>
To: linux-usb@vger.kernel.org
Cc: Alan Stern <stern@rowland.harvard.edu>,
	"Rafael J. Wysocki" <rjw@sisk.pl>,
	linux-pm@lists.linux-foundation.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [PATCH] usb: avoid PM error messages during resume if a device was disconnected
Date: Mon, 23 Mar 2009 22:11:49 +0100	[thread overview]
Message-ID: <200903232211.51154.elendil@planet.nl> (raw)

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>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Rafael J. Wysocki <rjw@sisk.pl>
---

I've walked through the code and AFAICT just returning 0 does not make any
difference for the PM core code.

In a first version of this patch I had the following included just before
the 'return 0':
	pr_info("usb %s: failed to resume: no longer connected\n",
						dev_name(&udev->dev));

Problem with that was that the message got printed twice for each device,
once for .resume and once for .complete. Given that the disconnects are
reported shortly after anyway, I decided the simpler patch might do just
as well.

Cheers,
FJP

diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index d0a21a5..97ea69b 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -1727,6 +1727,10 @@ int usb_external_resume_device(struct usb_device *udev, pm_message_t msg)
 	status = usb_resume_both(udev, msg);
 	udev->last_busy = jiffies;
 	usb_pm_unlock(udev);
+
+	if (status == -ENODEV)
+		return 0;
+
 	if (status == 0)
 		do_unbind_rebind(udev, DO_REBIND);
 

             reply	other threads:[~2009-03-23 21:12 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-23 21:11 Frans Pop [this message]
2009-03-23 21:30 ` [PATCH] usb: avoid PM error messages during resume if a device was disconnected Frans Pop
2009-03-23 21:44 ` Alan Stern
2009-03-23 22:25   ` Frans Pop
2009-03-24 14:11     ` Alan Stern
2009-06-02 21:26       ` Rafael J. Wysocki
2009-06-02 21:48         ` Alan Stern
2009-06-02 22:26           ` [PATCH v2] " Frans Pop
2009-06-02 22:53             ` Rafael J. Wysocki
2009-06-03  0:57               ` Alan Stern
2009-06-03  8:08                 ` Rafael J. Wysocki
  -- strict thread matches above, loose matches on Subject: below --
2009-06-04 20:30 [PATCH] USB: Avoid " Rafael J. Wysocki
2009-06-04 21:02 ` Greg KH

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=200903232211.51154.elendil@planet.nl \
    --to=elendil@planet.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=rjw@sisk.pl \
    --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