Skip to content

Commit 1bca17e

Browse files
committed
Merge branches 'acpi-power', 'acpi-fan', 'acpi-thermal', 'acpi-button' and 'acpi-video'
Merge five ACPI driver updates for 6.15-rc1: - Use the str_on_off() helper function instead of hard-coded strings in the ACPI power resources handling code (Thorsten Blum). - Add fan speed reporting for ACPI fans that have _FST, but otherwise do not support the entire ACPI 4 fan interface (Joshua Grisham). - Fix a stale comment regarding trip points in acpi_thermal_add() that diverged from the commented code after removing _CRT evaluation from acpi_thermal_get_trip_points() (xueqin Luo). - Make ACPI button driver also subscribe to system events (Mario Limonciello). - Use the str_yes_no() helper function instead of hard-coded strings in the ACPI backlight (video) driver (Thorsten Blum). * acpi-power: ACPI: power: Use str_on_off() helper function * acpi-fan: ACPI: fan: Add fan speed reporting for fans with only _FST * acpi-thermal: ACPI: thermal: Fix stale comment regarding trip points * acpi-button: ACPI: button: Install notifier for system events as well * acpi-video: ACPI: video: Use str_yes_no() helper in acpi_video_bus_add()
6 parents 425b1c9 + 7d36289 + 6c00f29 + 01ca284 + a7e23ec + 064009e commit 1bca17e

File tree

8 files changed

+65
-30
lines changed

8 files changed

+65
-30
lines changed

drivers/acpi/acpi_video.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <linux/acpi.h>
2828
#include <acpi/video.h>
2929
#include <linux/uaccess.h>
30+
#include <linux/string_choices.h>
3031

3132
#define ACPI_VIDEO_BUS_NAME "Video Bus"
3233
#define ACPI_VIDEO_DEVICE_NAME "Video Device"
@@ -2039,9 +2040,9 @@ static int acpi_video_bus_add(struct acpi_device *device)
20392040

20402041
pr_info("%s [%s] (multi-head: %s rom: %s post: %s)\n",
20412042
ACPI_VIDEO_DEVICE_NAME, acpi_device_bid(device),
2042-
video->flags.multihead ? "yes" : "no",
2043-
video->flags.rom ? "yes" : "no",
2044-
video->flags.post ? "yes" : "no");
2043+
str_yes_no(video->flags.multihead),
2044+
str_yes_no(video->flags.rom),
2045+
str_yes_no(video->flags.post));
20452046
mutex_lock(&video_list_lock);
20462047
list_add_tail(&video->entry, &video_bus_head);
20472048
mutex_unlock(&video_list_lock);

drivers/acpi/button.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#define ACPI_BUTTON_CLASS "button"
2525
#define ACPI_BUTTON_FILE_STATE "state"
2626
#define ACPI_BUTTON_TYPE_UNKNOWN 0x00
27+
#define ACPI_BUTTON_NOTIFY_WAKE 0x02
2728
#define ACPI_BUTTON_NOTIFY_STATUS 0x80
2829

2930
#define ACPI_BUTTON_SUBCLASS_POWER "power"
@@ -443,7 +444,12 @@ static void acpi_button_notify(acpi_handle handle, u32 event, void *data)
443444
struct input_dev *input;
444445
int keycode;
445446

446-
if (event != ACPI_BUTTON_NOTIFY_STATUS) {
447+
switch (event) {
448+
case ACPI_BUTTON_NOTIFY_STATUS:
449+
break;
450+
case ACPI_BUTTON_NOTIFY_WAKE:
451+
break;
452+
default:
447453
acpi_handle_debug(device->handle, "Unsupported event [0x%x]\n",
448454
event);
449455
return;
@@ -629,7 +635,7 @@ static int acpi_button_add(struct acpi_device *device)
629635
break;
630636
default:
631637
status = acpi_install_notify_handler(device->handle,
632-
ACPI_DEVICE_NOTIFY, handler,
638+
ACPI_ALL_NOTIFY, handler,
633639
device);
634640
break;
635641
}

drivers/acpi/fan.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ struct acpi_fan_fst {
4949

5050
struct acpi_fan {
5151
bool acpi4;
52+
bool has_fst;
5253
struct acpi_fan_fif fif;
5354
struct acpi_fan_fps *fps;
5455
int fps_count;

drivers/acpi/fan_attr.c

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,6 @@ int acpi_fan_create_attributes(struct acpi_device *device)
7575
struct acpi_fan *fan = acpi_driver_data(device);
7676
int i, status;
7777

78-
sysfs_attr_init(&fan->fine_grain_control.attr);
79-
fan->fine_grain_control.show = show_fine_grain_control;
80-
fan->fine_grain_control.store = NULL;
81-
fan->fine_grain_control.attr.name = "fine_grain_control";
82-
fan->fine_grain_control.attr.mode = 0444;
83-
status = sysfs_create_file(&device->dev.kobj, &fan->fine_grain_control.attr);
84-
if (status)
85-
return status;
86-
8778
/* _FST is present if we are here */
8879
sysfs_attr_init(&fan->fst_speed.attr);
8980
fan->fst_speed.show = show_fan_speed;
@@ -92,7 +83,19 @@ int acpi_fan_create_attributes(struct acpi_device *device)
9283
fan->fst_speed.attr.mode = 0444;
9384
status = sysfs_create_file(&device->dev.kobj, &fan->fst_speed.attr);
9485
if (status)
95-
goto rem_fine_grain_attr;
86+
return status;
87+
88+
if (!fan->acpi4)
89+
return 0;
90+
91+
sysfs_attr_init(&fan->fine_grain_control.attr);
92+
fan->fine_grain_control.show = show_fine_grain_control;
93+
fan->fine_grain_control.store = NULL;
94+
fan->fine_grain_control.attr.name = "fine_grain_control";
95+
fan->fine_grain_control.attr.mode = 0444;
96+
status = sysfs_create_file(&device->dev.kobj, &fan->fine_grain_control.attr);
97+
if (status)
98+
goto rem_fst_attr;
9699

97100
for (i = 0; i < fan->fps_count; ++i) {
98101
struct acpi_fan_fps *fps = &fan->fps[i];
@@ -109,18 +112,18 @@ int acpi_fan_create_attributes(struct acpi_device *device)
109112

110113
for (j = 0; j < i; ++j)
111114
sysfs_remove_file(&device->dev.kobj, &fan->fps[j].dev_attr.attr);
112-
goto rem_fst_attr;
115+
goto rem_fine_grain_attr;
113116
}
114117
}
115118

116119
return 0;
117120

118-
rem_fst_attr:
119-
sysfs_remove_file(&device->dev.kobj, &fan->fst_speed.attr);
120-
121121
rem_fine_grain_attr:
122122
sysfs_remove_file(&device->dev.kobj, &fan->fine_grain_control.attr);
123123

124+
rem_fst_attr:
125+
sysfs_remove_file(&device->dev.kobj, &fan->fst_speed.attr);
126+
124127
return status;
125128
}
126129

@@ -129,9 +132,13 @@ void acpi_fan_delete_attributes(struct acpi_device *device)
129132
struct acpi_fan *fan = acpi_driver_data(device);
130133
int i;
131134

135+
sysfs_remove_file(&device->dev.kobj, &fan->fst_speed.attr);
136+
137+
if (!fan->acpi4)
138+
return;
139+
132140
for (i = 0; i < fan->fps_count; ++i)
133141
sysfs_remove_file(&device->dev.kobj, &fan->fps[i].dev_attr.attr);
134142

135-
sysfs_remove_file(&device->dev.kobj, &fan->fst_speed.attr);
136143
sysfs_remove_file(&device->dev.kobj, &fan->fine_grain_control.attr);
137144
}

drivers/acpi/fan_core.c

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,16 @@ static const struct thermal_cooling_device_ops fan_cooling_ops = {
203203
* --------------------------------------------------------------------------
204204
*/
205205

206+
static bool acpi_fan_has_fst(struct acpi_device *device)
207+
{
208+
return acpi_has_method(device->handle, "_FST");
209+
}
210+
206211
static bool acpi_fan_is_acpi4(struct acpi_device *device)
207212
{
208213
return acpi_has_method(device->handle, "_FIF") &&
209214
acpi_has_method(device->handle, "_FPS") &&
210-
acpi_has_method(device->handle, "_FSL") &&
211-
acpi_has_method(device->handle, "_FST");
215+
acpi_has_method(device->handle, "_FSL");
212216
}
213217

214218
static int acpi_fan_get_fif(struct acpi_device *device)
@@ -327,25 +331,32 @@ static int acpi_fan_probe(struct platform_device *pdev)
327331
device->driver_data = fan;
328332
platform_set_drvdata(pdev, fan);
329333

330-
if (acpi_fan_is_acpi4(device)) {
334+
if (acpi_fan_has_fst(device)) {
335+
fan->has_fst = true;
336+
fan->acpi4 = acpi_fan_is_acpi4(device);
337+
}
338+
339+
if (fan->acpi4) {
331340
result = acpi_fan_get_fif(device);
332341
if (result)
333342
return result;
334343

335344
result = acpi_fan_get_fps(device);
336345
if (result)
337346
return result;
347+
}
338348

349+
if (fan->has_fst) {
339350
result = devm_acpi_fan_create_hwmon(device);
340351
if (result)
341352
return result;
342353

343354
result = acpi_fan_create_attributes(device);
344355
if (result)
345356
return result;
357+
}
346358

347-
fan->acpi4 = true;
348-
} else {
359+
if (!fan->acpi4) {
349360
result = acpi_device_update_power(device, NULL);
350361
if (result) {
351362
dev_err(&device->dev, "Failed to set initial power state\n");
@@ -391,7 +402,7 @@ static int acpi_fan_probe(struct platform_device *pdev)
391402
err_unregister:
392403
thermal_cooling_device_unregister(cdev);
393404
err_end:
394-
if (fan->acpi4)
405+
if (fan->has_fst)
395406
acpi_fan_delete_attributes(device);
396407

397408
return result;
@@ -401,7 +412,7 @@ static void acpi_fan_remove(struct platform_device *pdev)
401412
{
402413
struct acpi_fan *fan = platform_get_drvdata(pdev);
403414

404-
if (fan->acpi4) {
415+
if (fan->has_fst) {
405416
struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
406417

407418
acpi_fan_delete_attributes(device);

drivers/acpi/fan_hwmon.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ static umode_t acpi_fan_hwmon_is_visible(const void *drvdata, enum hwmon_sensor_
4343
case hwmon_fan_input:
4444
return 0444;
4545
case hwmon_fan_target:
46+
/* Only acpi4 fans support fan control. */
47+
if (!fan->acpi4)
48+
return 0;
49+
4650
/*
4751
* When in fine grain control mode, not every fan control value
4852
* has an associated fan performance state.
@@ -57,6 +61,10 @@ static umode_t acpi_fan_hwmon_is_visible(const void *drvdata, enum hwmon_sensor_
5761
case hwmon_power:
5862
switch (attr) {
5963
case hwmon_power_input:
64+
/* Only acpi4 fans support fan control. */
65+
if (!fan->acpi4)
66+
return 0;
67+
6068
/*
6169
* When in fine grain control mode, not every fan control value
6270
* has an associated fan performance state.

drivers/acpi/power.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <linux/init.h>
3030
#include <linux/types.h>
3131
#include <linux/slab.h>
32+
#include <linux/string_choices.h>
3233
#include <linux/pm_runtime.h>
3334
#include <linux/sysfs.h>
3435
#include <linux/acpi.h>
@@ -197,7 +198,7 @@ static int __get_state(acpi_handle handle, u8 *state)
197198
cur_state = sta & ACPI_POWER_RESOURCE_STATE_ON;
198199

199200
acpi_handle_debug(handle, "Power resource is %s\n",
200-
cur_state ? "on" : "off");
201+
str_on_off(cur_state));
201202

202203
*state = cur_state;
203204
return 0;
@@ -240,7 +241,7 @@ static int acpi_power_get_list_state(struct list_head *list, u8 *state)
240241
break;
241242
}
242243

243-
pr_debug("Power resource list is %s\n", cur_state ? "on" : "off");
244+
pr_debug("Power resource list is %s\n", str_on_off(cur_state));
244245

245246
*state = cur_state;
246247
return 0;

drivers/acpi/thermal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ static int acpi_thermal_add(struct acpi_device *device)
803803

804804
acpi_thermal_aml_dependency_fix(tz);
805805

806-
/* Get trip points [_CRT, _PSV, etc.] (required). */
806+
/* Get trip points [_ACi, _PSV, etc.] (required). */
807807
acpi_thermal_get_trip_points(tz);
808808

809809
crit_temp = acpi_thermal_get_critical_trip(tz);

0 commit comments

Comments
 (0)