FAILED: patch "[PATCH] platform/x86: asus-wmi: fix TUF keyboard power state shutdown naming" failed to apply to 6.1-stable tree
Sasha Levin
maintainerThe patch below does not apply to the 6.1-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x 3d9a175707eeb15a2d577af1e669b98e0236719b
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '[email protected]' --subject-prefix 'PATCH 6.1.y' 'HEAD^..'
Thanks,
Sasha
------------------ original commit in Linus's tree ------------------
From 3d9a175707eeb15a2d577af1e669b98e0236719b Mon Sep 17 00:00:00 2001
From: Bartu Alev <[email protected]>
Date: Sat, 10 Oct 2026 13:15:58 +0300
Subject: [PATCH] platform/x86: asus-wmi: fix TUF keyboard power state shutdown
naming
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The fourth state flag of kbd_rgb_state_index is named "keyboard" and has long been treated as having no effect. In hardware the flag, BIT(7) of the payload sent to the TUF RGB state device, gates whether the keyboard backlight stays lit while the machine powers off: with the bit set the keyboard lights up white during the ACPI S5 sequence, with the bit clear the machine powers off dark. Verified by A/B testing both values on a TUF Gaming A15 (FA507NV).
Rename the fourth field and its index entry from "keyboard" to "shutdown". The write format is unchanged, the value is still positional, and the diff is two variable names and one string, so it backports cleanly.
--- drivers/platform/x86/asus-wmi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/platform/x86/asus-wmi.c +4 -4
@@ -1130,10 +1130,10 @@ static ssize_t kbd_rgb_state_store(struct device *dev,struct device_attribute *attr, const char *buf, size_t count) { - u32 flags, cmd, boot, awake, sleep, keyboard; + u32 flags, cmd, boot, awake, sleep, shutdown;int err; -if (sscanf (buf,"%d %d %d %d %d" , &cmd, &boot, &awake, &sleep, &keyboard) !=5 ) +if (sscanf (buf,"%d %d %d %d %d" , &cmd, &boot, &awake, &sleep, &shutdown) !=5 )return -EINVAL ;if (cmd)
@@ -1146,7 +1146,7 @@ static ssize_t kbd_rgb_state_store(struct device *dev, flags |=BIT (3 );if (sleep) flags |=BIT (5 ); -if (keyboard) +if (shutdown) flags |=BIT (7 );/* 0xbd is the required default arg0 for the method. Nothing happens otherwise */
@@ -1160,7 +1160,7 @@ static ssize_t kbd_rgb_state_store(struct device *dev,static DEVICE_ATTR_WO (kbd_rgb_state); static DEVICE_STRING_ATTR_RO(kbd_rgb_state_index, 0444, - "cmd boot awake sleep keyboard"); + "cmd boot awake sleep shutdown");static struct attribute *kbd_rgb_state_attrs[] = { &dev_attr_kbd_rgb_state.attr,
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/4 driver core: device.h: add some missing kerneldocs
From: James Seo <[email protected]>
[ Upstream commit cd00bc2ca42705bf141a2bf6fb5224c7ae628dbe ]
struct device_attribute, struct dev_ext_attribute, dev_name(), and the DEVICE_ATTR() macros lack kerneldocs, preventing them from appearing in the driver core documentation and from being cross-referenced elsewhere.
Add the missing kerneldocs (except for DEVICE_ATTR_IGNORE_LOCKDEP(), which is only meaningful on debug builds with CONFIG_DEBUG_LOCK_ALLOC defined, and is aliased to DEVICE_ATTR() otherwise).
Stable-dep-of: 3d9a175707ee ("platform/x86: asus-wmi: fix TUF keyboard power state shutdown naming")
--- include/linux/device.h | 111 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 110 insertions(+), 1 deletion(-)
include/linux/device.h +110 -1
@@ -102,7 +102,12 @@ struct device_type {bool need_parent_lock; }; -/* interface for exporting device attributes */ +/** +* struct device_attribute - Interface for exporting device attributes. +* @attr: sysfs attribute definition. +* @show: Show handler. +* @store: Store handler. +*/ struct device_attribute {struct attribute attr; ssize_t (*show)(struct device *dev, struct device_attribute *attr,
@@ -111,6 +116,11 @@ struct device_attribute { const char *buf, size_t count); }; +/** +* struct dev_ext_attribute - Exported device attribute with extra context. +* @attr: Exported device attribute. +* @var: Pointer to context. +*/ struct dev_ext_attribute {struct device_attribute attr;void *var;
@@ -129,30 +139,124 @@ ssize_t device_show_bool(struct device *dev, struct device_attribute *attr,ssize_t device_store_bool (struct device *dev,struct device_attribute *attr,const char *buf,size_t count); +/** +* DEVICE_ATTR - Define a device attribute. +* @_name: Attribute name. +* @_mode: File mode. +* @_show: Show handler. Optional, but mandatory if attribute is readable. +* @_store: Store handler. Optional, but mandatory if attribute is writable. +* +* Convenience macro for defining a struct device_attribute. +* +* For example, ``DEVICE_ATTR(foo, 0644, foo_show, foo_store);`` expands to: +* +* .. code-block:: c +* +* struct device_attribute dev_attr_foo = { +* .attr = { .name = "foo", .mode = 0644 }, +* .show = foo_show, +* .store = foo_store, +* }; +*/ #define DEVICE_ATTR (_name, _mode, _show, _store) \ struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show, _store) + +/** +* DEVICE_ATTR_PREALLOC - Define a preallocated device attribute. +* @_name: Attribute name. +* @_mode: File mode. +* @_show: Show handler. Optional, but mandatory if attribute is readable. +* @_store: Store handler. Optional, but mandatory if attribute is writable. +* +* Like DEVICE_ATTR(), but ``SYSFS_PREALLOC`` is set on @_mode. +*/ #define DEVICE_ATTR_PREALLOC (_name, _mode, _show, _store) \ struct device_attribute dev_attr_##_name = \ __ATTR_PREALLOC(_name, _mode, _show, _store) + +/** +* DEVICE_ATTR_RW - Define a read-write device attribute. +* @_name: Attribute name. +* +* Like DEVICE_ATTR(), but @_mode is 0644, @_show is <_name>_show, +* and @_store is <_name>_store. +*/ #define DEVICE_ATTR_RW (_name) \ struct device_attribute dev_attr_##_name = __ATTR_RW(_name) + +/** +* DEVICE_ATTR_ADMIN_RW - Define an admin-only read-write device attribute. +* @_name: Attribute name. +* +* Like DEVICE_ATTR_RW(), but @_mode is 0600. +*/ #define DEVICE_ATTR_ADMIN_RW (_name) \ struct device_attribute dev_attr_##_name = __ATTR_RW_MODE(_name, 0600) + +/** +* DEVICE_ATTR_RO - Define a readable device attribute. +* @_name: Attribute name. +* +* Like DEVICE_ATTR(), but @_mode is 0444 and @_show is <_name>_show. +*/ #define DEVICE_ATTR_RO (_name) \ struct device_attribute dev_attr_##_name = __ATTR_RO(_name) + +/** +* DEVICE_ATTR_ADMIN_RO - Define an admin-only readable device attribute. +* @_name: Attribute name. +* +* Like DEVICE_ATTR_RO(), but @_mode is 0400. +*/ #define DEVICE_ATTR_ADMIN_RO (_name) \ struct device_attribute dev_attr_##_name = __ATTR_RO_MODE(_name, 0400) + +/** +* DEVICE_ATTR_WO - Define an admin-only writable device attribute. +* @_name: Attribute name. +* +* Like DEVICE_ATTR(), but @_mode is 0200 and @_store is <_name>_store. +*/ #define DEVICE_ATTR_WO (_name) \ struct device_attribute dev_attr_##_name = __ATTR_WO(_name) + +/** +* DEVICE_ULONG_ATTR - Define a device attribute backed by an unsigned long. +* @_name: Attribute name. +* @_mode: File mode. +* @_var: Identifier of unsigned long. +* +* Like DEVICE_ATTR(), but @_show and @_store are automatically provided +* such that reads and writes to the attribute from userspace affect @_var. +*/ #define DEVICE_ULONG_ATTR (_name, _mode, _var) \ struct dev_ext_attribute dev_attr_##_name = \ { __ATTR(_name, _mode, device_show_ulong, device_store_ulong), &(_var) } + +/** +* DEVICE_INT_ATTR - Define a device attribute backed by an int. +* @_name: Attribute name. +* @_mode: File mode. +* @_var: Identifier of int. +* +* Like DEVICE_ULONG_ATTR(), but @_var is an int. +*/ #define DEVICE_INT_ATTR (_name, _mode, _var) \ struct dev_ext_attribute dev_attr_##_name = \ { __ATTR(_name, _mode, device_show_int, device_store_int), &(_var) } + +/** +* DEVICE_BOOL_ATTR - Define a device attribute backed by a bool. +* @_name: Attribute name. +* @_mode: File mode. +* @_var: Identifier of bool. +* +* Like DEVICE_ULONG_ATTR(), but @_var is a bool. +*/ #define DEVICE_BOOL_ATTR (_name, _mode, _var) \ struct dev_ext_attribute dev_attr_##_name = \ { __ATTR(_name, _mode, device_show_bool, device_store_bool), &(_var) } +#define DEVICE_ATTR_IGNORE_LOCKDEP (_name, _mode, _show, _store) \ struct device_attribute dev_attr_##_name = \ __ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store)
@@ -750,6 +854,11 @@ static inline bool device_iommu_mapped(struct device *dev)/* Get the wakeup routines, which depend on struct device */ #include <linux/pm_wakeup.h> +/** +* dev_name - Return a device's name. +* @dev: Device with name to get. +* Return: The kobject name of the device, or its initial name if unavailable. +*/ static inline const char *dev_name (const struct device *dev) {/* Use the init name until the kobject becomes available */
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/4 driver core: Add device_show_string() helper for sysfs attributes
From: Lukas Wunner <[email protected]>
[ Upstream commit 3cc50d07be10f67aff836f8247a240ec132c6a67 ]
For drivers wishing to expose an unsigned long, int or bool at a static memory location in sysfs, the driver core provides ready-made helpers such as device_show_ulong() to be used as ->show() callback.
Some drivers need to expose a string and so far they all provide their own ->show() implementation. arch/powerpc/perf/hv-24x7.c went so far as to create a device_show_string() helper but kept it private.
Make it public for reuse by other drivers. The pattern seems to be sufficiently frequent to merit a public helper.
Add a DEVICE_STRING_ATTR_RO() macro in line with the existing DEVICE_ULONG_ATTR() and similar macros to ease declaration of string attributes.
Stable-dep-of: 3d9a175707ee ("platform/x86: asus-wmi: fix TUF keyboard power state shutdown naming")
--- arch/powerpc/perf/hv-24x7.c | 10 ---------- drivers/base/core.c | 9 +++++++++ include/linux/device.h | 15 +++++++++++++++ 3 files changed, 24 insertions(+), 10 deletions(-)
arch/powerpc/perf/hv-24x7.c +0 -10
@@ -438,16 +438,6 @@ static char *memdup_to_str(char *maybe_str, int max_len, gfp_t gfp)return kasprintf (gfp,"%.*s" , max_len, maybe_str); } -static ssize_t device_show_string (struct device *dev, -struct device_attribute *attr,char *buf) -{ -struct dev_ext_attribute *d; - - d = container_of(attr, struct dev_ext_attribute, attr); - -return sprintf (buf,"%s\n" , (char *)d->var); -} -static ssize_t cpumask_show (struct device *dev,struct device_attribute *attr,char *buf) {
drivers/base/core.c +9 -0
@@ -2474,6 +2474,15 @@ ssize_t device_show_bool(struct device *dev, struct device_attribute *attr, }EXPORT_SYMBOL_GPL (device_show_bool); +ssize_t device_show_string (struct device *dev, +struct device_attribute *attr,char *buf) +{ +struct dev_ext_attribute *ea =to_ext_attr (attr); + +return sysfs_emit (buf,"%s\n" , (char *)ea->var); +} +EXPORT_SYMBOL_GPL (device_show_string); +/** * device_release - free device structure. * @kobj: device's kobject.
include/linux/device.h +15 -0
@@ -138,6 +138,8 @@ ssize_t device_show_bool(struct device *dev, struct device_attribute *attr, char *buf);ssize_t device_store_bool (struct device *dev,struct device_attribute *attr,const char *buf,size_t count); +ssize_t device_show_string (struct device *dev,struct device_attribute *attr, +char *buf);/** * DEVICE_ATTR - Define a device attribute.
@@ -257,6 +259,19 @@ ssize_t device_store_bool(struct device *dev, struct device_attribute *attr, struct dev_ext_attribute dev_attr_##_name = \ {__ATTR (_name, _mode, device_show_bool, device_store_bool), &(_var) } +/** +* DEVICE_STRING_ATTR_RO - Define a device attribute backed by a r/o string. +* @_name: Attribute name. +* @_mode: File mode. +* @_var: Identifier of string. +* +* Like DEVICE_ULONG_ATTR(), but @_var is a string. Because the length of the +* string allocation is unknown, the attribute must be read-only. + */ +#define DEVICE_STRING_ATTR_RO (_name, _mode, _var) \ + struct dev_ext_attribute dev_attr_##_name = \ + { __ATTR(_name, (_mode) & ~0222, device_show_string, NULL), (_var) } +#define DEVICE_ATTR_IGNORE_LOCKDEP (_name, _mode, _show, _store) \ struct device_attribute dev_attr_##_name = \ __ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store)
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 3/4 platform/x86: Use device_show_string() helper for sysfs attributes
In reply to Sasha LevinFrom: Lukas Wunner <[email protected]>
[ Upstream commit 3182459b7bff642eb968d6203a08aea3862436c1 ]
Deduplicate sysfs ->show() callbacks which expose a string at a static memory location. Use the newly introduced device_show_string() helper in the driver core instead by declaring those sysfs attributes with DEVICE_STRING_ATTR_RO().
No functional change intended.
The third ASUS fan and ThinkPad auxiliary MAC attributes are absent, so omit their conversions. Keep the conversions for the existing keyboard, CPU/GPU fan and Toshiba version attributes.
Stable-dep-of: 3d9a175707ee ("platform/x86: asus-wmi: fix TUF keyboard power state shutdown naming")
--- drivers/platform/x86/asus-wmi.c | 49 ++++++++--------------------- drivers/platform/x86/toshiba_acpi.c | 9 ++---- 2 files changed, 15 insertions(+), 43 deletions(-)
drivers/platform/x86/asus-wmi.c +13 -36
@@ -783,17 +783,12 @@ static ssize_t kbd_rgb_mode_store(struct device *dev, }static DEVICE_ATTR_WO (kbd_rgb_mode); -static ssize_t kbd_rgb_mode_index_show (struct device *device, -struct device_attribute *attr, -char *buf) -{ -return sysfs_emit (buf,"%s\n" ,"cmd mode red green blue speed" ); -} -static DEVICE_ATTR_RO (kbd_rgb_mode_index); +static DEVICE_STRING_ATTR_RO(kbd_rgb_mode_index, 0444, + "cmd mode red green blue speed");static struct attribute *kbd_rgb_mode_attrs[] = { &dev_attr_kbd_rgb_mode.attr, - &dev_attr_kbd_rgb_mode_index.attr, + &dev_attr_kbd_rgb_mode_index.attr.attr,NULL , };
@@ -835,17 +830,12 @@ static ssize_t kbd_rgb_state_store(struct device *dev, }static DEVICE_ATTR_WO (kbd_rgb_state); -static ssize_t kbd_rgb_state_index_show (struct device *device, -struct device_attribute *attr, -char *buf) -{ -return sysfs_emit (buf,"%s\n" ,"cmd boot awake sleep keyboard" ); -} -static DEVICE_ATTR_RO (kbd_rgb_state_index); +static DEVICE_STRING_ATTR_RO(kbd_rgb_state_index, 0444, + "cmd boot awake sleep keyboard");static struct attribute *kbd_rgb_state_attrs[] = { &dev_attr_kbd_rgb_state.attr, - &dev_attr_kbd_rgb_state_index.attr, + &dev_attr_kbd_rgb_state_index.attr.attr,NULL , };
@@ -2074,13 +2064,6 @@ static ssize_t pwm1_enable_store(struct device *dev,return count; } -static ssize_t fan1_label_show (struct device *dev, -struct device_attribute *attr, -char *buf) -{ -return sysfs_emit (buf,"%s\n" ,ASUS_FAN_DESC ); -} -static ssize_t asus_hwmon_temp1 (struct device *dev,struct device_attribute *attr,char *buf)
@@ -2115,13 +2098,6 @@ static ssize_t fan2_input_show(struct device *dev,return sysfs_emit (buf,"%d\n" , value *100 ); } -static ssize_t fan2_label_show (struct device *dev, -struct device_attribute *attr, -char *buf) -{ -return sysfs_emit (buf,"%s\n" ,ASUS_GPU_FAN_DESC ); -} -static ssize_t pwm2_enable_show (struct device *dev,struct device_attribute *attr,char *buf)
@@ -2172,11 +2148,12 @@ static ssize_t pwm2_enable_store(struct device *dev,static DEVICE_ATTR_RW (pwm1);static DEVICE_ATTR_RW (pwm1_enable);static DEVICE_ATTR_RO (fan1_input); -static DEVICE_ATTR_RO (fan1_label); +static DEVICE_STRING_ATTR_RO(fan1_label, 0444, ASUS_FAN_DESC); +/* Fan2 - GPU fan */ static DEVICE_ATTR_RW (pwm2_enable);static DEVICE_ATTR_RO (fan2_input); -static DEVICE_ATTR_RO (fan2_label); +static DEVICE_STRING_ATTR_RO(fan2_label, 0444, ASUS_GPU_FAN_DESC);/* Temperature */ static DEVICE_ATTR(temp1_input, S_IRUGO, asus_hwmon_temp1, NULL);
@@ -2186,9 +2163,9 @@ static struct attribute *hwmon_attributes[] = { &dev_attr_pwm1_enable.attr, &dev_attr_pwm2_enable.attr, &dev_attr_fan1_input.attr, - &dev_attr_fan1_label.attr, + &dev_attr_fan1_label.attr.attr, &dev_attr_fan2_input.attr, - &dev_attr_fan2_label.attr, + &dev_attr_fan2_label.attr.attr, &dev_attr_temp1_input.attr,NULL
@@ -2205,12 +2182,12 @@ static umode_t asus_hwmon_sysfs_is_visible(struct kobject *kobj,if (asus->fan_type !=FAN_TYPE_AGFN )return 0 ; }else if (attr == &dev_attr_fan1_input.attr - || attr == &dev_attr_fan1_label.attr + || attr == &dev_attr_fan1_label.attr.attr || attr == &dev_attr_pwm1_enable.attr) {if (asus->fan_type ==FAN_TYPE_NONE )return 0 ; }else if (attr == &dev_attr_fan2_input.attr - || attr == &dev_attr_fan2_label.attr + || attr == &dev_attr_fan2_label.attr.attr || attr == &dev_attr_pwm2_enable.attr) {if (asus->gpu_fan_type ==FAN_TYPE_NONE )return 0 ;
drivers/platform/x86/toshiba_acpi.c +2 -7
@@ -1820,12 +1820,7 @@ static DECLARE_WORK(kbd_bl_work, toshiba_acpi_kbd_bl_work);/* * Sysfs files */ -static ssize_t version_show (struct device *dev, -struct device_attribute *attr,char *buf) -{ -return sprintf (buf,"%s\n" ,TOSHIBA_ACPI_VERSION ); -} -static DEVICE_ATTR_RO (version); +static DEVICE_STRING_ATTR_RO(version, 0444, TOSHIBA_ACPI_VERSION); static ssize_t fan_store(struct device *dev, struct device_attribute *attr,
@@ -2434,7 +2429,7 @@ static ssize_t cooling_method_store(struct device *dev,static DEVICE_ATTR_RW (cooling_method);static struct attribute *toshiba_attributes[] = { - &dev_attr_version.attr, + &dev_attr_version.attr.attr, &dev_attr_fan.attr, &dev_attr_kbd_backlight_mode.attr, &dev_attr_kbd_type.attr,
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 4/4 platform/x86: asus-wmi: fix TUF keyboard power state shutdown naming
In reply to Sasha LevinFrom: Bartu Alev <[email protected]>
[ Upstream commit 3d9a175707eeb15a2d577af1e669b98e0236719b ]
The fourth state flag of kbd_rgb_state_index is named "keyboard" and has long been treated as having no effect. In hardware the flag, BIT(7) of the payload sent to the TUF RGB state device, gates whether the keyboard backlight stays lit while the machine powers off: with the bit set the keyboard lights up white during the ACPI S5 sequence, with the bit clear the machine powers off dark. Verified by A/B testing both values on a TUF Gaming A15 (FA507NV).
Rename the fourth field and its index entry from "keyboard" to "shutdown". The write format is unchanged, the value is still positional, and the diff is two variable names and one string, so it backports cleanly.
--- drivers/platform/x86/asus-wmi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/platform/x86/asus-wmi.c +4 -4
@@ -801,10 +801,10 @@ static ssize_t kbd_rgb_state_store(struct device *dev,struct device_attribute *attr, const char *buf, size_t count) { - u32 flags, cmd, boot, awake, sleep, keyboard; + u32 flags, cmd, boot, awake, sleep, shutdown;int err; -if (sscanf (buf,"%d %d %d %d %d" , &cmd, &boot, &awake, &sleep, &keyboard) !=5 ) +if (sscanf (buf,"%d %d %d %d %d" , &cmd, &boot, &awake, &sleep, &shutdown) !=5 )return -EINVAL ;if (cmd)
@@ -817,7 +817,7 @@ static ssize_t kbd_rgb_state_store(struct device *dev, flags |=BIT (3 );if (sleep) flags |=BIT (5 ); -if (keyboard) +if (shutdown) flags |=BIT (7 );/* 0xbd is the required default arg0 for the method. Nothing happens otherwise */
@@ -831,7 +831,7 @@ static ssize_t kbd_rgb_state_store(struct device *dev,static DEVICE_ATTR_WO (kbd_rgb_state); static DEVICE_STRING_ATTR_RO(kbd_rgb_state_index, 0444, - "cmd boot awake sleep keyboard"); + "cmd boot awake sleep shutdown");static struct attribute *kbd_rgb_state_attrs[] = { &dev_attr_kbd_rgb_state.attr,
Signature · 1 line
2.53.0