diff options
author | Vivien Didelot <vivien.didelot@savoirfairelinux.com> | 2017-01-27 15:29:37 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-01-29 18:42:46 -0500 |
commit | 26895e299cfb583d304553e9c259e694a7e83397 (patch) | |
tree | 84efe62291aa646b75bb4778db06644e2062fb74 /net/dsa/dsa2.c | |
parent | a0c02161ecfc2f40a0837926efac5376bc6fd6d3 (diff) |
net: dsa: use ds->num_ports when possible
The dsa_switch structure contains the number of ports. Use it where the
structure is valid instead of the DSA_MAX_PORTS value.
Signed-off-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 | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index 4b3a44bec5c8..6e7b3e88b778 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c | |||
@@ -98,7 +98,7 @@ static bool dsa_ds_find_port_dn(struct dsa_switch *ds, | |||
98 | { | 98 | { |
99 | u32 index; | 99 | u32 index; |
100 | 100 | ||
101 | for (index = 0; index < DSA_MAX_PORTS; index++) | 101 | for (index = 0; index < ds->num_ports; index++) |
102 | if (ds->ports[index].dn == port) | 102 | if (ds->ports[index].dn == port) |
103 | return true; | 103 | return true; |
104 | return false; | 104 | return false; |
@@ -159,7 +159,7 @@ static int dsa_ds_complete(struct dsa_switch_tree *dst, struct dsa_switch *ds) | |||
159 | u32 index; | 159 | u32 index; |
160 | int err; | 160 | int err; |
161 | 161 | ||
162 | for (index = 0; index < DSA_MAX_PORTS; index++) { | 162 | for (index = 0; index < ds->num_ports; index++) { |
163 | port = &ds->ports[index]; | 163 | port = &ds->ports[index]; |
164 | if (!dsa_port_is_valid(port)) | 164 | if (!dsa_port_is_valid(port)) |
165 | continue; | 165 | continue; |
@@ -312,7 +312,7 @@ static int dsa_ds_apply(struct dsa_switch_tree *dst, struct dsa_switch *ds) | |||
312 | return err; | 312 | return err; |
313 | } | 313 | } |
314 | 314 | ||
315 | for (index = 0; index < DSA_MAX_PORTS; index++) { | 315 | for (index = 0; index < ds->num_ports; index++) { |
316 | port = &ds->ports[index]; | 316 | port = &ds->ports[index]; |
317 | if (!dsa_port_is_valid(port)) | 317 | if (!dsa_port_is_valid(port)) |
318 | continue; | 318 | continue; |
@@ -344,7 +344,7 @@ static void dsa_ds_unapply(struct dsa_switch_tree *dst, struct dsa_switch *ds) | |||
344 | struct dsa_port *port; | 344 | struct dsa_port *port; |
345 | u32 index; | 345 | u32 index; |
346 | 346 | ||
347 | for (index = 0; index < DSA_MAX_PORTS; index++) { | 347 | for (index = 0; index < ds->num_ports; index++) { |
348 | port = &ds->ports[index]; | 348 | port = &ds->ports[index]; |
349 | if (!dsa_port_is_valid(port)) | 349 | if (!dsa_port_is_valid(port)) |
350 | continue; | 350 | continue; |
@@ -475,7 +475,7 @@ static int dsa_ds_parse(struct dsa_switch_tree *dst, struct dsa_switch *ds) | |||
475 | u32 index; | 475 | u32 index; |
476 | int err; | 476 | int err; |
477 | 477 | ||
478 | for (index = 0; index < DSA_MAX_PORTS; index++) { | 478 | for (index = 0; index < ds->num_ports; index++) { |
479 | port = &ds->ports[index]; | 479 | port = &ds->ports[index]; |
480 | if (!dsa_port_is_valid(port)) | 480 | if (!dsa_port_is_valid(port)) |
481 | continue; | 481 | continue; |
@@ -529,7 +529,7 @@ static int dsa_parse_ports_dn(struct device_node *ports, struct dsa_switch *ds) | |||
529 | if (err) | 529 | if (err) |
530 | return err; | 530 | return err; |
531 | 531 | ||
532 | if (reg >= DSA_MAX_PORTS) | 532 | if (reg >= ds->num_ports) |
533 | return -EINVAL; | 533 | return -EINVAL; |
534 | 534 | ||
535 | ds->ports[reg].dn = port; | 535 | ds->ports[reg].dn = port; |