public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: David Brownell <david-b@pacbell.net>
To: linux-pm@lists.osdl.org
Subject: [patch 2/3] usb device wakeup flags
Date: Mon, 12 Sep 2005 19:39:39 -0700	[thread overview]
Message-ID: <200509121939.39358.david-b@pacbell.net> (raw)
In-Reply-To: <200509121923.58993.david-b@pacbell.net>

[-- Attachment #1: Type: text/plain, Size: 430 bytes --]

Here's a patch showing how USB can detect wakeup-capable devices,
such as hubs, keyboards, mice, and Ethernet adapters ... and use
the policy setting to enable remote wakeup only when appropriate.

There's another USB patch on the way, switching the HCDs over to
use the new driver model bits rather than the USB-only bits that
do the same thing.  I'm holding back on that till more of the
HCD level PM updates get made.

- Dave


[-- Attachment #2: pm-wake-usb.patch --]
[-- Type: text/x-diff, Size: 1901 bytes --]

This patch teaches "usb_device" about the new driver model wakeup support:

 - It updates device wakeup capabilities when entering a configuration
   with the WAKEUP attribute;

 - During suspend processing it consults the policy bit to see
   whether it should enable wakeup for that device.  (This resolves
   a FIXME to not assume the answer is always "yes"; some devices
   lie about supporting remote wakeup.)

Support for root hubs and the HCDs is separate (and more complex).

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>

--- g26.orig/drivers/usb/core/hub.c	2005-09-11 18:24:17.000000000 -0700
+++ g26/drivers/usb/core/hub.c	2005-09-12 11:43:16.000000000 -0700
@@ -1020,9 +1020,15 @@ void usb_set_device_state(struct usb_dev
 	spin_lock_irqsave(&device_state_lock, flags);
 	if (udev->state == USB_STATE_NOTATTACHED)
 		;	/* do nothing */
-	else if (new_state != USB_STATE_NOTATTACHED)
+	else if (new_state != USB_STATE_NOTATTACHED) {
 		udev->state = new_state;
-	else
+		if (new_state == USB_STATE_CONFIGURED)
+			device_init_wakeup(&udev->dev,
+				(udev->actconfig->desc.bmAttributes
+				 & USB_CONFIG_ATT_WAKEUP));
+		else if (new_state != USB_STATE_SUSPENDED)
+			device_init_wakeup(&udev->dev, 0);
+	} else
 		recursively_mark_NOTATTACHED(udev);
 	spin_unlock_irqrestore(&device_state_lock, flags);
 }
@@ -1546,11 +1552,7 @@ static int hub_port_suspend(struct usb_h
 	 * NOTE:  OTG devices may issue remote wakeup (or SRP) even when
 	 * we don't explicitly enable it here.
 	 */
-	if (udev->actconfig
-			// && FIXME (remote wakeup enabled on this bus)
-			// ... currently assuming it's always appropriate
-			&& (udev->actconfig->desc.bmAttributes
-				& USB_CONFIG_ATT_WAKEUP) != 0) {
+	if (device_may_wakeup(&udev->dev)) {
 		status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
 				USB_REQ_SET_FEATURE, USB_RECIP_DEVICE,
 				USB_DEVICE_REMOTE_WAKEUP, 0,

[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



  parent reply	other threads:[~2005-09-13  2:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-13  2:23 [patch 0/3] driver model wakeup flags David Brownell
2005-09-13  2:39 ` [patch 1/3] " David Brownell
2005-09-13  2:39 ` David Brownell [this message]
2005-09-13  2:48 ` [patch 3/3] pci device " David Brownell

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=200509121939.39358.david-b@pacbell.net \
    --to=david-b@pacbell.net \
    --cc=linux-pm@lists.osdl.org \
    /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