Skip to content

Commit

Permalink
Input: initialize input_no to -1 to avoid subtraction
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Aniroop Mathur authored and Dmitry Torokhov committed Dec 3, 2014
1 parent 8195077 commit 9c7d66f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/input/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down

0 comments on commit 9c7d66f

Please sign in to comment.