diff options
author | Aniroop Mathur <aniroop.mathur@gmail.com> | 2014-12-03 17:27:42 -0500 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2014-12-03 18:27:17 -0500 |
commit | 939ffb1712890ee22146d2dfc24adbc7da6afa84 (patch) | |
tree | 32f55ccf440835f0c929b6c7b173ffd87e18f2c6 /drivers/input/joystick/xpad.c | |
parent | 9c7d66fa9bb21ef89c6acdd0cf536eb84e760d8b (diff) |
Input: initialize device counter variables with -1
Let's initialize atomic_t variables keeping track of number of various
devices created so far with -1 in order to avoid extra subtraction
operation.
Signed-off-by: Aniroop Mathur <aniroop.mathur@gmail.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input/joystick/xpad.c')
-rw-r--r-- | drivers/input/joystick/xpad.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c index cd13c82ca0a1..36281eeabb19 100644 --- a/drivers/input/joystick/xpad.c +++ b/drivers/input/joystick/xpad.c | |||
@@ -884,8 +884,8 @@ static void xpad_led_set(struct led_classdev *led_cdev, | |||
884 | 884 | ||
885 | static int xpad_led_probe(struct usb_xpad *xpad) | 885 | static int xpad_led_probe(struct usb_xpad *xpad) |
886 | { | 886 | { |
887 | static atomic_t led_seq = ATOMIC_INIT(0); | 887 | static atomic_t led_seq = ATOMIC_INIT(-1); |
888 | long led_no; | 888 | unsigned long led_no; |
889 | struct xpad_led *led; | 889 | struct xpad_led *led; |
890 | struct led_classdev *led_cdev; | 890 | struct led_classdev *led_cdev; |
891 | int error; | 891 | int error; |
@@ -897,9 +897,9 @@ static int xpad_led_probe(struct usb_xpad *xpad) | |||
897 | if (!led) | 897 | if (!led) |
898 | return -ENOMEM; | 898 | return -ENOMEM; |
899 | 899 | ||
900 | led_no = (long)atomic_inc_return(&led_seq) - 1; | 900 | led_no = atomic_inc_return(&led_seq); |
901 | 901 | ||
902 | snprintf(led->name, sizeof(led->name), "xpad%ld", led_no); | 902 | snprintf(led->name, sizeof(led->name), "xpad%lu", led_no); |
903 | led->xpad = xpad; | 903 | led->xpad = xpad; |
904 | 904 | ||
905 | led_cdev = &led->led_cdev; | 905 | led_cdev = &led->led_cdev; |