diff options
author | Zhang Rui <rui.zhang@intel.com> | 2009-03-18 04:27:10 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2009-03-27 21:55:23 -0400 |
commit | 24450c7add575cef53097738f16a4c1a720fa5cb (patch) | |
tree | d144da0b0e0c79fdf3daad2e69f804c03b06ca96 /drivers/acpi | |
parent | c8890f903a6fdf5711726e8e8d65cb13423f8833 (diff) |
ACPI video: check the return value of acpi_video_device_lcd_set_level
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Acked-by: Matthew Garrett <mjg59@srcf.ucam.org>
Acked-by: Thomas Renninger <trenn@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi')
-rw-r--r-- | drivers/acpi/video.c | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index f0e6eb534161..52f52b32b63f 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c | |||
@@ -322,12 +322,12 @@ static int acpi_video_get_brightness(struct backlight_device *bd) | |||
322 | 322 | ||
323 | static int acpi_video_set_brightness(struct backlight_device *bd) | 323 | static int acpi_video_set_brightness(struct backlight_device *bd) |
324 | { | 324 | { |
325 | int request_level = bd->props.brightness+2; | 325 | int request_level = bd->props.brightness + 2; |
326 | struct acpi_video_device *vd = | 326 | struct acpi_video_device *vd = |
327 | (struct acpi_video_device *)bl_get_data(bd); | 327 | (struct acpi_video_device *)bl_get_data(bd); |
328 | acpi_video_device_lcd_set_level(vd, | 328 | |
329 | vd->brightness->levels[request_level]); | 329 | return acpi_video_device_lcd_set_level(vd, |
330 | return 0; | 330 | vd->brightness->levels[request_level]); |
331 | } | 331 | } |
332 | 332 | ||
333 | static struct backlight_ops acpi_backlight_ops = { | 333 | static struct backlight_ops acpi_backlight_ops = { |
@@ -482,23 +482,29 @@ acpi_video_device_lcd_query_levels(struct acpi_video_device *device, | |||
482 | static int | 482 | static int |
483 | acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level) | 483 | acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level) |
484 | { | 484 | { |
485 | int status = AE_OK; | 485 | int status; |
486 | union acpi_object arg0 = { ACPI_TYPE_INTEGER }; | 486 | union acpi_object arg0 = { ACPI_TYPE_INTEGER }; |
487 | struct acpi_object_list args = { 1, &arg0 }; | 487 | struct acpi_object_list args = { 1, &arg0 }; |
488 | int state; | 488 | int state; |
489 | 489 | ||
490 | |||
491 | arg0.integer.value = level; | 490 | arg0.integer.value = level; |
492 | 491 | ||
493 | if (device->cap._BCM) | 492 | status = acpi_evaluate_object(device->dev->handle, "_BCM", |
494 | status = acpi_evaluate_object(device->dev->handle, "_BCM", | 493 | &args, NULL); |
495 | &args, NULL); | 494 | if (ACPI_FAILURE(status)) { |
495 | ACPI_ERROR((AE_INFO, "Evaluating _BCM failed")); | ||
496 | return -EIO; | ||
497 | } | ||
498 | |||
496 | device->brightness->curr = level; | 499 | device->brightness->curr = level; |
497 | for (state = 2; state < device->brightness->count; state++) | 500 | for (state = 2; state < device->brightness->count; state++) |
498 | if (level == device->brightness->levels[state]) | 501 | if (level == device->brightness->levels[state]) { |
499 | device->backlight->props.brightness = state - 2; | 502 | device->backlight->props.brightness = state - 2; |
503 | return 0; | ||
504 | } | ||
500 | 505 | ||
501 | return status; | 506 | ACPI_ERROR((AE_INFO, "Current brightness invalid")); |
507 | return -EINVAL; | ||
502 | } | 508 | } |
503 | 509 | ||
504 | static int | 510 | static int |
@@ -1082,13 +1088,12 @@ acpi_video_device_write_brightness(struct file *file, | |||
1082 | /* validate through the list of available levels */ | 1088 | /* validate through the list of available levels */ |
1083 | for (i = 2; i < dev->brightness->count; i++) | 1089 | for (i = 2; i < dev->brightness->count; i++) |
1084 | if (level == dev->brightness->levels[i]) { | 1090 | if (level == dev->brightness->levels[i]) { |
1085 | if (ACPI_SUCCESS | 1091 | if (!acpi_video_device_lcd_set_level(dev, level)) |
1086 | (acpi_video_device_lcd_set_level(dev, level))) | 1092 | return count; |
1087 | dev->brightness->curr = level; | ||
1088 | break; | 1093 | break; |
1089 | } | 1094 | } |
1090 | 1095 | ||
1091 | return count; | 1096 | return -EINVAL; |
1092 | } | 1097 | } |
1093 | 1098 | ||
1094 | static int acpi_video_device_EDID_seq_show(struct seq_file *seq, void *offset) | 1099 | static int acpi_video_device_EDID_seq_show(struct seq_file *seq, void *offset) |
@@ -1786,7 +1791,7 @@ acpi_video_switch_brightness(struct acpi_video_device *device, int event) | |||
1786 | 1791 | ||
1787 | level_next = acpi_video_get_next_level(device, level_current, event); | 1792 | level_next = acpi_video_get_next_level(device, level_current, event); |
1788 | 1793 | ||
1789 | acpi_video_device_lcd_set_level(device, level_next); | 1794 | result = acpi_video_device_lcd_set_level(device, level_next); |
1790 | 1795 | ||
1791 | out: | 1796 | out: |
1792 | if (result) | 1797 | if (result) |