linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Benson Leung <bleung@chromium.org>
To: stern@rowland.harvard.edu, johan@kernel.org, jkosina@suse.cz,
	linux-usb@vger.kernel.org, linux-input@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: snanda@chromium.org, Benson Leung <bleung@chromium.org>
Subject: [PATCH v2] HID: usbhid: clear needs_remote_wakeup before usb_kill_urb
Date: Thu, 13 Nov 2014 13:25:17 -0800	[thread overview]
Message-ID: <1415913917-15370-1-git-send-email-bleung@chromium.org> (raw)
In-Reply-To: <1415909806-23848-1-git-send-email-bleung@chromium.org>

usbhid->intf->needs_remote_wakeup is set when a device is
opened, and is cleared when a device is closed.

When a usbhid device that does not support remote wake
( i.e. !device_can_wakeup() ) is closed, we fail out of
autosuspend_check() because the autosuspend check is called
before the flag is cleared as a result of usb_kill_urb(usbhid->urbin);

The result is that a device that may otherwise autosuspend will
fail to enter suspend again after all handles to it are closed.

Clear the flag first before usb_kill_urb, which may result in a
autosuspend_check().

Signed-off-by: Benson Leung <bleung@chromium.org>
---
 drivers/hid/usbhid/hid-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index 04e34b9..ca66ad7 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -734,8 +734,8 @@ void usbhid_close(struct hid_device *hid)
 		spin_unlock_irq(&usbhid->lock);
 		hid_cancel_delayed_stuff(usbhid);
 		if (!(hid->quirks & HID_QUIRK_ALWAYS_POLL)) {
-			usb_kill_urb(usbhid->urbin);
 			usbhid->intf->needs_remote_wakeup = 0;
+			usb_kill_urb(usbhid->urbin);
 		}
 	} else {
 		spin_unlock_irq(&usbhid->lock);
-- 
2.1.0.rc2.206.gedb03e5


  parent reply	other threads:[~2014-11-13 21:25 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-13 20:16 [PATCH] HID: usbhid: get/put around clearing needs_remote_wakeup Benson Leung
2014-11-13 20:41 ` Alan Stern
2014-11-13 20:44   ` Benson Leung
2014-11-13 21:18     ` Alan Stern
2014-11-13 21:41       ` Benson Leung
2014-11-13 22:11         ` Alan Stern
2014-11-13 22:15           ` Benson Leung
2014-11-14 15:17             ` Alan Stern
2014-11-22  0:44               ` Benson Leung
2014-11-22 15:55                 ` Alan Stern
2014-11-22 16:02                   ` Alan Stern
2014-11-25  1:29                   ` Benson Leung
2014-11-25 15:24                     ` Alan Stern
2014-11-25 15:29                       ` Benson Leung
2014-11-13 21:25 ` Benson Leung [this message]
2014-11-14  9:08 ` Oliver Neukum
2014-11-22  1:00   ` Benson Leung
2014-11-24  9:13     ` Oliver Neukum
2014-11-25  0:56       ` Benson Leung
2014-11-25  9:53         ` Oliver Neukum

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=1415913917-15370-1-git-send-email-bleung@chromium.org \
    --to=bleung@chromium.org \
    --cc=jkosina@suse.cz \
    --cc=johan@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=snanda@chromium.org \
    --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;
as well as URLs for NNTP newsgroup(s).