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

ACPI / Thermal / video: fix max_level incorrect value

commit 059500940def (ACPI/video: export acpi_video_get_levels)
mistakenly dropped the correct value of max_level and that caused the
set_level function following failed and the acpi_video backlight interface
didn't get created. Fix this by passing back the correct max_level value.

While at it, also fix the param used in acpi_video_device_lcd_query_levels
where acpi_handle is expected but acpi_video_device is passed.

Fixes: 059500940def (ACPI/video: export acpi_video_get_levels)
Reported-and-tested-by: Valdis Kletnieks <valdis.kletnieks@vt.edu>
Signed-off-by: Aaron Lu <aaron.lu@intel.com>
Acked-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Aaron Lu and committed by
Rafael J. Wysocki
9f9cd7ee e4f35c13

+11 -6
+6 -3
drivers/acpi/acpi_video.c
··· 754 754 } 755 755 756 756 int acpi_video_get_levels(struct acpi_device *device, 757 - struct acpi_video_device_brightness **dev_br) 757 + struct acpi_video_device_brightness **dev_br, 758 + int *pmax_level) 758 759 { 759 760 union acpi_object *obj = NULL; 760 761 int i, max_level = 0, count = 0, level_ac_battery = 0; ··· 842 841 843 842 br->count = count; 844 843 *dev_br = br; 844 + if (pmax_level) 845 + *pmax_level = max_level; 845 846 846 847 out: 847 848 kfree(obj); ··· 872 869 struct acpi_video_device_brightness *br = NULL; 873 870 int result = -EINVAL; 874 871 875 - result = acpi_video_get_levels(device->dev, &br); 872 + result = acpi_video_get_levels(device->dev, &br, &max_level); 876 873 if (result) 877 874 return result; 878 875 device->brightness = br; ··· 1740 1737 1741 1738 mutex_lock(&video->device_list_lock); 1742 1739 list_for_each_entry(dev, &video->video_device_list, entry) { 1743 - if (!acpi_video_device_lcd_query_levels(dev, &levels)) 1740 + if (!acpi_video_device_lcd_query_levels(dev->dev->handle, &levels)) 1744 1741 kfree(levels); 1745 1742 } 1746 1743 mutex_unlock(&video->device_list_lock);
+1 -1
drivers/thermal/int340x_thermal/int3406_thermal.c
··· 177 177 return -ENODEV; 178 178 d->raw_bd = bd; 179 179 180 - ret = acpi_video_get_levels(ACPI_COMPANION(&pdev->dev), &d->br); 180 + ret = acpi_video_get_levels(ACPI_COMPANION(&pdev->dev), &d->br, NULL); 181 181 if (ret) 182 182 return ret; 183 183
+4 -2
include/acpi/video.h
··· 51 51 */ 52 52 extern bool acpi_video_handles_brightness_key_presses(void); 53 53 extern int acpi_video_get_levels(struct acpi_device *device, 54 - struct acpi_video_device_brightness **dev_br); 54 + struct acpi_video_device_brightness **dev_br, 55 + int *pmax_level); 55 56 #else 56 57 static inline int acpi_video_register(void) { return 0; } 57 58 static inline void acpi_video_unregister(void) { return; } ··· 73 72 return false; 74 73 } 75 74 static inline int acpi_video_get_levels(struct acpi_device *device, 76 - struct acpi_video_device_brightness **dev_br) 75 + struct acpi_video_device_brightness **dev_br, 76 + int *pmax_level) 77 77 { 78 78 return -ENODEV; 79 79 }