summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2016-01-31 19:10:12 -0800
committerSascha Hauer <s.hauer@pengutronix.de>2016-02-03 08:36:33 +0100
commit993a28aa48f26da8d7e06ee4c3011c66c47df8c9 (patch)
treecc1a4c4284eaf5f72b68fd8ae2d770a41edced56 /drivers
parentb88381df6ef2930fb6072489b93b1fc31257162a (diff)
downloadbarebox-993a28aa48f26da8d7e06ee4c3011c66c47df8c9.tar.gz
barebox-993a28aa48f26da8d7e06ee4c3011c66c47df8c9.tar.xz
mdio_bus: Change PHY's naming scheme
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 <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/phy/mdio_bus.c4
-rw-r--r--drivers/net/phy/phy.c6
2 files changed, 7 insertions, 3 deletions
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index b74b27e991..41bf018141 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;
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 25c999c550..d128a5e8d5 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -168,8 +168,10 @@ static struct phy_device *phy_device_create(struct mii_bus *bus, int addr, int p
phydev->bus = bus;
phydev->dev.bus = &mdio_bus_type;
- strcpy(phydev->dev.name, "phy");
- phydev->dev.id = DEVICE_ID_DYNAMIC;
+ sprintf(phydev->dev.name, "mdio%d-phy%02x",
+ phydev->bus->dev.id,
+ phydev->addr);
+ phydev->dev.id = DEVICE_ID_SINGLE;
return phydev;
}