Skip to content

Commit 9f9cd7e

Browse files
Aaron Lurafaeljw
authored andcommitted
ACPI / Thermal / video: fix max_level incorrect value
commit 0595009 (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: 0595009 (ACPI/video: export acpi_video_get_levels) Reported-and-tested-by: Valdis Kletnieks <[email protected]> Signed-off-by: Aaron Lu <[email protected]> Acked-by: Zhang Rui <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent e4f35c1 commit 9f9cd7e

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

drivers/acpi/acpi_video.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,8 @@ static int acpi_video_bqc_quirk(struct acpi_video_device *device,
754754
}
755755

756756
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)
758759
{
759760
union acpi_object *obj = NULL;
760761
int i, max_level = 0, count = 0, level_ac_battery = 0;
@@ -841,6 +842,8 @@ int acpi_video_get_levels(struct acpi_device *device,
841842

842843
br->count = count;
843844
*dev_br = br;
845+
if (pmax_level)
846+
*pmax_level = max_level;
844847

845848
out:
846849
kfree(obj);
@@ -869,7 +872,7 @@ acpi_video_init_brightness(struct acpi_video_device *device)
869872
struct acpi_video_device_brightness *br = NULL;
870873
int result = -EINVAL;
871874

872-
result = acpi_video_get_levels(device->dev, &br);
875+
result = acpi_video_get_levels(device->dev, &br, &max_level);
873876
if (result)
874877
return result;
875878
device->brightness = br;
@@ -1737,7 +1740,7 @@ static void acpi_video_run_bcl_for_osi(struct acpi_video_bus *video)
17371740

17381741
mutex_lock(&video->device_list_lock);
17391742
list_for_each_entry(dev, &video->video_device_list, entry) {
1740-
if (!acpi_video_device_lcd_query_levels(dev, &levels))
1743+
if (!acpi_video_device_lcd_query_levels(dev->dev->handle, &levels))
17411744
kfree(levels);
17421745
}
17431746
mutex_unlock(&video->device_list_lock);

drivers/thermal/int340x_thermal/int3406_thermal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ static int int3406_thermal_probe(struct platform_device *pdev)
177177
return -ENODEV;
178178
d->raw_bd = bd;
179179

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);
181181
if (ret)
182182
return ret;
183183

include/acpi/video.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ extern void acpi_video_set_dmi_backlight_type(enum acpi_backlight_type type);
5151
*/
5252
extern bool acpi_video_handles_brightness_key_presses(void);
5353
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);
5556
#else
5657
static inline int acpi_video_register(void) { return 0; }
5758
static inline void acpi_video_unregister(void) { return; }
@@ -72,7 +73,8 @@ static inline bool acpi_video_handles_brightness_key_presses(void)
7273
return false;
7374
}
7475
static inline int acpi_video_get_levels(struct acpi_device *device,
75-
struct acpi_video_device_brightness **dev_br)
76+
struct acpi_video_device_brightness **dev_br,
77+
int *pmax_level)
7678
{
7779
return -ENODEV;
7880
}

0 commit comments

Comments
 (0)