diff options
Diffstat (limited to 'net/dsa/dsa.c')
-rw-r--r-- | net/dsa/dsa.c | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c index 2173402d87e0..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) | |||
501 | #ifdef CONFIG_OF | 501 | #ifdef CONFIG_OF |
502 | static int dsa_of_setup_routing_table(struct dsa_platform_data *pd, | 502 | static int dsa_of_setup_routing_table(struct dsa_platform_data *pd, |
503 | struct dsa_chip_data *cd, | 503 | struct dsa_chip_data *cd, |
504 | int chip_index, | 504 | int chip_index, int port_index, |
505 | struct device_node *link) | 505 | struct device_node *link) |
506 | { | 506 | { |
507 | int ret; | ||
508 | const __be32 *reg; | 507 | const __be32 *reg; |
509 | int link_port_addr; | ||
510 | int link_sw_addr; | 508 | int link_sw_addr; |
511 | struct device_node *parent_sw; | 509 | struct device_node *parent_sw; |
512 | int len; | 510 | int len; |
@@ -519,6 +517,10 @@ static int dsa_of_setup_routing_table(struct dsa_platform_data *pd, | |||
519 | if (!reg || (len != sizeof(*reg) * 2)) | 517 | if (!reg || (len != sizeof(*reg) * 2)) |
520 | return -EINVAL; | 518 | return -EINVAL; |
521 | 519 | ||
520 | /* | ||
521 | * Get the destination switch number from the second field of its 'reg' | ||
522 | * property, i.e. for "reg = <0x19 1>" sw_addr is '1'. | ||
523 | */ | ||
522 | link_sw_addr = be32_to_cpup(reg + 1); | 524 | link_sw_addr = be32_to_cpup(reg + 1); |
523 | 525 | ||
524 | if (link_sw_addr >= pd->nr_chips) | 526 | if (link_sw_addr >= pd->nr_chips) |
@@ -535,20 +537,9 @@ static int dsa_of_setup_routing_table(struct dsa_platform_data *pd, | |||
535 | memset(cd->rtable, -1, pd->nr_chips * sizeof(s8)); | 537 | memset(cd->rtable, -1, pd->nr_chips * sizeof(s8)); |
536 | } | 538 | } |
537 | 539 | ||
538 | reg = of_get_property(link, "reg", NULL); | 540 | cd->rtable[link_sw_addr] = port_index; |
539 | if (!reg) { | ||
540 | ret = -EINVAL; | ||
541 | goto out; | ||
542 | } | ||
543 | |||
544 | link_port_addr = be32_to_cpup(reg); | ||
545 | |||
546 | cd->rtable[link_sw_addr] = link_port_addr; | ||
547 | 541 | ||
548 | return 0; | 542 | return 0; |
549 | out: | ||
550 | kfree(cd->rtable); | ||
551 | return ret; | ||
552 | } | 543 | } |
553 | 544 | ||
554 | static void dsa_of_free_platform_data(struct dsa_platform_data *pd) | 545 | static void dsa_of_free_platform_data(struct dsa_platform_data *pd) |
@@ -658,7 +649,7 @@ static int dsa_of_probe(struct platform_device *pdev) | |||
658 | if (!strcmp(port_name, "dsa") && link && | 649 | if (!strcmp(port_name, "dsa") && link && |
659 | pd->nr_chips > 1) { | 650 | pd->nr_chips > 1) { |
660 | ret = dsa_of_setup_routing_table(pd, cd, | 651 | ret = dsa_of_setup_routing_table(pd, cd, |
661 | chip_index, link); | 652 | chip_index, port_index, link); |
662 | if (ret) | 653 | if (ret) |
663 | goto out_free_chip; | 654 | goto out_free_chip; |
664 | } | 655 | } |