@@ -2587,8 +2587,8 @@ static int ksz_irq_phy_setup(struct ksz_device *dev)
25872587
25882588 irq = irq_find_mapping (dev -> ports [port ].pirq .domain ,
25892589 PORT_SRC_PHY_INT );
2590- if (irq < 0 ) {
2591- ret = irq ;
2590+ if (! irq ) {
2591+ ret = - EINVAL ;
25922592 goto out ;
25932593 }
25942594 ds -> user_mii_bus -> irq [phy ] = irq ;
@@ -2952,8 +2952,8 @@ static int ksz_pirq_setup(struct ksz_device *dev, u8 p)
29522952 snprintf (pirq -> name , sizeof (pirq -> name ), "port_irq-%d" , p );
29532953
29542954 pirq -> irq_num = irq_find_mapping (dev -> girq .domain , p );
2955- if (pirq -> irq_num < 0 )
2956- return pirq -> irq_num ;
2955+ if (! pirq -> irq_num )
2956+ return - EINVAL ;
29572957
29582958 return ksz_irq_common_setup (dev , pirq );
29592959}
@@ -3038,12 +3038,12 @@ static int ksz_setup(struct dsa_switch *ds)
30383038 dsa_switch_for_each_user_port (dp , dev -> ds ) {
30393039 ret = ksz_pirq_setup (dev , dp -> index );
30403040 if (ret )
3041- goto out_girq ;
3041+ goto port_release ;
30423042
30433043 if (dev -> info -> ptp_capable ) {
30443044 ret = ksz_ptp_irq_setup (ds , dp -> index );
30453045 if (ret )
3046- goto out_pirq ;
3046+ goto pirq_release ;
30473047 }
30483048 }
30493049 }
@@ -3053,7 +3053,7 @@ static int ksz_setup(struct dsa_switch *ds)
30533053 if (ret ) {
30543054 dev_err (dev -> dev , "Failed to register PTP clock: %d\n" ,
30553055 ret );
3056- goto out_ptpirq ;
3056+ goto port_release ;
30573057 }
30583058 }
30593059
@@ -3076,17 +3076,16 @@ static int ksz_setup(struct dsa_switch *ds)
30763076out_ptp_clock_unregister :
30773077 if (dev -> info -> ptp_capable )
30783078 ksz_ptp_clock_unregister (ds );
3079- out_ptpirq :
3080- if (dev -> irq > 0 && dev -> info -> ptp_capable )
3081- dsa_switch_for_each_user_port (dp , dev -> ds )
3082- ksz_ptp_irq_free (ds , dp -> index );
3083- out_pirq :
3084- if (dev -> irq > 0 )
3085- dsa_switch_for_each_user_port (dp , dev -> ds )
3079+ port_release :
3080+ if (dev -> irq > 0 ) {
3081+ dsa_switch_for_each_user_port_continue_reverse (dp , dev -> ds ) {
3082+ if (dev -> info -> ptp_capable )
3083+ ksz_ptp_irq_free (ds , dp -> index );
3084+ pirq_release :
30863085 ksz_irq_free (& dev -> ports [dp -> index ].pirq );
3087- out_girq :
3088- if (dev -> irq > 0 )
3086+ }
30893087 ksz_irq_free (& dev -> girq );
3088+ }
30903089
30913090 return ret ;
30923091}
0 commit comments