diff options
author | Vivien Didelot <vivien.didelot@savoirfairelinux.com> | 2017-11-06 16:11:47 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-11-08 19:26:49 -0500 |
commit | 1f08f9e9cbc63d92c246f40ae4221cba86ef8ec6 (patch) | |
tree | 566ea8fb4a0c055d3522fa979215d7fb84b5308f /net/dsa | |
parent | ec15dd4269d0cbf947c9a2dfdcf08a917098fab1 (diff) |
net: dsa: setup and teardown switches
This patches brings no functional changes. It removes the unused dst
argument from the dsa_ds_apply and dsa_ds_unapply functions, rename them
to dsa_switch_setup and dsa_switch_teardown for a more explicit scope.
This clarifies the steps of the setup or teardown of a switch fabric.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dsa')
-rw-r--r-- | net/dsa/dsa2.c | 62 |
1 files changed, 39 insertions, 23 deletions
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index 1a8df0a177b5..2b3b2a86791d 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c | |||
@@ -362,7 +362,7 @@ static void dsa_user_port_unapply(struct dsa_port *port) | |||
362 | } | 362 | } |
363 | } | 363 | } |
364 | 364 | ||
365 | static int dsa_ds_apply(struct dsa_switch_tree *dst, struct dsa_switch *ds) | 365 | static int dsa_switch_setup(struct dsa_switch *ds) |
366 | { | 366 | { |
367 | struct dsa_port *port; | 367 | struct dsa_port *port; |
368 | u32 index; | 368 | u32 index; |
@@ -433,7 +433,7 @@ static int dsa_ds_apply(struct dsa_switch_tree *dst, struct dsa_switch *ds) | |||
433 | return 0; | 433 | return 0; |
434 | } | 434 | } |
435 | 435 | ||
436 | static void dsa_ds_unapply(struct dsa_switch_tree *dst, struct dsa_switch *ds) | 436 | static void dsa_switch_teardown(struct dsa_switch *ds) |
437 | { | 437 | { |
438 | struct dsa_port *port; | 438 | struct dsa_port *port; |
439 | u32 index; | 439 | u32 index; |
@@ -469,6 +469,39 @@ static void dsa_ds_unapply(struct dsa_switch_tree *dst, struct dsa_switch *ds) | |||
469 | 469 | ||
470 | } | 470 | } |
471 | 471 | ||
472 | static int dsa_tree_setup_switches(struct dsa_switch_tree *dst) | ||
473 | { | ||
474 | struct dsa_switch *ds; | ||
475 | int device; | ||
476 | int err; | ||
477 | |||
478 | for (device = 0; device < DSA_MAX_SWITCHES; device++) { | ||
479 | ds = dst->ds[device]; | ||
480 | if (!ds) | ||
481 | continue; | ||
482 | |||
483 | err = dsa_switch_setup(ds); | ||
484 | if (err) | ||
485 | return err; | ||
486 | } | ||
487 | |||
488 | return 0; | ||
489 | } | ||
490 | |||
491 | static void dsa_tree_teardown_switches(struct dsa_switch_tree *dst) | ||
492 | { | ||
493 | struct dsa_switch *ds; | ||
494 | int device; | ||
495 | |||
496 | for (device = 0; device < DSA_MAX_SWITCHES; device++) { | ||
497 | ds = dst->ds[device]; | ||
498 | if (!ds) | ||
499 | continue; | ||
500 | |||
501 | dsa_switch_teardown(ds); | ||
502 | } | ||
503 | } | ||
504 | |||
472 | static int dsa_tree_setup_master(struct dsa_switch_tree *dst) | 505 | static int dsa_tree_setup_master(struct dsa_switch_tree *dst) |
473 | { | 506 | { |
474 | struct dsa_port *cpu_dp = dst->cpu_dp; | 507 | struct dsa_port *cpu_dp = dst->cpu_dp; |
@@ -488,8 +521,6 @@ static void dsa_tree_teardown_master(struct dsa_switch_tree *dst) | |||
488 | 521 | ||
489 | static int dsa_tree_setup(struct dsa_switch_tree *dst) | 522 | static int dsa_tree_setup(struct dsa_switch_tree *dst) |
490 | { | 523 | { |
491 | struct dsa_switch *ds; | ||
492 | u32 index; | ||
493 | int err; | 524 | int err; |
494 | 525 | ||
495 | if (dst->setup) { | 526 | if (dst->setup) { |
@@ -502,15 +533,9 @@ static int dsa_tree_setup(struct dsa_switch_tree *dst) | |||
502 | if (err) | 533 | if (err) |
503 | return err; | 534 | return err; |
504 | 535 | ||
505 | for (index = 0; index < DSA_MAX_SWITCHES; index++) { | 536 | err = dsa_tree_setup_switches(dst); |
506 | ds = dst->ds[index]; | 537 | if (err) |
507 | if (!ds) | 538 | return err; |
508 | continue; | ||
509 | |||
510 | err = dsa_ds_apply(dst, ds); | ||
511 | if (err) | ||
512 | return err; | ||
513 | } | ||
514 | 539 | ||
515 | err = dsa_tree_setup_master(dst); | 540 | err = dsa_tree_setup_master(dst); |
516 | if (err) | 541 | if (err) |
@@ -525,21 +550,12 @@ static int dsa_tree_setup(struct dsa_switch_tree *dst) | |||
525 | 550 | ||
526 | static void dsa_tree_teardown(struct dsa_switch_tree *dst) | 551 | static void dsa_tree_teardown(struct dsa_switch_tree *dst) |
527 | { | 552 | { |
528 | struct dsa_switch *ds; | ||
529 | u32 index; | ||
530 | |||
531 | if (!dst->setup) | 553 | if (!dst->setup) |
532 | return; | 554 | return; |
533 | 555 | ||
534 | dsa_tree_teardown_master(dst); | 556 | dsa_tree_teardown_master(dst); |
535 | 557 | ||
536 | for (index = 0; index < DSA_MAX_SWITCHES; index++) { | 558 | dsa_tree_teardown_switches(dst); |
537 | ds = dst->ds[index]; | ||
538 | if (!ds) | ||
539 | continue; | ||
540 | |||
541 | dsa_ds_unapply(dst, ds); | ||
542 | } | ||
543 | 559 | ||
544 | dsa_tree_teardown_default_cpu(dst); | 560 | dsa_tree_teardown_default_cpu(dst); |
545 | 561 | ||