tg3:Add error handling to the function tg3_test_loopback
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
Michael Chan
Acked-byQuoted 7 lines · Nicholas Krause
This adds proper error handling for if the calls to the function
tg3_phy_lpbk_setfail by returning-EIOby assigning the return value to the variable err and if it equals anything other then zero jumps to the goto label done as no other work can be handled internally in the functiontg3_test_loopback.Signed-off-by Nicholas Krause <[email protected]>
Quoted 34 lines
--- drivers/net/ethernet/broadcom/tg3.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)drivers/net/ethernet/broadcom/tg3.c +8
-4@@ -13625,8 +13625,10 @@ static int tg3_test_loopback(struct tg3 *tp, u64 *data, bool do_extlpbk) !tg3_flag(tp, USE_PHYLIB)) {int i; -tg3_phy_lpbk_set (tp,0 , false); - + err =tg3_phy_lpbk_set (tp,0 , false); +if (err) + goto done; +/* Wait for link */ for (i =0 ; i <100 ; i++) {if (tr32 (MAC_TX_STATUS ) &TX_STATUS_LINK_UP )@@ -13644,8 +13646,10 @@ static int tg3_test_loopback(struct tg3 *tp, u64 *data, bool do_extlpbk) data[TG3_PHY_LOOPB_TEST ] |=TG3_JMB_LOOPBACK_FAILED ;if (do_extlpbk) { -tg3_phy_lpbk_set (tp,0 , true); - + err =tg3_phy_lpbk_set (tp,0 , true); + +if (err) + goto done;/* All link indications report up, but the hardware * isn't really ready for about 20 msec. Double it * to be sure.
Quoted 10 lines · Michael Chan
Quoted 7 lines · Nicholas Krause
This adds proper error handling for if the calls to the function
tg3_phy_lpbk_setfail by returning-EIOby assigning the return value to the variable err and if it equals anything other then zero jumps to the goto label done as no other work can be handled internally in the functiontg3_test_loopback.Signed-off-by Nicholas Krause <[email protected]>Acked-by Michael Chan <[email protected]>
Your indentation doesn't look right. Other than that, it is ok.
Quoted 36 lines
Quoted 35 lines
--- drivers/net/ethernet/broadcom/tg3.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)drivers/net/ethernet/broadcom/tg3.c +8
-4@@ -13625,8 +13625,10 @@ static int tg3_test_loopback(struct tg3 *tp, u64 *data, bool do_extlpbk) !tg3_flag(tp, USE_PHYLIB)) {int i; -tg3_phy_lpbk_set (tp,0 , false); - + err =tg3_phy_lpbk_set (tp,0 , false); +if (err) + goto done; +/* Wait for link */ for (i =0 ; i <100 ; i++) {if (tr32 (MAC_TX_STATUS ) &TX_STATUS_LINK_UP )@@ -13644,8 +13646,10 @@ static int tg3_test_loopback(struct tg3 *tp, u64 *data, bool do_extlpbk) data[TG3_PHY_LOOPB_TEST ] |=TG3_JMB_LOOPBACK_FAILED ;if (do_extlpbk) { -tg3_phy_lpbk_set (tp,0 , true); - + err =tg3_phy_lpbk_set (tp,0 , true); + +if (err) + goto done;/* All link indications report up, but the hardware * isn't really ready for about 20 msec. Double it * to be sure.