Switch devices are component slaves. Such devices have a "switch" property in the DSA device tree which is a phandle to the switch device. Add a component match on the device node.
Signed-off-by: Andrew Lunn <and...@lunn.ch> --- net/dsa/dsa.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c index be8e181f161b..8b89eece6b52 100644 --- a/net/dsa/dsa.c +++ b/net/dsa/dsa.c @@ -871,18 +871,25 @@ static int dsa_bind(struct device *dev) return dsa_setup_dst(dst, dst->master_netdev, dev); } +static int compare_of(struct device *dev, void *data) +{ + return dev->of_node == data; +} + static int dsa_probe(struct platform_device *pdev) { struct dsa_platform_data *pd = pdev->dev.platform_data; + struct device_node *np = pdev->dev.of_node; struct component_match *match = NULL; + struct device_node *chip; struct net_device *dev; struct dsa_switch_tree *dst; - int ret; + int i, ret; pr_notice_once("Distributed Switch Architecture driver version %s\n", dsa_driver_version); - if (pdev->dev.of_node) { + if (np) { pd = devm_kzalloc(&pdev->dev, sizeof(*pd), GFP_KERNEL); if (!pd) return -ENOMEM; @@ -926,6 +933,12 @@ static int dsa_probe(struct platform_device *pdev) platform_set_drvdata(pdev, dst); + for (i = 0; i < pd->nr_chips; i++) { + chip = pd->chip[i].of_chip; + if (chip) + component_match_add(&pdev->dev, &match, compare_of, + chip); + } return component_master_add_with_match(&pdev->dev, &dsa_ops, match); -- 2.6.3 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html