Skip to contentSkip to conversation

ice: Use common error handling code in two functions

PATCH In review Markus Elfring 5 participants 6 messages Sep 19, 2024 – Oct 4, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ice: Use common error handling code in two functions

From: Markus Elfring <[email protected]>
Date: Thu, 19 Sep 2024 19:00:25 +0200

Add jump targets so that a bit of exception handling can be better reused at the end of two function implementations.

This issue was detected by using the Coccinelle software.

---
 drivers/net/ethernet/intel/ice/ice_ptp.c | 32 ++++++++++++------------
 1 file changed, 16 insertions(+), 16 deletions(-)
drivers/net/ethernet/intel/ice/ice_ptp.c +16 -16
index ef2e858f49bb..c445ae80094b 100644
@@ -2813,10 +2813,8 @@ static int ice_ptp_rebuild_owner(struct ice_pf *pf)
 
 	/* Write the increment time value to PHY and LAN */
 	err = ice_ptp_write_incval(hw, ice_base_incval(pf));
-	if (err) {
-		ice_ptp_unlock(hw);
-		return err;
-	}
+	if (err)
+		goto err_unlock;
 
 	/* Write the initial Time value to PHY and LAN using the cached PHC
 	 * time before the reset and time difference between stopping and
@@ -2829,10 +2827,8 @@ static int ice_ptp_rebuild_owner(struct ice_pf *pf)
 		ts = ktime_to_timespec64(ktime_get_real());
 	}
 	err = ice_ptp_write_init(pf, &ts);
-	if (err) {
-		ice_ptp_unlock(hw);
-		return err;
-	}
+	if (err)
+		goto err_unlock;
 
 	/* Release the global hardware lock */
 	ice_ptp_unlock(hw);
@@ -2856,6 +2852,10 @@ static int ice_ptp_rebuild_owner(struct ice_pf *pf)
 	ice_ptp_enable_all_extts(pf);
 
 	return 0;
+
+err_unlock:
+	ice_ptp_unlock(hw);
+	return err;
 }
 
 /**
@@ -3129,18 +3129,14 @@ static int ice_ptp_init_owner(struct ice_pf *pf)
 
 	/* Write the increment time value to PHY and LAN */
 	err = ice_ptp_write_incval(hw, ice_base_incval(pf));
-	if (err) {
-		ice_ptp_unlock(hw);
-		goto err_exit;
-	}
+	if (err)
+		goto err_unlock;
 
 	ts = ktime_to_timespec64(ktime_get_real());
 	/* Write the initial Time value to PHY and LAN */
 	err = ice_ptp_write_init(pf, &ts);
-	if (err) {
-		ice_ptp_unlock(hw);
-		goto err_exit;
-	}
+	if (err)
+		goto err_unlock;
 
 	/* Release the global hardware lock */
 	ice_ptp_unlock(hw);
@@ -3168,6 +3164,10 @@ static int ice_ptp_init_owner(struct ice_pf *pf)
 	pf->ptp.clock = NULL;
 err_exit:
 	return err;
+
+err_unlock:
+	ice_ptp_unlock(hw);
+	return err;
 }
 
 /**

--
2.46.0

Reviewed-by on v1 1/1
#1 lore raw
Quoted 17 lines

-----Original Message-----
From: Markus Elfring <[email protected]>
Sent: Thursday, September 19, 2024 10:15 AM
To: [email protected]; [email protected]; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Keller, Jacob E <[email protected]>; Jakub Kicinski <[email protected]>; Kolacinski, Karol <[email protected]>; Paolo Abeni <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Richard Cochran <[email protected]>; Nguyen, Anthony L <[email protected]>
Cc: LKML <[email protected]>
Subject: [PATCH] ice: Use common error handling code in two functions

From: Markus Elfring <[email protected]>
Date: Thu, 19 Sep 2024 19:00:25 +0200

Quoted 7 lines

Add jump targets so that a bit of exception handling can be better reused at the end of two function implementations.

This issue was detected by using the Coccinelle software.

---

Seems fine.

maintainer
#2 lore raw
In reply to Markus Elfring
Quoted 5 lines · Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 19 Sep 2024 19:00:25 +0200

Add jump targets so that a bit of exception handling can be better reused at the end of two function implementations.

Thank you for contribution, the change is fine, but not as a bugfix. Please send as a [iwl-next], when the submission window opens.

Quoted 7 lines

This issue was detected by using the Coccinelle software.

drivers/net/ethernet/intel/ice/ice_ptp.c static int ice_ptp_init_owner(struct ice_pf *pf) · line 3171

Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +4 -0
@@ -3168,6 +3164,10 @@ static int ice_ptp_init_owner(struct ice_pf *pf)
  	pf->ptp.clock = NULL;
  err_exit:
  	return err;
+
+err_unlock:
+	ice_ptp_unlock(hw);
+	return err;
  }

You kept the current label naming scheme, that's good.

#3 lore raw
Quoted 4 lines
Quoted 2 lines

Add jump targets so that a bit of exception handling can be better reused at the end of two function implementations.

Thank you for contribution, the change is fine,

Thanks for this positive feedback.

Quoted 1 line

but not as a bugfix.

Would you like to qualify my update suggestion as a correction for a coding style issue?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?h=v6.11#n526

Quoted 1 line

Please send as a [iwl-next], when the submission window opens.

Will a patch resend really be needed for the proposed adjustment?

Regards,
Markus

maintainer
#4 lore raw
Quoted 5 lines · Markus Elfring
Quoted 4 lines
Quoted 2 lines

Add jump targets so that a bit of exception handling can be better reused at the end of two function implementations.

Thank you for contribution, the change is fine,

Quoted 8 lines

Thanks for this positive feedback.

Quoted 1 line

but not as a bugfix.

Would you like to qualify my update suggestion as a correction for a coding style issue?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?h=v6.11#n526

It can go to -next to correct the coding style, however, for -net it should be user visible bugs.

Quoted 3 lines
Quoted 1 line

Please send as a [iwl-next], when the submission window opens.

Will a patch resend really be needed for the proposed adjustment?

I'll go ahead and apply this to iwl-next without a re-send, but please keep Przemek's comments in mind for future submissions.

Thanks,
Tony

Tested-by on v1 1/1
#5 lore raw
In reply to Markus Elfring
Quoted 10 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Markus Elfring
Sent: Thursday, September 19, 2024 10:45 PM
To: [email protected]; [email protected]; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Keller, Jacob E <[email protected]>; Jakub Kicinski <[email protected]>; Kolacinski, Karol <[email protected]>; Paolo Abeni <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Richard Cochran <[email protected]>; Nguyen, Anthony L <[email protected]>
Cc: LKML <[email protected]>
Subject: [Intel-wired-lan] [PATCH] ice: Use common error handling code in two functions

From: Markus Elfring <[email protected]>
Date: Thu, 19 Sep 2024 19:00:25 +0200

Quoted 9 lines

Add jump targets so that a bit of exception handling can be better reused at the end of two function implementations.

This issue was detected by using the Coccinelle software.

---
 drivers/net/ethernet/intel/ice/ice_ptp.c | 32 ++++++++++++------------
 1 file changed, 16 insertions(+), 16 deletions(-)