Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+14 -2
+14 -2
drivers/input/input-leds.c
··· 71 71 { 72 72 } 73 73 74 + static int input_leds_get_count(struct input_dev *dev) 75 + { 76 + unsigned int led_code; 77 + int count = 0; 78 + 79 + for_each_set_bit(led_code, dev->ledbit, LED_CNT) 80 + if (input_led_info[led_code].name) 81 + count++; 82 + 83 + return count; 84 + } 85 + 74 86 static int input_leds_connect(struct input_handler *handler, 75 87 struct input_dev *dev, 76 88 const struct input_device_id *id) ··· 93 81 int led_no; 94 82 int error; 95 83 96 - num_leds = bitmap_weight(dev->ledbit, LED_CNT); 84 + num_leds = input_leds_get_count(dev); 97 85 if (!num_leds) 98 86 return -ENXIO; 99 87 ··· 124 112 led->handle = &leds->handle; 125 113 led->code = led_code; 126 114 127 - if (WARN_ON(!input_led_info[led_code].name)) 115 + if (!input_led_info[led_code].name) 128 116 continue; 129 117 130 118 led->cdev.name = kasprintf(GFP_KERNEL, "%s::%s",