From patchwork Wed Jan 24 15:47:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcus Folkesson X-Patchwork-Id: 10182773 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 906D1602B7 for ; Wed, 24 Jan 2018 15:49:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F110288B2 for ; Wed, 24 Jan 2018 15:49:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 714F128902; Wed, 24 Jan 2018 15:49:26 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_HI,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 1B811288B2 for ; Wed, 24 Jan 2018 15:49:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934194AbeAXPr1 (ORCPT ); Wed, 24 Jan 2018 10:47:27 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:45022 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934121AbeAXPrY (ORCPT ); Wed, 24 Jan 2018 10:47:24 -0500 Received: by mail-lf0-f67.google.com with SMTP id v188so5807806lfa.11; Wed, 24 Jan 2018 07:47:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=YuIo0xCoIHXiohZtA0uxqzZzfzG/X3jcBl5Lzz5qOG0=; b=Gzd5JEMsAG7oDWcZHpsWRHis/4NUA2zlCjkkdxiuj/EAPf+RoU9lkgUU6vvvLFj9Oa srii4vXqgHPw8USyh2UBYagVHuslj77Tob+r/gs7+qkRkG5G4bUqRX42/cG9oyxTirZV URmp04r7yO17a+5cry32AsZKQcMNDp+JbbQ+wp+EDqPF8p9XeTmx1NtbLg0t0Zwx88bk WuU/M3990OkS0Kk+A6GgJADP9kjv63HulBOcAiccjJFdnpC2v5SpGQLwJxTGIDOEfzvP UPq5EYvC2HzxKt593L67rJI7Cuu+UQwJpPIvCXCKnZWMOyaKf7gs4O1ANBWzAp+ZOd24 jo4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=YuIo0xCoIHXiohZtA0uxqzZzfzG/X3jcBl5Lzz5qOG0=; b=DXZu9XOWYDjS+1YO2ERck+6OtylJtZXsXThZkwHkGqUwqx6f8jNwi4BI9HNJfWITWU t/2nl0iem1OQvn550EZuD0Pt+b2NOCRNvFhRpPEE01mpQVWzWis0r8O1aAl7C5bUT6ol C0Hrc+djUw6k7mReKhQp1rGiO95ebvMujpy7chB0vfMQQhsV29FJ2Z2cDlOPWOJyGGiN injOod0LKxitrUYqiDgF7vPbuocfJpTWRcwi7AhdBodY4e96Q83AM1iCUhOAfJ42A8X5 4QglRooL0lYjrE7tastes4WcxrlS4soC4V8Rw1sxypuxmX+lNVfY1m9In3P2ho/gAHhd qorQ== X-Gm-Message-State: AKwxytf6oGUWm1qbnZEqCa74g1KsQ0uEhM23zjmxenDRYqJShsdx/Yif EIxrU+ENY39coCCrA7tV7izjrwuI X-Google-Smtp-Source: AH8x227Uil/Y5i59nzp4HpAxE9GzjoHWOC4nvIhr8WIg+b/zhTmnOt43pzvOrdsdOr2TnzhZWRTfaw== X-Received: by 10.25.222.18 with SMTP id v18mr3650904lfg.92.1516808842942; Wed, 24 Jan 2018 07:47:22 -0800 (PST) Received: from localhost.localdomain ([81.236.84.183]) by smtp.gmail.com with ESMTPSA id t6sm121711ljb.7.2018.01.24.07.47.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Jan 2018 07:47:22 -0800 (PST) From: Marcus Folkesson To: Dmitry Torokhov Cc: Marcus Folkesson , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] input: usbtouchscreen: do not rely on input_dev->users Date: Wed, 24 Jan 2018 16:47:13 +0100 Message-Id: <20180124154713.28962-2-marcus.folkesson@gmail.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180124154713.28962-1-marcus.folkesson@gmail.com> References: <20180124154713.28962-1-marcus.folkesson@gmail.com> 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 If the device is unused and suspended, a call to open will cause the device to autoresume through the call to usb_autopm_get_interface(). input_dev->users is already incremented by the input subsystem, therefore this expression will always be evaluated to true: if (input->users || usbtouch->type->irq_always) result = usb_submit_urb(usbtouch->irq, GFP_NOIO); The same URB will then be fail when resubmitted in usbtouch_open(). Introduce usbtouch->is_open to keep track of the state instead. Signed-off-by: Marcus Folkesson --- drivers/input/touchscreen/usbtouchscreen.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c index e964658203d8..0356ad792e40 100644 --- a/drivers/input/touchscreen/usbtouchscreen.c +++ b/drivers/input/touchscreen/usbtouchscreen.c @@ -114,6 +114,7 @@ struct usbtouch_usb { struct input_dev *input; struct usbtouch_device_info *type; struct mutex pm_mutex; /* serialize access to open/suspend */ + bool is_open; char name[128]; char phys[64]; void *priv; @@ -1466,6 +1467,7 @@ static int usbtouch_open(struct input_dev *input) } usbtouch->interface->needs_remote_wakeup = 1; + usbtouch->is_open = 1; out_put: mutex_unlock(&usbtouch->pm_mutex); usb_autopm_put_interface(usbtouch->interface); @@ -1481,6 +1483,7 @@ static void usbtouch_close(struct input_dev *input) mutex_lock(&usbtouch->pm_mutex); if (!usbtouch->type->irq_always) usb_kill_urb(usbtouch->irq); + usbtouch->is_open = 0; mutex_lock(&usbtouch->pm_mutex); r = usb_autopm_get_interface(usbtouch->interface); @@ -1502,11 +1505,10 @@ static int usbtouch_suspend static int usbtouch_resume(struct usb_interface *intf) { struct usbtouch_usb *usbtouch = usb_get_intfdata(intf); - struct input_dev *input = usbtouch->input; int result = 0; mutex_lock(&usbtouch->pm_mutex); - if (input->users || usbtouch->type->irq_always) + if (usbtouch->is_open || usbtouch->type->irq_always) result = usb_submit_urb(usbtouch->irq, GFP_NOIO); mutex_unlock(&usbtouch->pm_mutex); @@ -1516,7 +1518,6 @@ static int usbtouch_resume(struct usb_interface *intf) static int usbtouch_reset_resume(struct usb_interface *intf) { struct usbtouch_usb *usbtouch = usb_get_intfdata(intf); - struct input_dev *input = usbtouch->input; int err = 0; /* reinit the device */ @@ -1532,7 +1533,7 @@ static int usbtouch_reset_resume(struct usb_interface *intf) /* restart IO if needed */ mutex_lock(&usbtouch->pm_mutex); - if (input->users) + if (usbtouch->is_open) err = usb_submit_urb(usbtouch->irq, GFP_NOIO); mutex_unlock(&usbtouch->pm_mutex);