From 18de61d6aa5c7a184cf9e0756b41ccf70d6a8aad Mon Sep 17 00:00:00 2001 From: Mika Westerberg Date: Tue, 4 Feb 2025 13:22:19 +0200 Subject: MAINTAINERS: Use my kernel.org address for ACPI PMIC work Switch to use my kernel.org address for ACPI PMIC work. Signed-off-by: Mika Westerberg Link: https://patch.msgid.link/20250204112219.3969629-1-mika.westerberg@linux.intel.com Signed-off-by: Rafael J. Wysocki --- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index efee40ea589f..7356c1f16369 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -355,7 +355,7 @@ ACPI PMIC DRIVERS M: "Rafael J. Wysocki" M: Len Brown R: Andy Shevchenko -R: Mika Westerberg +R: Mika Westerberg L: linux-acpi@vger.kernel.org S: Supported Q: https://patchwork.kernel.org/project/linux-acpi/list/ -- cgit v1.2.3 From 01ca2846338d314cdcd3da1aca7f290ec380542c Mon Sep 17 00:00:00 2001 From: xueqin Luo Date: Sat, 8 Feb 2025 09:33:35 +0800 Subject: ACPI: thermal: Fix stale comment regarding trip points Update the comment next to acpi_thermal_get_trip_points() call site in acpi_thermal_add() to reflect what the code does. It has diverged from the code after changes that removed the _CRT evaluation from acpi_thermal_get_trip_points() among other things. Signed-off-by: xueqin Luo Link: https://patch.msgid.link/20250208013335.126343-1-luoxueqin@kylinos.cn [ rjw: Subject and changelog edits ] Signed-off-by: Rafael J. Wysocki --- drivers/acpi/thermal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index 95982c098d5b..0c874186f8ae 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c @@ -803,7 +803,7 @@ static int acpi_thermal_add(struct acpi_device *device) acpi_thermal_aml_dependency_fix(tz); - /* Get trip points [_CRT, _PSV, etc.] (required). */ + /* Get trip points [_ACi, _PSV, etc.] (required). */ acpi_thermal_get_trip_points(tz); crit_temp = acpi_thermal_get_critical_trip(tz); -- cgit v1.2.3 From 7d36289aa7447283883df4dc3ea816dbe06e1c8b Mon Sep 17 00:00:00 2001 From: Thorsten Blum Date: Sun, 9 Feb 2025 23:08:35 +0100 Subject: ACPI: power: Use str_on_off() helper function Use the str_on_off() helper function instead of hard-coded strings. Signed-off-by: Thorsten Blum Link: https://patch.msgid.link/20250209220835.78434-2-thorsten.blum@linux.dev [ rjw: Changelog edits ] Signed-off-by: Rafael J. Wysocki --- drivers/acpi/power.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c index 25174c24d3d7..b7243d7563b1 100644 --- a/drivers/acpi/power.c +++ b/drivers/acpi/power.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -197,7 +198,7 @@ static int __get_state(acpi_handle handle, u8 *state) cur_state = sta & ACPI_POWER_RESOURCE_STATE_ON; acpi_handle_debug(handle, "Power resource is %s\n", - cur_state ? "on" : "off"); + str_on_off(cur_state)); *state = cur_state; return 0; @@ -240,7 +241,7 @@ static int acpi_power_get_list_state(struct list_head *list, u8 *state) break; } - pr_debug("Power resource list is %s\n", cur_state ? "on" : "off"); + pr_debug("Power resource list is %s\n", str_on_off(cur_state)); *state = cur_state; return 0; -- cgit v1.2.3 From dd4f730b557ce701a2cd4f604bf1e57667bd8b6e Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Mon, 10 Feb 2025 21:28:25 -0500 Subject: ACPI: platform-profile: Fix CFI violation when accessing sysfs files When an attribute group is created with sysfs_create_group(), the ->sysfs_ops() callback is set to kobj_sysfs_ops, which sets the ->show() and ->store() callbacks to kobj_attr_show() and kobj_attr_store() respectively. These functions use container_of() to get the respective callback from the passed attribute, meaning that these callbacks need to be of the same type as the callbacks in 'struct kobj_attribute'. However, ->show() and ->store() in the platform_profile driver are defined for struct device_attribute with the help of DEVICE_ATTR_RO() and DEVICE_ATTR_RW(), which results in a CFI violation when accessing platform_profile or platform_profile_choices under /sys/firmware/acpi because the types do not match: CFI failure at kobj_attr_show+0x19/0x30 (target: platform_profile_choices_show+0x0/0x140; expected type: 0x7a69590c) There is no functional issue from the type mismatch because the layout of 'struct kobj_attribute' and 'struct device_attribute' are the same, so the container_of() cast does not break anything aside from CFI. Change the type of platform_profile_choices_show() and platform_profile_{show,store}() to match the callbacks in 'struct kobj_attribute' and update the attribute variables to match, which resolves the CFI violation. Cc: All applicable Fixes: a2ff95e018f1 ("ACPI: platform: Add platform profile support") Reported-by: John Rowley Closes: https://github.com/ClangBuiltLinux/linux/issues/2047 Tested-by: John Rowley Reviewed-by: Sami Tolvanen Signed-off-by: Nathan Chancellor Acked-by: Greg Kroah-Hartman Reviewed-by: Mark Pearson Tested-by: Mark Pearson Link: https://patch.msgid.link/20250210-acpi-platform_profile-fix-cfi-violation-v3-1-ed9e9901c33a@kernel.org [ rjw: Changelog edits ] Signed-off-by: Rafael J. Wysocki --- drivers/acpi/platform_profile.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index fc92e43d0fe9..1b6317f759f9 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -260,14 +260,14 @@ static int _aggregate_choices(struct device *dev, void *data) /** * platform_profile_choices_show - Show the available profile choices for legacy sysfs interface - * @dev: The device + * @kobj: The kobject * @attr: The attribute * @buf: The buffer to write to * * Return: The number of bytes written */ -static ssize_t platform_profile_choices_show(struct device *dev, - struct device_attribute *attr, +static ssize_t platform_profile_choices_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) { unsigned long aggregate[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; @@ -333,14 +333,14 @@ static int _store_and_notify(struct device *dev, void *data) /** * platform_profile_show - Show the current profile for legacy sysfs interface - * @dev: The device + * @kobj: The kobject * @attr: The attribute * @buf: The buffer to write to * * Return: The number of bytes written */ -static ssize_t platform_profile_show(struct device *dev, - struct device_attribute *attr, +static ssize_t platform_profile_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) { enum platform_profile_option profile = PLATFORM_PROFILE_LAST; @@ -362,15 +362,15 @@ static ssize_t platform_profile_show(struct device *dev, /** * platform_profile_store - Set the profile for legacy sysfs interface - * @dev: The device + * @kobj: The kobject * @attr: The attribute * @buf: The buffer to read from * @count: The number of bytes to read * * Return: The number of bytes read */ -static ssize_t platform_profile_store(struct device *dev, - struct device_attribute *attr, +static ssize_t platform_profile_store(struct kobject *kobj, + struct kobj_attribute *attr, const char *buf, size_t count) { unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; @@ -401,12 +401,12 @@ static ssize_t platform_profile_store(struct device *dev, return count; } -static DEVICE_ATTR_RO(platform_profile_choices); -static DEVICE_ATTR_RW(platform_profile); +static struct kobj_attribute attr_platform_profile_choices = __ATTR_RO(platform_profile_choices); +static struct kobj_attribute attr_platform_profile = __ATTR_RW(platform_profile); static struct attribute *platform_profile_attrs[] = { - &dev_attr_platform_profile_choices.attr, - &dev_attr_platform_profile.attr, + &attr_platform_profile_choices.attr, + &attr_platform_profile.attr, NULL }; -- cgit v1.2.3 From bb519cf6113473c09d571e555137a36d7e2c8566 Mon Sep 17 00:00:00 2001 From: Kurt Borja Date: Wed, 12 Feb 2025 14:03:08 -0500 Subject: ACPI: platform_profile: Improve platform_profile_unregister() Drivers usually call this method on error/exit paths and do not check for it's return value, which is always 0 anyway, so make it void. This is safe to do as currently all drivers use devm_platform_profile_register(). While at it, improve the style and make the function safer by checking for IS_ERR_OR_NULL before dereferencing the device pointer. Signed-off-by: Kurt Borja Reviewed-by: Mark Pearson Link: https://patch.msgid.link/20250212190308.21209-1-kuurtb@gmail.com [ rjw: Minor changelog edits ] Signed-off-by: Rafael J. Wysocki --- drivers/acpi/platform_profile.c | 19 +++++++++---------- include/linux/platform_profile.h | 2 +- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 1b6317f759f9..f01455905830 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -569,24 +569,23 @@ EXPORT_SYMBOL_GPL(platform_profile_register); /** * platform_profile_remove - Unregisters a platform profile class device * @dev: Class device - * - * Return: 0 */ -int platform_profile_remove(struct device *dev) +void platform_profile_remove(struct device *dev) { - struct platform_profile_handler *pprof = to_pprof_handler(dev); - int id; + struct platform_profile_handler *pprof; + + if (IS_ERR_OR_NULL(dev)) + return; + + pprof = to_pprof_handler(dev); + guard(mutex)(&profile_lock); - id = pprof->minor; + ida_free(&platform_profile_ida, pprof->minor); device_unregister(&pprof->dev); - ida_free(&platform_profile_ida, id); sysfs_notify(acpi_kobj, NULL, "platform_profile"); - sysfs_update_group(acpi_kobj, &platform_profile_group); - - return 0; } EXPORT_SYMBOL_GPL(platform_profile_remove); diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index 8ab5b0e8eb2c..d5499eca9e1d 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -47,7 +47,7 @@ struct platform_profile_ops { struct device *platform_profile_register(struct device *dev, const char *name, void *drvdata, const struct platform_profile_ops *ops); -int platform_profile_remove(struct device *dev); +void platform_profile_remove(struct device *dev); struct device *devm_platform_profile_register(struct device *dev, const char *name, void *drvdata, const struct platform_profile_ops *ops); -- cgit v1.2.3 From 064009ebc171dc11aaa86c0bdce939640e1d033d Mon Sep 17 00:00:00 2001 From: Thorsten Blum Date: Tue, 11 Feb 2025 11:45:32 +0100 Subject: ACPI: video: Use str_yes_no() helper in acpi_video_bus_add() Use the str_yes_no() helper function instead of hard-coded strings. Signed-off-by: Thorsten Blum Link: https://patch.msgid.link/20250211104532.699124-1-thorsten.blum@linux.dev [ rjw: Changelog edits ] Signed-off-by: Rafael J. Wysocki --- drivers/acpi/acpi_video.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c index a972831dbd66..efdadc74e3f4 100644 --- a/drivers/acpi/acpi_video.c +++ b/drivers/acpi/acpi_video.c @@ -27,6 +27,7 @@ #include #include #include +#include #define ACPI_VIDEO_BUS_NAME "Video Bus" #define ACPI_VIDEO_DEVICE_NAME "Video Device" @@ -2039,9 +2040,9 @@ static int acpi_video_bus_add(struct acpi_device *device) pr_info("%s [%s] (multi-head: %s rom: %s post: %s)\n", ACPI_VIDEO_DEVICE_NAME, acpi_device_bid(device), - video->flags.multihead ? "yes" : "no", - video->flags.rom ? "yes" : "no", - video->flags.post ? "yes" : "no"); + str_yes_no(video->flags.multihead), + str_yes_no(video->flags.rom), + str_yes_no(video->flags.post)); mutex_lock(&video_list_lock); list_add_tail(&video->entry, &video_bus_head); mutex_unlock(&video_list_lock); -- cgit v1.2.3 From c9e6f7fb1c581fe3b9150b02edb42dddd76fe769 Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Tue, 11 Feb 2025 14:32:52 -0600 Subject: x86/ACPI: CPPC: Add missing include Some minimial kernel configurations will fail with -Werror=implicit-function-declaration due to a missing header include. Add that header. Signed-off-by: Mario Limonciello Link: https://patch.msgid.link/20250211203314.762755-1-superm1@kernel.org [ rjw: Subject edit ] Signed-off-by: Rafael J. Wysocki --- arch/x86/kernel/acpi/cppc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/kernel/acpi/cppc.c b/arch/x86/kernel/acpi/cppc.c index d745dd586303..f96053c305c6 100644 --- a/arch/x86/kernel/acpi/cppc.c +++ b/arch/x86/kernel/acpi/cppc.c @@ -4,6 +4,8 @@ * Copyright (c) 2016, Intel Corporation. */ +#include + #include #include #include -- cgit v1.2.3 From cccf6ee090c8c133072d5d5b52ae25f3bc907a16 Mon Sep 17 00:00:00 2001 From: Xiaofei Tan Date: Wed, 12 Feb 2025 14:34:08 +0800 Subject: ACPI: HED: Always initialize before evged When the HED driver is built-in, it initializes after evged because they both are at the same initcall level, so the initialization ordering depends on the Makefile order. However, this prevents RAS records coming in between the evged driver initialization and the HED driver initialization from being handled. If the number of such RAS records is above the APEI HEST error source number, the HEST resources may be exhausted, and that may affect subsequent RAS error reporting. To fix this issue, change the initcall level of HED to subsys_initcall and prevent the driver from being built as a module by changing ACPI_HED in Kconfig from "tristate" to "bool". Signed-off-by: Xiaofei Tan Link: https://patch.msgid.link/20250212063408.927666-1-tanxiaofei@huawei.com [ rjw: Changelog edits ] Signed-off-by: Rafael J. Wysocki --- drivers/acpi/Kconfig | 2 +- drivers/acpi/hed.c | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index d81b55f5068c..7f10aa38269d 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -452,7 +452,7 @@ config ACPI_SBS the modules will be called sbs and sbshc. config ACPI_HED - tristate "Hardware Error Device" + bool "Hardware Error Device" help This driver supports the Hardware Error Device (PNP0C33), which is used to report some hardware errors notified via diff --git a/drivers/acpi/hed.c b/drivers/acpi/hed.c index 7652515a6be1..3499f86c411e 100644 --- a/drivers/acpi/hed.c +++ b/drivers/acpi/hed.c @@ -80,7 +80,12 @@ static struct acpi_driver acpi_hed_driver = { .remove = acpi_hed_remove, }, }; -module_acpi_driver(acpi_hed_driver); + +static int __init acpi_hed_driver_init(void) +{ + return acpi_bus_register_driver(&acpi_hed_driver); +} +subsys_initcall(acpi_hed_driver_init); MODULE_AUTHOR("Huang Ying"); MODULE_DESCRIPTION("ACPI Hardware Error Device Driver"); -- cgit v1.2.3 From 6c00f29f74cb2c063b6f31a0b6d73f9db132b9ac Mon Sep 17 00:00:00 2001 From: Joshua Grisham Date: Sat, 22 Feb 2025 10:44:07 +0100 Subject: ACPI: fan: Add fan speed reporting for fans with only _FST Add support for ACPI fans with _FST to report their speed even if they do not support fan control. As suggested by Armin Wolf [1] and per the Windows Thermal Management Design Guide [2], Samsung Galaxy Book series devices (and possibly many more devices where the Windows guide was strictly followed) only implement the _FST method and do not support ACPI-based fan control. Currently, these fans are not supported by the kernel driver but this patch will make some very small adjustments to allow them to be supported. This patch is tested and working for me on a Samsung Galaxy Book2 Pro whose DSDT (and several other Samsung Galaxy Book series notebooks which currently have the same issue) can be found at [3]. Link: https://lore.kernel.org/platform-driver-x86/53c5075b-1967-45d0-937f-463912dd966d@gmx.de [1] Link: https://learn.microsoft.com/en-us/windows-hardware/design/device-experiences/design-guide [2] Link: https://github.com/joshuagrisham/samsung-galaxybook-extras/tree/8e3087a06b8bdcdfdd081367af4b744a56cc4ee9/dsdt [3] Signed-off-by: Joshua Grisham Reviewed-by: Armin Wolf Link: https://patch.msgid.link/20250222094407.9753-1-josh@joshuagrisham.com Signed-off-by: Rafael J. Wysocki --- drivers/acpi/fan.h | 1 + drivers/acpi/fan_attr.c | 37 ++++++++++++++++++++++--------------- drivers/acpi/fan_core.c | 25 ++++++++++++++++++------- drivers/acpi/fan_hwmon.c | 8 ++++++++ 4 files changed, 49 insertions(+), 22 deletions(-) diff --git a/drivers/acpi/fan.h b/drivers/acpi/fan.h index 488b51e2cb31..15eba1c70e66 100644 --- a/drivers/acpi/fan.h +++ b/drivers/acpi/fan.h @@ -49,6 +49,7 @@ struct acpi_fan_fst { struct acpi_fan { bool acpi4; + bool has_fst; struct acpi_fan_fif fif; struct acpi_fan_fps *fps; int fps_count; diff --git a/drivers/acpi/fan_attr.c b/drivers/acpi/fan_attr.c index f4f6e2381f1d..22d29ac2447c 100644 --- a/drivers/acpi/fan_attr.c +++ b/drivers/acpi/fan_attr.c @@ -75,15 +75,6 @@ int acpi_fan_create_attributes(struct acpi_device *device) struct acpi_fan *fan = acpi_driver_data(device); int i, status; - sysfs_attr_init(&fan->fine_grain_control.attr); - fan->fine_grain_control.show = show_fine_grain_control; - fan->fine_grain_control.store = NULL; - fan->fine_grain_control.attr.name = "fine_grain_control"; - fan->fine_grain_control.attr.mode = 0444; - status = sysfs_create_file(&device->dev.kobj, &fan->fine_grain_control.attr); - if (status) - return status; - /* _FST is present if we are here */ sysfs_attr_init(&fan->fst_speed.attr); fan->fst_speed.show = show_fan_speed; @@ -92,7 +83,19 @@ int acpi_fan_create_attributes(struct acpi_device *device) fan->fst_speed.attr.mode = 0444; status = sysfs_create_file(&device->dev.kobj, &fan->fst_speed.attr); if (status) - goto rem_fine_grain_attr; + return status; + + if (!fan->acpi4) + return 0; + + sysfs_attr_init(&fan->fine_grain_control.attr); + fan->fine_grain_control.show = show_fine_grain_control; + fan->fine_grain_control.store = NULL; + fan->fine_grain_control.attr.name = "fine_grain_control"; + fan->fine_grain_control.attr.mode = 0444; + status = sysfs_create_file(&device->dev.kobj, &fan->fine_grain_control.attr); + if (status) + goto rem_fst_attr; for (i = 0; i < fan->fps_count; ++i) { struct acpi_fan_fps *fps = &fan->fps[i]; @@ -109,18 +112,18 @@ int acpi_fan_create_attributes(struct acpi_device *device) for (j = 0; j < i; ++j) sysfs_remove_file(&device->dev.kobj, &fan->fps[j].dev_attr.attr); - goto rem_fst_attr; + goto rem_fine_grain_attr; } } return 0; -rem_fst_attr: - sysfs_remove_file(&device->dev.kobj, &fan->fst_speed.attr); - rem_fine_grain_attr: sysfs_remove_file(&device->dev.kobj, &fan->fine_grain_control.attr); +rem_fst_attr: + sysfs_remove_file(&device->dev.kobj, &fan->fst_speed.attr); + return status; } @@ -129,9 +132,13 @@ void acpi_fan_delete_attributes(struct acpi_device *device) struct acpi_fan *fan = acpi_driver_data(device); int i; + sysfs_remove_file(&device->dev.kobj, &fan->fst_speed.attr); + + if (!fan->acpi4) + return; + for (i = 0; i < fan->fps_count; ++i) sysfs_remove_file(&device->dev.kobj, &fan->fps[i].dev_attr.attr); - sysfs_remove_file(&device->dev.kobj, &fan->fst_speed.attr); sysfs_remove_file(&device->dev.kobj, &fan->fine_grain_control.attr); } diff --git a/drivers/acpi/fan_core.c b/drivers/acpi/fan_core.c index 10016f52f4f4..8ad12ad3aaaf 100644 --- a/drivers/acpi/fan_core.c +++ b/drivers/acpi/fan_core.c @@ -203,12 +203,16 @@ static const struct thermal_cooling_device_ops fan_cooling_ops = { * -------------------------------------------------------------------------- */ +static bool acpi_fan_has_fst(struct acpi_device *device) +{ + return acpi_has_method(device->handle, "_FST"); +} + static bool acpi_fan_is_acpi4(struct acpi_device *device) { return acpi_has_method(device->handle, "_FIF") && acpi_has_method(device->handle, "_FPS") && - acpi_has_method(device->handle, "_FSL") && - acpi_has_method(device->handle, "_FST"); + acpi_has_method(device->handle, "_FSL"); } static int acpi_fan_get_fif(struct acpi_device *device) @@ -327,7 +331,12 @@ static int acpi_fan_probe(struct platform_device *pdev) device->driver_data = fan; platform_set_drvdata(pdev, fan); - if (acpi_fan_is_acpi4(device)) { + if (acpi_fan_has_fst(device)) { + fan->has_fst = true; + fan->acpi4 = acpi_fan_is_acpi4(device); + } + + if (fan->acpi4) { result = acpi_fan_get_fif(device); if (result) return result; @@ -335,7 +344,9 @@ static int acpi_fan_probe(struct platform_device *pdev) result = acpi_fan_get_fps(device); if (result) return result; + } + if (fan->has_fst) { result = devm_acpi_fan_create_hwmon(device); if (result) return result; @@ -343,9 +354,9 @@ static int acpi_fan_probe(struct platform_device *pdev) result = acpi_fan_create_attributes(device); if (result) return result; + } - fan->acpi4 = true; - } else { + if (!fan->acpi4) { result = acpi_device_update_power(device, NULL); if (result) { dev_err(&device->dev, "Failed to set initial power state\n"); @@ -391,7 +402,7 @@ err_remove_link: err_unregister: thermal_cooling_device_unregister(cdev); err_end: - if (fan->acpi4) + if (fan->has_fst) acpi_fan_delete_attributes(device); return result; @@ -401,7 +412,7 @@ static void acpi_fan_remove(struct platform_device *pdev) { struct acpi_fan *fan = platform_get_drvdata(pdev); - if (fan->acpi4) { + if (fan->has_fst) { struct acpi_device *device = ACPI_COMPANION(&pdev->dev); acpi_fan_delete_attributes(device); diff --git a/drivers/acpi/fan_hwmon.c b/drivers/acpi/fan_hwmon.c index bd0d31a398fa..e8d90605106e 100644 --- a/drivers/acpi/fan_hwmon.c +++ b/drivers/acpi/fan_hwmon.c @@ -43,6 +43,10 @@ static umode_t acpi_fan_hwmon_is_visible(const void *drvdata, enum hwmon_sensor_ case hwmon_fan_input: return 0444; case hwmon_fan_target: + /* Only acpi4 fans support fan control. */ + if (!fan->acpi4) + return 0; + /* * When in fine grain control mode, not every fan control value * has an associated fan performance state. @@ -57,6 +61,10 @@ static umode_t acpi_fan_hwmon_is_visible(const void *drvdata, enum hwmon_sensor_ case hwmon_power: switch (attr) { case hwmon_power_input: + /* Only acpi4 fans support fan control. */ + if (!fan->acpi4) + return 0; + /* * When in fine grain control mode, not every fan control value * has an associated fan performance state. -- cgit v1.2.3 From a7e23ec17feecc7bac0d500cea900cace7b50129 Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Mon, 3 Mar 2025 15:27:09 -0600 Subject: ACPI: button: Install notifier for system events as well On some systems when the system is put to sleep pressing the ACPI power button will cause the EC SCI to try to wake the system by a Notify(DEV, 0x2) with an intention to wake the system up from suspend. This behavior matches the ACPI specification in ACPI 6.4 section 4.8.3.1.1.2 which describes that the AML handler would generate a Notify() with a code of 0x2 to indicate it was responsible for waking the system. This currently doesn't work because acpi_button_add() only configured `ACPI_DEVICE_NOTIFY` which means that device handler notifications 0x80 through 0xFF are handled. To fix the wakeups on such systems, adjust the ACPI button handler to use `ACPI_ALL_NOTIFY` which will handle all events 0x00 through 0x7F. Reported-by: Yijun Shen Tested-by: Richard Gong Link: https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/04_ACPI_Hardware_Specification/ACPI_Hardware_Specification.html?highlight=0x2#control-method-power-button Signed-off-by: Mario Limonciello Tested-by: Yijun Shen Link: https://patch.msgid.link/20250303212719.4153485-1-superm1@kernel.org [ rjw: Removed uneeded semicolon ] Signed-off-by: Rafael J. Wysocki --- drivers/acpi/button.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c index 7773e6b860e7..90b09840536d 100644 --- a/drivers/acpi/button.c +++ b/drivers/acpi/button.c @@ -24,6 +24,7 @@ #define ACPI_BUTTON_CLASS "button" #define ACPI_BUTTON_FILE_STATE "state" #define ACPI_BUTTON_TYPE_UNKNOWN 0x00 +#define ACPI_BUTTON_NOTIFY_WAKE 0x02 #define ACPI_BUTTON_NOTIFY_STATUS 0x80 #define ACPI_BUTTON_SUBCLASS_POWER "power" @@ -443,7 +444,12 @@ static void acpi_button_notify(acpi_handle handle, u32 event, void *data) struct input_dev *input; int keycode; - if (event != ACPI_BUTTON_NOTIFY_STATUS) { + switch (event) { + case ACPI_BUTTON_NOTIFY_STATUS: + break; + case ACPI_BUTTON_NOTIFY_WAKE: + break; + default: acpi_handle_debug(device->handle, "Unsupported event [0x%x]\n", event); return; @@ -629,7 +635,7 @@ static int acpi_button_add(struct acpi_device *device) break; default: status = acpi_install_notify_handler(device->handle, - ACPI_DEVICE_NOTIFY, handler, + ACPI_ALL_NOTIFY, handler, device); break; } -- cgit v1.2.3 From 270247a209a91ba5248341bad7264357a9870c8d Mon Sep 17 00:00:00 2001 From: "Dr. David Alan Gilbert" Date: Fri, 7 Mar 2025 21:49:36 +0000 Subject: PNP: Remove prehistoric deadcode pnp_remove_card() is currently unused, it has been since it was added in 2003's BKrev: 3e6d3f19XSmESWEZnNEReEJOJW5SOw pnp_unregister_protocol() is currently unused, it has been since it was added in 2002's BKrev: 3df0cf6d4FVUKndhbfxjL7pksw5PGA Remove them, and pnp_remove_card_device() and __pnp_remove_device() which are now no longer used. Signed-off-by: Dr. David Alan Gilbert Link: https://patch.msgid.link/20250307214936.74504-1-linux@treblig.org Signed-off-by: Rafael J. Wysocki --- Documentation/admin-guide/pnp.rst | 3 --- drivers/pnp/base.h | 4 ---- drivers/pnp/card.c | 32 -------------------------------- drivers/pnp/core.c | 16 ---------------- 4 files changed, 55 deletions(-) diff --git a/Documentation/admin-guide/pnp.rst b/Documentation/admin-guide/pnp.rst index 3eda08191d13..24d80e3eb309 100644 --- a/Documentation/admin-guide/pnp.rst +++ b/Documentation/admin-guide/pnp.rst @@ -129,9 +129,6 @@ pnp_put_protocol pnp_register_protocol use this to register a new PnP protocol -pnp_unregister_protocol - use this function to remove a PnP protocol from the Plug and Play Layer - pnp_register_driver adds a PnP driver to the Plug and Play Layer diff --git a/drivers/pnp/base.h b/drivers/pnp/base.h index 4e80273dfb1e..b342570d0236 100644 --- a/drivers/pnp/base.h +++ b/drivers/pnp/base.h @@ -9,7 +9,6 @@ extern const struct attribute_group *pnp_dev_groups[]; extern const struct bus_type pnp_bus_type; int pnp_register_protocol(struct pnp_protocol *protocol); -void pnp_unregister_protocol(struct pnp_protocol *protocol); #define PNP_EISA_ID_MASK 0x7fffffff void pnp_eisa_id_to_string(u32 id, char *str); @@ -21,9 +20,7 @@ int pnp_add_device(struct pnp_dev *dev); struct pnp_id *pnp_add_id(struct pnp_dev *dev, const char *id); int pnp_add_card(struct pnp_card *card); -void pnp_remove_card(struct pnp_card *card); int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev); -void pnp_remove_card_device(struct pnp_dev *dev); struct pnp_port { resource_size_t min; /* min base number */ @@ -138,7 +135,6 @@ void pnp_init_resources(struct pnp_dev *dev); void pnp_fixup_device(struct pnp_dev *dev); void pnp_free_options(struct pnp_dev *dev); int __pnp_add_device(struct pnp_dev *dev); -void __pnp_remove_device(struct pnp_dev *dev); int pnp_check_port(struct pnp_dev *dev, struct resource *res); int pnp_check_mem(struct pnp_dev *dev, struct resource *res); diff --git a/drivers/pnp/card.c b/drivers/pnp/card.c index 9610a9f08ff4..c7596dc24fbd 100644 --- a/drivers/pnp/card.c +++ b/drivers/pnp/card.c @@ -269,25 +269,6 @@ int pnp_add_card(struct pnp_card *card) return 0; } -/** - * pnp_remove_card - removes a PnP card from the PnP Layer - * @card: pointer to the card to remove - */ -void pnp_remove_card(struct pnp_card *card) -{ - struct list_head *pos, *temp; - - device_unregister(&card->dev); - mutex_lock(&pnp_lock); - list_del(&card->global_list); - list_del(&card->protocol_list); - mutex_unlock(&pnp_lock); - list_for_each_safe(pos, temp, &card->devices) { - struct pnp_dev *dev = card_to_pnp_dev(pos); - pnp_remove_card_device(dev); - } -} - /** * pnp_add_card_device - adds a device to the specified card * @card: pointer to the card to add to @@ -306,19 +287,6 @@ int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev) return 0; } -/** - * pnp_remove_card_device- removes a device from the specified card - * @dev: pointer to the device to remove - */ -void pnp_remove_card_device(struct pnp_dev *dev) -{ - mutex_lock(&pnp_lock); - dev->card = NULL; - list_del(&dev->card_list); - mutex_unlock(&pnp_lock); - __pnp_remove_device(dev); -} - /** * pnp_request_card_device - Searches for a PnP device under the specified card * @clink: pointer to the card link, cannot be NULL diff --git a/drivers/pnp/core.c b/drivers/pnp/core.c index 6a60c5d83383..ac48db6dcfe3 100644 --- a/drivers/pnp/core.c +++ b/drivers/pnp/core.c @@ -78,16 +78,6 @@ int pnp_register_protocol(struct pnp_protocol *protocol) return ret; } -/** - * pnp_unregister_protocol - removes a pnp protocol from the pnp layer - * @protocol: pointer to the corresponding pnp_protocol structure - */ -void pnp_unregister_protocol(struct pnp_protocol *protocol) -{ - pnp_remove_protocol(protocol); - device_unregister(&protocol->dev); -} - static void pnp_free_ids(struct pnp_dev *dev) { struct pnp_id *id; @@ -220,12 +210,6 @@ int pnp_add_device(struct pnp_dev *dev) return 0; } -void __pnp_remove_device(struct pnp_dev *dev) -{ - pnp_delist_device(dev); - device_unregister(&dev->dev); -} - static int __init pnp_init(void) { return bus_register(&pnp_bus_type); -- cgit v1.2.3 From 425b1c97b07f2290700f708edabef32861e2b2db Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Mon, 10 Mar 2025 15:24:33 -0700 Subject: PNP: Expand length of fixup id string GCC 15's -Wunterminated-string-initialization saw that "id" was not including the required trailing NUL character. Instead of marking "id" with __nonstring[1], expand the length of the string as it is used in (debugging) format strings that expect a properly formed C string. Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117178 [1] Signed-off-by: Kees Cook Link: https://patch.msgid.link/20250310222432.work.826-kees@kernel.org Signed-off-by: Rafael J. Wysocki --- include/linux/pnp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/pnp.h b/include/linux/pnp.h index b7a7158aaf65..23fe3eaf242d 100644 --- a/include/linux/pnp.h +++ b/include/linux/pnp.h @@ -290,7 +290,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data) } struct pnp_fixup { - char id[7]; + char id[8]; void (*quirk_function) (struct pnp_dev *dev); /* fixup function */ }; -- cgit v1.2.3