Skip to content

Commit 415c33d

Browse files
TomAi0jwrdegoede
authored andcommitted
platform/x86: huawei-wmi: use sysfs_emit() instead of sprintf()
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/20240319064243.297320-1-aichao@kylinos.cn Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
1 parent 79bd127 commit 415c33d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/platform/x86/huawei-wmi.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ static ssize_t charge_control_start_threshold_show(struct device *dev,
379379
if (err)
380380
return err;
381381

382-
return sprintf(buf, "%d\n", start);
382+
return sysfs_emit(buf, "%d\n", start);
383383
}
384384

385385
static ssize_t charge_control_end_threshold_show(struct device *dev,
@@ -392,7 +392,7 @@ static ssize_t charge_control_end_threshold_show(struct device *dev,
392392
if (err)
393393
return err;
394394

395-
return sprintf(buf, "%d\n", end);
395+
return sysfs_emit(buf, "%d\n", end);
396396
}
397397

398398
static ssize_t charge_control_thresholds_show(struct device *dev,
@@ -405,7 +405,7 @@ static ssize_t charge_control_thresholds_show(struct device *dev,
405405
if (err)
406406
return err;
407407

408-
return sprintf(buf, "%d %d\n", start, end);
408+
return sysfs_emit(buf, "%d %d\n", start, end);
409409
}
410410

411411
static ssize_t charge_control_start_threshold_store(struct device *dev,
@@ -562,7 +562,7 @@ static ssize_t fn_lock_state_show(struct device *dev,
562562
if (err)
563563
return err;
564564

565-
return sprintf(buf, "%d\n", on);
565+
return sysfs_emit(buf, "%d\n", on);
566566
}
567567

568568
static ssize_t fn_lock_state_store(struct device *dev,

0 commit comments

Comments
 (0)