提交 ef0c883c 编写于 作者: Y Yang Guang 提交者: Zheng Zengkai

ptp: replace snprintf with sysfs_emit

stable inclusion
from stable-v5.10.111
commit 02e2ee8619849f7ac1555d250698fd900ba95d2d
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5GL1Z

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=02e2ee8619849f7ac1555d250698fd900ba95d2d

--------------------------------

[ Upstream commit e2cf0765 ]

coccinelle report:
./drivers/ptp/ptp_sysfs.c:17:8-16:
WARNING: use scnprintf or sprintf
./drivers/ptp/ptp_sysfs.c:390:8-16:
WARNING: use scnprintf or sprintf

Use sysfs_emit instead of scnprintf or sprintf makes more sense.
Reported-by: NZeal Robot <zealci@zte.com.cn>
Signed-off-by: NYang Guang <yang.guang5@zte.com.cn>
Signed-off-by: NDavid Yang <davidcomponentone@gmail.com>
Acked-by: NRichard Cochran <richardcochran@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Reviewed-by: NWei Li <liwei391@huawei.com>
上级 44c65a9b
...@@ -13,7 +13,7 @@ static ssize_t clock_name_show(struct device *dev, ...@@ -13,7 +13,7 @@ static ssize_t clock_name_show(struct device *dev,
struct device_attribute *attr, char *page) struct device_attribute *attr, char *page)
{ {
struct ptp_clock *ptp = dev_get_drvdata(dev); struct ptp_clock *ptp = dev_get_drvdata(dev);
return snprintf(page, PAGE_SIZE-1, "%s\n", ptp->info->name); return sysfs_emit(page, "%s\n", ptp->info->name);
} }
static DEVICE_ATTR_RO(clock_name); static DEVICE_ATTR_RO(clock_name);
...@@ -227,7 +227,7 @@ static ssize_t ptp_pin_show(struct device *dev, struct device_attribute *attr, ...@@ -227,7 +227,7 @@ static ssize_t ptp_pin_show(struct device *dev, struct device_attribute *attr,
mutex_unlock(&ptp->pincfg_mux); mutex_unlock(&ptp->pincfg_mux);
return snprintf(page, PAGE_SIZE, "%u %u\n", func, chan); return sysfs_emit(page, "%u %u\n", func, chan);
} }
static ssize_t ptp_pin_store(struct device *dev, struct device_attribute *attr, static ssize_t ptp_pin_store(struct device *dev, struct device_attribute *attr,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册