Skip to contentSkip to conversation

i2c: core: replace boolean variable by integer

PATCH In review Andy Shevchenko 3 participants 4 messages Nov 19, 2015 – Jan 26, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 i2c: core: replace boolean variable by integer

There is a warning when compiling i2c-core.c drivers/i2c/i2c-core.c:2561:36: warning: dubious: x | !y

Replace boolean exdpression by a plain bitwise AND since I2C_M_RD is a bit 0 and thus we are on the safe side.

---
Changelog v3:
- add tag
- rephrase commit message

 drivers/i2c/i2c-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/i2c-core.c +1 -1
index 040af5c..873ca1c 100644
@@ -2591,7 +2591,7 @@ static u8 i2c_smbus_pec(u8 crc, u8 *p, size_t count)
 static u8 i2c_smbus_msg_pec(u8 pec, struct i2c_msg *msg)
 {
 	/* The address will be sent first */
-	u8 addr = (msg->addr << 1) | !!(msg->flags & I2C_M_RD);
+	u8 addr = (msg->addr << 1) | (msg->flags & I2C_M_RD);
 	pec = i2c_smbus_pec(pec, &addr, 1);
 
 	/* The data buffer follows */
Signature · 1 line
2.6.2
#1 lore raw
Quoted 6 lines · Andy Shevchenko

There is a warning when compiling i2c-core.c drivers/i2c/i2c-core.c:2561:36: warning: dubious: x | !y

Replace boolean exdpression by a plain bitwise AND since I2C_M_RD is a bit 0
and thus we are on the safe side.

Wolfram, any news about this change? Last time I remember you talked about your series which makes this change obsolete.

Quoted 24 lines

---
Changelog v3:
- add tag
- rephrase commit message
 drivers/i2c/i2c-core.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/i2c-core.c +1 -1
index 040af5c..873ca1c 100644
@@ -2591,7 +2591,7 @@ static u8 i2c_smbus_pec(u8 crc, u8 *p, size_t
 count)
  static u8 i2c_smbus_msg_pec(u8 pec, struct i2c_msg *msg)
  {
  	/* The address will be sent first */
-	u8 addr = (msg->addr << 1) | !!(msg->flags & I2C_M_RD);
+	u8 addr = (msg->addr << 1) | (msg->flags & I2C_M_RD);
  	pec = i2c_smbus_pec(pec, &addr, 1);


  /* The data buffer follows */

Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
#2 lore raw
Quoted 10 lines · Andy Shevchenko
Quoted 6 lines · Andy Shevchenko

There is a warning when compiling i2c-core.c drivers/i2c/i2c-core.c:2561:36: warning: dubious: x | !y

Replace boolean exdpression by a plain bitwise AND since I2C_M_RD is a bit 0
and thus we are on the safe side.

Wolfram, any news about this change? Last time I remember you talked about your series which makes this change obsolete.

-EBUSY :/

I hope to tackle it on the train to FOSDEM later this week...

#3 lore raw
In reply to Andy Shevchenko

Hello,

Quoted 4 lines · Andy Shevchenko

There is a warning when compiling i2c-core.c drivers/i2c/i2c-core.c:2561:36: warning: dubious: x | !y

Replace boolean exdpression by a plain bitwise AND since I2C_M_RD is a bit 0

s/exdpression/expression/

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |