Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: initialize input_no to -1 to avoid subtraction

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>

authored by

Aniroop Mathur and committed by
Dmitry Torokhov
9c7d66fa 8195077c

+2 -2
+2 -2
drivers/input/input.c
··· 1775 1775 */ 1776 1776 struct input_dev *input_allocate_device(void) 1777 1777 { 1778 - static atomic_t input_no = ATOMIC_INIT(0); 1778 + static atomic_t input_no = ATOMIC_INIT(-1); 1779 1779 struct input_dev *dev; 1780 1780 1781 1781 dev = kzalloc(sizeof(struct input_dev), GFP_KERNEL); ··· 1790 1790 INIT_LIST_HEAD(&dev->node); 1791 1791 1792 1792 dev_set_name(&dev->dev, "input%lu", 1793 - (unsigned long) atomic_inc_return(&input_no) - 1); 1793 + (unsigned long)atomic_inc_return(&input_no)); 1794 1794 1795 1795 __module_get(THIS_MODULE); 1796 1796 }