summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-12-11 10:18:40 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2013-12-11 10:45:00 +0100
commit5f0a71708e04ae7c5c0d4ef859d680bcce44dd86 (patch)
tree30eb8b99226d6700e73545ff6c8a73e59509f812 /drivers
parent72930d623c6e708284429d36d709c7642d4a280f (diff)
downloadbarebox-5f0a71708e04ae7c5c0d4ef859d680bcce44dd86.tar.gz
barebox-5f0a71708e04ae7c5c0d4ef859d680bcce44dd86.tar.xz
net: phy: cleanup attached device handling
phy_register_device() currently requires an attached ethernet device. This is not needed, a phy device can equally well be registered as a standalone device without an ethernet device. Remove the need for an attached ethernet device in phy_register_device. Also, make the edev <-> phy connection on a registered device which simplifies the code. 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.c14
2 files changed, 3 insertions, 15 deletions
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 87072be289..b0fbf2df36 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -153,8 +153,6 @@ static int mdio_bus_probe(struct device_d *_dev)
int ret;
- dev->attached_dev->phydev = dev;
-
if (drv->probe) {
ret = drv->probe(dev);
if (ret)
@@ -204,8 +202,6 @@ static int mdio_bus_probe(struct device_d *_dev)
return 0;
err:
- dev->attached_dev->phydev = NULL;
- dev->attached_dev = NULL;
return ret;
}
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 2a33054589..d8966cd469 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -228,7 +228,7 @@ static int phy_register_device(struct phy_device* dev)
{
int ret;
- dev->dev.parent = &dev->attached_dev->dev;
+ dev->dev.parent = &dev->bus->dev;
ret = register_device(&dev->dev);
if (ret)
@@ -259,7 +259,6 @@ int phy_device_connect(struct eth_device *edev, struct mii_bus *bus, int addr,
goto fail;
}
- dev->attached_dev = edev;
dev->interface = interface;
dev->dev_flags = flags;
@@ -276,7 +275,6 @@ int phy_device_connect(struct eth_device *edev, struct mii_bus *bus, int addr,
if (IS_ERR(dev) || dev->attached_dev)
continue;
- dev->attached_dev = edev;
dev->interface = interface;
dev->dev_flags = flags;
@@ -287,14 +285,10 @@ int phy_device_connect(struct eth_device *edev, struct mii_bus *bus, int addr,
break;
}
}
-
- if (!edev->phydev) {
- ret = -EIO;
- goto fail;
- }
}
- dev = edev->phydev;
+ edev->phydev = dev;
+ dev->attached_dev = edev;
drv = to_phy_driver(dev->dev.driver);
drv->config_aneg(dev);
@@ -304,8 +298,6 @@ int phy_device_connect(struct eth_device *edev, struct mii_bus *bus, int addr,
return 0;
fail:
- if (!IS_ERR(dev))
- dev->attached_dev = NULL;
puts("Unable to find a PHY (unknown ID?)\n");
return ret;
}