Input: initialize input_no to -1 to avoid subtraction
authorAniroop Mathur <aniroop.mathur@gmail.com>
Tue, 2 Dec 2014 23:22:28 +0000 (15:22 -0800)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Wed, 3 Dec 2014 05:34:49 +0000 (21:34 -0800)
Let's initializes input_no to -1 in order to avoid extra subtraction
operation performed every time we allocate an input device.

Signed-off-by: Aniroop Mathur <aniroop.mathur@gmail.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/input.c

index 0f175f55782b4113e37229a5f47d37a27f8cf7bd..04217c2e345c0ddcaa8e5b1d2525dbb14b5854fe 100644 (file)
@@ -1775,7 +1775,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);
@@ -1790,7 +1790,7 @@ struct input_dev *input_allocate_device(void)
                INIT_LIST_HEAD(&dev->node);
 
                dev_set_name(&dev->dev, "input%lu",
-                            (unsigned long) atomic_inc_return(&input_no) - 1);
+                            (unsigned long)atomic_inc_return(&input_no));
 
                __module_get(THIS_MODULE);
        }