From patchwork Wed Jun 14 07:29:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Binoy Jayan X-Patchwork-Id: 105455 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp164413qgd; Wed, 14 Jun 2017 00:30:21 -0700 (PDT) X-Received: by 10.99.64.199 with SMTP id n190mr2914675pga.281.1497425421787; Wed, 14 Jun 2017 00:30:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497425421; cv=none; d=google.com; s=arc-20160816; b=lj3AO9+uWyWrfUO85MbVuPhzY4WsUIjkv5UDydQV4Oop6Z8GTG4lgv2oXT3EEVWKFU e8npe7HTlqD6BX5cqi/DGzlHv5tv1aMUhiigXotDSN4+Wu472s8cnEFv2wqgLencXcHW CaBI+s/e50G4hG8hKvV1TrPtDly5YWwKA6a7hCAUESUHCSkv3oiWTy00CLFmX6dwQ2J+ PhFGavWqR+VlRjRvaICM/GV31FUtHwXQ/xo5KS/giXS3224RgDqF1wbK1k988QqcGdMl iCXg15KF/HYU5DXO/4jRW1ZvvwmzM9QznoUtvZisnBT4FSdFSapJR83rZF+xfqIsxGVY N8QQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=PHmwvinbE4s0RDiWlj3aHH4fqnsP768EIbStL3XEwx4=; b=lUgoVHVqfmw7wWAxoYyoZZwn6UBM5mCbSAlxmbBwv0oDqEMU37r+Rz7wj70mZr+akZ ydGmd7pn5CpAH7l05PCUkeYCKde1MNOmZ8CJHwXx2Ksuf38MP71LKkzUFiZSYHjsMyj9 2XxO/1N2wMj4rBNOqI1ATK/jW8p9pnArkmhOoq8v7bG5u1icgh80BPfNOE8GZ00DuPA3 CfTSPq6DIvzkz4yzMWVWjNRxc9Y1yZYxInW9fpXWgUtKpcFJQU7ZdPwB0KeFNflrj//k vTKilwUSzUtp2t9rqNTf2uLbsR0GriRLs2QYquiarmymjV0bt3BfohW3ItyfQ5pQk2y/ iRuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=Gco7hum6; spf=pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-input-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k123si69996pgk.325.2017.06.14.00.30.21 for ; Wed, 14 Jun 2017 00:30:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=Gco7hum6; spf=pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-input-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754122AbdFNHaU (ORCPT ); Wed, 14 Jun 2017 03:30:20 -0400 Received: from mail-pg0-f51.google.com ([74.125.83.51]:34703 "EHLO mail-pg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751324AbdFNHaU (ORCPT ); Wed, 14 Jun 2017 03:30:20 -0400 Received: by mail-pg0-f51.google.com with SMTP id v18so71919417pgb.1 for ; Wed, 14 Jun 2017 00:30:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=qeOany88zUFXRo8EMMTOGQJNqFIsXQhrdA/jHYSOwJI=; b=Gco7hum6hvTMs2Cv6ahZnmGppLHO17lNCwbBxG2mZlGMWvb0YyYU2s/MoxBAqeOpv+ Ak6oD0AvXFT1e7MD+0m7FZslPVv62wJ6o+0GgCib9wzXkDJjRs+CNi7mwQmncs2eBgyx bD5pO6fRiL8VfYitVUc6l+0HOkqp5ekWmaXrg= 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; bh=qeOany88zUFXRo8EMMTOGQJNqFIsXQhrdA/jHYSOwJI=; b=mLlBzOEpYy/5stdIEvO+aNUO3lTr5sGi7UDKA68M8YCjuBvo6OiJ1+2fpErnyhGrHs lroRfLs/L14VDmXwZS3MrDWdWvfy+NKXaMQA7PjtO4hsLvK1AMg7GEUz1VHOdYGmPHOj qxYrfLA4c1FLjiPz2qyx5IlNtbU59dIm8SJaAKt0Hu1RSGEyyGGVSV8V2bUDPVbntK6M sD8BDsQCb8L5Wh6MhtWerPFnMxj/6BlUEL5XFe6gZIp4bg9bH3dTPHufQPdYDAuU1VLP NRVYFLsdzwfBlXdk1N2YmCiMlwxBh4RPDdY7ExbzRhcw4VlkcsyufMbwq+H1Q6s98G5Q pZ1g== X-Gm-Message-State: AKS2vOwv/+rpmmxwHRqIvghXIRbwvADVSGRrRPyzGZo7h8Xno9uJXPJZ H8UGp2BmsKrUgzny X-Received: by 10.98.59.92 with SMTP id i89mr2910862pfa.122.1497425419275; Wed, 14 Jun 2017 00:30:19 -0700 (PDT) Received: from blr-ubuntu-59.ap.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id 204sm374712pfu.23.2017.06.14.00.30.16 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Jun 2017 00:30:18 -0700 (PDT) From: Binoy Jayan To: Binoy Jayan Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, Arnd Bergmann , Rajendra , Mark Brown , Jiri Kosina , Benjamin Tissoires , David Herrmann , Andrew de los Reyes Subject: [PATCH v4] HID: Remove the semaphore driver_lock Date: Wed, 14 Jun 2017 12:59:51 +0530 Message-Id: <1497425391-7188-1-git-send-email-binoy.jayan@linaro.org> X-Mailer: git-send-email 1.9.1 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org The semaphore 'driver_lock' is used as a simple mutex, and also unnecessary as suggested by Arnd. Hence removing it, as the concurrency between the probe and remove is already handled in the driver core. Suggested-by: Arnd Bergmann Signed-off-by: Binoy Jayan Acked-by: Benjamin Tissoires Reviewed-by: David Herrmann --- v3 --> v4: Changed title v2 --> v3: Removed reference to driver_lock in comments v1 --> v2: Removed driver_lock drivers/hid/hid-core.c | 15 ++++----------- include/linux/hid.h | 3 +-- 2 files changed, 5 insertions(+), 13 deletions(-) -- Binoy Jayan -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 04cee65..559533b 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -2225,11 +2225,9 @@ static int hid_device_probe(struct device *dev) const struct hid_device_id *id; int ret = 0; - if (down_interruptible(&hdev->driver_lock)) - return -EINTR; if (down_interruptible(&hdev->driver_input_lock)) { ret = -EINTR; - goto unlock_driver_lock; + goto end; } hdev->io_started = false; @@ -2256,8 +2254,7 @@ static int hid_device_probe(struct device *dev) unlock: if (!hdev->io_started) up(&hdev->driver_input_lock); -unlock_driver_lock: - up(&hdev->driver_lock); +end: return ret; } @@ -2267,11 +2264,9 @@ static int hid_device_remove(struct device *dev) struct hid_driver *hdrv; int ret = 0; - if (down_interruptible(&hdev->driver_lock)) - return -EINTR; if (down_interruptible(&hdev->driver_input_lock)) { ret = -EINTR; - goto unlock_driver_lock; + goto end; } hdev->io_started = false; @@ -2287,8 +2282,7 @@ static int hid_device_remove(struct device *dev) if (!hdev->io_started) up(&hdev->driver_input_lock); -unlock_driver_lock: - up(&hdev->driver_lock); +end: return ret; } @@ -2745,7 +2739,6 @@ struct hid_device *hid_allocate_device(void) init_waitqueue_head(&hdev->debug_wait); INIT_LIST_HEAD(&hdev->debug_list); spin_lock_init(&hdev->debug_list_lock); - sema_init(&hdev->driver_lock, 1); sema_init(&hdev->driver_input_lock, 1); return hdev; diff --git a/include/linux/hid.h b/include/linux/hid.h index 5be325d..a49203f 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -516,7 +516,6 @@ struct hid_device { /* device report descriptor */ struct hid_report_enum report_enum[HID_REPORT_TYPES]; struct work_struct led_work; /* delayed LED worker */ - struct semaphore driver_lock; /* protects the current driver, except during input */ struct semaphore driver_input_lock; /* protects the current driver */ struct device dev; /* device */ struct hid_driver *driver; @@ -538,7 +537,7 @@ struct hid_device { /* device report descriptor */ unsigned int status; /* see STAT flags above */ unsigned claimed; /* Claimed by hidinput, hiddev? */ unsigned quirks; /* Various quirks the device can pull on us */ - bool io_started; /* Protected by driver_lock. If IO has started */ + bool io_started; /* If IO has started */ struct list_head inputs; /* The list of inputs */ void *hiddev; /* The hiddev structure */