diff options
author | Florian Fainelli <f.fainelli@gmail.com> | 2017-06-02 15:31:23 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-06-04 20:05:15 -0400 |
commit | 14be36c2c96cd18cfa036f230b57ea78d82a303f (patch) | |
tree | 588f98e84727f296a0383a1e359359017e6704d2 /net/dsa/dsa2.c | |
parent | e41c1b5030e279c6626d3d052c3ca5ce5e2508df (diff) |
net: dsa: Initialize all CPU and enabled ports masks in dsa_ds_parse()
There was no reason for duplicating the code that initializes
ds->enabled_port_mask in both dsa_parse_ports_dn() and
dsa_parse_ports(), instead move this to dsa_ds_parse() which is early
enough before ops->setup() has run.
While at it, we can now make dsa_is_cpu_port() check ds->cpu_port_mask
which is a step towards being multi-CPU port capable.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dsa/dsa2.c')
-rw-r--r-- | net/dsa/dsa2.c | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index 067daec644c1..cd13bb54a30c 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c | |||
@@ -250,8 +250,6 @@ static int dsa_cpu_port_apply(struct dsa_port *port) | |||
250 | return err; | 250 | return err; |
251 | } | 251 | } |
252 | 252 | ||
253 | ds->cpu_port_mask |= BIT(port->index); | ||
254 | |||
255 | memset(&port->devlink_port, 0, sizeof(port->devlink_port)); | 253 | memset(&port->devlink_port, 0, sizeof(port->devlink_port)); |
256 | err = devlink_port_register(ds->devlink, &port->devlink_port, | 254 | err = devlink_port_register(ds->devlink, &port->devlink_port, |
257 | port->index); | 255 | port->index); |
@@ -522,6 +520,12 @@ static int dsa_cpu_parse(struct dsa_port *port, u32 index, | |||
522 | 520 | ||
523 | dst->rcv = dst->tag_ops->rcv; | 521 | dst->rcv = dst->tag_ops->rcv; |
524 | 522 | ||
523 | /* Initialize cpu_port_mask now for drv->setup() | ||
524 | * to have access to a correct value, just like what | ||
525 | * net/dsa/dsa.c::dsa_switch_setup_one does. | ||
526 | */ | ||
527 | ds->cpu_port_mask |= BIT(index); | ||
528 | |||
525 | return 0; | 529 | return 0; |
526 | } | 530 | } |
527 | 531 | ||
@@ -533,14 +537,22 @@ static int dsa_ds_parse(struct dsa_switch_tree *dst, struct dsa_switch *ds) | |||
533 | 537 | ||
534 | for (index = 0; index < ds->num_ports; index++) { | 538 | for (index = 0; index < ds->num_ports; index++) { |
535 | port = &ds->ports[index]; | 539 | port = &ds->ports[index]; |
536 | if (!dsa_port_is_valid(port)) | 540 | if (!dsa_port_is_valid(port) || |
541 | dsa_port_is_dsa(port)) | ||
537 | continue; | 542 | continue; |
538 | 543 | ||
539 | if (dsa_port_is_cpu(port)) { | 544 | if (dsa_port_is_cpu(port)) { |
540 | err = dsa_cpu_parse(port, index, dst, ds); | 545 | err = dsa_cpu_parse(port, index, dst, ds); |
541 | if (err) | 546 | if (err) |
542 | return err; | 547 | return err; |
548 | } else { | ||
549 | /* Initialize enabled_port_mask now for drv->setup() | ||
550 | * to have access to a correct value, just like what | ||
551 | * net/dsa/dsa.c::dsa_switch_setup_one does. | ||
552 | */ | ||
553 | ds->enabled_port_mask |= BIT(index); | ||
543 | } | 554 | } |
555 | |||
544 | } | 556 | } |
545 | 557 | ||
546 | pr_info("DSA: switch %d %d parsed\n", dst->tree, ds->index); | 558 | pr_info("DSA: switch %d %d parsed\n", dst->tree, ds->index); |
@@ -589,13 +601,6 @@ static int dsa_parse_ports_dn(struct device_node *ports, struct dsa_switch *ds) | |||
589 | return -EINVAL; | 601 | return -EINVAL; |
590 | 602 | ||
591 | ds->ports[reg].dn = port; | 603 | ds->ports[reg].dn = port; |
592 | |||
593 | /* Initialize enabled_port_mask now for ops->setup() | ||
594 | * to have access to a correct value, just like what | ||
595 | * net/dsa/dsa.c::dsa_switch_setup_one does. | ||
596 | */ | ||
597 | if (!dsa_port_is_cpu(&ds->ports[reg])) | ||
598 | ds->enabled_port_mask |= 1 << reg; | ||
599 | } | 604 | } |
600 | 605 | ||
601 | return 0; | 606 | return 0; |
@@ -611,14 +616,6 @@ static int dsa_parse_ports(struct dsa_chip_data *cd, struct dsa_switch *ds) | |||
611 | continue; | 616 | continue; |
612 | 617 | ||
613 | ds->ports[i].name = cd->port_names[i]; | 618 | ds->ports[i].name = cd->port_names[i]; |
614 | |||
615 | /* Initialize enabled_port_mask now for drv->setup() | ||
616 | * to have access to a correct value, just like what | ||
617 | * net/dsa/dsa.c::dsa_switch_setup_one does. | ||
618 | */ | ||
619 | if (!dsa_port_is_cpu(&ds->ports[i])) | ||
620 | ds->enabled_port_mask |= 1 << i; | ||
621 | |||
622 | valid_name_found = true; | 619 | valid_name_found = true; |
623 | } | 620 | } |
624 | 621 | ||