[PATCH] i2c/highlander: remover superflous variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When cppcheck found this flaw

[./i2c/busses/i2c-highlander.c:284]: (style) Warning - using char variable in bit operation

it was noted that the 'read'-variable could just be removed as read_write can
only be 0 or 1 anyhow. So, we remove the flaw by simplifying the code.

Reported-by: d binderman <dcb314@xxxxxxxxxxx>
Signed-off-by: Wolfram Sang <w.sang@xxxxxxxxxxxxxx>
Cc: Paul Mundt <lethal@xxxxxxxxxxxx>
Cc: Jean Delvare <khali@xxxxxxxxxxxx>
Cc: Ben Dooks <ben-linux@xxxxxxxxx>
---

There was no patch following the original report, so I picked it up. Not
tested, due to no hardware.

Jean, I put you on CC as you commented on the original mail, although it is
more an embedded driver.

 drivers/i2c/busses/i2c-highlander.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-highlander.c b/drivers/i2c/busses/i2c-highlander.c
index 87ecace..db290b9 100644
--- a/drivers/i2c/busses/i2c-highlander.c
+++ b/drivers/i2c/busses/i2c-highlander.c
@@ -281,7 +281,6 @@ static int highlander_i2c_smbus_xfer(struct i2c_adapter *adap, u16 addr,
 				  union i2c_smbus_data *data)
 {
 	struct highlander_i2c_dev *dev = i2c_get_adapdata(adap);
-	int read = read_write & I2C_SMBUS_READ;
 	u16 tmp;
 
 	init_completion(&dev->cmd_complete);
@@ -336,11 +335,11 @@ static int highlander_i2c_smbus_xfer(struct i2c_adapter *adap, u16 addr,
 	highlander_i2c_done(dev);
 
 	/* Set slave address */
-	iowrite16((addr << 1) | read, dev->base + SMSMADR);
+	iowrite16((addr << 1) | read_write, dev->base + SMSMADR);
 
 	highlander_i2c_command(dev, command, dev->buf_len);
 
-	if (read)
+	if (read_write)
 		return highlander_i2c_read(dev);
 	else
 		return highlander_i2c_write(dev);
-- 
1.6.5

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux