9
0
Fork 0

Merge branch 'for-next/phylib'

This commit is contained in:
Sascha Hauer 2012-11-16 14:02:49 +01:00
commit 1bfbbcca51
2 changed files with 10 additions and 24 deletions

View File

@ -36,7 +36,7 @@
*/
int mdiobus_register(struct mii_bus *bus)
{
int i, err;
int err;
if (NULL == bus ||
NULL == bus->read ||
@ -59,29 +59,8 @@ int mdiobus_register(struct mii_bus *bus)
if (bus->reset)
bus->reset(bus);
for (i = 0; i < PHY_MAX_ADDR; i++) {
if ((bus->phy_mask & (1 << i)) == 0) {
struct phy_device *phydev;
phydev = mdiobus_scan(bus, i);
if (IS_ERR(phydev)) {
err = PTR_ERR(phydev);
goto error;
}
}
}
pr_info("%s: probed\n", dev_name(&bus->dev));
return 0;
error:
while (--i >= 0) {
if (bus->phy_map[i]) {
kfree(bus->phy_map[i]);
bus->phy_map[i] = NULL;
}
}
return err;
}
EXPORT_SYMBOL(mdiobus_register);
@ -101,6 +80,9 @@ struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr)
{
struct phy_device *phydev;
if (bus->phy_map[addr])
return bus->phy_map[addr];
phydev = get_phy_device(bus, addr);
if (IS_ERR(phydev) || phydev == NULL)
return phydev;

View File

@ -154,7 +154,7 @@ int phy_device_connect(struct eth_device *edev, struct mii_bus *bus, int addr,
if (!edev->phydev) {
if (addr >= 0) {
dev = bus->phy_map[addr];
dev = mdiobus_scan(bus, addr);
if (!dev) {
ret = -EIO;
goto fail;
@ -169,7 +169,11 @@ int phy_device_connect(struct eth_device *edev, struct mii_bus *bus, int addr,
goto fail;
} else {
for (i = 0; i < PHY_MAX_ADDR && !edev->phydev; i++) {
dev = bus->phy_map[i];
/* skip masked out PHY addresses */
if (bus->phy_mask & (1 << i))
continue;
dev = mdiobus_scan(bus, i);
if (!dev || dev->attached_dev)
continue;