From patchwork Wed Dec 3 20:39:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aniroop Mathur X-Patchwork-Id: 5433171 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CD1F19F1C5 for ; Wed, 3 Dec 2014 20:39:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D1B0B20256 for ; Wed, 3 Dec 2014 20:39:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D59362021A for ; Wed, 3 Dec 2014 20:39:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752105AbaLCUjR (ORCPT ); Wed, 3 Dec 2014 15:39:17 -0500 Received: from mail-pd0-f169.google.com ([209.85.192.169]:51683 "EHLO mail-pd0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752102AbaLCUjR (ORCPT ); Wed, 3 Dec 2014 15:39:17 -0500 Received: by mail-pd0-f169.google.com with SMTP id z10so1016269pdj.28 for ; Wed, 03 Dec 2014 12:39:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=oYLQp+UA9hpF8a+pyNaZZXiZr5JCqmFFCZ+b4mk5NJk=; b=llQIYV4+U7y5Z+YgKKYhLhLbNc06woUWVI69xzBoyhvoNqvwFupjUed309C+4oH6s+ we5bLwumVgYuMhie0MN0JPbcaJ/YVT5VlOsfpgf/cYentUuZ3p8g30IWlJDuVFri2x4K QhqUf8VnnLgCarFXMnO2sIlhwMh6J4BB8VSJwa6zKyTSYeG1xPGTy1Q29AP4WtKi7YLB mbMY976+eWrPP1yRWnY6v8mG0fJVInGluQ5pAM3EbtvArggjMYmLdT7+/fwZsvbzwwbt FrInUPxevnwZiY/xdbKOUtfyAl5l942+KOO9IlH8USJM2iLSXl5huF18Ck+IW3Z0GHuk I0Mw== X-Received: by 10.68.57.167 with SMTP id j7mr19460209pbq.160.1417639156429; Wed, 03 Dec 2014 12:39:16 -0800 (PST) Received: from localhost.localdomain ([115.118.74.131]) by mx.google.com with ESMTPSA id gx5sm8584591pbb.96.2014.12.03.12.39.13 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 03 Dec 2014 12:39:15 -0800 (PST) From: Aniroop Mathur To: , , Cc: , Subject: [PATCH] Input: Initialize device count variables by -1 Date: Thu, 4 Dec 2014 02:09:06 +0530 Message-Id: <1417639146-3494-1-git-send-email-aniroop.mathur@gmail.com> 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 X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch initializes input device count variables by -1 in order to avoid extra subtraction operation performed everytime for allocation of an input device. Signed-off-by: Aniroop Mathur --- drivers/input/gameport/gameport.c | 4 ++-- drivers/input/joystick/xpad.c | 4 ++-- drivers/input/misc/ims-pcu.c | 4 ++-- drivers/input/serio/serio.c | 4 ++-- drivers/input/serio/serio_raw.c | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c index 24c41ba..d8371e8 100644 --- a/drivers/input/gameport/gameport.c +++ b/drivers/input/gameport/gameport.c @@ -490,14 +490,14 @@ EXPORT_SYMBOL(gameport_set_phys); */ static void gameport_init_port(struct gameport *gameport) { - static atomic_t gameport_no = ATOMIC_INIT(0); + static atomic_t gameport_no = ATOMIC_INIT(-1); __module_get(THIS_MODULE); mutex_init(&gameport->drv_mutex); device_initialize(&gameport->dev); dev_set_name(&gameport->dev, "gameport%lu", - (unsigned long)atomic_inc_return(&gameport_no) - 1); + (unsigned long)atomic_inc_return(&gameport_no)); gameport->dev.bus = &gameport_bus; gameport->dev.release = gameport_release_port; if (gameport->parent) diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c index 177602c..64dc7cb 100644 --- a/drivers/input/joystick/xpad.c +++ b/drivers/input/joystick/xpad.c @@ -850,7 +850,7 @@ static void xpad_led_set(struct led_classdev *led_cdev, static int xpad_led_probe(struct usb_xpad *xpad) { - static atomic_t led_seq = ATOMIC_INIT(0); + static atomic_t led_seq = ATOMIC_INIT(-1); long led_no; struct xpad_led *led; struct led_classdev *led_cdev; @@ -863,7 +863,7 @@ static int xpad_led_probe(struct usb_xpad *xpad) if (!led) return -ENOMEM; - led_no = (long)atomic_inc_return(&led_seq) - 1; + led_no = (long)atomic_inc_return(&led_seq); snprintf(led->name, sizeof(led->name), "xpad%ld", led_no); led->xpad = xpad; diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c index 719410f..69caee9 100644 --- a/drivers/input/misc/ims-pcu.c +++ b/drivers/input/misc/ims-pcu.c @@ -1851,7 +1851,7 @@ static int ims_pcu_identify_type(struct ims_pcu *pcu, u8 *device_id) static int ims_pcu_init_application_mode(struct ims_pcu *pcu) { - static atomic_t device_no = ATOMIC_INIT(0); + static atomic_t device_no = ATOMIC_INIT(-1); const struct ims_pcu_device_info *info; int error; @@ -1882,7 +1882,7 @@ static int ims_pcu_init_application_mode(struct ims_pcu *pcu) } /* Device appears to be operable, complete initialization */ - pcu->device_no = atomic_inc_return(&device_no) - 1; + pcu->device_no = atomic_inc_return(&device_no); /* * PCU-B devices, both GEN_1 and GEN_2 do not have OFN sensor diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c index b29134d..21698cc 100644 --- a/drivers/input/serio/serio.c +++ b/drivers/input/serio/serio.c @@ -514,7 +514,7 @@ static void serio_release_port(struct device *dev) */ static void serio_init_port(struct serio *serio) { - static atomic_t serio_no = ATOMIC_INIT(0); + static atomic_t serio_no = ATOMIC_INIT(-1); __module_get(THIS_MODULE); @@ -525,7 +525,7 @@ static void serio_init_port(struct serio *serio) mutex_init(&serio->drv_mutex); device_initialize(&serio->dev); dev_set_name(&serio->dev, "serio%ld", - (long)atomic_inc_return(&serio_no) - 1); + (long)atomic_inc_return(&serio_no)); serio->dev.bus = &serio_bus; serio->dev.release = serio_release_port; serio->dev.groups = serio_device_attr_groups; diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c index c9a02fe..71ef5d6 100644 --- a/drivers/input/serio/serio_raw.c +++ b/drivers/input/serio/serio_raw.c @@ -292,7 +292,7 @@ static irqreturn_t serio_raw_interrupt(struct serio *serio, unsigned char data, static int serio_raw_connect(struct serio *serio, struct serio_driver *drv) { - static atomic_t serio_raw_no = ATOMIC_INIT(0); + static atomic_t serio_raw_no = ATOMIC_INIT(-1); struct serio_raw *serio_raw; int err; @@ -303,7 +303,7 @@ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv) } snprintf(serio_raw->name, sizeof(serio_raw->name), - "serio_raw%ld", (long)atomic_inc_return(&serio_raw_no) - 1); + "serio_raw%ld", (long)atomic_inc_return(&serio_raw_no)); kref_init(&serio_raw->kref); INIT_LIST_HEAD(&serio_raw->client_list); init_waitqueue_head(&serio_raw->wait);