From patchwork Wed Jun 7 06:59:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 9770661 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 E2E3F60234 for ; Wed, 7 Jun 2017 07:00:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD94F28472 for ; Wed, 7 Jun 2017 07:00:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C19CD284ED; Wed, 7 Jun 2017 07:00:44 +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 7332928472 for ; Wed, 7 Jun 2017 07:00:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751743AbdFGHAb (ORCPT ); Wed, 7 Jun 2017 03:00:31 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:34060 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751617AbdFGG7p (ORCPT ); Wed, 7 Jun 2017 02:59:45 -0400 Received: by mail-pg0-f65.google.com with SMTP id v14so634504pgn.1; Tue, 06 Jun 2017 23:59:45 -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=57cihdWp6R7diDHw6Ae6cNL1oxvQ3QQxEIe2gW/4zpk=; b=O2BCKiKpXJbwzln/NRjKH+65G97qQ1SfeuOkxGY+uuUip0agBNnYW8PpInvFkLLolN +xsGaIvI/NsmvzZmnCnd8kWfmCWIB3UyN86PZ7VSGvMigog5pdCg1WbwJsaprz+/mZDU 0sZbOXkybhIXejV7NtzSCoGa1HgTAw2BM9DUqyLYsJdAsdYTbo+xBbtJA7fYjmU6hmTL a/h2FwmueRsG30wp65Uk0ePFpRup1MEgjsYKgzWUjZ+QH0IzOcBGGMxQJrW8VpGOgQEk fF21/m5ZhGFRf+zEgtCO+UFllEiAWHLxN8M/tdA3hIK1BZcdOWLKYmMK0Ouf3JRfsC3y zQPw== 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=57cihdWp6R7diDHw6Ae6cNL1oxvQ3QQxEIe2gW/4zpk=; b=ZNJEmbZNxhk0LGAXb6H60aoxFFQsJJ7CzoC9wh+W8Gs+Rsiwd335Q65gVztNNizKh/ AZ+C6io015iNX1V5+Ovd8Tp3Vno053DBqHBNakLKjvkkqaGnn/6w0b2LU+H0o8FwxAtw 9wY8/E+mTqEvH/hDEZnwR43gBrqNB6v3lv29khtavjHv1q56YJ6q+7Z+VZPIKLf57KKB aG2M7SLPSoQmGxvY/ed6Xay6gLdzzsVd/VDs72MlB0eDOqSaiLjCZLSq43nYcmJ+sVUk /YKC0j1f+CAsaAhcPnJdIM04KOW8InuYkBpEhBLZ6J7ImfGiL8p52sJ8sL347QdpVVFN /ZIQ== X-Gm-Message-State: AODbwcC3xET2JDobZG/PlaeLAXnmZdxNqq1DMhLj4BehSQTHSVp04pyP p2tSL5zzdHwB4Q== X-Received: by 10.84.229.8 with SMTP id b8mr26496120plk.239.1496818784919; Tue, 06 Jun 2017 23:59:44 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([172.22.152.34]) by smtp.gmail.com with ESMTPSA id r86sm1873184pfi.77.2017.06.06.23.59.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Jun 2017 23:59:44 -0700 (PDT) From: Dmitry Torokhov To: Jiri Kosina , Benjamin Tissoires Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman Subject: [PATCH v2 5/8] HID: i2c-hid: remove custom locking from i2c_hid_open/close Date: Tue, 6 Jun 2017 23:59:35 -0700 Message-Id: <20170607065938.33332-6-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.13.0.506.g27d5fe0cd-goog In-Reply-To: <20170607065938.33332-1-dmitry.torokhov@gmail.com> References: <20170607065938.33332-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 fb55fb4c39fc..6355015ed249 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)