aboutsummaryrefslogtreecommitdiffstats
path: root/net/dsa/dsa.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/dsa/dsa.c')
-rw-r--r--net/dsa/dsa.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index b40f11bb419c..899772108ee3 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -20,6 +20,7 @@
20#include <linux/of.h> 20#include <linux/of.h>
21#include <linux/of_mdio.h> 21#include <linux/of_mdio.h>
22#include <linux/of_platform.h> 22#include <linux/of_platform.h>
23#include <linux/of_net.h>
23#include <linux/sysfs.h> 24#include <linux/sysfs.h>
24#include "dsa_priv.h" 25#include "dsa_priv.h"
25 26
@@ -583,7 +584,7 @@ static int dsa_of_probe(struct device *dev)
583 struct device_node *np = dev->of_node; 584 struct device_node *np = dev->of_node;
584 struct device_node *child, *mdio, *ethernet, *port, *link; 585 struct device_node *child, *mdio, *ethernet, *port, *link;
585 struct mii_bus *mdio_bus; 586 struct mii_bus *mdio_bus;
586 struct platform_device *ethernet_dev; 587 struct net_device *ethernet_dev;
587 struct dsa_platform_data *pd; 588 struct dsa_platform_data *pd;
588 struct dsa_chip_data *cd; 589 struct dsa_chip_data *cd;
589 const char *port_name; 590 const char *port_name;
@@ -604,7 +605,7 @@ static int dsa_of_probe(struct device *dev)
604 if (!ethernet) 605 if (!ethernet)
605 return -EINVAL; 606 return -EINVAL;
606 607
607 ethernet_dev = of_find_device_by_node(ethernet); 608 ethernet_dev = of_find_net_device_by_node(ethernet);
608 if (!ethernet_dev) 609 if (!ethernet_dev)
609 return -EPROBE_DEFER; 610 return -EPROBE_DEFER;
610 611
@@ -613,7 +614,7 @@ static int dsa_of_probe(struct device *dev)
613 return -ENOMEM; 614 return -ENOMEM;
614 615
615 dev->platform_data = pd; 616 dev->platform_data = pd;
616 pd->netdev = &ethernet_dev->dev; 617 pd->of_netdev = ethernet_dev;
617 pd->nr_chips = of_get_available_child_count(np); 618 pd->nr_chips = of_get_available_child_count(np);
618 if (pd->nr_chips > DSA_MAX_SWITCHES) 619 if (pd->nr_chips > DSA_MAX_SWITCHES)
619 pd->nr_chips = DSA_MAX_SWITCHES; 620 pd->nr_chips = DSA_MAX_SWITCHES;
@@ -771,10 +772,15 @@ static int dsa_probe(struct platform_device *pdev)
771 pd = pdev->dev.platform_data; 772 pd = pdev->dev.platform_data;
772 } 773 }
773 774
774 if (pd == NULL || pd->netdev == NULL) 775 if (pd == NULL || (pd->netdev == NULL && pd->of_netdev == NULL))
775 return -EINVAL; 776 return -EINVAL;
776 777
777 dev = dev_to_net_device(pd->netdev); 778 if (pd->of_netdev) {
779 dev = pd->of_netdev;
780 dev_hold(dev);
781 } else {
782 dev = dev_to_net_device(pd->netdev);
783 }
778 if (dev == NULL) { 784 if (dev == NULL) {
779 ret = -EPROBE_DEFER; 785 ret = -EPROBE_DEFER;
780 goto out; 786 goto out;