diff mbox series

i2c: mux: pca9541: replace ternary operator with min()

Message ID 20220512132511.40637-1-guozhengkui@vivo.com
State Needs Review / ACK
Delegated to: Peter Rosin
Headers show
Series i2c: mux: pca9541: replace ternary operator with min() | expand

Commit Message

Guo Zhengkui May 12, 2022, 1:25 p.m. UTC
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 mbox series

Patch

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);