From patchwork Sat Jan 20 21:47:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcus Folkesson X-Patchwork-Id: 10176761 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 D9808605BA for ; Sat, 20 Jan 2018 21:48:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CAAFB20453 for ; Sat, 20 Jan 2018 21:48:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BFE64207A7; Sat, 20 Jan 2018 21:48:13 +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=ham 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 65B60205A8 for ; Sat, 20 Jan 2018 21:48:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756652AbeATVrx (ORCPT ); Sat, 20 Jan 2018 16:47:53 -0500 Received: from mail-lf0-f66.google.com ([209.85.215.66]:41837 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756695AbeATVrp (ORCPT ); Sat, 20 Jan 2018 16:47:45 -0500 Received: by mail-lf0-f66.google.com with SMTP id f136so6160973lff.8; Sat, 20 Jan 2018 13:47:44 -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=6WdRj+Xz63Mwal6vQxPXIksyckAFD3Ft1cM6QRBCgJ8=; b=W7KEmMmwA3G9MMxguWk0CltVeYVS+WtKiQ75sovHYQIQt5ErDL4hjwG/dNayG5fKae efg75AqaLpmDvXtsSnXmjPk5uQ9H9KNGLgOc7kMLgC+vTG31oiDqeYG8jbiyeVlQPEpM C9EBTbvbdixrbiwNfM5fBLkTb1Av/P8snEKwY98knyAHmtVILJOl+htq1DGWnEQtrGmM XfxFqOpxt9Q3xPNncgIhV/K7nrd5RywDh3bRsaNb7pyMc41wBtq1oxeVa0JTPHSFV/Qb dUb8VV7QJFNTXXWkSxviY0MK6A+Z9Ngz9W1i3wQ9+ISElAMX724+CkMRmLq1+09lxEEp MPIA== 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=6WdRj+Xz63Mwal6vQxPXIksyckAFD3Ft1cM6QRBCgJ8=; b=m+VDDNoneUHc6LmPs0/ZiIEf7VILUFuv2s+dzq80VVZI8qj6WmIrVU2HN97fs/nt20 AdbhoanPt9zW+Frub6eMEZlKfPMCZ1gMB6Mot8aE+aZXYN8auzLXRuspWfHFPBAiW3nG kLk9GePxW3q324pmnqDQpKq3XiKK38cHGnAu4ygowqtHR4Tg5yCirwcwgd+uCq+gWr3y 9sOp11T2INmb1kPldJ/MVo6g+aa6Ys9z8zPgh5GsJVRwy7e349KdApfaynxZ8GG2o59o FOecESv1hN/qDXP1Odr8IysGcUDRodzlSRvthph0ftivGSPBJw7mTA3+kom+UHQW5ehO z00Q== X-Gm-Message-State: AKwxytcL3gXMMWPeZyiUAr5vReQO5pe9VBKcZj8fsNwItOe9Bo6dZd16 oFqXXj04yHAyFhO2gGV+LDY= X-Google-Smtp-Source: AH8x225hs/pmyAJtZC/qb+N3uKbZOvXcfw0j20g0uFCxJuDL8ryrODqhtpPSvj7d0/dL/U2mgVC2xw== X-Received: by 10.46.4.15 with SMTP id 15mr1313522lje.64.1516484863842; Sat, 20 Jan 2018 13:47:43 -0800 (PST) Received: from localhost.localdomain (c-2ec2e669-74736162.cust.telenor.se. [46.194.230.105]) by smtp.gmail.com with ESMTPSA id m25sm2127185lfc.38.2018.01.20.13.47.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 20 Jan 2018 13:47:42 -0800 (PST) From: Marcus Folkesson To: Dmitry Torokhov , Marcus Folkesson , Arvind Yadav Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] input: synaptics_usb: do not rely on input_dev->users Date: Sat, 20 Jan 2018 22:47:27 +0100 Message-Id: <20180120214727.9067-2-marcus.folkesson@gmail.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180120214727.9067-1-marcus.folkesson@gmail.com> References: <20180120214727.9067-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; }