From patchwork Wed Feb 28 13:38:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcus Folkesson X-Patchwork-Id: 10247543 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 A290160211 for ; Wed, 28 Feb 2018 13:38:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9292428D2A for ; Wed, 28 Feb 2018 13:38:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 874E628D34; Wed, 28 Feb 2018 13:38:46 +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 30BE328D2A for ; Wed, 28 Feb 2018 13:38:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752516AbeB1Nic (ORCPT ); Wed, 28 Feb 2018 08:38:32 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:42343 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752478AbeB1NiW (ORCPT ); Wed, 28 Feb 2018 08:38:22 -0500 Received: by mail-lf0-f68.google.com with SMTP id t204so3531584lff.9; Wed, 28 Feb 2018 05:38:21 -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=sM64fkkhu/jzWgYlNxD3FAJ+yu4nq6Nj4BoktDN8hi0=; b=QHc4QEHOptmZsjis57NLqsc868TAhAd3x23EBz8k4nyqTGUyuc+UHN6hVO4C9DRMWD fzN2eB1KeXk//GMt4SSvnkhXibkNqUy+vhRCvYWH4OFX6m8lP4x0fVBcME/Wm54Z3igT oyA+LgvkaovPjwdcdfWOoKx6Z5WmWxbwuLBSLL013eGjkEYUHEpe4v6mzF4Egjiv5L85 XkFZ6/FsZBBjd7jJ/mt0YxsZpxip5D6kxMahsvnPBOd7M0qFo88ZulwtfgaSJ7GDjnRZ Ofg7WAu96w4kd5zLC74NS/WGtBrDhM720YcG7efN+o6Gdvww+eYq7M5PMp5nf7AwsZtH CovQ== 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=sM64fkkhu/jzWgYlNxD3FAJ+yu4nq6Nj4BoktDN8hi0=; b=N+mdFpp2lAhavtPWO9MNuNkMwXbJM3A1IjzusWlbLA6sh4/gMphUiH0thT4KQz12tZ NkFORkADJDoYGxrvuv36ttOmosqCocTUOXzmbQDU+9GEWSTOqYxksxkM35dvRu6W9X/z 56uGR02t5tH2kF3dhUSBO53UNIUH2vRFFu/L9tUc2b1dk680Ln8/PdYAIPO5YZRywZgl GJ2BfBED5GQ/+p3o5+JWeNn3BfyM5ZR/cXr5+KqVDQ1tS38eg+6fN2vpaAmztgyw3yWO S8JK1U7Xc9CT1O2KQ6JiaE/PxvK4c2xL+DjM/4ziJp4s+fLdt/3lFP8yF/eD9WXzjYH1 SLeA== X-Gm-Message-State: APf1xPACDbKiY9aku4PPO+x7Y8T4BkKUanxuoftcAEq5+zrM3MaXqFTE gbnl9uXNFu91pWlV7UOxgd8= X-Google-Smtp-Source: AH8x224m9zFZF/JJ8j3kvQ8AXpaR98GOxJWEuaLcVxYS48oHrCRDCD+qsSOJRGQzbjZURXu0TG4myg== X-Received: by 10.46.81.25 with SMTP id f25mr12653546ljb.50.1519825101131; Wed, 28 Feb 2018 05:38:21 -0800 (PST) Received: from localhost.localdomain (c-2ec257a5-74736162.cust.telenor.se. [46.194.87.165]) by smtp.gmail.com with ESMTPSA id f70sm373992lfi.4.2018.02.28.05.38.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Feb 2018 05:38:20 -0800 (PST) From: Marcus Folkesson To: Dmitry Torokhov , Arvind Yadav Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Marcus Folkesson Subject: [RESEND PATCH 6/6] input: usbtouchscreen: do not rely on input_dev->users Date: Wed, 28 Feb 2018 14:38:03 +0100 Message-Id: <20180228133803.30040-7-marcus.folkesson@gmail.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180228133803.30040-1-marcus.folkesson@gmail.com> References: <20180228133803.30040-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);