Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'net-phy-lan87xx-use-genphy_read_master_slave-function'

Arun Ramadoss says:

====================
net: phy: lan87xx: use genphy_read_master_slave function

LAN87xx T1 Phy has the same register field as gigabit phy for reading the
master slave configuration. But the genphy_read_master_slave function has a
check of gigabit phy. So refactored the function in such a way, moved the speed
check to the genphy_read_status function. Analyzed the nxp-tja11xx function for
refactoring, but the register for configuring master/slave is nxp specific
which is not extended phy register.
And analyzed the reusing genphy_setup_master_slave, but for LAN87xx
MASTER_ENABLE is always 1 and Preferred state is always 0. So, I didn't try to
change it.
====================

Link: https://lore.kernel.org/r/20220307161515.14970-1-arun.ramadoss@microchip.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

+11 -39
+1 -29
drivers/net/phy/microchip_t1.c
··· 674 674 return 0; 675 675 } 676 676 677 - static int lan87xx_read_master_slave(struct phy_device *phydev) 678 - { 679 - int rc = 0; 680 - 681 - phydev->master_slave_get = MASTER_SLAVE_CFG_UNKNOWN; 682 - phydev->master_slave_state = MASTER_SLAVE_STATE_UNKNOWN; 683 - 684 - rc = phy_read(phydev, MII_CTRL1000); 685 - if (rc < 0) 686 - return rc; 687 - 688 - if (rc & CTL1000_AS_MASTER) 689 - phydev->master_slave_get = MASTER_SLAVE_CFG_MASTER_FORCE; 690 - else 691 - phydev->master_slave_get = MASTER_SLAVE_CFG_SLAVE_FORCE; 692 - 693 - rc = phy_read(phydev, MII_STAT1000); 694 - if (rc < 0) 695 - return rc; 696 - 697 - if (rc & LPA_1000MSRES) 698 - phydev->master_slave_state = MASTER_SLAVE_STATE_MASTER; 699 - else 700 - phydev->master_slave_state = MASTER_SLAVE_STATE_SLAVE; 701 - 702 - return rc; 703 - } 704 - 705 677 static int lan87xx_read_status(struct phy_device *phydev) 706 678 { 707 679 int rc = 0; ··· 692 720 phydev->pause = 0; 693 721 phydev->asym_pause = 0; 694 722 695 - rc = lan87xx_read_master_slave(phydev); 723 + rc = genphy_read_master_slave(phydev); 696 724 if (rc < 0) 697 725 return rc; 698 726
+9 -10
drivers/net/phy/phy_device.c
··· 2051 2051 CTL1000_PREFER_MASTER), ctl); 2052 2052 } 2053 2053 2054 - static int genphy_read_master_slave(struct phy_device *phydev) 2054 + int genphy_read_master_slave(struct phy_device *phydev) 2055 2055 { 2056 2056 int cfg, state; 2057 2057 int val; 2058 - 2059 - if (!phydev->is_gigabit_capable) { 2060 - phydev->master_slave_get = MASTER_SLAVE_CFG_UNSUPPORTED; 2061 - phydev->master_slave_state = MASTER_SLAVE_STATE_UNSUPPORTED; 2062 - return 0; 2063 - } 2064 2058 2065 2059 phydev->master_slave_get = MASTER_SLAVE_CFG_UNKNOWN; 2066 2060 phydev->master_slave_state = MASTER_SLAVE_STATE_UNKNOWN; ··· 2096 2102 2097 2103 return 0; 2098 2104 } 2105 + EXPORT_SYMBOL(genphy_read_master_slave); 2099 2106 2100 2107 /** 2101 2108 * genphy_restart_aneg - Enable and Restart Autonegotiation ··· 2391 2396 if (phydev->autoneg == AUTONEG_ENABLE && old_link && phydev->link) 2392 2397 return 0; 2393 2398 2399 + phydev->master_slave_get = MASTER_SLAVE_CFG_UNSUPPORTED; 2400 + phydev->master_slave_state = MASTER_SLAVE_STATE_UNSUPPORTED; 2394 2401 phydev->speed = SPEED_UNKNOWN; 2395 2402 phydev->duplex = DUPLEX_UNKNOWN; 2396 2403 phydev->pause = 0; 2397 2404 phydev->asym_pause = 0; 2398 2405 2399 - err = genphy_read_master_slave(phydev); 2400 - if (err < 0) 2401 - return err; 2406 + if (phydev->is_gigabit_capable) { 2407 + err = genphy_read_master_slave(phydev); 2408 + if (err < 0) 2409 + return err; 2410 + } 2402 2411 2403 2412 err = genphy_read_lpa(phydev); 2404 2413 if (err < 0)
+1
include/linux/phy.h
··· 1578 1578 int genphy_read_lpa(struct phy_device *phydev); 1579 1579 int genphy_read_status_fixed(struct phy_device *phydev); 1580 1580 int genphy_read_status(struct phy_device *phydev); 1581 + int genphy_read_master_slave(struct phy_device *phydev); 1581 1582 int genphy_suspend(struct phy_device *phydev); 1582 1583 int genphy_resume(struct phy_device *phydev); 1583 1584 int genphy_loopback(struct phy_device *phydev, bool enable);