From patchwork Wed Jan 24 15:46:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcus Folkesson X-Patchwork-Id: 10182775 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 6C904602B7 for ; Wed, 24 Jan 2018 15:49:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B216288B2 for ; Wed, 24 Jan 2018 15:49:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4E7D028911; Wed, 24 Jan 2018 15:49:38 +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 019E1288B2 for ; Wed, 24 Jan 2018 15:49:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934209AbeAXPrF (ORCPT ); Wed, 24 Jan 2018 10:47:05 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:33218 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934094AbeAXPqv (ORCPT ); Wed, 24 Jan 2018 10:46:51 -0500 Received: by mail-lf0-f67.google.com with SMTP id t139so5853619lff.0; Wed, 24 Jan 2018 07:46:50 -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=AiuIGMFULl17jpjE2e14zNGhahpM3Kkccppb0iBuuzE=; b=A5939xxoPobU8J+dq4YAbZZ050hqmmcr+/iZcIPNunnmWBvdzF1o3M8yFCNNDMpPJd rPutKTYEyIYTOHvMYgwZgB/td/hUbKCAocjZnVBrg9MJpUBd3RrJ9yPnxQPXNCra7Fa+ YIjr1luWFR9hshwsJVCHdqACscpnVUjM/my2/kK7FCmFvufHa5I8WRI0TXsQy3Bo0m3j coW/wFJ30ysjKiCVFuaGfwd9xyZNg3ieBSesDUgMxWwoDqGnAojEPIqOAnR+pNU1NSM7 OGbGHKGngJhRt6aGRxsVCIMhLoFPzM8EQTG379i1iL0oCHzntnmfpYdpDZN8PgdIbWRR i3bg== 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=AiuIGMFULl17jpjE2e14zNGhahpM3Kkccppb0iBuuzE=; b=g6SsxvbZxvXD3S2FhX1lTCMOuHYCbE8GRpASq7xzsDzQS5JebS59XUxe3HSOwhds7H qyQbnroCi1ic9L7CjvPrMuxj8AB7tchmF8FDTUUS6yQh0XN13/M/2qaepaSddNCg73ne C1HB3BNNAvDZEZCsDPBdUcaqMwneVqkgycPbPFq2RiaLV3GlkcP/fhUdLbq8wQ/um7UT yHHFdMZK51mytbQ1w52c0HentwBj60chd7xSFqP1JS4VKPkCKC/hLctHYff6va5lhrCx oAgLUAV00v8kndL8WpDjyCqAUS8MGIxHQkbleKCsVubiziDzD6z3IH2P6dEe/6NiEIti MCIg== X-Gm-Message-State: AKwxytfDUprG/ub8L87CUHD5QO82f5cUGAfFXvNehLYsUVec5vxT5+xf ewUakSxyqSzw9LFpOCElebhpjYen X-Google-Smtp-Source: AH8x224MJwLGdtm3UYI5ZqC4WmqwUIoJsw1KQ4vrFdmOG5UlfkGY4s/t7YfFtOcigSYLU11sWmbVuA== X-Received: by 10.25.72.203 with SMTP id v194mr3788801lfa.26.1516808810239; Wed, 24 Jan 2018 07:46:50 -0800 (PST) Received: from localhost.localdomain ([81.236.84.183]) by smtp.gmail.com with ESMTPSA id w26sm109782lje.75.2018.01.24.07.46.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Jan 2018 07:46:49 -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: pegasus_notetaker: do not rely on input_dev->users Date: Wed, 24 Jan 2018 16:46:42 +0100 Message-Id: <20180124154642.28824-2-marcus.folkesson@gmail.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180124154642.28824-1-marcus.folkesson@gmail.com> References: <20180124154642.28824-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 (pegasus->dev->users && usb_submit_urb(pegasus->irq, GFP_NOIO) < 0) retval = -EIO; The same URB will then be fail when resubmitted in pegasus_open(). Introduce pegasus->is_open to keep track of the state instead. Signed-off-by: Marcus Folkesson --- drivers/input/tablet/pegasus_notetaker.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/input/tablet/pegasus_notetaker.c b/drivers/input/tablet/pegasus_notetaker.c index 9ab1ed5e20e7..74c93e09c337 100644 --- a/drivers/input/tablet/pegasus_notetaker.c +++ b/drivers/input/tablet/pegasus_notetaker.c @@ -80,6 +80,7 @@ struct pegasus { /* serialize access to open/suspend */ struct mutex pm_mutex; + bool is_open; char name[128]; char phys[64]; @@ -232,6 +233,7 @@ static int pegasus_open(struct input_dev *dev) if (error) goto err_kill_urb; + pegasus->is_open = 1; mutex_unlock(&pegasus->pm_mutex); return 0; @@ -251,6 +253,7 @@ static void pegasus_close(struct input_dev *dev) mutex_lock(&pegasus->pm_mutex); usb_kill_urb(pegasus->irq); cancel_work_sync(&pegasus->init); + pegasus->is_open = 0; mutex_unlock(&pegasus->pm_mutex); usb_autopm_put_interface(pegasus->intf); @@ -415,7 +418,7 @@ static int pegasus_resume(struct usb_interface *intf) int retval = 0; mutex_lock(&pegasus->pm_mutex); - if (pegasus->dev->users && usb_submit_urb(pegasus->irq, GFP_NOIO) < 0) + if (pegasus->is_open && usb_submit_urb(pegasus->irq, GFP_NOIO) < 0) retval = -EIO; mutex_unlock(&pegasus->pm_mutex); @@ -428,7 +431,7 @@ static int pegasus_reset_resume(struct usb_interface *intf) int retval = 0; mutex_lock(&pegasus->pm_mutex); - if (pegasus->dev->users) { + if (pegasus->is_open) { retval = pegasus_set_mode(pegasus, PEN_MODE_XY, NOTETAKER_LED_MOUSE); if (!retval && usb_submit_urb(pegasus->irq, GFP_NOIO) < 0)