From patchwork Wed May 31 20:59:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 9758137 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 A7CAE60390 for ; Wed, 31 May 2017 21:01:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A5A1284AF for ; Wed, 31 May 2017 21:01:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F315284E3; Wed, 31 May 2017 21:01:04 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 36CEF284AF for ; Wed, 31 May 2017 21:01:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751041AbdEaVAp (ORCPT ); Wed, 31 May 2017 17:00:45 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:34226 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751266AbdEaVAD (ORCPT ); Wed, 31 May 2017 17:00:03 -0400 Received: by mail-pf0-f196.google.com with SMTP id w69so4191731pfk.1; Wed, 31 May 2017 13:59:57 -0700 (PDT) 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=9DIZHsNE9pXfau8yCi3IuT3l1lsS8PeSxvsY7Pyiidk=; b=K8ml+LTPeOrdB3eDM/ZE2vTFcm0vdOFpNoJ9yYkfQ5hzad4bmeRKeI31lVw8W3ffPc xcSu0LvePHL+BU9YJViDAUAUlVnKF3GC7JQyUeGd+OAA2cDzTcv859it41WHvaM48I3g sgwMtp0R0l9Xkr+yFbaNOH5czRMhW+kRu7RD1TPhkEWxTGmlDyZN+jsqTXV0qR0eC4Zt +oFbCh3OH5YrcBBSXcElIVR+8s2Dkeh18leSwVS6tUJ6RJmDFWQL/7inXkDPhw6obU+q 7lnTwqNe7wdt3rKBcs7dQAoUlki350rsM28RU350tLdHo2jQwBepy9ARmTHIX5iDU3FB u94g== 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=9DIZHsNE9pXfau8yCi3IuT3l1lsS8PeSxvsY7Pyiidk=; b=XhwZhy48MkxBqCeOPYwV16rzBg8g5qvECMmuml+H+HvkasY0l04b0vLfFNdGuOalsp TovB0CKMwdcd3oJL3jBnRAB13TxbxapJdOyHvIM9AI3FC3EMkmUErrwQPb9t6LCTpsGE Km78ymtoVn7IWFH77ou5UPv8g4Y34RiAdQYmQ1Rf1dRFZUuIB7SQpo9G5VDSTJ3X472I qmPQ871tK8tTg07GiBDF5Tbiqs/dRcaua6sscRWXu8mRSlYoMtnCZoYfOQQCY8B1Zm1f mUIUKWLyCTA8Dlf1j2ZkKZMOdDnCbJKJM7XYgBOHGjMeG7FVKoSJzMLTycvvWnNIVK+i nEHA== X-Gm-Message-State: AODbwcCsPNYyXa4apVPEhTZ7zycY+jxSMOqMtgaP19EbnicR5uSCe/HA feLBfZiug0MYWQ== X-Received: by 10.98.252.21 with SMTP id e21mr32563445pfh.33.1496264397513; Wed, 31 May 2017 13:59:57 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([172.22.152.34]) by smtp.gmail.com with ESMTPSA id i5sm28547444pfj.41.2017.05.31.13.59.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 31 May 2017 13:59:57 -0700 (PDT) From: Dmitry Torokhov To: Jiri Kosina , Benjamin Tissoires Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/7] HID: i2c-hid: remove custom locking from i2c_hid_open/close Date: Wed, 31 May 2017 13:59:49 -0700 Message-Id: <20170531205951.30852-6-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.13.0.506.g27d5fe0cd-goog In-Reply-To: <20170531205951.30852-1-dmitry.torokhov@gmail.com> References: <20170531205951.30852-1-dmitry.torokhov@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 Now that HID core enforces serialization of transport driver open/close calls we can remove custom locking from i2c-hid driver. Signed-off-by: Dmitry Torokhov --- drivers/hid/i2c-hid/i2c-hid.c | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c index 8daa8ce64ebb..735669c9777e 100644 --- a/drivers/hid/i2c-hid/i2c-hid.c +++ b/drivers/hid/i2c-hid/i2c-hid.c @@ -743,18 +743,12 @@ static int i2c_hid_open(struct hid_device *hid) struct i2c_hid *ihid = i2c_get_clientdata(client); int ret = 0; - mutex_lock(&i2c_hid_open_mut); - if (!hid->open++) { - ret = pm_runtime_get_sync(&client->dev); - if (ret < 0) { - hid->open--; - goto done; - } - set_bit(I2C_HID_STARTED, &ihid->flags); - } -done: - mutex_unlock(&i2c_hid_open_mut); - return ret < 0 ? ret : 0; + ret = pm_runtime_get_sync(&client->dev); + if (ret < 0) + return ret; + + set_bit(I2C_HID_STARTED, &ihid->flags); + return 0; } static void i2c_hid_close(struct hid_device *hid) @@ -762,18 +756,10 @@ static void i2c_hid_close(struct hid_device *hid) struct i2c_client *client = hid->driver_data; struct i2c_hid *ihid = i2c_get_clientdata(client); - /* protecting hid->open to make sure we don't restart - * data acquistion due to a resumption we no longer - * care about - */ - mutex_lock(&i2c_hid_open_mut); - if (!--hid->open) { - clear_bit(I2C_HID_STARTED, &ihid->flags); + clear_bit(I2C_HID_STARTED, &ihid->flags); - /* Save some power */ - pm_runtime_put(&client->dev); - } - mutex_unlock(&i2c_hid_open_mut); + /* Save some power */ + pm_runtime_put(&client->dev); } static int i2c_hid_power(struct hid_device *hid, int lvl)