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 | |
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')
-rw-r--r-- | drivers/input/gameport/gameport.c | 4 | ||||
-rw-r--r-- | drivers/input/joystick/xpad.c | 8 | ||||
-rw-r--r-- | drivers/input/misc/ims-pcu.c | 4 | ||||
-rw-r--r-- | drivers/input/serio/serio.c | 4 | ||||
-rw-r--r-- | drivers/input/serio/serio_raw.c | 4 |
5 files changed, 12 insertions, 12 deletions
diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c index e29c04e2aff4..e853a2134680 100644 --- a/drivers/input/gameport/gameport.c +++ b/drivers/input/gameport/gameport.c | |||
@@ -527,14 +527,14 @@ EXPORT_SYMBOL(gameport_set_phys); | |||
527 | */ | 527 | */ |
528 | static void gameport_init_port(struct gameport *gameport) | 528 | static void gameport_init_port(struct gameport *gameport) |
529 | { | 529 | { |
530 | static atomic_t gameport_no = ATOMIC_INIT(0); | 530 | static atomic_t gameport_no = ATOMIC_INIT(-1); |
531 | 531 | ||
532 | __module_get(THIS_MODULE); | 532 | __module_get(THIS_MODULE); |
533 | 533 | ||
534 | mutex_init(&gameport->drv_mutex); | 534 | mutex_init(&gameport->drv_mutex); |
535 | device_initialize(&gameport->dev); | 535 | device_initialize(&gameport->dev); |
536 | dev_set_name(&gameport->dev, "gameport%lu", | 536 | dev_set_name(&gameport->dev, "gameport%lu", |
537 | (unsigned long)atomic_inc_return(&gameport_no) - 1); | 537 | (unsigned long)atomic_inc_return(&gameport_no)); |
538 | gameport->dev.bus = &gameport_bus; | 538 | gameport->dev.bus = &gameport_bus; |
539 | gameport->dev.release = gameport_release_port; | 539 | gameport->dev.release = gameport_release_port; |
540 | if (gameport->parent) | 540 | if (gameport->parent) |
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; |
diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c index 719410feb84b..69caee906ecd 100644 --- a/drivers/input/misc/ims-pcu.c +++ b/drivers/input/misc/ims-pcu.c | |||
@@ -1851,7 +1851,7 @@ static int ims_pcu_identify_type(struct ims_pcu *pcu, u8 *device_id) | |||
1851 | 1851 | ||
1852 | static int ims_pcu_init_application_mode(struct ims_pcu *pcu) | 1852 | static int ims_pcu_init_application_mode(struct ims_pcu *pcu) |
1853 | { | 1853 | { |
1854 | static atomic_t device_no = ATOMIC_INIT(0); | 1854 | static atomic_t device_no = ATOMIC_INIT(-1); |
1855 | 1855 | ||
1856 | const struct ims_pcu_device_info *info; | 1856 | const struct ims_pcu_device_info *info; |
1857 | int error; | 1857 | int error; |
@@ -1882,7 +1882,7 @@ static int ims_pcu_init_application_mode(struct ims_pcu *pcu) | |||
1882 | } | 1882 | } |
1883 | 1883 | ||
1884 | /* Device appears to be operable, complete initialization */ | 1884 | /* Device appears to be operable, complete initialization */ |
1885 | pcu->device_no = atomic_inc_return(&device_no) - 1; | 1885 | pcu->device_no = atomic_inc_return(&device_no); |
1886 | 1886 | ||
1887 | /* | 1887 | /* |
1888 | * PCU-B devices, both GEN_1 and GEN_2 do not have OFN sensor | 1888 | * PCU-B devices, both GEN_1 and GEN_2 do not have OFN sensor |
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c index d399b8b0f000..a05a5179da32 100644 --- a/drivers/input/serio/serio.c +++ b/drivers/input/serio/serio.c | |||
@@ -514,7 +514,7 @@ static void serio_release_port(struct device *dev) | |||
514 | */ | 514 | */ |
515 | static void serio_init_port(struct serio *serio) | 515 | static void serio_init_port(struct serio *serio) |
516 | { | 516 | { |
517 | static atomic_t serio_no = ATOMIC_INIT(0); | 517 | static atomic_t serio_no = ATOMIC_INIT(-1); |
518 | 518 | ||
519 | __module_get(THIS_MODULE); | 519 | __module_get(THIS_MODULE); |
520 | 520 | ||
@@ -525,7 +525,7 @@ static void serio_init_port(struct serio *serio) | |||
525 | mutex_init(&serio->drv_mutex); | 525 | mutex_init(&serio->drv_mutex); |
526 | device_initialize(&serio->dev); | 526 | device_initialize(&serio->dev); |
527 | dev_set_name(&serio->dev, "serio%lu", | 527 | dev_set_name(&serio->dev, "serio%lu", |
528 | (unsigned long)atomic_inc_return(&serio_no) - 1); | 528 | (unsigned long)atomic_inc_return(&serio_no)); |
529 | serio->dev.bus = &serio_bus; | 529 | serio->dev.bus = &serio_bus; |
530 | serio->dev.release = serio_release_port; | 530 | serio->dev.release = serio_release_port; |
531 | serio->dev.groups = serio_device_attr_groups; | 531 | serio->dev.groups = serio_device_attr_groups; |
diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c index c9a02fe57576..71ef5d65a0c6 100644 --- a/drivers/input/serio/serio_raw.c +++ b/drivers/input/serio/serio_raw.c | |||
@@ -292,7 +292,7 @@ static irqreturn_t serio_raw_interrupt(struct serio *serio, unsigned char data, | |||
292 | 292 | ||
293 | static int serio_raw_connect(struct serio *serio, struct serio_driver *drv) | 293 | static int serio_raw_connect(struct serio *serio, struct serio_driver *drv) |
294 | { | 294 | { |
295 | static atomic_t serio_raw_no = ATOMIC_INIT(0); | 295 | static atomic_t serio_raw_no = ATOMIC_INIT(-1); |
296 | struct serio_raw *serio_raw; | 296 | struct serio_raw *serio_raw; |
297 | int err; | 297 | int err; |
298 | 298 | ||
@@ -303,7 +303,7 @@ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv) | |||
303 | } | 303 | } |
304 | 304 | ||
305 | snprintf(serio_raw->name, sizeof(serio_raw->name), | 305 | snprintf(serio_raw->name, sizeof(serio_raw->name), |
306 | "serio_raw%ld", (long)atomic_inc_return(&serio_raw_no) - 1); | 306 | "serio_raw%ld", (long)atomic_inc_return(&serio_raw_no)); |
307 | kref_init(&serio_raw->kref); | 307 | kref_init(&serio_raw->kref); |
308 | INIT_LIST_HEAD(&serio_raw->client_list); | 308 | INIT_LIST_HEAD(&serio_raw->client_list); |
309 | init_waitqueue_head(&serio_raw->wait); | 309 | init_waitqueue_head(&serio_raw->wait); |