Re: [PATCH] net: phy: Add sysfs attribute for PHY c45 identifiers.

From: Andrew Lunn
Date: Sun Jun 11 2023 - 11:40:37 EST


On Sun, Jun 11, 2023 at 11:27:43PM +0800, Jianhui Zhao wrote:
> If a phydevice use c45, its phy_id property is always 0, so
> this adds a phy_c45_ids sysfs attribute to MDIO devices. This
> attribute can be useful when debugging problems related to
> phy drivers.

> + for (i = 1; i < num_ids; i++) {
> + if (phydev->c45_ids.device_ids[i] == 0xffffffff)
> + continue;
> +
> + ret += sprintf(buf + ret, "%d: 0x%.8lx\n", i,
> + (unsigned long)phydev->c45_ids.device_ids[i]);
> + }

https://www.kernel.org/doc/html/next/filesystems/sysfs.html says:

Attributes should be ASCII text files, preferably with only one
value per file. It is noted that it may not be efficient to contain
only one value per file, so it is socially acceptable to express an
array of values of the same type.

How about putting all 32 values in a subdirectory, one file per MMD?

Please also remember to document the attributes in
Documentation/ABI/testing/sysfs-class-net-phydev.

Andrew