generic: rtl836x: support defered probe on mdio-bus
[openwrt/staging/chunkeey.git] / target / linux / generic / files / drivers / net / phy / rtl8366_smi.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);