aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform/x86/thinkpad_acpi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/platform/x86/thinkpad_acpi.c')
-rw-r--r--drivers/platform/x86/thinkpad_acpi.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index be67e5e28d18..03ca6c139f1a 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -369,7 +369,7 @@ struct tpacpi_led_classdev {
369 struct led_classdev led_classdev; 369 struct led_classdev led_classdev;
370 struct work_struct work; 370 struct work_struct work;
371 enum led_status_t new_state; 371 enum led_status_t new_state;
372 unsigned int led; 372 int led;
373}; 373};
374 374
375/* brightness level capabilities */ 375/* brightness level capabilities */
@@ -5296,6 +5296,16 @@ static int __init led_init(struct ibm_init_struct *iibm)
5296 5296
5297 led_supported = led_init_detect_mode(); 5297 led_supported = led_init_detect_mode();
5298 5298
5299 if (led_supported != TPACPI_LED_NONE) {
5300 useful_leds = tpacpi_check_quirks(led_useful_qtable,
5301 ARRAY_SIZE(led_useful_qtable));
5302
5303 if (!useful_leds) {
5304 led_handle = NULL;
5305 led_supported = TPACPI_LED_NONE;
5306 }
5307 }
5308
5299 vdbg_printk(TPACPI_DBG_INIT, "LED commands are %s, mode %d\n", 5309 vdbg_printk(TPACPI_DBG_INIT, "LED commands are %s, mode %d\n",
5300 str_supported(led_supported), led_supported); 5310 str_supported(led_supported), led_supported);
5301 5311
@@ -5309,10 +5319,9 @@ static int __init led_init(struct ibm_init_struct *iibm)
5309 return -ENOMEM; 5319 return -ENOMEM;
5310 } 5320 }
5311 5321
5312 useful_leds = tpacpi_check_quirks(led_useful_qtable,
5313 ARRAY_SIZE(led_useful_qtable));
5314
5315 for (i = 0; i < TPACPI_LED_NUMLEDS; i++) { 5322 for (i = 0; i < TPACPI_LED_NUMLEDS; i++) {
5323 tpacpi_leds[i].led = -1;
5324
5316 if (!tpacpi_is_led_restricted(i) && 5325 if (!tpacpi_is_led_restricted(i) &&
5317 test_bit(i, &useful_leds)) { 5326 test_bit(i, &useful_leds)) {
5318 rc = tpacpi_init_led(i); 5327 rc = tpacpi_init_led(i);
@@ -5370,9 +5379,13 @@ static int led_write(char *buf)
5370 return -ENODEV; 5379 return -ENODEV;
5371 5380
5372 while ((cmd = next_cmd(&buf))) { 5381 while ((cmd = next_cmd(&buf))) {
5373 if (sscanf(cmd, "%d", &led) != 1 || led < 0 || led > 15) 5382 if (sscanf(cmd, "%d", &led) != 1)
5374 return -EINVAL; 5383 return -EINVAL;
5375 5384
5385 if (led < 0 || led > (TPACPI_LED_NUMLEDS - 1) ||
5386 tpacpi_leds[led].led < 0)
5387 return -ENODEV;
5388
5376 if (strstr(cmd, "off")) { 5389 if (strstr(cmd, "off")) {
5377 s = TPACPI_LED_OFF; 5390 s = TPACPI_LED_OFF;
5378 } else if (strstr(cmd, "on")) { 5391 } else if (strstr(cmd, "on")) {