Change the way PHY devices are named upon creation. This commit replaces
sequentialy numbered "/dev/phy%d" with "/dev/mdio%d-phy%02x". This way
it is significanlty easier to identify which PHY in real-life (e.g. on a
schematic) corresponds to which device in /dev.

Also, replace asprintf with xasprintf to provide some form of memory
allocation failure checking.

Signed-off-by: Andrey Smirnov <[email protected]>
---
 drivers/net/phy/mdio_bus.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index b74b27e..41bf018 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -333,7 +333,9 @@ static int mdio_bus_probe(struct device_d *_dev)
        dev_add_param_int_ro(&dev->dev, "phy_addr", dev->addr, "%d");
        dev_add_param_int_ro(&dev->dev, "phy_id", dev->phy_id, "0x%08x");
 
-       dev->cdev.name = asprintf("phy%d", _dev->id);
+       dev->cdev.name = xasprintf("mdio%d-phy%02x",
+                                  dev->bus->dev.id,
+                                  dev->addr);
        dev->cdev.size = 64;
        dev->cdev.ops = &phydev_ops;
        dev->cdev.priv = dev;
-- 
2.5.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Reply via email to