diff options
Diffstat (limited to 'drivers/net/phy/phy_device.c')
-rw-r--r-- | drivers/net/phy/phy_device.c | 54 |
1 files changed, 33 insertions, 21 deletions
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 25acbbde4a60..e35460165bf7 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c | |||
@@ -74,7 +74,7 @@ int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask, | |||
74 | if (!fixup) | 74 | if (!fixup) |
75 | return -ENOMEM; | 75 | return -ENOMEM; |
76 | 76 | ||
77 | strncpy(fixup->bus_id, bus_id, BUS_ID_SIZE); | 77 | strlcpy(fixup->bus_id, bus_id, sizeof(fixup->bus_id)); |
78 | fixup->phy_uid = phy_uid; | 78 | fixup->phy_uid = phy_uid; |
79 | fixup->phy_uid_mask = phy_uid_mask; | 79 | fixup->phy_uid_mask = phy_uid_mask; |
80 | fixup->run = run; | 80 | fixup->run = run; |
@@ -109,7 +109,7 @@ EXPORT_SYMBOL(phy_register_fixup_for_id); | |||
109 | */ | 109 | */ |
110 | static int phy_needs_fixup(struct phy_device *phydev, struct phy_fixup *fixup) | 110 | static int phy_needs_fixup(struct phy_device *phydev, struct phy_fixup *fixup) |
111 | { | 111 | { |
112 | if (strcmp(fixup->bus_id, phydev->dev.bus_id) != 0) | 112 | if (strcmp(fixup->bus_id, dev_name(&phydev->dev)) != 0) |
113 | if (strcmp(fixup->bus_id, PHY_ANY_ID) != 0) | 113 | if (strcmp(fixup->bus_id, PHY_ANY_ID) != 0) |
114 | return 0; | 114 | return 0; |
115 | 115 | ||
@@ -232,7 +232,7 @@ struct phy_device * get_phy_device(struct mii_bus *bus, int addr) | |||
232 | return NULL; | 232 | return NULL; |
233 | 233 | ||
234 | /* | 234 | /* |
235 | * Broken hardware is sometimes missing the pull down resistor on the | 235 | * Broken hardware is sometimes missing the pull-up resistor on the |
236 | * MDIO line, which results in reads to non-existent devices returning | 236 | * MDIO line, which results in reads to non-existent devices returning |
237 | * 0 rather than 0xffff. Catch this here and treat 0 as a non-existent | 237 | * 0 rather than 0xffff. Catch this here and treat 0 as a non-existent |
238 | * device as well. | 238 | * device as well. |
@@ -517,23 +517,6 @@ int genphy_setup_forced(struct phy_device *phydev) | |||
517 | 517 | ||
518 | err = phy_write(phydev, MII_BMCR, ctl); | 518 | err = phy_write(phydev, MII_BMCR, ctl); |
519 | 519 | ||
520 | if (err < 0) | ||
521 | return err; | ||
522 | |||
523 | /* | ||
524 | * Run the fixups on this PHY, just in case the | ||
525 | * board code needs to change something after a reset | ||
526 | */ | ||
527 | err = phy_scan_fixups(phydev); | ||
528 | |||
529 | if (err < 0) | ||
530 | return err; | ||
531 | |||
532 | /* We just reset the device, so we'd better configure any | ||
533 | * settings the PHY requires to operate */ | ||
534 | if (phydev->drv->config_init) | ||
535 | err = phydev->drv->config_init(phydev); | ||
536 | |||
537 | return err; | 520 | return err; |
538 | } | 521 | } |
539 | 522 | ||
@@ -779,7 +762,35 @@ static int genphy_config_init(struct phy_device *phydev) | |||
779 | 762 | ||
780 | return 0; | 763 | return 0; |
781 | } | 764 | } |
765 | int genphy_suspend(struct phy_device *phydev) | ||
766 | { | ||
767 | int value; | ||
782 | 768 | ||
769 | mutex_lock(&phydev->lock); | ||
770 | |||
771 | value = phy_read(phydev, MII_BMCR); | ||
772 | phy_write(phydev, MII_BMCR, (value | BMCR_PDOWN)); | ||
773 | |||
774 | mutex_unlock(&phydev->lock); | ||
775 | |||
776 | return 0; | ||
777 | } | ||
778 | EXPORT_SYMBOL(genphy_suspend); | ||
779 | |||
780 | int genphy_resume(struct phy_device *phydev) | ||
781 | { | ||
782 | int value; | ||
783 | |||
784 | mutex_lock(&phydev->lock); | ||
785 | |||
786 | value = phy_read(phydev, MII_BMCR); | ||
787 | phy_write(phydev, MII_BMCR, (value & ~BMCR_PDOWN)); | ||
788 | |||
789 | mutex_unlock(&phydev->lock); | ||
790 | |||
791 | return 0; | ||
792 | } | ||
793 | EXPORT_SYMBOL(genphy_resume); | ||
783 | 794 | ||
784 | /** | 795 | /** |
785 | * phy_probe - probe and init a PHY device | 796 | * phy_probe - probe and init a PHY device |
@@ -855,7 +866,6 @@ int phy_driver_register(struct phy_driver *new_driver) | |||
855 | { | 866 | { |
856 | int retval; | 867 | int retval; |
857 | 868 | ||
858 | memset(&new_driver->driver, 0, sizeof(new_driver->driver)); | ||
859 | new_driver->driver.name = new_driver->name; | 869 | new_driver->driver.name = new_driver->name; |
860 | new_driver->driver.bus = &mdio_bus_type; | 870 | new_driver->driver.bus = &mdio_bus_type; |
861 | new_driver->driver.probe = phy_probe; | 871 | new_driver->driver.probe = phy_probe; |
@@ -890,6 +900,8 @@ static struct phy_driver genphy_driver = { | |||
890 | .features = 0, | 900 | .features = 0, |
891 | .config_aneg = genphy_config_aneg, | 901 | .config_aneg = genphy_config_aneg, |
892 | .read_status = genphy_read_status, | 902 | .read_status = genphy_read_status, |
903 | .suspend = genphy_suspend, | ||
904 | .resume = genphy_resume, | ||
893 | .driver = {.owner= THIS_MODULE, }, | 905 | .driver = {.owner= THIS_MODULE, }, |
894 | }; | 906 | }; |
895 | 907 | ||