generic: rtl836x: support defered probe on mdio-bus
authorChristian Lamparter <chunkeey@gmail.com>
Wed, 17 Oct 2018 20:37:36 +0000 (22:37 +0200)
committerJo-Philipp Wich <jo@mein.io>
Tue, 18 Dec 2018 16:48:16 +0000 (17:48 +0100)
On the WNDAP620, the mdio and mdc lines are controlled by
the EMAC ethernet device. This results in a hen-vs-egg problem.
The rtl8367b driver is probed before the ethernet driver and
the mdio-bus is not available yet, which caused the rtl8367b
driver to fail.

This patch changes the rtl8366_smi_probe_of() function to
return -EPROBE_DEFER if the mdio-bus lookup failed and changes
rtl8366_smi_probe()'s signature to return the error code back to
the callee, so it can propagate back to the kernel. Which, will
retry the switch probe at a later time.

Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
(backported from 910c2f9e68554ed36f622d005c76f39780b367ab)

target/linux/generic/files/drivers/net/phy/rtl8366_smi.c
target/linux/generic/files/drivers/net/phy/rtl8366rb.c
target/linux/generic/files/drivers/net/phy/rtl8366s.c
target/linux/generic/files/drivers/net/phy/rtl8367.c
target/linux/generic/files/drivers/net/phy/rtl8367b.c

index c0cb680e23ba31299a828ab1b9a38599de6db867..2c4d53fc6769680495cf9d4d918e768ae2a3f895 100644 (file)
@@ -1553,8 +1553,8 @@ int rtl8366_smi_probe_of(struct platform_device *pdev, struct rtl8366_smi *smi)
 
        smi->ext_mbus = of_mdio_find_bus(mdio_node);
        if (!smi->ext_mbus) {
-               dev_err(&pdev->dev,
-                       "cannot find mdio bus from bus handle");
+               dev_info(&pdev->dev,
+                       "cannot find mdio bus from bus handle (yet)");
                goto try_gpio;
        }
 
@@ -1562,8 +1562,12 @@ int rtl8366_smi_probe_of(struct platform_device *pdev, struct rtl8366_smi *smi)
 
 try_gpio:
        if (!gpio_is_valid(sck) || !gpio_is_valid(sda)) {
-               dev_err(&pdev->dev, "gpios missing in devictree\n");
-               return -EINVAL;
+               if (!mdio_node) {
+                       dev_err(&pdev->dev, "gpios missing in devictree\n");
+                       return -EINVAL;
+               } else {
+                       return -EPROBE_DEFER;
+               }
        }
 
        smi->gpio_sda = sda;
@@ -1619,7 +1623,7 @@ struct rtl8366_smi *rtl8366_smi_probe(struct platform_device *pdev)
 
 free_smi:
        kfree(smi);
-       return NULL;
+       return ERR_PTR(err);
 }
 EXPORT_SYMBOL_GPL(rtl8366_smi_probe);
 
index dc394c02b6660cfc2fc419b70c534e0a6365d734..0e0116051a8cb377667124b08ae7ee4ede4a0d0b 100644 (file)
@@ -1445,8 +1445,8 @@ static int rtl8366rb_probe(struct platform_device *pdev)
                       " version " RTL8366RB_DRIVER_VER"\n");
 
        smi = rtl8366_smi_probe(pdev);
-       if (!smi)
-               return -ENODEV;
+       if (IS_ERR(smi))
+               return PTR_ERR(smi);
 
        smi->clk_delay = 10;
        smi->cmd_read = 0xa9;
index 3f458f9dec91e9ef9fe732d5e9728270e6b72ab1..8c746778b8f820d94756a7a7ee40c91d7ea6217d 100644 (file)
@@ -1233,8 +1233,8 @@ static int rtl8366s_probe(struct platform_device *pdev)
                       " version " RTL8366S_DRIVER_VER"\n");
 
        smi = rtl8366_smi_probe(pdev);
-       if (!smi)
-               return -ENODEV;
+       if (IS_ERR(smi))
+               return PTR_ERR(smi);
 
        smi->clk_delay = 10;
        smi->cmd_read = 0xa9;
index 9549961d767589789abedafd5b2d932c0e340273..7f0569d0385b0ce61cc04a9870027a5606881c4a 100644 (file)
@@ -1752,8 +1752,8 @@ static int rtl8367_probe(struct platform_device *pdev)
        int err;
 
        smi = rtl8366_smi_probe(pdev);
-       if (!smi)
-               return -ENODEV;
+       if (IS_ERR(smi))
+               return PTR_ERR(smi);
 
        smi->clk_delay = 1500;
        smi->cmd_read = 0xb9;
index e6ea6509ae061cf23fe521bd1c8cf51384c4dcd3..cd8de810b51c746e257288afb637d4e398f03264 100644 (file)
@@ -1527,8 +1527,8 @@ static int  rtl8367b_probe(struct platform_device *pdev)
        int err;
 
        smi = rtl8366_smi_probe(pdev);
-       if (!smi)
-               return -ENODEV;
+       if (IS_ERR(smi))
+               return PTR_ERR(smi);
 
        smi->clk_delay = 1500;
        smi->cmd_read = 0xb9;