net: phy: Fix get_phy_device return value
A function should either return an ERR_PTR or NULL on failure, but not both. Let get_phy_device() return an ERR_PTR and fix the return checks in mdiobus_scan and phy_device_connect. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
6b5874f706
commit
7614ee1640
|
@ -82,7 +82,7 @@ struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr)
|
||||||
return bus->phy_map[addr];
|
return bus->phy_map[addr];
|
||||||
|
|
||||||
phydev = get_phy_device(bus, addr);
|
phydev = get_phy_device(bus, addr);
|
||||||
if (IS_ERR(phydev) || phydev == NULL)
|
if (IS_ERR(phydev))
|
||||||
return phydev;
|
return phydev;
|
||||||
|
|
||||||
bus->phy_map[addr] = phydev;
|
bus->phy_map[addr] = phydev;
|
||||||
|
|
|
@ -217,7 +217,7 @@ struct phy_device *get_phy_device(struct mii_bus *bus, int addr)
|
||||||
|
|
||||||
/* If the phy_id is mostly Fs, there is no device there */
|
/* If the phy_id is mostly Fs, there is no device there */
|
||||||
if ((phy_id & 0x1fffffff) == 0x1fffffff)
|
if ((phy_id & 0x1fffffff) == 0x1fffffff)
|
||||||
return NULL;
|
return ERR_PTR(-ENODEV);
|
||||||
|
|
||||||
dev = phy_device_create(bus, addr, phy_id);
|
dev = phy_device_create(bus, addr, phy_id);
|
||||||
|
|
||||||
|
@ -254,7 +254,7 @@ int phy_device_connect(struct eth_device *edev, struct mii_bus *bus, int addr,
|
||||||
if (!edev->phydev) {
|
if (!edev->phydev) {
|
||||||
if (addr >= 0) {
|
if (addr >= 0) {
|
||||||
dev = mdiobus_scan(bus, addr);
|
dev = mdiobus_scan(bus, addr);
|
||||||
if (!dev) {
|
if (IS_ERR(dev)) {
|
||||||
ret = -EIO;
|
ret = -EIO;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
@ -273,7 +273,7 @@ int phy_device_connect(struct eth_device *edev, struct mii_bus *bus, int addr,
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
dev = mdiobus_scan(bus, i);
|
dev = mdiobus_scan(bus, i);
|
||||||
if (!dev || dev->attached_dev)
|
if (IS_ERR(dev) || dev->attached_dev)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
dev->attached_dev = edev;
|
dev->attached_dev = edev;
|
||||||
|
@ -304,7 +304,7 @@ int phy_device_connect(struct eth_device *edev, struct mii_bus *bus, int addr,
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
if (dev)
|
if (!IS_ERR(dev))
|
||||||
dev->attached_dev = NULL;
|
dev->attached_dev = NULL;
|
||||||
puts("Unable to find a PHY (unknown ID?)\n");
|
puts("Unable to find a PHY (unknown ID?)\n");
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in New Issue