From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: Lukas Wunner <lukas@wunner.de>,
Hans de Goede <hdegoede@redhat.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 6.1.y 3/4] platform/x86: Use device_show_string() helper for sysfs attributes
Date: Tue, 10 Nov 2026 19:17:26 -0500 [thread overview]
Message-ID: <20261111001652.217391-3-sashal@kernel.org> (raw)
In-Reply-To: <20261111001652.217391-1-sashal@kernel.org>
From: Lukas Wunner <lukas@wunner.de>
[ 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.
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/3ae8c9a73fbb291c1c863777af175c657a2a10e9.1713608122.git.lukas@wunner.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
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")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/platform/x86/asus-wmi.c | 49 ++++++++---------------------
drivers/platform/x86/toshiba_acpi.c | 9 ++----
2 files changed, 15 insertions(+), 43 deletions(-)
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 8814b258caa55..2506f15ce53a1 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -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;
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index 3541c2048905b..7307249f812d3 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -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,
--
2.53.0
next prev parent reply other threads:[~2026-11-11 0:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-07 10:53 FAILED: patch "[PATCH] platform/x86: asus-wmi: fix TUF keyboard power state shutdown naming" failed to apply to 6.1-stable tree Sasha Levin
2026-11-11 0:17 ` [PATCH 6.1.y 1/4] driver core: device.h: add some missing kerneldocs Sasha Levin
2026-11-11 0:17 ` [PATCH 6.1.y 2/4] driver core: Add device_show_string() helper for sysfs attributes Sasha Levin
2026-11-11 0:17 ` Sasha Levin [this message]
2026-11-11 0:17 ` [PATCH 6.1.y 4/4] platform/x86: asus-wmi: fix TUF keyboard power state shutdown naming Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261111001652.217391-3-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=hdegoede@redhat.com \
--cc=lukas@wunner.de \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox