diff mbox series

[v2] asix: Use min() instead of doing it manually

Message ID 20211227113839.92352-1-jiapeng.chong@linux.alibaba.com
State New
Headers show
Series [v2] asix: Use min() instead of doing it manually | expand

Commit Message

Jiapeng Chong Dec. 27, 2021, 11:38 a.m. UTC
Eliminate following coccicheck warning:

./drivers/net/usb/asix_common.c:545:12-13: WARNING opportunity for
min().

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
Changes in v2:
  -Modified commmit message.

 drivers/net/usb/asix_common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Greg KH Dec. 27, 2021, 11:51 a.m. UTC | #1
On Mon, Dec 27, 2021 at 07:38:39PM +0800, Jiapeng Chong wrote:
> Eliminate following coccicheck warning:
> 
> ./drivers/net/usb/asix_common.c:545:12-13: WARNING opportunity for
> min().
> 
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
> ---
> Changes in v2:
>   -Modified commmit message.
> 
>  drivers/net/usb/asix_common.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/usb/asix_common.c b/drivers/net/usb/asix_common.c
> index 71682970be58..da5a7df312d2 100644
> --- a/drivers/net/usb/asix_common.c
> +++ b/drivers/net/usb/asix_common.c
> @@ -542,7 +542,7 @@ static int __asix_mdio_write(struct net_device *netdev, int phy_id, int loc,
>  out:
>  	mutex_unlock(&dev->phy_mutex);
>  
> -	return ret < 0 ? ret : 0;
> +	return min(ret, 0);

This is not a good idea, as was already pointed out.  Please fix your
tools.

thanks,

greg k-h
diff mbox series

Patch

diff --git a/drivers/net/usb/asix_common.c b/drivers/net/usb/asix_common.c
index 71682970be58..da5a7df312d2 100644
--- a/drivers/net/usb/asix_common.c
+++ b/drivers/net/usb/asix_common.c
@@ -542,7 +542,7 @@  static int __asix_mdio_write(struct net_device *netdev, int phy_id, int loc,
 out:
 	mutex_unlock(&dev->phy_mutex);
 
-	return ret < 0 ? ret : 0;
+	return min(ret, 0);
 }
 
 void asix_mdio_write(struct net_device *netdev, int phy_id, int loc, int val)