Init speed and duplex to unknown, so phy_lookup_setting() knows that
it should select the mode only based on the PHY allowed link modes.

Signed-off-by: Lucas Stach <l.st...@pengutronix.de>
---
 drivers/net/phy/phy-core.c   | 5 +++++
 drivers/net/phy/phy_device.c | 2 ++
 2 files changed, 7 insertions(+)

diff --git a/drivers/net/phy/phy-core.c b/drivers/net/phy/phy-core.c
index 21f75ae244b3..149a4bab1e6f 100644
--- a/drivers/net/phy/phy-core.c
+++ b/drivers/net/phy/phy-core.c
@@ -149,6 +149,11 @@ phy_lookup_setting(int speed, int duplex, const unsigned 
long *mask,
        const struct phy_setting *p, *match = NULL, *last = NULL;
        int i;
 
+       if (!exact && speed == SPEED_UNKNOWN)
+               speed = INT_MAX;
+       if (!exact && duplex == DUPLEX_UNKNOWN)
+               duplex = DUPLEX_FULL;
+
        for (i = 0, p = settings; i < ARRAY_SIZE(settings); i++, p++) {
                if (p->bit < maxbit && test_bit(p->bit, mask)) {
                        last = p;
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 8ef48b38d97b..35278282259a 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -1785,6 +1785,8 @@ static int phy_probe(struct device *dev)
        phydev->supported = phydrv->features;
        of_set_phy_supported(phydev);
        phydev->advertising = phydev->supported;
+       phydev->speed = SPEED_UNKNOWN;
+       phydev->duplex = DUPLEX_UNKNOWN;
 
        /* Get the EEE modes we want to prohibit. We will ask
         * the PHY stop advertising these mode later on
-- 
2.11.0

Reply via email to