Skip to contentSkip to conversation

ice: remove redundant checks from PTP init

PATCH In review Natalia Wochtman 3 participants 3 messages Feb 25 – Apr 1

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

PATCH 1/1 ice: remove redundant checks from PTP init

Remove unnecessary condition checks in
ice_ptp_setup_adapter() and ice_ptp_init().
They are duplicated in ice_pf_src_tmr_owned().

Change ice_ptp_setup_adapter() to return void.

---
 drivers/net/ethernet/intel/ice/ice_ptp.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/net/ethernet/intel/ice/ice_ptp.c +4 -10
index d8fd01fa617b..2b26024de888 100644
@@ -3065,14 +3065,9 @@ void ice_ptp_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type)
 	dev_err(ice_pf_to_dev(pf), "PTP reset failed %d\n", err);
 }
 
-static int ice_ptp_setup_adapter(struct ice_pf *pf)
+static void ice_ptp_setup_adapter(struct ice_pf *pf)
 {
-	if (!ice_pf_src_tmr_owned(pf) || !ice_is_primary(&pf->hw))
-		return -EPERM;
-
 	pf->adapter->ctrl_pf = pf;
-
-	return 0;
 }
 
 static int ice_ptp_setup_pf(struct ice_pf *pf)
@@ -3315,10 +3310,9 @@ void ice_ptp_init(struct ice_pf *pf)
 	/* If this function owns the clock hardware, it must allocate and
 	 * configure the PTP clock device to represent it.
 	 */
-	if (ice_pf_src_tmr_owned(pf) && ice_is_primary(hw)) {
-		err = ice_ptp_setup_adapter(pf);
-		if (err)
-			goto err_exit;
+	if (ice_pf_src_tmr_owned(pf)) {
+		ice_ptp_setup_adapter(pf);
+
 		err = ice_ptp_init_owner(pf);
 		if (err)
 			goto err_exit;
Signature · 1 line
2.49.0
#1 lore raw

Dear Natalia,

Thank you for the patch.

Am 25.02.26 um 10:02 schrieb Natalia Wochtman:

Quoted 3 lines

Remove unnecessary condition checks in
ice_ptp_setup_adapter() and ice_ptp_init().
They are duplicated in ice_pf_src_tmr_owned().

Using 75 characters per line, the above would fit in two lines.

Quoted 30 lines

Change ice_ptp_setup_adapter() to return void.

---
  drivers/net/ethernet/intel/ice/ice_ptp.c | 14 ++++----------
  1 file changed, 4 insertions(+), 10 deletions(-)
drivers/net/ethernet/intel/ice/ice_ptp.c +1 -6
index d8fd01fa617b..2b26024de888 100644
@@ -3065,14 +3065,9 @@ void ice_ptp_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type)
  	dev_err(ice_pf_to_dev(pf), "PTP reset failed %d\n", err);
  }
 
-static int ice_ptp_setup_adapter(struct ice_pf *pf)
+static void ice_ptp_setup_adapter(struct ice_pf *pf)
  {
-	if (!ice_pf_src_tmr_owned(pf) || !ice_is_primary(&pf->hw))
-		return -EPERM;
-
  	pf->adapter->ctrl_pf = pf;
-
-	return 0;
  }
 
  static int ice_ptp_setup_pf(struct ice_pf *pf)

drivers/net/ethernet/intel/ice/ice_ptp.c void ice_ptp_init(struct ice_pf *pf) · line 3314

Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +2 -4
@@ -3315,10 +3310,9 @@ void ice_ptp_init(struct ice_pf *pf)
  	/* If this function owns the clock hardware, it must allocate and
  	 * configure the PTP clock device to represent it.
  	 */
-	if (ice_pf_src_tmr_owned(pf) && ice_is_primary(hw)) {
-		err = ice_ptp_setup_adapter(pf);
-		if (err)
-			goto err_exit;
+	if (ice_pf_src_tmr_owned(pf)) {
+		ice_ptp_setup_adapter(pf);

As the checks were duplicated, this branch was never taken, and therefore err was never set? Is that your argument?

Did the compiler notice this redundancy, and is different code generated now?

drivers/net/ethernet/intel/ice/ice_ptp.c void ice_ptp_init(struct ice_pf *pf) · line 3318

Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +1 -0
+
  		err = ice_ptp_init_owner(pf);
  		if (err)
  			goto err_exit;

Kind regards,

Paul

Tested-by on v1 1/1
#2 lore raw
In reply to Natalia Wochtman
Quoted 11 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Natalia Wochtman
Sent: 25 February 2026 14:33
To: [email protected]
Cc: Loktionov, Aleksandr <[email protected]>; [email protected]; Wochtman, Natalia <[email protected]>; Kitszel, Przemyslaw <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-next v1] ice: remove redundant checks from PTP init

Remove unnecessary condition checks in
ice_ptp_setup_adapter() and ice_ptp_init().
They are duplicated in ice_pf_src_tmr_owned().

Quoted 9 lines

Change ice_ptp_setup_adapter() to return void.

---
drivers/net/ethernet/intel/ice/ice_ptp.c | 14 ++++----------

1 file changed, 4 insertions(+), 10 deletions(-)