Both RTL8366x PHY drivers use the same PHY ID, so both match for either
chip, which results in the following behavior when using a RTL8366RB with
Port 4 as separate WAN port (seen on a WZR-HP-G301NH):

 - rtl8366rb probes addr 4
 - rtl8366s phy driver matches phy id => attaches
...
 - rtl8366s_phy_config_init gets called and fails (since wrong MII bus)
 - eth1 is unsable

Moving the MII bus check into the probe fixes this as then the next 
matching driver gets tried (the correct rtl8366rb phy driver), but this
produces a bit of log spam (each failed probe get reported).

Signed-off-by: Jonas Gorski <jonas.gorski+open...@gmail.com>
---

Getting rid of the log spam would mean that the way probing works needs to
be changed so that only the associated phy driver gets tried.

Support for the mentioned WZR-HP-G301NH comes in a later patch.

 .../generic/files/drivers/net/phy/rtl8366rb.c      |    8 +++++++-
 .../linux/generic/files/drivers/net/phy/rtl8366s.c |    8 +++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/target/linux/generic/files/drivers/net/phy/rtl8366rb.c 
b/target/linux/generic/files/drivers/net/phy/rtl8366rb.c
index 90c37ad..82db790 100644
--- a/target/linux/generic/files/drivers/net/phy/rtl8366rb.c
+++ b/target/linux/generic/files/drivers/net/phy/rtl8366rb.c
@@ -1282,7 +1282,7 @@ static int __devinit rtl8366rb_probe(struct 
platform_device *pdev)
        return err;
 }
 
-static int rtl8366rb_phy_config_init(struct phy_device *phydev)
+static int rtl8366rb_phy_probe(struct phy_device *phydev)
 {
        if (!rtl8366rb_mii_bus_match(phydev->bus))
                return -EINVAL;
@@ -1299,11 +1299,17 @@ static int rtl8366rb_phy_config_aneg(struct phy_device 
*phydev)
        return 0;
 }
 
+static int rtl8366rb_phy_config_init(struct phy_device *phydev)
+{
+       return 0;
+}
+
 static struct phy_driver rtl8366rb_phy_driver = {
        .phy_id         = 0x001cc960,
        .name           = "Realtek RTL8366RB",
        .phy_id_mask    = 0x1ffffff0,
        .features       = PHY_GBIT_FEATURES,
+       .probe          = rtl8366rb_phy_probe,
        .config_aneg    = rtl8366rb_phy_config_aneg,
        .config_init    = rtl8366rb_phy_config_init,
        .read_status    = genphy_read_status,
diff --git a/target/linux/generic/files/drivers/net/phy/rtl8366s.c 
b/target/linux/generic/files/drivers/net/phy/rtl8366s.c
index 7e72164..8a21d3e 100644
--- a/target/linux/generic/files/drivers/net/phy/rtl8366s.c
+++ b/target/linux/generic/files/drivers/net/phy/rtl8366s.c
@@ -1111,7 +1111,7 @@ static int __devinit rtl8366s_probe(struct 
platform_device *pdev)
        return err;
 }
 
-static int rtl8366s_phy_config_init(struct phy_device *phydev)
+static int rtl8366s_phy_probe(struct phy_device *phydev)
 {
        if (!rtl8366s_mii_bus_match(phydev->bus))
                return -EINVAL;
@@ -1128,11 +1128,17 @@ static int rtl8366s_phy_config_aneg(struct phy_device 
*phydev)
        return 0;
 }
 
+static int rtl8366s_phy_config_init(struct phy_device *phydev)
+{
+       return 0;
+}
+
 static struct phy_driver rtl8366s_phy_driver = {
        .phy_id         = 0x001cc960,
        .name           = "Realtek RTL8366S",
        .phy_id_mask    = 0x1ffffff0,
        .features       = PHY_GBIT_FEATURES,
+       .probe          = rtl8366s_phy_probe,
        .config_aneg    = rtl8366s_phy_config_aneg,
        .config_init    = rtl8366s_phy_config_init,
        .read_status    = genphy_read_status,
-- 
1.5.6.5

_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to