Skip to contentSkip to conversation

platform/x86: lg-laptop: Advertise platform_profile interface

PATCH New Do Yun Kim 1 participant 1 message Nov 28

Subsystems (3)
lore
Share & tools
lore

Do Yun Kim

author
#0 lore raw

PATCH 1/1 platform/x86: lg-laptop: Advertise platform_profile interface

Create a platform_profile device and wire it to the ACPI calls used by /sys/devices/platform/lg-laptop/fan_mode.

Also call platform_profile_notify() when fan_mode is written to.

Manage the device's lifetime manually instead of using devres. The device's parent needs to be the synthetic 'lg-laptop' device to match other drivers. Using devres here would remove the platform_profile device when the driver is unbound, and writing into fan_mode afterwards would trigger a use-after-free. (Or require extra tracking code)

---
 .../admin-guide/laptops/lg-laptop.rst         |   8 ++
 drivers/platform/x86/Kconfig                  |   1 +
 drivers/platform/x86/lg-laptop.c              | 118 +++++++++++++++++-
 3 files changed, 122 insertions(+), 5 deletions(-)
Documentation/admin-guide/laptops/lg-laptop.rst +8 -0
index c4dd534f91ed..554e2164209d 100644
@@ -51,6 +51,14 @@ Fan mode
 Writing 0/1/2 to /sys/devices/platform/lg-laptop/fan_mode sets fan mode to
 Optimal/Silent/Performance respectively.
 
+Fan mode is also exposed via the
+Documentation/userspace-api/sysfs-platform_profile.rst interface at
+/sys/devices/platform/lg-laptop/platform-profile:
+
+- "Optimal" maps to ``balanced``
+- "Silent" maps to ``quiet``
+- "Performance" maps to ``performance``
+
 
 USB charge
 ----------
drivers/platform/x86/Kconfig +1 -0
index 9ce384e0475e..a81bd0b3e25d 100644
@@ -806,6 +806,7 @@ config LG_LAPTOP
 	select INPUT_SPARSEKMAP
 	select NEW_LEDS
 	select LEDS_CLASS
+	select ACPI_PLATFORM_PROFILE
 	help
 	 This driver adds support for hotkeys as well as control of keyboard
 	 backlight, battery maximum charge level and various other ACPI
drivers/platform/x86/lg-laptop.c +113 -5

179 lines not on this page · raw message

base-commit: c339f4010dea8b0d754f84ace70cd1b089878ef8

Signature · 1 line
2.56.1