platform/chrome: wilco_ec: use sysfs_emit() instead of sprintf()
authorAi Chao <aichao@kylinos.cn>
Thu, 14 Mar 2024 05:28:28 +0000 (13:28 +0800)
committerTzung-Bi Shih <tzungbi@kernel.org>
Wed, 24 Apr 2024 08:45:56 +0000 (16:45 +0800)
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/20240314052828.186924-1-aichao@kylinos.cn
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
drivers/platform/chrome/wilco_ec/sysfs.c

index 893c59dde32a949e394ac5244da9350d1cec0631..d44c435596213f694ab52c59d24563a307c125a8 100644 (file)
@@ -192,7 +192,7 @@ static ssize_t usb_charge_show(struct device *dev,
        if (ret < 0)
                return ret;
 
-       return sprintf(buf, "%d\n", rs.val);
+       return sysfs_emit(buf, "%d\n", rs.val);
 }
 
 static ssize_t usb_charge_store(struct device *dev,