From patchwork Thu Nov 13 21:25:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benson Leung X-Patchwork-Id: 5300801 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0825BC11AC for ; Thu, 13 Nov 2014 21:25:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3105D201E4 for ; Thu, 13 Nov 2014 21:25:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 51810201C0 for ; Thu, 13 Nov 2014 21:25:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934179AbaKMVZc (ORCPT ); Thu, 13 Nov 2014 16:25:32 -0500 Received: from mail-ie0-f175.google.com ([209.85.223.175]:58276 "EHLO mail-ie0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934400AbaKMVZ2 (ORCPT ); Thu, 13 Nov 2014 16:25:28 -0500 Received: by mail-ie0-f175.google.com with SMTP id at20so1204521iec.34 for ; Thu, 13 Nov 2014 13:25:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PxV4TnQNZnrHntzJ5Bd/YHP9a98n+x05qx3FrLYS+hI=; b=nV9MIwf/TRHw/TmEa2vg6yZLEqJVwD3Gu3ZpnbxibslaGo2rlSZbCqxaKeo1zGBaKB vmMVauYl5TtpE2N5AQSRBjaJc8Z3PDSU8DEQoxeIV5zsYnuukc2YbUd9gb8h/3kWNVGH uYi1Sym/gCker3yDF+iGEhDw7yxo8YuzE6n1M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PxV4TnQNZnrHntzJ5Bd/YHP9a98n+x05qx3FrLYS+hI=; b=mKE8BYyaVzHb3nN08jz+mwjXDgXxCSS+vOXrISIvM3XYsYWJ0hwVveD2f3lQRVSDNs ab0esOsS7KsbxZeFcOPC1iXscTxmQN6Q6aOncSGN50P8bIHsUDYHkyiVjDqff8zELYSV ETMWK+ArFOHYlx681Zswczx9LqFpZf+x/82W1AcuRxSuo5oL4PXdUeOCOL6CGCXonwka GeE0CeEY8rsuiTApDgE8XNQD5qGwJUktkJevQt75B1yDjtR0Pnb7fn3E73bXLZAKaZkF Mzq1hj563n3gZRXeyNPNAGLl06H4MPe1E9rSTxXmvDP2ocQD0Fh8kPxyv8WT/1P0xHK9 G+TA== X-Gm-Message-State: ALoCoQlkLxjBo0rFUBlxILqvYSPGp/YqlFmMfbP8qkwJr5hxEIQTBE0rkB9jZ9oAb6xksKpfidHk X-Received: by 10.107.47.89 with SMTP id j86mr5568549ioo.32.1415913927760; Thu, 13 Nov 2014 13:25:27 -0800 (PST) Received: from laughingman.mtv.corp.google.com ([172.22.65.61]) by mx.google.com with ESMTPSA id dy3sm346158igb.1.2014.11.13.13.25.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 13 Nov 2014 13:25:26 -0800 (PST) From: Benson Leung 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 Subject: [PATCH v2] HID: usbhid: clear needs_remote_wakeup before usb_kill_urb Date: Thu, 13 Nov 2014 13:25:17 -0800 Message-Id: <1415913917-15370-1-git-send-email-bleung@chromium.org> X-Mailer: git-send-email 2.1.0.rc2.206.gedb03e5 In-Reply-To: <1415909806-23848-1-git-send-email-bleung@chromium.org> References: <1415909806-23848-1-git-send-email-bleung@chromium.org> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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);