@@ -362,7 +362,7 @@ static void dsa_user_port_unapply(struct dsa_port *port)
362362 }
363363}
364364
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 )
366366{
367367 struct dsa_port * port ;
368368 u32 index ;
@@ -433,7 +433,7 @@ static int dsa_ds_apply(struct dsa_switch_tree *dst, struct dsa_switch *ds)
433433 return 0 ;
434434}
435435
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 )
437437{
438438 struct dsa_port * port ;
439439 u32 index ;
@@ -469,6 +469,39 @@ static void dsa_ds_unapply(struct dsa_switch_tree *dst, struct dsa_switch *ds)
469469
470470}
471471
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+
472505static int dsa_tree_setup_master (struct dsa_switch_tree * dst )
473506{
474507 struct dsa_port * cpu_dp = dst -> cpu_dp ;
@@ -488,8 +521,6 @@ static void dsa_tree_teardown_master(struct dsa_switch_tree *dst)
488521
489522static int dsa_tree_setup (struct dsa_switch_tree * dst )
490523{
491- struct dsa_switch * ds ;
492- u32 index ;
493524 int err ;
494525
495526 if (dst -> setup ) {
@@ -502,15 +533,9 @@ static int dsa_tree_setup(struct dsa_switch_tree *dst)
502533 if (err )
503534 return err ;
504535
505- for (index = 0 ; index < DSA_MAX_SWITCHES ; index ++ ) {
506- ds = dst -> ds [index ];
507- if (!ds )
508- continue ;
509-
510- err = dsa_ds_apply (dst , ds );
511- if (err )
512- return err ;
513- }
536+ err = dsa_tree_setup_switches (dst );
537+ if (err )
538+ return err ;
514539
515540 err = dsa_tree_setup_master (dst );
516541 if (err )
@@ -525,21 +550,12 @@ static int dsa_tree_setup(struct dsa_switch_tree *dst)
525550
526551static void dsa_tree_teardown (struct dsa_switch_tree * dst )
527552{
528- struct dsa_switch * ds ;
529- u32 index ;
530-
531553 if (!dst -> setup )
532554 return ;
533555
534556 dsa_tree_teardown_master (dst );
535557
536- for (index = 0 ; index < DSA_MAX_SWITCHES ; index ++ ) {
537- ds = dst -> ds [index ];
538- if (!ds )
539- continue ;
540-
541- dsa_ds_unapply (dst , ds );
542- }
558+ dsa_tree_teardown_switches (dst );
543559
544560 dsa_tree_teardown_default_cpu (dst );
545561
0 commit comments