netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] ice: remove redundant continue statement in a for-loop
@ 2021-06-15 14:28 Colin King
  2021-06-16 23:27 ` Jacob Keller
  0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2021-06-15 14:28 UTC (permalink / raw)
  To: Jesse Brandeburg, Tony Nguyen, David S . Miller, Jakub Kicinski,
	intel-wired-lan, netdev
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The continue statement in the for-loop is redundant. Re-work the hw_lock
check to remove it.

Addresses-Coverity: ("Continue has no effect")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_ptp_hw.c b/drivers/net/ethernet/intel/ice/ice_ptp_hw.c
index 267312fad59a..3eca0e4eab0b 100644
--- a/drivers/net/ethernet/intel/ice/ice_ptp_hw.c
+++ b/drivers/net/ethernet/intel/ice/ice_ptp_hw.c
@@ -410,13 +410,11 @@ bool ice_ptp_lock(struct ice_hw *hw)
 	for (i = 0; i < MAX_TRIES; i++) {
 		hw_lock = rd32(hw, PFTSYN_SEM + (PFTSYN_SEM_BYTES * hw->pf_id));
 		hw_lock = hw_lock & PFTSYN_SEM_BUSY_M;
-		if (hw_lock) {
-			/* Somebody is holding the lock */
-			usleep_range(10000, 20000);
-			continue;
-		} else {
+		if (!hw_lock)
 			break;
-		}
+
+		/* Somebody is holding the lock */
+		usleep_range(10000, 20000);
 	}
 
 	return !hw_lock;
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH][next] ice: remove redundant continue statement in a for-loop
  2021-06-15 14:28 [PATCH][next] ice: remove redundant continue statement in a for-loop Colin King
@ 2021-06-16 23:27 ` Jacob Keller
  0 siblings, 0 replies; 2+ messages in thread
From: Jacob Keller @ 2021-06-16 23:27 UTC (permalink / raw)
  To: Colin King, Jesse Brandeburg, Tony Nguyen, David S . Miller,
	Jakub Kicinski, intel-wired-lan, netdev
  Cc: kernel-janitors, linux-kernel



On 6/15/2021 7:28 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The continue statement in the for-loop is redundant. Re-work the hw_lock
> check to remove it.
> 
> Addresses-Coverity: ("Continue has no effect")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---

Yep, that logic makes more sense.

Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>

>  drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/ice/ice_ptp_hw.c b/drivers/net/ethernet/intel/ice/ice_ptp_hw.c
> index 267312fad59a..3eca0e4eab0b 100644
> --- a/drivers/net/ethernet/intel/ice/ice_ptp_hw.c
> +++ b/drivers/net/ethernet/intel/ice/ice_ptp_hw.c
> @@ -410,13 +410,11 @@ bool ice_ptp_lock(struct ice_hw *hw)
>  	for (i = 0; i < MAX_TRIES; i++) {
>  		hw_lock = rd32(hw, PFTSYN_SEM + (PFTSYN_SEM_BYTES * hw->pf_id));
>  		hw_lock = hw_lock & PFTSYN_SEM_BUSY_M;
> -		if (hw_lock) {
> -			/* Somebody is holding the lock */
> -			usleep_range(10000, 20000);
> -			continue;
> -		} else {
> +		if (!hw_lock)
>  			break;
> -		}
> +
> +		/* Somebody is holding the lock */
> +		usleep_range(10000, 20000);
>  	}
>  
>  	return !hw_lock;
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-16 23:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-15 14:28 [PATCH][next] ice: remove redundant continue statement in a for-loop Colin King
2021-06-16 23:27 ` Jacob Keller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).