[PATCH 2/3] commands: i2c: simplify i2c wide access logic

Silvio Fricke silvio.fricke at gmail.com
Thu Jul 10 07:19:55 PDT 2014


Signed-off-by: Silvio Fricke <silvio.fricke at gmail.com>
---
 commands/i2c.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/commands/i2c.c b/commands/i2c.c
index 7a39e6e..e3d79b0 100644
--- a/commands/i2c.c
+++ b/commands/i2c.c
@@ -90,7 +90,7 @@ static int do_i2c_write(int argc, char *argv[])
 			verbose = 1;
 			break;
 		case 'w':
-			wide = 1;
+			wide = I2C_ADDR_16_BIT;
 			break;
 		}
 	}
@@ -113,7 +113,7 @@ static int do_i2c_write(int argc, char *argv[])
 	for (i = 0; i < count; i++)
 		*(buf + i) = (char) simple_strtol(argv[optind+i], NULL, 16);
 
-	ret = i2c_write_reg(&client, reg | (wide ? I2C_ADDR_16_BIT : 0), buf, count);
+	ret = i2c_write_reg(&client, reg | wide, buf, count);
 	if (ret != count)
 		goto out;
 	ret = 0;
@@ -173,7 +173,7 @@ static int do_i2c_read(int argc, char *argv[])
 			verbose = 1;
 			break;
 		case 'w':
-			wide = 1;
+			wide = I2C_ADDR_16_BIT;
 			break;
 		}
 	}
@@ -191,7 +191,7 @@ static int do_i2c_read(int argc, char *argv[])
 	client.addr = addr;
 
 	buf = xmalloc(count);
-	ret = i2c_read_reg(&client, reg | (wide ? I2C_ADDR_16_BIT : 0), buf, count);
+	ret = i2c_read_reg(&client, reg | wide, buf, count);
 	if (ret == count) {
 		int i;
 		if (verbose)
-- 
2.0.1




More information about the barebox mailing list