Skip to content

Commit 66c1f38

Browse files
AbdelrahmanYousryyrafaeljw
authored andcommitted
ACPI: fan: Replace sprintf()/scnprintf() with sysfs_emit() in show() functions
Update two sysfs show() functions in the ACPI fan driver to use sysfs_emit() and sysfs_emit_at() instead of sprintf() and scnprintf(). - show_fan_speed(): replaced sprintf() with sysfs_emit(). - show_state(): replaced scnprintf() with sysfs_emit() for the first write, and retained sysfs_emit_at() for incremental writes. This change is in accordance with Documentation/filesystems/sysfs.rst, which recommends using sysfs_emit/sysfs_emit_at in all sysfs show() callbacks for buffer safety, clarity, and consistency. Signed-off-by: Abdelrahman Fekry <abdelrahmanfekry375@gmail.com> Link: https://patch.msgid.link/20250621055200.166361-1-abdelrahmanfekry375@gmail.com Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent d0b3b7b commit 66c1f38

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

drivers/acpi/fan_attr.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ static ssize_t show_state(struct device *dev, struct device_attribute *attr, cha
2222
int count;
2323

2424
if (fps->control == 0xFFFFFFFF || fps->control > 100)
25-
count = scnprintf(buf, PAGE_SIZE, "not-defined:");
25+
count = sysfs_emit(buf, "not-defined:");
2626
else
27-
count = scnprintf(buf, PAGE_SIZE, "%lld:", fps->control);
27+
count = sysfs_emit(buf, "%lld:", fps->control);
2828

2929
if (fps->trip_point == 0xFFFFFFFF || fps->trip_point > 9)
3030
count += sysfs_emit_at(buf, count, "not-defined:");
@@ -59,7 +59,7 @@ static ssize_t show_fan_speed(struct device *dev, struct device_attribute *attr,
5959
if (status)
6060
return status;
6161

62-
return sprintf(buf, "%lld\n", fst.speed);
62+
return sysfs_emit(buf, "%lld\n", fst.speed);
6363
}
6464

6565
static ssize_t show_fine_grain_control(struct device *dev, struct device_attribute *attr, char *buf)

0 commit comments

Comments
 (0)