From patchwork Tue Dec 2 16:45:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aniroop Mathur X-Patchwork-Id: 5421261 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id DBC7EBEEA8 for ; Tue, 2 Dec 2014 16:45:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 17F4E20225 for ; Tue, 2 Dec 2014 16:45:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 38E7C2022A for ; Tue, 2 Dec 2014 16:45:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753984AbaLBQpo (ORCPT ); Tue, 2 Dec 2014 11:45:44 -0500 Received: from mail-pd0-f173.google.com ([209.85.192.173]:45629 "EHLO mail-pd0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753928AbaLBQpo (ORCPT ); Tue, 2 Dec 2014 11:45:44 -0500 Received: by mail-pd0-f173.google.com with SMTP id ft15so13441194pdb.18 for ; Tue, 02 Dec 2014 08:45:43 -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=9o2hhr5tDKmToID0V9SSEksAniBai8d5pvCbLJc7m/M=; b=accBhOZ7PapSs7s1XmvMMDIjh4TFjOGMIdL0r8IUvMNwpGhQBrAJARdICCSFDUk/Oo dVmMR83QDALtccmVam24rMfJFCJmmNflZN5X/84bN39rsRwERZTToeY2NylHSwmD5rXb hzxlWfMpKq870wS8gqz52KmQDhBqYVAm8rKd7h+2Wa7auaNL8qwO5w72fKoQIgDVhH4F v/3+MDJ5MRtlK4ZKX9T2BBByI8qkeg8qL7Smr6wfofhGpv4NNecuFOedqx62eaH9Q8gW 8p8+qTS9T9+YCJyTJ+TdhvJvCy+upqMycIGIRqtkCR4ahcg/48eO1Ldcd8wP1cHYdm3S 8FnA== X-Received: by 10.70.96.145 with SMTP id ds17mr349946pdb.88.1417538743559; Tue, 02 Dec 2014 08:45:43 -0800 (PST) Received: from localhost.localdomain ([115.118.139.65]) by mx.google.com with ESMTPSA id th1sm20876958pab.4.2014.12.02.08.45.40 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Dec 2014 08:45:42 -0800 (PST) From: Aniroop Mathur To: , , Cc: , Subject: [PATCH] Input : Initialize input_no by -1 Date: Tue, 2 Dec 2014 22:15:29 +0530 Message-Id: <1417538729-2751-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_no by -1 in order to avoid extra subtraction operation performed everytime for allocation of an input device. Signed-off-by: Aniroop Mathur --- drivers/input/input.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/input/input.c b/drivers/input/input.c index 29ca0bb..01fe49e 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -1774,7 +1774,7 @@ EXPORT_SYMBOL_GPL(input_class); */ struct input_dev *input_allocate_device(void) { - static atomic_t input_no = ATOMIC_INIT(0); + static atomic_t input_no = ATOMIC_INIT(-1); struct input_dev *dev; dev = kzalloc(sizeof(struct input_dev), GFP_KERNEL); @@ -1789,7 +1789,7 @@ struct input_dev *input_allocate_device(void) INIT_LIST_HEAD(&dev->node); dev_set_name(&dev->dev, "input%ld", - (unsigned long) atomic_inc_return(&input_no) - 1); + (unsigned long) atomic_inc_return(&input_no)); __module_get(THIS_MODULE); }