aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/phy
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/phy')
-rw-r--r--drivers/net/phy/bcm-phy-lib.c4
-rw-r--r--drivers/net/phy/marvell.c4
-rw-r--r--drivers/net/phy/micrel.c27
-rw-r--r--drivers/net/phy/phy.c127
-rw-r--r--drivers/net/phy/phy_device.c32
-rw-r--r--drivers/net/phy/realtek.c2
6 files changed, 101 insertions, 95 deletions
diff --git a/drivers/net/phy/bcm-phy-lib.c b/drivers/net/phy/bcm-phy-lib.c
index 171010eb4d9c..5ad130c3da43 100644
--- a/drivers/net/phy/bcm-phy-lib.c
+++ b/drivers/net/phy/bcm-phy-lib.c
@@ -341,8 +341,8 @@ void bcm_phy_get_strings(struct phy_device *phydev, u8 *data)
341 unsigned int i; 341 unsigned int i;
342 342
343 for (i = 0; i < ARRAY_SIZE(bcm_phy_hw_stats); i++) 343 for (i = 0; i < ARRAY_SIZE(bcm_phy_hw_stats); i++)
344 memcpy(data + i * ETH_GSTRING_LEN, 344 strlcpy(data + i * ETH_GSTRING_LEN,
345 bcm_phy_hw_stats[i].string, ETH_GSTRING_LEN); 345 bcm_phy_hw_stats[i].string, ETH_GSTRING_LEN);
346} 346}
347EXPORT_SYMBOL_GPL(bcm_phy_get_strings); 347EXPORT_SYMBOL_GPL(bcm_phy_get_strings);
348 348
diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index 98fd6b7ceeec..a75c511950c3 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -1452,8 +1452,8 @@ static void marvell_get_strings(struct phy_device *phydev, u8 *data)
1452 int i; 1452 int i;
1453 1453
1454 for (i = 0; i < ARRAY_SIZE(marvell_hw_stats); i++) { 1454 for (i = 0; i < ARRAY_SIZE(marvell_hw_stats); i++) {
1455 memcpy(data + i * ETH_GSTRING_LEN, 1455 strlcpy(data + i * ETH_GSTRING_LEN,
1456 marvell_hw_stats[i].string, ETH_GSTRING_LEN); 1456 marvell_hw_stats[i].string, ETH_GSTRING_LEN);
1457 } 1457 }
1458} 1458}
1459 1459
diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 0f45310300f6..f41b224a9cdb 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -635,25 +635,6 @@ static int ksz8873mll_config_aneg(struct phy_device *phydev)
635 return 0; 635 return 0;
636} 636}
637 637
638/* This routine returns -1 as an indication to the caller that the
639 * Micrel ksz9021 10/100/1000 PHY does not support standard IEEE
640 * MMD extended PHY registers.
641 */
642static int
643ksz9021_rd_mmd_phyreg(struct phy_device *phydev, int devad, u16 regnum)
644{
645 return -1;
646}
647
648/* This routine does nothing since the Micrel ksz9021 does not support
649 * standard IEEE MMD extended PHY registers.
650 */
651static int
652ksz9021_wr_mmd_phyreg(struct phy_device *phydev, int devad, u16 regnum, u16 val)
653{
654 return -1;
655}
656
657static int kszphy_get_sset_count(struct phy_device *phydev) 638static int kszphy_get_sset_count(struct phy_device *phydev)
658{ 639{
659 return ARRAY_SIZE(kszphy_hw_stats); 640 return ARRAY_SIZE(kszphy_hw_stats);
@@ -664,8 +645,8 @@ static void kszphy_get_strings(struct phy_device *phydev, u8 *data)
664 int i; 645 int i;
665 646
666 for (i = 0; i < ARRAY_SIZE(kszphy_hw_stats); i++) { 647 for (i = 0; i < ARRAY_SIZE(kszphy_hw_stats); i++) {
667 memcpy(data + i * ETH_GSTRING_LEN, 648 strlcpy(data + i * ETH_GSTRING_LEN,
668 kszphy_hw_stats[i].string, ETH_GSTRING_LEN); 649 kszphy_hw_stats[i].string, ETH_GSTRING_LEN);
669 } 650 }
670} 651}
671 652
@@ -946,8 +927,8 @@ static struct phy_driver ksphy_driver[] = {
946 .get_stats = kszphy_get_stats, 927 .get_stats = kszphy_get_stats,
947 .suspend = genphy_suspend, 928 .suspend = genphy_suspend,
948 .resume = genphy_resume, 929 .resume = genphy_resume,
949 .read_mmd = ksz9021_rd_mmd_phyreg, 930 .read_mmd = genphy_read_mmd_unsupported,
950 .write_mmd = ksz9021_wr_mmd_phyreg, 931 .write_mmd = genphy_write_mmd_unsupported,
951}, { 932}, {
952 .phy_id = PHY_ID_KSZ9031, 933 .phy_id = PHY_ID_KSZ9031,
953 .phy_id_mask = MICREL_PHY_ID_MASK, 934 .phy_id_mask = MICREL_PHY_ID_MASK,
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index c2d9027be863..05c1e8ef15e6 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -618,6 +618,68 @@ static void phy_error(struct phy_device *phydev)
618} 618}
619 619
620/** 620/**
621 * phy_disable_interrupts - Disable the PHY interrupts from the PHY side
622 * @phydev: target phy_device struct
623 */
624static int phy_disable_interrupts(struct phy_device *phydev)
625{
626 int err;
627
628 /* Disable PHY interrupts */
629 err = phy_config_interrupt(phydev, PHY_INTERRUPT_DISABLED);
630 if (err)
631 return err;
632
633 /* Clear the interrupt */
634 return phy_clear_interrupt(phydev);
635}
636
637/**
638 * phy_change - Called by the phy_interrupt to handle PHY changes
639 * @phydev: phy_device struct that interrupted
640 */
641static irqreturn_t phy_change(struct phy_device *phydev)
642{
643 if (phy_interrupt_is_valid(phydev)) {
644 if (phydev->drv->did_interrupt &&
645 !phydev->drv->did_interrupt(phydev))
646 return IRQ_NONE;
647
648 if (phydev->state == PHY_HALTED)
649 if (phy_disable_interrupts(phydev))
650 goto phy_err;
651 }
652
653 mutex_lock(&phydev->lock);
654 if ((PHY_RUNNING == phydev->state) || (PHY_NOLINK == phydev->state))
655 phydev->state = PHY_CHANGELINK;
656 mutex_unlock(&phydev->lock);
657
658 /* reschedule state queue work to run as soon as possible */
659 phy_trigger_machine(phydev, true);
660
661 if (phy_interrupt_is_valid(phydev) && phy_clear_interrupt(phydev))
662 goto phy_err;
663 return IRQ_HANDLED;
664
665phy_err:
666 phy_error(phydev);
667 return IRQ_NONE;
668}
669
670/**
671 * phy_change_work - Scheduled by the phy_mac_interrupt to handle PHY changes
672 * @work: work_struct that describes the work to be done
673 */
674void phy_change_work(struct work_struct *work)
675{
676 struct phy_device *phydev =
677 container_of(work, struct phy_device, phy_queue);
678
679 phy_change(phydev);
680}
681
682/**
621 * phy_interrupt - PHY interrupt handler 683 * phy_interrupt - PHY interrupt handler
622 * @irq: interrupt line 684 * @irq: interrupt line
623 * @phy_dat: phy_device pointer 685 * @phy_dat: phy_device pointer
@@ -632,9 +694,7 @@ static irqreturn_t phy_interrupt(int irq, void *phy_dat)
632 if (PHY_HALTED == phydev->state) 694 if (PHY_HALTED == phydev->state)
633 return IRQ_NONE; /* It can't be ours. */ 695 return IRQ_NONE; /* It can't be ours. */
634 696
635 phy_change(phydev); 697 return phy_change(phydev);
636
637 return IRQ_HANDLED;
638} 698}
639 699
640/** 700/**
@@ -652,23 +712,6 @@ static int phy_enable_interrupts(struct phy_device *phydev)
652} 712}
653 713
654/** 714/**
655 * phy_disable_interrupts - Disable the PHY interrupts from the PHY side
656 * @phydev: target phy_device struct
657 */
658static int phy_disable_interrupts(struct phy_device *phydev)
659{
660 int err;
661
662 /* Disable PHY interrupts */
663 err = phy_config_interrupt(phydev, PHY_INTERRUPT_DISABLED);
664 if (err)
665 return err;
666
667 /* Clear the interrupt */
668 return phy_clear_interrupt(phydev);
669}
670
671/**
672 * phy_start_interrupts - request and enable interrupts for a PHY device 715 * phy_start_interrupts - request and enable interrupts for a PHY device
673 * @phydev: target phy_device struct 716 * @phydev: target phy_device struct
674 * 717 *
@@ -711,50 +754,6 @@ int phy_stop_interrupts(struct phy_device *phydev)
711EXPORT_SYMBOL(phy_stop_interrupts); 754EXPORT_SYMBOL(phy_stop_interrupts);
712 755
713/** 756/**
714 * phy_change - Called by the phy_interrupt to handle PHY changes
715 * @phydev: phy_device struct that interrupted
716 */
717void phy_change(struct phy_device *phydev)
718{
719 if (phy_interrupt_is_valid(phydev)) {
720 if (phydev->drv->did_interrupt &&
721 !phydev->drv->did_interrupt(phydev))
722 return;
723
724 if (phydev->state == PHY_HALTED)
725 if (phy_disable_interrupts(phydev))
726 goto phy_err;
727 }
728
729 mutex_lock(&phydev->lock);
730 if ((PHY_RUNNING == phydev->state) || (PHY_NOLINK == phydev->state))
731 phydev->state = PHY_CHANGELINK;
732 mutex_unlock(&phydev->lock);
733
734 /* reschedule state queue work to run as soon as possible */
735 phy_trigger_machine(phydev, true);
736
737 if (phy_interrupt_is_valid(phydev) && phy_clear_interrupt(phydev))
738 goto phy_err;
739 return;
740
741phy_err:
742 phy_error(phydev);
743}
744
745/**
746 * phy_change_work - Scheduled by the phy_mac_interrupt to handle PHY changes
747 * @work: work_struct that describes the work to be done
748 */
749void phy_change_work(struct work_struct *work)
750{
751 struct phy_device *phydev =
752 container_of(work, struct phy_device, phy_queue);
753
754 phy_change(phydev);
755}
756
757/**
758 * phy_stop - Bring down the PHY link, and stop checking the status 757 * phy_stop - Bring down the PHY link, and stop checking the status
759 * @phydev: target phy_device struct 758 * @phydev: target phy_device struct
760 */ 759 */
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index b285323327c4..ac23322a32e1 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -1012,10 +1012,17 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
1012 err = sysfs_create_link(&phydev->mdio.dev.kobj, &dev->dev.kobj, 1012 err = sysfs_create_link(&phydev->mdio.dev.kobj, &dev->dev.kobj,
1013 "attached_dev"); 1013 "attached_dev");
1014 if (!err) { 1014 if (!err) {
1015 err = sysfs_create_link(&dev->dev.kobj, &phydev->mdio.dev.kobj, 1015 err = sysfs_create_link_nowarn(&dev->dev.kobj,
1016 "phydev"); 1016 &phydev->mdio.dev.kobj,
1017 if (err) 1017 "phydev");
1018 goto error; 1018 if (err) {
1019 dev_err(&dev->dev, "could not add device link to %s err %d\n",
1020 kobject_name(&phydev->mdio.dev.kobj),
1021 err);
1022 /* non-fatal - some net drivers can use one netdevice
1023 * with more then one phy
1024 */
1025 }
1019 1026
1020 phydev->sysfs_links = true; 1027 phydev->sysfs_links = true;
1021 } 1028 }
@@ -1666,6 +1673,23 @@ int genphy_config_init(struct phy_device *phydev)
1666} 1673}
1667EXPORT_SYMBOL(genphy_config_init); 1674EXPORT_SYMBOL(genphy_config_init);
1668 1675
1676/* This is used for the phy device which doesn't support the MMD extended
1677 * register access, but it does have side effect when we are trying to access
1678 * the MMD register via indirect method.
1679 */
1680int genphy_read_mmd_unsupported(struct phy_device *phdev, int devad, u16 regnum)
1681{
1682 return -EOPNOTSUPP;
1683}
1684EXPORT_SYMBOL(genphy_read_mmd_unsupported);
1685
1686int genphy_write_mmd_unsupported(struct phy_device *phdev, int devnum,
1687 u16 regnum, u16 val)
1688{
1689 return -EOPNOTSUPP;
1690}
1691EXPORT_SYMBOL(genphy_write_mmd_unsupported);
1692
1669int genphy_suspend(struct phy_device *phydev) 1693int genphy_suspend(struct phy_device *phydev)
1670{ 1694{
1671 return phy_set_bits(phydev, MII_BMCR, BMCR_PDOWN); 1695 return phy_set_bits(phydev, MII_BMCR, BMCR_PDOWN);
diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
index ee3ca4a2f12b..9f48ecf9c627 100644
--- a/drivers/net/phy/realtek.c
+++ b/drivers/net/phy/realtek.c
@@ -172,6 +172,8 @@ static struct phy_driver realtek_drvs[] = {
172 .flags = PHY_HAS_INTERRUPT, 172 .flags = PHY_HAS_INTERRUPT,
173 .ack_interrupt = &rtl821x_ack_interrupt, 173 .ack_interrupt = &rtl821x_ack_interrupt,
174 .config_intr = &rtl8211b_config_intr, 174 .config_intr = &rtl8211b_config_intr,
175 .read_mmd = &genphy_read_mmd_unsupported,
176 .write_mmd = &genphy_write_mmd_unsupported,
175 }, { 177 }, {
176 .phy_id = 0x001cc914, 178 .phy_id = 0x001cc914,
177 .name = "RTL8211DN Gigabit Ethernet", 179 .name = "RTL8211DN Gigabit Ethernet",