diff options
author | Zhang Rui <rui.zhang@intel.com> | 2009-03-18 04:27:08 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2009-03-27 21:48:29 -0400 |
commit | c8890f903a6fdf5711726e8e8d65cb13423f8833 (patch) | |
tree | a31480d951ac809e4ce43e2f483a72bba49fe194 /drivers | |
parent | 8e0ee43bc2c3e19db56a4adaa9a9b04ce885cd84 (diff) |
ACPI video: check the return value of acpi_video_device_lcd_get_level_current
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')
-rw-r--r-- | drivers/acpi/video.c | 55 |
1 files changed, 45 insertions, 10 deletions
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index bb5ed059114a..f0e6eb534161 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c | |||
@@ -294,7 +294,7 @@ static int acpi_video_device_lcd_get_level_current( | |||
294 | unsigned long long *level); | 294 | unsigned long long *level); |
295 | static int acpi_video_get_next_level(struct acpi_video_device *device, | 295 | static int acpi_video_get_next_level(struct acpi_video_device *device, |
296 | u32 level_current, u32 event); | 296 | u32 level_current, u32 event); |
297 | static void acpi_video_switch_brightness(struct acpi_video_device *device, | 297 | static int acpi_video_switch_brightness(struct acpi_video_device *device, |
298 | int event); | 298 | int event); |
299 | static int acpi_video_device_get_state(struct acpi_video_device *device, | 299 | static int acpi_video_device_get_state(struct acpi_video_device *device, |
300 | unsigned long long *state); | 300 | unsigned long long *state); |
@@ -308,7 +308,9 @@ static int acpi_video_get_brightness(struct backlight_device *bd) | |||
308 | int i; | 308 | int i; |
309 | struct acpi_video_device *vd = | 309 | struct acpi_video_device *vd = |
310 | (struct acpi_video_device *)bl_get_data(bd); | 310 | (struct acpi_video_device *)bl_get_data(bd); |
311 | acpi_video_device_lcd_get_level_current(vd, &cur_level); | 311 | |
312 | if (acpi_video_device_lcd_get_level_current(vd, &cur_level)) | ||
313 | return -EINVAL; | ||
312 | for (i = 2; i < vd->brightness->count; i++) { | 314 | for (i = 2; i < vd->brightness->count; i++) { |
313 | if (vd->brightness->levels[i] == cur_level) | 315 | if (vd->brightness->levels[i] == cur_level) |
314 | /* The first two entries are special - see page 575 | 316 | /* The first two entries are special - see page 575 |
@@ -373,7 +375,8 @@ static int video_get_cur_state(struct thermal_cooling_device *cdev, char *buf) | |||
373 | unsigned long long level; | 375 | unsigned long long level; |
374 | int state; | 376 | int state; |
375 | 377 | ||
376 | acpi_video_device_lcd_get_level_current(video, &level); | 378 | if (acpi_video_device_lcd_get_level_current(video, &level)) |
379 | return -EINVAL; | ||
377 | for (state = 2; state < video->brightness->count; state++) | 380 | for (state = 2; state < video->brightness->count; state++) |
378 | if (level == video->brightness->levels[state]) | 381 | if (level == video->brightness->levels[state]) |
379 | return sprintf(buf, "%d\n", | 382 | return sprintf(buf, "%d\n", |
@@ -502,11 +505,29 @@ static int | |||
502 | acpi_video_device_lcd_get_level_current(struct acpi_video_device *device, | 505 | acpi_video_device_lcd_get_level_current(struct acpi_video_device *device, |
503 | unsigned long long *level) | 506 | unsigned long long *level) |
504 | { | 507 | { |
505 | if (device->cap._BQC) | 508 | acpi_status status = AE_OK; |
506 | return acpi_evaluate_integer(device->dev->handle, "_BQC", NULL, | 509 | |
507 | level); | 510 | if (device->cap._BQC) { |
511 | status = acpi_evaluate_integer(device->dev->handle, "_BQC", | ||
512 | NULL, level); | ||
513 | if (ACPI_SUCCESS(status)) { | ||
514 | device->brightness->curr = *level; | ||
515 | return 0; | ||
516 | } else { | ||
517 | /* Fixme: | ||
518 | * should we return an error or ignore this failure? | ||
519 | * dev->brightness->curr is a cached value which stores | ||
520 | * the correct current backlight level in most cases. | ||
521 | * ACPI video backlight still works w/ buggy _BQC. | ||
522 | * http://bugzilla.kernel.org/show_bug.cgi?id=12233 | ||
523 | */ | ||
524 | ACPI_WARNING((AE_INFO, "Evaluating _BQC failed")); | ||
525 | device->cap._BQC = 0; | ||
526 | } | ||
527 | } | ||
528 | |||
508 | *level = device->brightness->curr; | 529 | *level = device->brightness->curr; |
509 | return AE_OK; | 530 | return 0; |
510 | } | 531 | } |
511 | 532 | ||
512 | static int | 533 | static int |
@@ -1749,15 +1770,29 @@ acpi_video_get_next_level(struct acpi_video_device *device, | |||
1749 | } | 1770 | } |
1750 | } | 1771 | } |
1751 | 1772 | ||
1752 | static void | 1773 | static int |
1753 | acpi_video_switch_brightness(struct acpi_video_device *device, int event) | 1774 | acpi_video_switch_brightness(struct acpi_video_device *device, int event) |
1754 | { | 1775 | { |
1755 | unsigned long long level_current, level_next; | 1776 | unsigned long long level_current, level_next; |
1777 | int result = -EINVAL; | ||
1778 | |||
1756 | if (!device->brightness) | 1779 | if (!device->brightness) |
1757 | return; | 1780 | goto out; |
1758 | acpi_video_device_lcd_get_level_current(device, &level_current); | 1781 | |
1782 | result = acpi_video_device_lcd_get_level_current(device, | ||
1783 | &level_current); | ||
1784 | if (result) | ||
1785 | goto out; | ||
1786 | |||
1759 | level_next = acpi_video_get_next_level(device, level_current, event); | 1787 | level_next = acpi_video_get_next_level(device, level_current, event); |
1788 | |||
1760 | acpi_video_device_lcd_set_level(device, level_next); | 1789 | acpi_video_device_lcd_set_level(device, level_next); |
1790 | |||
1791 | out: | ||
1792 | if (result) | ||
1793 | printk(KERN_ERR PREFIX "Failed to switch the brightness\n"); | ||
1794 | |||
1795 | return result; | ||
1761 | } | 1796 | } |
1762 | 1797 | ||
1763 | static int | 1798 | static int |