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.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 4f4568ef124e..ca5ec3e18d36 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -355,7 +355,7 @@ int phy_device_register(struct phy_device *phydev)
355 phydev->bus->phy_map[phydev->addr] = phydev; 355 phydev->bus->phy_map[phydev->addr] = phydev;
356 356
357 /* Run all of the fixups for this PHY */ 357 /* Run all of the fixups for this PHY */
358 err = phy_init_hw(phydev); 358 err = phy_scan_fixups(phydev);
359 if (err) { 359 if (err) {
360 pr_err("PHY %d failed to initialize\n", phydev->addr); 360 pr_err("PHY %d failed to initialize\n", phydev->addr);
361 goto out; 361 goto out;
@@ -575,6 +575,7 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
575 u32 flags, phy_interface_t interface) 575 u32 flags, phy_interface_t interface)
576{ 576{
577 struct device *d = &phydev->dev; 577 struct device *d = &phydev->dev;
578 struct module *bus_module;
578 int err; 579 int err;
579 580
580 /* Assume that if there is no driver, that it doesn't 581 /* Assume that if there is no driver, that it doesn't
@@ -599,6 +600,14 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
599 return -EBUSY; 600 return -EBUSY;
600 } 601 }
601 602
603 /* Increment the bus module reference count */
604 bus_module = phydev->bus->dev.driver ?
605 phydev->bus->dev.driver->owner : NULL;
606 if (!try_module_get(bus_module)) {
607 dev_err(&dev->dev, "failed to get the bus module\n");
608 return -EIO;
609 }
610
602 phydev->attached_dev = dev; 611 phydev->attached_dev = dev;
603 dev->phydev = phydev; 612 dev->phydev = phydev;
604 613
@@ -664,6 +673,10 @@ EXPORT_SYMBOL(phy_attach);
664void phy_detach(struct phy_device *phydev) 673void phy_detach(struct phy_device *phydev)
665{ 674{
666 int i; 675 int i;
676
677 if (phydev->bus->dev.driver)
678 module_put(phydev->bus->dev.driver->owner);
679
667 phydev->attached_dev->phydev = NULL; 680 phydev->attached_dev->phydev = NULL;
668 phydev->attached_dev = NULL; 681 phydev->attached_dev = NULL;
669 phy_suspend(phydev); 682 phy_suspend(phydev);