lkml.org 
[lkml]   [2022]   [May]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] i2c: mux: pca9541: replace ternary operator with min()
Date
Fix the following coccicheck warning:

drivers/i2c/muxes/i2c-mux-pca9541.c:263:14-15: WARNING opportunity
for min()

min() macro is defined in include/linux/minmax.h. It avoids multiple
evaluations of the arguments when non-constant and performs strict
type-checking.

Signed-off-by: Guo Zhengkui <guozhengkui@vivo.com>
---
drivers/i2c/muxes/i2c-mux-pca9541.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/muxes/i2c-mux-pca9541.c b/drivers/i2c/muxes/i2c-mux-pca9541.c
index 6daec8d3d331..f374a1e85837 100644
--- a/drivers/i2c/muxes/i2c-mux-pca9541.c
+++ b/drivers/i2c/muxes/i2c-mux-pca9541.c
@@ -260,7 +260,7 @@ static int pca9541_select_chan(struct i2c_mux_core *muxc, u32 chan)
do {
ret = pca9541_arbitrate(client);
if (ret)
- return ret < 0 ? ret : 0;
+ return min(ret, 0);

if (data->select_timeout == SELECT_DELAY_SHORT)
udelay(data->select_timeout);
--
2.20.1
\
 
 \ /
  Last update: 2022-05-12 15:27    [W:0.835 / U:0.352 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site