i2c: remove redundant condition
authorHsin-Yu.Chen <harry021633@gmail.com>
Wed, 6 Mar 2024 04:19:00 +0000 (12:19 +0800)
committerWolfram Sang <wsa+renesas@sang-engineering.com>
Thu, 7 Mar 2024 08:36:08 +0000 (09:36 +0100)
I2C_M_RD is defined as and guaranteed to be 1 and 'flag & I2C_M_RD' is
one or zero. No need for an additional condition to obtain the value.

Signed-off-by: Hsin-Yu.Chen <harry021633@gmail.com>
Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
[wsa: slightly updated commit message]
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
include/linux/i2c.h

index ff93ff8b257cea6a029d178c5d49e7ad3d93a2c4..5e6cd43a6dbdd9fcd29e30d59492c736a149e25a 100644 (file)
@@ -931,7 +931,7 @@ static inline int i2c_adapter_id(struct i2c_adapter *adap)
 
 static inline u8 i2c_8bit_addr_from_msg(const struct i2c_msg *msg)
 {
-       return (msg->addr << 1) | (msg->flags & I2C_M_RD ? 1 : 0);
+       return (msg->addr << 1) | (msg->flags & I2C_M_RD);
 }
 
 u8 *i2c_get_dma_safe_msg_buf(struct i2c_msg *msg, unsigned int threshold);