diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2015-07-22 14:56:39 -0700 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2015-07-24 09:11:01 -0700 |
commit | b38ebd1d4b6656582b8c16358bb88d059d28b794 (patch) | |
tree | 0e7effd682f1ee6ae784bcdc05d5104d82df4a67 /drivers/input/input-leds.c | |
parent | 968491709e5b1aaf429428814fff3d932fa90b60 (diff) | |
download | talos-obmc-linux-b38ebd1d4b6656582b8c16358bb88d059d28b794.tar.gz talos-obmc-linux-b38ebd1d4b6656582b8c16358bb88d059d28b794.zip |
Input: LEDs - skip unnamed LEDs
Devices may declare more LEDs than what is known to input-leds
(HID does this for some devices). Instead of showing ugly warnings
on connect and, even worse, oopsing on disconnect, let's simply
ignore LEDs that are not known to us.
Reported-and-tested-by: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input/input-leds.c')
-rw-r--r-- | drivers/input/input-leds.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/drivers/input/input-leds.c b/drivers/input/input-leds.c index 074a65ed17bb..766bf2660116 100644 --- a/drivers/input/input-leds.c +++ b/drivers/input/input-leds.c @@ -71,6 +71,18 @@ static void input_leds_event(struct input_handle *handle, unsigned int type, { } +static int input_leds_get_count(struct input_dev *dev) +{ + unsigned int led_code; + int count = 0; + + for_each_set_bit(led_code, dev->ledbit, LED_CNT) + if (input_led_info[led_code].name) + count++; + + return count; +} + static int input_leds_connect(struct input_handler *handler, struct input_dev *dev, const struct input_device_id *id) @@ -81,7 +93,7 @@ static int input_leds_connect(struct input_handler *handler, int led_no; int error; - num_leds = bitmap_weight(dev->ledbit, LED_CNT); + num_leds = input_leds_get_count(dev); if (!num_leds) return -ENXIO; @@ -112,7 +124,7 @@ static int input_leds_connect(struct input_handler *handler, led->handle = &leds->handle; led->code = led_code; - if (WARN_ON(!input_led_info[led_code].name)) + if (!input_led_info[led_code].name) continue; led->cdev.name = kasprintf(GFP_KERNEL, "%s::%s", |