Skip to content

Commit 79bd127

Browse files
TomAi0jwrdegoede
authored andcommitted
platform/x86: asus-wmi: use sysfs_emit() instead of sprintf()
This changes all *_show attributes in asus-wmi.c to use sysfs_emit() instead of the older method of writing to the output buffer manually. Follow the advice in Documentation/filesystems/sysfs.rst: show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. Signed-off-by: Ai Chao <aichao@kylinos.cn> Link: https://lore.kernel.org/r/20240319055636.150289-1-aichao@kylinos.cn Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
1 parent 6d9b262 commit 79bd127

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/platform/x86/asus-wmi.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2326,7 +2326,7 @@ static ssize_t pwm1_show(struct device *dev,
23262326

23272327
/* If we already set a value then just return it */
23282328
if (asus->agfn_pwm >= 0)
2329-
return sprintf(buf, "%d\n", asus->agfn_pwm);
2329+
return sysfs_emit(buf, "%d\n", asus->agfn_pwm);
23302330

23312331
/*
23322332
* If we haven't set already set a value through the AGFN interface,
@@ -2512,8 +2512,8 @@ static ssize_t asus_hwmon_temp1(struct device *dev,
25122512
if (err < 0)
25132513
return err;
25142514

2515-
return sprintf(buf, "%ld\n",
2516-
deci_kelvin_to_millicelsius(value & 0xFFFF));
2515+
return sysfs_emit(buf, "%ld\n",
2516+
deci_kelvin_to_millicelsius(value & 0xFFFF));
25172517
}
25182518

25192519
/* GPU fan on modern ROG laptops */
@@ -4061,7 +4061,7 @@ static ssize_t show_sys_wmi(struct asus_wmi *asus, int devid, char *buf)
40614061
if (value < 0)
40624062
return value;
40634063

4064-
return sprintf(buf, "%d\n", value);
4064+
return sysfs_emit(buf, "%d\n", value);
40654065
}
40664066

40674067
#define ASUS_WMI_CREATE_DEVICE_ATTR(_name, _mode, _cm) \

0 commit comments

Comments
 (0)