All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH -next] net: phy: micrel: use min() macro instead of doing it manually
@ 2021-12-24  9:12 Yang Li
  2021-12-24  9:30 ` Heiner Kallweit
  0 siblings, 1 reply; 2+ messages in thread
From: Yang Li @ 2021-12-24  9:12 UTC (permalink / raw)
  To: davem
  Cc: kuba, andrew, hkallweit1, linux, netdev, linux-kernel, Yang Li,
	Abaci Robot

Fix following coccicheck warning:
./drivers/net/phy/micrel.c:1482:12-13: WARNING opportunity for min()

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
---
 drivers/net/phy/micrel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index c6a97fcca0e6..dda426596445 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -1479,7 +1479,7 @@ static int ksz886x_cable_test_wait_for_completion(struct phy_device *phydev)
 				    !(val & KSZ8081_LMD_ENABLE_TEST),
 				    30000, 100000, true);
 
-	return ret < 0 ? ret : 0;
+	return min(ret, 0);
 }
 
 static int ksz886x_cable_test_one_pair(struct phy_device *phydev, int pair)
-- 
2.20.1.7.g153144c


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

* Re: [PATCH -next] net: phy: micrel: use min() macro instead of doing it manually
  2021-12-24  9:12 [PATCH -next] net: phy: micrel: use min() macro instead of doing it manually Yang Li
@ 2021-12-24  9:30 ` Heiner Kallweit
  0 siblings, 0 replies; 2+ messages in thread
From: Heiner Kallweit @ 2021-12-24  9:30 UTC (permalink / raw)
  To: Yang Li, davem; +Cc: kuba, andrew, linux, netdev, linux-kernel, Abaci Robot

On 24.12.2021 10:12, Yang Li wrote:
> Fix following coccicheck warning:
> ./drivers/net/phy/micrel.c:1482:12-13: WARNING opportunity for min()
> 
Please always check whether a coccicheck warning makes sense,
and don't create "fixes" mechanically w/o thinking.
Here using min() doesn't make sense because it's not about a
numerical operation. ret < 0 is equivalent to is_err(ret).


> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
> ---
>  drivers/net/phy/micrel.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
> index c6a97fcca0e6..dda426596445 100644
> --- a/drivers/net/phy/micrel.c
> +++ b/drivers/net/phy/micrel.c
> @@ -1479,7 +1479,7 @@ static int ksz886x_cable_test_wait_for_completion(struct phy_device *phydev)
>  				    !(val & KSZ8081_LMD_ENABLE_TEST),
>  				    30000, 100000, true);
>  
> -	return ret < 0 ? ret : 0;
> +	return min(ret, 0);
>  }
>  
>  static int ksz886x_cable_test_one_pair(struct phy_device *phydev, int pair)


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

end of thread, other threads:[~2021-12-24  9:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-24  9:12 [PATCH -next] net: phy: micrel: use min() macro instead of doing it manually Yang Li
2021-12-24  9:30 ` Heiner Kallweit

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.