From patchwork Thu Jul 13 00:14:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 9837571 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C9C2C602D8 for ; Thu, 13 Jul 2017 00:14:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9328286C0 for ; Thu, 13 Jul 2017 00:14:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD4A7286D4; Thu, 13 Jul 2017 00:14:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60CF3286C0 for ; Thu, 13 Jul 2017 00:14:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752000AbdGMAO3 (ORCPT ); Wed, 12 Jul 2017 20:14:29 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:33363 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751019AbdGMAO1 (ORCPT ); Wed, 12 Jul 2017 20:14:27 -0400 Received: by mail-pf0-f194.google.com with SMTP id e199so5002676pfh.0; Wed, 12 Jul 2017 17:14:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=9C7FM9NfdH3aTJ4UrgFipOwdafaCE9FP6RbRMjNO9YU=; b=Hxb8dfqfSWeuuV/llDx4zDOruUjL7Mj1z7DH5el4u5Z30fH5cNHQW0L5SZu12B0m7S 2y2qdqqfZ5G3cOrYoh10gBDRnH5NvvJUnM2/nDyl7hLgR4ojY9N5koAD+BeHRXNeuWqE HDzGrQ7GIC2olozs5wL786WaJ9dfInIH+bOllBK0rTys8Z0I8JSngoHhq/7DEPSBFyGt VyEBHjkuc7bGvhvdjl1fuAJ17sbbywzSG0QfqITnrW1vuUXvPI6Cir3BCeD7U2Q57jAi QH8PBIII2NzMO6K8Bo56E32iTEZF4dQOkZ09oFEcR/7NOirFsGfkJNh+ZpBWYc6ZB2zl v+5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=9C7FM9NfdH3aTJ4UrgFipOwdafaCE9FP6RbRMjNO9YU=; b=OwyYgqf+LlEH6ZUPCXjeSeZ4VBLQmr7xHCxFGXdMt4BPjUsj9s94GrlGkQrPC4DdMU XyzCUX9OEU2RVjcZqzVZS44UsAn1vFYF/MTBRodgypcokls/q4UF0iOZ1AKokFPjxm7p LWOA/CQmoMRokF9Uo7JNJQvxFSaJwBp2kxSSK/tzLWVt+bAOHDwJqB5ge2SQD/r/rbsu IoJ245xFO/q9yW+vq0Ihhc+jgN0+z22HTYH/Snk4rjssLvs2d/VLDlN3w8zfN8Dbdomu jg2da50gRAOpdyDzw/o3Fe1e3bMQzw0J6I0tl0U/U9E3sTW6c+aWX6IX8G6NzSHq5WKG eKwA== X-Gm-Message-State: AIVw1101U1k0AuZNMWF1CGO9pguo4MRRXbe38vJlX8DrYt4+uP1xTyM/ y3lpka8dwFslkQ== X-Received: by 10.84.216.28 with SMTP id m28mr6844692pli.275.1499904866988; Wed, 12 Jul 2017 17:14:26 -0700 (PDT) Received: from dtor-ws ([2620:0:1000:1311:b087:6a1c:96e1:e780]) by smtp.gmail.com with ESMTPSA id p11sm8188136pfk.128.2017.07.12.17.14.26 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Wed, 12 Jul 2017 17:14:26 -0700 (PDT) Date: Wed, 12 Jul 2017 17:14:24 -0700 From: Dmitry Torokhov To: Jiri Kosina Cc: Benjamin Tissoires , Olof Johansson , linux-usb@vger.kernel.org, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] HID: usbhid: fix "always poll" quirk Message-ID: <20170713001424.GA7990@dtor-ws> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Even though the IO for devices with "always poll" quirk is already running, we still need to set HID_OPENED bit in usbhid->iofl so the interrupt handler does not ignore the data coming from the device. Reported-by: Olof Johansson Tested-by: Olof Johansson Fixes: e399396a6b0 ("HID: usbhid: remove custom locking from usbhid_open...") Signed-off-by: Dmitry Torokhov Acked-by: Benjamin Tissoires --- drivers/hid/usbhid/hid-core.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c index 76013eb5cb7f..c008847e0b20 100644 --- a/drivers/hid/usbhid/hid-core.c +++ b/drivers/hid/usbhid/hid-core.c @@ -680,18 +680,21 @@ static int usbhid_open(struct hid_device *hid) struct usbhid_device *usbhid = hid->driver_data; int res; + set_bit(HID_OPENED, &usbhid->iofl); + if (hid->quirks & HID_QUIRK_ALWAYS_POLL) return 0; res = usb_autopm_get_interface(usbhid->intf); /* the device must be awake to reliably request remote wakeup */ - if (res < 0) + if (res < 0) { + clear_bit(HID_OPENED, &usbhid->iofl); return -EIO; + } usbhid->intf->needs_remote_wakeup = 1; set_bit(HID_RESUME_RUNNING, &usbhid->iofl); - set_bit(HID_OPENED, &usbhid->iofl); set_bit(HID_IN_POLLING, &usbhid->iofl); res = hid_start_in(hid); @@ -727,19 +730,20 @@ static void usbhid_close(struct hid_device *hid) { struct usbhid_device *usbhid = hid->driver_data; - if (hid->quirks & HID_QUIRK_ALWAYS_POLL) - return; - /* * Make sure we don't restart data acquisition due to * a resumption we no longer care about by avoiding racing * with hid_start_in(). */ spin_lock_irq(&usbhid->lock); - clear_bit(HID_IN_POLLING, &usbhid->iofl); clear_bit(HID_OPENED, &usbhid->iofl); + if (!(hid->quirks & HID_QUIRK_ALWAYS_POLL)) + clear_bit(HID_IN_POLLING, &usbhid->iofl); spin_unlock_irq(&usbhid->lock); + if (hid->quirks & HID_QUIRK_ALWAYS_POLL) + return; + hid_cancel_delayed_stuff(usbhid); usb_kill_urb(usbhid->urbin); usbhid->intf->needs_remote_wakeup = 0;