ACPI: platform-profile: call sysfs_notify() from platform_profile_store()
Subsystems (2)
PATCH 1/1 ACPI: platform-profile: call sysfs_notify() from platform_profile_store()
Drivers like thinkpad_acpi and ideapad_laptop call the platform_profile_notify() helper when the profile is changed by hardware (the embedded-controller/EC) in response to an EC handled hotkey.
This allows userspace to monitor for such changes by polling for POLLPRI on the platform_profile sysfs file. But the profile can also be changed underneath a userspace program monitoring it by anonther userspace program storing a new value.
Add a sysfs_notify() call to platform_profile_store(), so that userspace programs monitoring for changes also get notified in this case.
Also update the documentation to document that POLLPRI polling can be used to watch for changes.
--- Documentation/ABI/testing/sysfs-platform_profile | 7 +++++++ drivers/acpi/platform_profile.c | 3 +++ 2 files changed, 10 insertions(+)
Documentation/ABI/testing/sysfs-platform_profile +7 -0
@@ -26,3 +26,10 @@ Contact: Hans de Goede <[email protected]> Description: Reading this file gives the current selected profile for this device. Writing this file with one of the strings from platform_profile_choices changes the profile to the new value. + + This file can be monitored for changes by polling for POLLPRI, + POLLPRI will be signalled on any changes, independent of those + changes coming from a userspace write; or coming from another + source such as e.g. a hotkey triggered profile change handled + either directly by the embedded-controller or fully handled + inside the kernel.
drivers/acpi/platform_profile.c +3 -0
@@ -106,6 +106,9 @@ static ssize_t platform_profile_store(struct device *dev, } err = cur_profile->profile_set (cur_profile, i); +if (!err) +sysfs_notify (acpi_kobj,NULL ,"platform_profile" ); +mutex_unlock (&profile_lock);if (err)return err;
Signature · 1 line
2.31.1
Quoted 42 lines · Hans de Goede
Drivers like
thinkpad_acpiandideapad_laptopcall theplatform_profile_notify()helper when the profile is changed by hardware (the embedded-controller/EC) in response to an EC handled hotkey.This allows userspace to monitor for such changes by polling for POLLPRI on the
platform_profilesysfs file. But the profile can also be changed underneath a userspace program monitoring it by anonther userspace program storing a new value.Add a
sysfs_notify()call toplatform_profile_store(), so that userspace programs monitoring for changes also get notified in this case.Also update the documentation to document that POLLPRI polling can be used to watch for changes.
Signed-off-by Hans de Goede <[email protected]>--- Documentation/ABI/testing/sysfs-platform_profile | 7 +++++++ drivers/acpi/platform_profile.c | 3 +++ 2 files changed, 10 insertions(+)Documentation/ABI/testing/sysfs-platform_profile +7
-0@@ -26,3 +26,10 @@ Contact: Hans de Goede <[email protected]> Description: Reading this file gives the current selected profile for this device. Writing this file with one of the strings from platform_profile_choices changes the profile to the new value. + + This file can be monitored for changes by polling for POLLPRI, + POLLPRI will be signalled on any changes, independent of those + changes coming from a userspace write; or coming from another + source such as e.g. a hotkey triggered profile change handled + either directly by the embedded-controller or fully handled + inside the kernel.drivers/acpi/platform_profile.c +0
-0
drivers/acpi/platform_profile.c static ssize_t platform_profile_store(struct device *dev,
Quoted 10 lines
drivers/acpi/platform_profile.c +3
-1@@ -106,6 +106,9 @@ static ssize_t platform_profile_store(struct device *dev, } err = cur_profile->profile_set (cur_profile, i); +if (!err) +sysfs_notify (acpi_kobj,NULL ,"platform_profile" ); +mutex_unlock (&profile_lock);if (err)return err; --
Applied as 5.15 material, thanks!