]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
w1: core: use sysfs_emit() instead of sprintf()
authorzhangheng <zhangheng@kylinos.cn>
Fri, 20 Dec 2024 10:23:37 +0000 (18:23 +0800)
committerKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Sun, 22 Dec 2024 14:42:15 +0000 (15:42 +0100)
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: zhangheng <zhangheng@kylinos.cn>
Link: https://lore.kernel.org/r/20241220102337.295864-1-zhangheng@kylinos.cn
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
drivers/w1/slaves/w1_ds28e17.c

index 52261b54d842eb2428825f6dc492fa08cbf8fa19..5738cbce1a37f31edfe74c794a6b75277296bf96 100644 (file)
@@ -583,7 +583,7 @@ static ssize_t speed_show(struct device *dev, struct device_attribute *attr,
                return result;
 
        /* Return current speed value. */
-       return sprintf(buf, "%d\n", result);
+       return sysfs_emit(buf, "%d\n", result);
 }
 
 static ssize_t speed_store(struct device *dev, struct device_attribute *attr,
@@ -633,7 +633,7 @@ static ssize_t stretch_show(struct device *dev, struct device_attribute *attr,
        struct w1_f19_data *data = sl->family_data;
 
        /* Return current stretch value. */
-       return sprintf(buf, "%d\n", data->stretch);
+       return sysfs_emit(buf, "%d\n", data->stretch);
 }
 
 static ssize_t stretch_store(struct device *dev, struct device_attribute *attr,