Input: xpad - use ida() for finding the pad_nr
authorPavel Rojtberg <rojtberg@gmail.com>
Sat, 10 Oct 2015 17:00:49 +0000 (10:00 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 1 Dec 2018 08:48:00 +0000 (09:48 +0100)
commit12a85e058d8cf767061f704dcc0b9f850378ddb1
tree59a02a84e8cdc44900bb54124f5b063ecaa1e777
parenta9040f8123720e21c2d2c0e5ce13882febe7dbd1
Input: xpad - use ida() for finding the pad_nr

[ Upstream commit e3b651745a03810efffd7ebf2a9b5be65fb70ec3 ]

The pad_nr corresponds to the lit up LED on the controller. Therefore there
should be no gaps when enumerating. Currently a LED is only re-assigned
after a controller is re-connected 4 times.

This patch uses ida to track connected pads - this way we can re-assign
freed up pad number immediately.

Consider the following case:
1. pad A is connected and gets pad_nr = 0
2. pad B is connected and gets pad_nr = 1
3. pad A is disconnected
4. pad A is connected again

using ida_simple_get() controller A now correctly gets pad_nr = 0 again.

Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/input/joystick/xpad.c