rpmsg: Replace sprintf() with sysfs_emit() in sysfs show

Use sysfs_emit() instead of sprintf() in sysfs attribute show functions.
sysfs_emit() is the recommended API for sysfs output as it provides buffer
overflow protection and proper formatting.

No functional changes.

Signed-off-by: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com>
Reviewed-by: Chris Lew <christopher.lew@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20251217065112.18392-2-zhongqiu.han@oss.qualcomm.com
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
This commit is contained in:
Zhongqiu Han
2026-07-09 14:45:34 -05:00
committed by Bjorn Andersson
parent dc59e4fea9
commit ef22e806ae
3 changed files with 6 additions and 6 deletions
+1 -1
View File
@@ -1460,7 +1460,7 @@ static ssize_t rpmsg_name_show(struct device *dev,
{
struct qcom_smd_edge *edge = to_smd_edge(dev);
return sprintf(buf, "%s\n", edge->name);
return sysfs_emit(buf, "%s\n", edge->name);
}
static DEVICE_ATTR_RO(rpmsg_name);
+3 -3
View File
@@ -371,7 +371,7 @@ static ssize_t name_show(struct device *dev, struct device_attribute *attr,
{
struct rpmsg_eptdev *eptdev = dev_get_drvdata(dev);
return sprintf(buf, "%s\n", eptdev->chinfo.name);
return sysfs_emit(buf, "%s\n", eptdev->chinfo.name);
}
static DEVICE_ATTR_RO(name);
@@ -380,7 +380,7 @@ static ssize_t src_show(struct device *dev, struct device_attribute *attr,
{
struct rpmsg_eptdev *eptdev = dev_get_drvdata(dev);
return sprintf(buf, "%d\n", eptdev->chinfo.src);
return sysfs_emit(buf, "%d\n", eptdev->chinfo.src);
}
static DEVICE_ATTR_RO(src);
@@ -389,7 +389,7 @@ static ssize_t dst_show(struct device *dev, struct device_attribute *attr,
{
struct rpmsg_eptdev *eptdev = dev_get_drvdata(dev);
return sprintf(buf, "%d\n", eptdev->chinfo.dst);
return sysfs_emit(buf, "%d\n", eptdev->chinfo.dst);
}
static DEVICE_ATTR_RO(dst);
+2 -2
View File
@@ -348,7 +348,7 @@ field##_show(struct device *dev, \
{ \
struct rpmsg_device *rpdev = to_rpmsg_device(dev); \
\
return sprintf(buf, format_string, rpdev->path); \
return sysfs_emit(buf, format_string, rpdev->path); \
} \
static DEVICE_ATTR_RO(field);
@@ -368,7 +368,7 @@ static ssize_t modalias_show(struct device *dev,
if (len != -ENODEV)
return len;
return sprintf(buf, RPMSG_DEVICE_MODALIAS_FMT "\n", rpdev->id.name);
return sysfs_emit(buf, RPMSG_DEVICE_MODALIAS_FMT "\n", rpdev->id.name);
}
static DEVICE_ATTR_RO(modalias);