From 939ffb1712890ee22146d2dfc24adbc7da6afa84 Mon Sep 17 00:00:00 2001 From: Aniroop Mathur Date: Wed, 3 Dec 2014 14:27:42 -0800 Subject: 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 Signed-off-by: Dmitry Torokhov --- drivers/input/joystick/xpad.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/input/joystick') 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, static int xpad_led_probe(struct usb_xpad *xpad) { - static atomic_t led_seq = ATOMIC_INIT(0); - long led_no; + static atomic_t led_seq = ATOMIC_INIT(-1); + unsigned long led_no; struct xpad_led *led; struct led_classdev *led_cdev; int error; @@ -897,9 +897,9 @@ static int xpad_led_probe(struct usb_xpad *xpad) if (!led) return -ENOMEM; - led_no = (long)atomic_inc_return(&led_seq) - 1; + led_no = atomic_inc_return(&led_seq); - snprintf(led->name, sizeof(led->name), "xpad%ld", led_no); + snprintf(led->name, sizeof(led->name), "xpad%lu", led_no); led->xpad = xpad; led_cdev = &led->led_cdev; -- cgit v1.2.3