From 7a4dc023a4c73058d86cf8501dba6b8c92c6b02f Mon Sep 17 00:00:00 2001 From: Tao Huang Date: Tue, 4 Mar 2025 14:23:18 +0800 Subject: [PATCH] net: phy: Convert to use sysfs_emit_at() API Follow the advice of the Documentation/filesystems/sysfs.rst and show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. Fixes: ea074eb6278f ("net: phy: add sysfs node for reading PHY's registers") Signed-off-by: Tao Huang Change-Id: I642da13c8e4b9351b13592a817c9bf9a9b5c34a7 --- drivers/net/phy/phy_device.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 389f4e5256fa..c0056c391c7e 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -568,12 +568,13 @@ phy_registers_show(struct device *dev, struct device_attribute *attr, char *buf) { struct phy_device *phydev = to_phy_device(dev); int index; + int len = 0; for (index = 0; index < 32; index++) - sprintf(buf, "%s%2d: 0x%x\n", buf, index, - phy_read(phydev, index)); + len += sysfs_emit_at(buf, len, "%2d: 0x%x\n", index, + phy_read(phydev, index)); - return strlen(buf); + return len; } static ssize_t