diff options
| -rw-r--r-- | drivers/platform/x86/thinkpad_acpi.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index be67e5e28d18..359c87b3b1b2 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 */ |
| @@ -5313,6 +5313,8 @@ static int __init led_init(struct ibm_init_struct *iibm) | |||
| 5313 | ARRAY_SIZE(led_useful_qtable)); | 5313 | ARRAY_SIZE(led_useful_qtable)); |
| 5314 | 5314 | ||
| 5315 | for (i = 0; i < TPACPI_LED_NUMLEDS; i++) { | 5315 | for (i = 0; i < TPACPI_LED_NUMLEDS; i++) { |
| 5316 | tpacpi_leds[i].led = -1; | ||
| 5317 | |||
| 5316 | if (!tpacpi_is_led_restricted(i) && | 5318 | if (!tpacpi_is_led_restricted(i) && |
| 5317 | test_bit(i, &useful_leds)) { | 5319 | test_bit(i, &useful_leds)) { |
| 5318 | rc = tpacpi_init_led(i); | 5320 | rc = tpacpi_init_led(i); |
| @@ -5370,9 +5372,13 @@ static int led_write(char *buf) | |||
| 5370 | return -ENODEV; | 5372 | return -ENODEV; |
| 5371 | 5373 | ||
| 5372 | while ((cmd = next_cmd(&buf))) { | 5374 | while ((cmd = next_cmd(&buf))) { |
| 5373 | if (sscanf(cmd, "%d", &led) != 1 || led < 0 || led > 15) | 5375 | if (sscanf(cmd, "%d", &led) != 1) |
| 5374 | return -EINVAL; | 5376 | return -EINVAL; |
| 5375 | 5377 | ||
| 5378 | if (led < 0 || led > (TPACPI_LED_NUMLEDS - 1) || | ||
| 5379 | tpacpi_leds[led].led < 0) | ||
| 5380 | return -ENODEV; | ||
| 5381 | |||
| 5376 | if (strstr(cmd, "off")) { | 5382 | if (strstr(cmd, "off")) { |
| 5377 | s = TPACPI_LED_OFF; | 5383 | s = TPACPI_LED_OFF; |
| 5378 | } else if (strstr(cmd, "on")) { | 5384 | } else if (strstr(cmd, "on")) { |
