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: ea074eb627 ("net: phy: add sysfs node for reading PHY's registers")
Signed-off-by: Tao Huang <huangtao@rock-chips.com>
Change-Id: I642da13c8e4b9351b13592a817c9bf9a9b5c34a7
This commit is contained in:
Tao Huang
2025-03-04 14:23:18 +08:00
parent 59bcd15ac0
commit 7a4dc023a4

View File

@@ -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