net: davinci_emac: match the mdio device against its compatible if possible
authorBartosz Golaszewski <bgolaszewski@baylibre.com>
Wed, 20 Jun 2018 08:03:56 +0000 (10:03 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 21 Jun 2018 01:23:48 +0000 (10:23 +0900)
Device tree based systems without of_dev_auxdata will have the mdio
device named differently than "davinci_mdio(.0)". In this case use the
device's parent's compatible string for matching

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/ti/davinci_emac.c

index a1a6445b5a7e2568af9e876f346b124958a51eee..f270beebb4289326baff5e86b33f47eae2eaa49b 100644 (file)
@@ -1387,6 +1387,10 @@ static int emac_devioctl(struct net_device *ndev, struct ifreq *ifrq, int cmd)
 
 static int match_first_device(struct device *dev, void *data)
 {
+       if (dev->parent && dev->parent->of_node)
+               return of_device_is_compatible(dev->parent->of_node,
+                                              "ti,davinci_mdio");
+
        return !strncmp(dev_name(dev), "davinci_mdio", 12);
 }