From patchwork Tue Nov 25 16:08:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aniroop Mathur X-Patchwork-Id: 5380441 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 6F515C11AC for ; Tue, 25 Nov 2014 16:08:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BDF0F2015D for ; Tue, 25 Nov 2014 16:08:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2B30E20114 for ; Tue, 25 Nov 2014 16:08:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750951AbaKYQIn (ORCPT ); Tue, 25 Nov 2014 11:08:43 -0500 Received: from mail-pd0-f177.google.com ([209.85.192.177]:53865 "EHLO mail-pd0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750935AbaKYQIm (ORCPT ); Tue, 25 Nov 2014 11:08:42 -0500 Received: by mail-pd0-f177.google.com with SMTP id ft15so830125pdb.8 for ; Tue, 25 Nov 2014 08:08:42 -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=b1scCmeXugEXrTm9JCyIOia+HhBFklQaN0acXNwP+IFsu3Ss6AE6sxpytaD1i3ZRMF y9XK5kQVP5548MEo0mDCI9uXmHXBcsKQlymeAoakJLBAYErHPMZPKP5QVoIz8ZcRlEjR jszLuK5UyYp8R8yyff8+UIaNpTRbmlA7ae0DWyXPeLUX99ahf90k/VsRiYboPYdXk1u2 CGjFVtSE7z5N22du9+XRSPrAyUpJQHnJxjTx/3DD4f4molValfzHlOEGt0bD2aDJRBzR 1Hmyb64ekjIUttlIM5sBsDHccP9qdmbh+ZJJNKlHKFM+BKsJ2GcxDKfFVgs+ic64zNNd NEkg== X-Received: by 10.66.157.4 with SMTP id wi4mr44312860pab.63.1416931722085; Tue, 25 Nov 2014 08:08:42 -0800 (PST) Received: from localhost.localdomain ([115.118.51.104]) by mx.google.com with ESMTPSA id v5sm1919946pdn.20.2014.11.25.08.08.38 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Nov 2014 08:08:40 -0800 (PST) From: Aniroop Mathur To: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org Cc: aniroop.mathur@gmail.com Subject: [PATCH] Input: Initialize input_no by -1 Date: Tue, 25 Nov 2014 21:38:35 +0530 Message-Id: <1416931715-2902-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); }