05e4ec8328fb75c298b61e5de41e96feec36a598
[openwrt/staging/wigyori.git] / target / linux / lantiq / patches-5.4 / 0701-NET-lantiq-etop-of-mido.patch
1 --- a/drivers/net/ethernet/lantiq_etop.c
2 +++ b/drivers/net/ethernet/lantiq_etop.c
3 @@ -40,6 +40,7 @@
4 #include <linux/of_net.h>
5 #include <linux/of_irq.h>
6 #include <linux/of_platform.h>
7 +#include <linux/of_mdio.h>
8
9 #include <asm/checksum.h>
10
11 @@ -571,7 +572,8 @@ static int
12 ltq_etop_mdio_init(struct net_device *dev)
13 {
14 struct ltq_etop_priv *priv = netdev_priv(dev);
15 - int err;
16 + struct device_node *mdio_np = NULL;
17 + int err, ret;
18
19 priv->mii_bus = mdiobus_alloc();
20 if (!priv->mii_bus) {
21 @@ -591,7 +593,15 @@ ltq_etop_mdio_init(struct net_device *de
22 priv->mii_bus->name = "ltq_mii";
23 snprintf(priv->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
24 priv->pdev->name, priv->pdev->id);
25 - if (mdiobus_register(priv->mii_bus)) {
26 +
27 + mdio_np = of_get_child_by_name(priv->pdev->dev.of_node, "mdio-bus");
28 +
29 + if (mdio_np)
30 + ret = of_mdiobus_register(priv->mii_bus, mdio_np);
31 + else
32 + ret = mdiobus_register(priv->mii_bus);
33 +
34 + if (ret) {
35 err = -ENXIO;
36 goto err_out_free_mdiobus;
37 }