aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/phy/phy_device.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/phy/phy_device.c')
-rw-r--r--drivers/net/phy/phy_device.c47
1 files changed, 32 insertions, 15 deletions
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index b10fedd82143..db1794546c56 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -177,6 +177,7 @@ struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id)
177 dev->state = PHY_DOWN; 177 dev->state = PHY_DOWN;
178 178
179 mutex_init(&dev->lock); 179 mutex_init(&dev->lock);
180 INIT_DELAYED_WORK(&dev->state_queue, phy_state_machine);
180 181
181 return dev; 182 return dev;
182} 183}
@@ -276,6 +277,22 @@ int phy_device_register(struct phy_device *phydev)
276EXPORT_SYMBOL(phy_device_register); 277EXPORT_SYMBOL(phy_device_register);
277 278
278/** 279/**
280 * phy_find_first - finds the first PHY device on the bus
281 * @bus: the target MII bus
282 */
283struct phy_device *phy_find_first(struct mii_bus *bus)
284{
285 int addr;
286
287 for (addr = 0; addr < PHY_MAX_ADDR; addr++) {
288 if (bus->phy_map[addr])
289 return bus->phy_map[addr];
290 }
291 return NULL;
292}
293EXPORT_SYMBOL(phy_find_first);
294
295/**
279 * phy_prepare_link - prepares the PHY layer to monitor link status 296 * phy_prepare_link - prepares the PHY layer to monitor link status
280 * @phydev: target phy_device struct 297 * @phydev: target phy_device struct
281 * @handler: callback function for link status change notifications 298 * @handler: callback function for link status change notifications
@@ -378,6 +395,20 @@ void phy_disconnect(struct phy_device *phydev)
378} 395}
379EXPORT_SYMBOL(phy_disconnect); 396EXPORT_SYMBOL(phy_disconnect);
380 397
398int phy_init_hw(struct phy_device *phydev)
399{
400 int ret;
401
402 if (!phydev->drv || !phydev->drv->config_init)
403 return 0;
404
405 ret = phy_scan_fixups(phydev);
406 if (ret < 0)
407 return ret;
408
409 return phydev->drv->config_init(phydev);
410}
411
381/** 412/**
382 * phy_attach_direct - attach a network device to a given PHY device pointer 413 * phy_attach_direct - attach a network device to a given PHY device pointer
383 * @dev: network device to attach 414 * @dev: network device to attach
@@ -425,21 +456,7 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
425 /* Do initial configuration here, now that 456 /* Do initial configuration here, now that
426 * we have certain key parameters 457 * we have certain key parameters
427 * (dev_flags and interface) */ 458 * (dev_flags and interface) */
428 if (phydev->drv->config_init) { 459 return phy_init_hw(phydev);
429 int err;
430
431 err = phy_scan_fixups(phydev);
432
433 if (err < 0)
434 return err;
435
436 err = phydev->drv->config_init(phydev);
437
438 if (err < 0)
439 return err;
440 }
441
442 return 0;
443} 460}
444EXPORT_SYMBOL(phy_attach_direct); 461EXPORT_SYMBOL(phy_attach_direct);
445 462