[PATCH] i2c: mux: pca9541: replace ternary operator with min()

Guo Zhengkui posted 1 patch 4 years ago
drivers/i2c/muxes/i2c-mux-pca9541.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] i2c: mux: pca9541: replace ternary operator with min()
Posted by Guo Zhengkui 4 years ago
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