Skip to contentSkip to conversation

i2c: i2c-core: fix coding style issues in i2c-core.c

PATCH In review RAGHAVENDRA GANIGA 3 participants 3 messages Oct 14, 2013 – Jan 14, 2014

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

PATCH 3/3 i2c: i2c-core: fix coding style issues in i2c-core.c

Quoted 1 line

From 2c324e677fd8bfb0ad13a8c949317e40cc5fd23e Mon Sep 17 00:00:00 2001

From: Raghavendra Ganiga <[email protected]>
Date: Mon, 14 Oct 2013 20:42:37 +0530
Subject: [PATCH 3/3] i2c: i2c-core: fix coding style issues in i2c-core.c

This is a patch to the i2c-core.c file that fixes the coding style issues found by checkpatch.pl tool

---
 drivers/i2c/i2c-core.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/i2c/i2c-core.c +4 -3
index 66e38a9..7e95fcd 100644
@@ -1737,9 +1737,9 @@ int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
 		for (ret = 0; ret < num; ret++) {
 			dev_dbg(&adap->dev, "master_xfer[%d] %c, addr=0x%02x, len=%d%s\n",
 				ret,
-				((msgs[ret].flags & I2C_M_RD) ? 'R' : 'W'),
+				msgs[ret].flags & I2C_M_RD ? 'R' : 'W',
 				msgs[ret].addr, msgs[ret].len,
-				(msgs[ret].flags & I2C_M_RECV_LEN) ? "+" : "");
+				msgs[ret].flags & I2C_M_RECV_LEN ? "+" : "");
 		}
 #endif
 
@@ -2120,7 +2120,8 @@ EXPORT_SYMBOL(i2c_smbus_read_byte);
 s32 i2c_smbus_write_byte(const struct i2c_client *client, u8 value)
 {
 	return i2c_smbus_xfer(client->adapter, client->addr, client->flags,
-				I2C_SMBUS_WRITE, value, I2C_SMBUS_BYTE, NULL);
+			      I2C_SMBUS_WRITE, value,
+			      I2C_SMBUS_BYTE, NULL);
 }
 EXPORT_SYMBOL(i2c_smbus_write_byte);
 
Signature · 1 line
1.7.10.4
#1 lore raw

drivers/i2c/i2c-core.c int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) · line 1742

Quoted 12 lines
drivers/i2c/i2c-core.c +2 -2
@@ -1737,9 +1737,9 @@ int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
 		for (ret = 0; ret < num; ret++) {
 			dev_dbg(&adap->dev, "master_xfer[%d] %c, addr=0x%02x, len=%d%s\n",
 				ret,
-				((msgs[ret].flags & I2C_M_RD) ? 'R' : 'W'),
+				msgs[ret].flags & I2C_M_RD ? 'R' : 'W',
 				msgs[ret].addr, msgs[ret].len,
-				(msgs[ret].flags & I2C_M_RECV_LEN) ? "+" : "");
+				msgs[ret].flags & I2C_M_RECV_LEN ? "+" : "");

Don't spend time changing too much here like the paranthesis. It will probably be removed soon in favour of the tracing approach.

drivers/i2c/i2c-core.c EXPORT_SYMBOL(i2c_smbus_read_byte); · line 2124

Quoted 7 lines
drivers/i2c/i2c-core.c +2 -1
@@ -2120,7 +2120,8 @@ EXPORT_SYMBOL(i2c_smbus_read_byte);
 s32 i2c_smbus_write_byte(const struct i2c_client *client, u8 value)
 {
 	return i2c_smbus_xfer(client->adapter, client->addr, client->flags,
-				I2C_SMBUS_WRITE, value, I2C_SMBUS_BYTE, NULL);
+			      I2C_SMBUS_WRITE, value,
+			      I2C_SMBUS_BYTE, NULL);

Not worth the change IMO. Just drop this patch.

#2 lore raw
Quoted 6 lines · Wolfram Sang
Quoted 6 lines
drivers/i2c/i2c-core.c +0 -0
@@ -1737,9 +1737,9 @@ int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
 		for (ret = 0; ret < num; ret++) {
 			dev_dbg(&adap->dev, "master_xfer[%d] %c, addr=0x%02x, len=%d%s\n",
 				ret,
Quoted 8 lines

drivers/i2c/i2c-core.c int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) · line 1742

Quoted 5 lines
drivers/i2c/i2c-core.c +2 -2
-				((msgs[ret].flags & I2C_M_RD) ? 'R' : 'W'),
+				msgs[ret].flags & I2C_M_RD ? 'R' : 'W',
 				msgs[ret].addr, msgs[ret].len,
-				(msgs[ret].flags & I2C_M_RECV_LEN) ? "+" : "");
+				msgs[ret].flags & I2C_M_RECV_LEN ? "+" : "");

Don't spend time changing too much here like the paranthesis. It will probably be removed soon in favour of the tracing approach.

That'd be good. There are a lot of function tracing style dev_dbg uses in i2c-core that can be removed.

Just an fyi not to Raghavendra:

This sort of loop could have been further modified removing the unnecessary #if DEBUG/#endif too

Also, reusing ret for a loop index is efficient, but a bit odd.

Maybe something like:

drivers/i2c/i2c-core.c +7 -8
index d74c0b3..5ca078e 100644
@@ -1758,14 +1758,13 @@ int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
 	 */
 
 	if (adap->algo->master_xfer) {
-#ifdef DEBUG
-		for (ret = 0; ret < num; ret++) {
-			dev_dbg(&adap->dev, "master_xfer[%d] %c, addr=0x%02x, "
-				"len=%d%s\n", ret, (msgs[ret].flags & I2C_M_RD)
-				? 'R' : 'W', msgs[ret].addr, msgs[ret].len,
-				(msgs[ret].flags & I2C_M_RECV_LEN) ? "+" : "");
-		}
-#endif
+		int i;
+
+		for (i = 0; i < num; i++)
+			dev_dbg(&adap->dev, "master_xfer[%d] %c, addr=0x%02x, len=%d%s\n",
+				ret, msgs[i].flags & I2C_M_RD ? 'R' : 'W',
+				msgs[i].addr, msgs[i].len,
+				msgs[i].flags & I2C_M_RECV_LEN ? "+" : "");
 
 		if (in_atomic() || irqs_disabled()) {
 			ret = i2c_trylock_adapter(adap);