From patchwork Wed Feb 28 13:37:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcus Folkesson X-Patchwork-Id: 10247557 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 CEDFC60211 for ; Wed, 28 Feb 2018 13:39:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE4FC28D2A for ; Wed, 28 Feb 2018 13:39:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B2B9B28D34; Wed, 28 Feb 2018 13:39:39 +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 6280F28D2A for ; Wed, 28 Feb 2018 13:39:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752556AbeB1NjY (ORCPT ); Wed, 28 Feb 2018 08:39:24 -0500 Received: from mail-lf0-f66.google.com ([209.85.215.66]:32990 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752346AbeB1NiQ (ORCPT ); Wed, 28 Feb 2018 08:38:16 -0500 Received: by mail-lf0-f66.google.com with SMTP id o145so3574095lff.0; Wed, 28 Feb 2018 05:38:15 -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=tVBdTEhrMFS9DMX06bbjtCq635qS79hVbWSqQq5d/bY=; b=qu/9MeafysYHryuGe4FU9S8k1HQT/jBI7YTkThJcYkKiU0W73bo+W9llDuse+gk+CK hu/wIhFUuLIpxaFZHd0/A65NBx6rmSfQTmuI4+DnZFno1FvQIdCLPjjzGz/hNilKaE/2 e0LloAiI85vWjzYcCEqDLzKgdUXAAkMVfTD31nFJpJGA1+nPdl4sKw6yr4sJsus4eXKJ lY+3jNDIuRuCCIWz/xF0aWEP+1ZnJLbPzyGmq86JSTMk/0bA++W3N43l4g1pw4ln7yn1 vfYBjz7yDY3spcIaOnhdjEy6uJ9Ru5RvTWlfp2zmG20IVHtKLVaPAvX7MGA3mWcBq69L fbuQ== 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=tVBdTEhrMFS9DMX06bbjtCq635qS79hVbWSqQq5d/bY=; b=jrMfXCYI3zQTkLfKfoC5y9qXUi7YCRhhCH4C39wCLwW/EzvIx1Ow58lMUO/RtJiwuN KDPdYfcS61g3uMwuEO9uLDJgQIV3/MHkxPW1U4cgA/XcbFTNvIFfbvJcvBDMP8hgAEQI jk4nhxKp5ntiK7CciaRmlqg5eZLKh6nxMS3GmSVkSFc6fKtOAzimXCXQ51rcxxDxlTi1 eQBH2D3ayk4VOKU/9ccB3Jgk0XaXMsm6lnEPY55njZfCV/4N1TFnVe3S9O7UAh8+p2vO ww4EkA823+SkmSnD1myFajr0OkgAJSAa2CMaL3r0FpaIvYDxuSQRBdzK4ewRrG2dIYvh n3yA== X-Gm-Message-State: APf1xPC9aH9rFw0mt/DEb0hafdNau2vhIyPJsN07ZNQ0ElAkoxRTtffp WL/v1VCAyEv1RFSNouKe6CA= X-Google-Smtp-Source: AG47ELt5V9PdrIJg5FSTEq4DHNm3oTtt+Jx33xASLYcw0xtRs6ekNcsuRVWtLsTD+pBzs23SPgxwWg== X-Received: by 10.46.60.22 with SMTP id j22mr12766813lja.27.1519825094765; Wed, 28 Feb 2018 05:38:14 -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.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Feb 2018 05:38:13 -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 2/6] input: synaptics_usb: do not rely on input_dev->users Date: Wed, 28 Feb 2018 14:37:59 +0100 Message-Id: <20180228133803.30040-3-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_dev->users || (synusb->flags & SYNUSB_IO_ALWAYS)) && usb_submit_urb(synusb->urb, GFP_NOIO) < 0) { retval = -EIO; } The same URB will then be fail when resubmitted in synusb_open(). Introduce synusb->is_open to keep track of the state instead. Signed-off-by: Marcus Folkesson --- drivers/input/mouse/synaptics_usb.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/input/mouse/synaptics_usb.c b/drivers/input/mouse/synaptics_usb.c index 2c66913cf5a2..e2b726751220 100644 --- a/drivers/input/mouse/synaptics_usb.c +++ b/drivers/input/mouse/synaptics_usb.c @@ -84,6 +84,7 @@ struct synusb { /* serialize access to open/suspend */ struct mutex pm_mutex; + bool is_open; /* input device related data structures */ struct input_dev *input; @@ -266,6 +267,7 @@ static int synusb_open(struct input_dev *dev) } synusb->intf->needs_remote_wakeup = 1; + synusb->is_open = 1; out: mutex_unlock(&synusb->pm_mutex); @@ -283,6 +285,7 @@ static void synusb_close(struct input_dev *dev) mutex_lock(&synusb->pm_mutex); usb_kill_urb(synusb->urb); synusb->intf->needs_remote_wakeup = 0; + synusb->is_open = 0; mutex_unlock(&synusb->pm_mutex); if (!autopm_error) @@ -485,12 +488,11 @@ static int synusb_suspend(struct usb_interface *intf, pm_message_t message) static int synusb_resume(struct usb_interface *intf) { struct synusb *synusb = usb_get_intfdata(intf); - struct input_dev *input_dev = synusb->input; int retval = 0; mutex_lock(&synusb->pm_mutex); - if ((input_dev->users || (synusb->flags & SYNUSB_IO_ALWAYS)) && + if ((synusb->is_open || (synusb->flags & SYNUSB_IO_ALWAYS)) && usb_submit_urb(synusb->urb, GFP_NOIO) < 0) { retval = -EIO; } @@ -513,10 +515,9 @@ static int synusb_pre_reset(struct usb_interface *intf) static int synusb_post_reset(struct usb_interface *intf) { struct synusb *synusb = usb_get_intfdata(intf); - struct input_dev *input_dev = synusb->input; int retval = 0; - if ((input_dev->users || (synusb->flags & SYNUSB_IO_ALWAYS)) && + if ((synusb->is_open || (synusb->flags & SYNUSB_IO_ALWAYS)) && usb_submit_urb(synusb->urb, GFP_NOIO) < 0) { retval = -EIO; }