diff options
| author | Chris Zankel <[email protected]> | 2015-04-14 03:51:35 +0000 | 
|---|---|---|
| committer | Chris Zankel <[email protected]> | 2015-04-14 03:51:35 +0000 | 
| commit | 7ead5b7e4a3cf4a16579a8f164022345b93fe972 (patch) | |
| tree | 0a9b9497f53d1593c9e2ac197b2e686ea74a9975 /net/dsa/dsa.c | |
| parent | 834a316eeebcb75316c0a7d9088fa638c52dc584 (diff) | |
| parent | 39a8804455fb23f09157341d3ba7db6d7ae6ee76 (diff) | |
Merge tag 'v4.0' into for_next
Linux 4.0
Diffstat (limited to 'net/dsa/dsa.c')
| -rw-r--r-- | net/dsa/dsa.c | 25 | 
1 files changed, 8 insertions, 17 deletions
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c index 37317149f918..4dea2e0681d1 100644 --- a/net/dsa/dsa.c +++ b/net/dsa/dsa.c @@ -501,12 +501,10 @@ static struct net_device *dev_to_net_device(struct device *dev)  #ifdef CONFIG_OF  static int dsa_of_setup_routing_table(struct dsa_platform_data *pd,  					struct dsa_chip_data *cd, -					int chip_index, +					int chip_index, int port_index,  					struct device_node *link)  { -	int ret;  	const __be32 *reg; -	int link_port_addr;  	int link_sw_addr;  	struct device_node *parent_sw;  	int len; @@ -519,6 +517,10 @@ static int dsa_of_setup_routing_table(struct dsa_platform_data *pd,  	if (!reg || (len != sizeof(*reg) * 2))  		return -EINVAL; +	/* +	 * Get the destination switch number from the second field of its 'reg' +	 * property, i.e. for "reg = <0x19 1>" sw_addr is '1'. +	 */  	link_sw_addr = be32_to_cpup(reg + 1);  	if (link_sw_addr >= pd->nr_chips) @@ -535,20 +537,9 @@ static int dsa_of_setup_routing_table(struct dsa_platform_data *pd,  		memset(cd->rtable, -1, pd->nr_chips * sizeof(s8));  	} -	reg = of_get_property(link, "reg", NULL); -	if (!reg) { -		ret = -EINVAL; -		goto out; -	} - -	link_port_addr = be32_to_cpup(reg); - -	cd->rtable[link_sw_addr] = link_port_addr; +	cd->rtable[link_sw_addr] = port_index;  	return 0; -out: -	kfree(cd->rtable); -	return ret;  }  static void dsa_of_free_platform_data(struct dsa_platform_data *pd) @@ -603,7 +594,7 @@ static int dsa_of_probe(struct platform_device *pdev)  	pdev->dev.platform_data = pd;  	pd->netdev = ðernet_dev->dev; -	pd->nr_chips = of_get_child_count(np); +	pd->nr_chips = of_get_available_child_count(np);  	if (pd->nr_chips > DSA_MAX_SWITCHES)  		pd->nr_chips = DSA_MAX_SWITCHES; @@ -658,7 +649,7 @@ static int dsa_of_probe(struct platform_device *pdev)  			if (!strcmp(port_name, "dsa") && link &&  					pd->nr_chips > 1) {  				ret = dsa_of_setup_routing_table(pd, cd, -						chip_index, link); +						chip_index, port_index, link);  				if (ret)  					goto out_free_chip;  			}  |