]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
x86/cacheinfo: Use sysfs_emit() for sysfs attributes show()
authorAhmed S. Darwish <darwi@linutronix.de>
Mon, 24 Mar 2025 13:33:09 +0000 (14:33 +0100)
committerIngo Molnar <mingo@kernel.org>
Tue, 25 Mar 2025 09:22:43 +0000 (10:22 +0100)
Per Documentation/filesystems/sysfs.rst, a sysfs attribute's show()
method should only use sysfs_emit() or sysfs_emit_at() when returning
values to user space.

Use sysfs_emit() for the AMD L3 cache sysfs attributes cache_disable_0,
cache_disable_1, and subcaches.

Signed-off-by: Ahmed S. Darwish <darwi@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://lore.kernel.org/r/20250324133324.23458-15-darwi@linutronix.de
arch/x86/kernel/cpu/amd_cache_disable.c

index 6d53aee0d8691da795f834de02172c512cfe9633..d860ad3f8a5a7c70b684e64b31b56e84dc4fad3d 100644 (file)
@@ -66,9 +66,9 @@ static ssize_t show_cache_disable(struct cacheinfo *ci, char *buf, unsigned int
 
        index = amd_get_l3_disable_slot(nb, slot);
        if (index >= 0)
-               return sprintf(buf, "%d\n", index);
+               return sysfs_emit(buf, "%d\n", index);
 
-       return sprintf(buf, "FREE\n");
+       return sysfs_emit(buf, "FREE\n");
 }
 
 #define SHOW_CACHE_DISABLE(slot)                                       \
@@ -189,7 +189,7 @@ static ssize_t subcaches_show(struct device *dev, struct device_attribute *attr,
        struct cacheinfo *ci = dev_get_drvdata(dev);
        int cpu = cpumask_first(&ci->shared_cpu_map);
 
-       return sprintf(buf, "%x\n", amd_get_subcaches(cpu));
+       return sysfs_emit(buf, "%x\n", amd_get_subcaches(cpu));
 }
 
 static ssize_t subcaches_store(struct device *dev,