From patchwork Fri Nov 21 18:48:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aniroop Mathur X-Patchwork-Id: 5357321 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 8DFA3C11AC for ; Fri, 21 Nov 2014 18:48:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C60AB20154 for ; Fri, 21 Nov 2014 18:48:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1CD8B20220 for ; Fri, 21 Nov 2014 18:48:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750859AbaKUSsl (ORCPT ); Fri, 21 Nov 2014 13:48:41 -0500 Received: from mail-la0-f46.google.com ([209.85.215.46]:58681 "EHLO mail-la0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750807AbaKUSsl (ORCPT ); Fri, 21 Nov 2014 13:48:41 -0500 Received: by mail-la0-f46.google.com with SMTP id gd6so4836657lab.33 for ; Fri, 21 Nov 2014 10:48:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=9o2hhr5tDKmToID0V9SSEksAniBai8d5pvCbLJc7m/M=; b=RMFqH7yu0nOPozpqnwP6+lilQvjCIZIsNQVEfFnwpdD9sE7GT+W5Z6ACpgsBlrxNFy /RW32X+7khXQM+zbNA8EfniUCkOfuhyAHgTANBDhF9gijjWOxx+SyxhtOMMud8YslPHC ZIfeP7xVaSGIUxA+uEz6H80rZ3EQ2uUWWXf65Y7s/NvZsF801OlAL0inLH5RX5eWVmeC DGjKApgPVrFWSedSUI9HqRxUu8h7hiTexLo8xDcOAnl033in30sTlex59IiBn17y6T9j waNplrTOYea2uorTQ+z5oc90Vqmz337dfeRVKsn61LANluhJLczZUP6UgrPEziTfg+YV +UaQ== MIME-Version: 1.0 X-Received: by 10.112.157.194 with SMTP id wo2mr6977109lbb.55.1416595719154; Fri, 21 Nov 2014 10:48:39 -0800 (PST) Received: by 10.152.115.197 with HTTP; Fri, 21 Nov 2014 10:48:39 -0800 (PST) Date: Sat, 22 Nov 2014 00:18:39 +0530 Message-ID: Subject: [PATCH] Input: Initialize input_no by -1 From: Aniroop Mathur To: Dmitry Torokhov , "linux-input@vger.kernel.org" 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); }