Skip to content

Commit

Permalink
phylib: mdio: Add sysfs attribute for PHY identifiers.
Browse files Browse the repository at this point in the history
This adds a phy_id sysfs attribute to MDIO devices, containing the
32-bit PHY identifier reported by the device.  This attribute can
be useful when debugging problems related to phy drivers.  Other
enumerable buses already have similar attributes.

Signed-off-by: Nick Bowler <nbowler@elliptictech.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Nick Bowler authored and David S. Miller committed Nov 9, 2012
1 parent b1ead1a commit 56277f4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Documentation/ABI/testing/sysfs-bus-mdio
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
What: /sys/bus/mdio_bus/devices/.../phy_id
Date: November 2012
KernelVersion: 3.8
Contact: netdev@vger.kernel.org
Description:
This attribute contains the 32-bit PHY Identifier as reported
by the device during bus enumeration, encoded in hexadecimal.
This ID is used to match the device with the appropriate
driver.
14 changes: 14 additions & 0 deletions drivers/net/phy/mdio_bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,24 @@ static struct dev_pm_ops mdio_bus_pm_ops = {

#endif /* CONFIG_PM */

static ssize_t
phy_id_show(struct device *dev, struct device_attribute *attr, char *buf)
{
struct phy_device *phydev = to_phy_device(dev);

return sprintf(buf, "0x%.8lx\n", (unsigned long)phydev->phy_id);
}

static struct device_attribute mdio_dev_attrs[] = {
__ATTR_RO(phy_id),
__ATTR_NULL
};

struct bus_type mdio_bus_type = {
.name = "mdio_bus",
.match = mdio_bus_match,
.pm = MDIO_BUS_PM_OPS,
.dev_attrs = mdio_dev_attrs,
};
EXPORT_SYMBOL(mdio_bus_type);

Expand Down

0 comments on commit 56277f4

Please sign in to comment.