arch/arm/l2x0: Use sysfs_emit() in show() callback function
Commit Message
Using sprintf/snprintf functions are error prone and suggested to be
replaced by scnprintf/vscnrptintf as outlined in this [1] LWN article.
A more recent recommendation is to use sysfs_emit() or sysfs_emit_at()
as per Documentation/filesystems/sysfs.rst in show() callback function
when formatting values to be returned to user-space. These helper
functions are PAGE_SIZE aware and wrap a safer call to vscnprintf().
[1] https://lwn.net/Articles/69419/
Issue identified using the coccinelle device_attr_show.cocci script.
Signed-off-by: Deepak R Varma <drv@mailo.com>
---
Please note:
1. Change compile tested using sama7_defconfig
2. The driver name in the patch subject is best derived out of the 5 unique
names available for the current committed patches. If this is incorrect,
please suggest what it should be set to.
arch/arm/mm/cache-l2x0-pmu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@@ -343,7 +343,7 @@ static ssize_t l2x0_pmu_event_show(struct device *dev,
struct l2x0_event_attribute *lattr;
lattr = container_of(attr, typeof(*lattr), attr);
- return snprintf(buf, PAGE_SIZE, "config=0x%x\n", lattr->config);
+ return sysfs_emit(buf, "config=0x%x\n", lattr->config);
}
static umode_t l2x0_pmu_event_attr_is_visible(struct kobject *kobj,