mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Silvio Fricke <silvio.fricke@gmail.com>
To: barebox@lists.infradead.org
Cc: Silvio Fricke <silvio.fricke@gmail.com>
Subject: [PATCH 2/3] commands: i2c: simplify i2c wide access logic
Date: Thu, 10 Jul 2014 16:19:55 +0200	[thread overview]
Message-ID: <f59edce3b96b69577dbb8ff1aee1eeb74f25762e.1405001817.git.silvio.fricke@gmail.com> (raw)
In-Reply-To: <cover.1405000144.git.silvio.fricke@gmail.com>
In-Reply-To: <cover.1405000144.git.silvio.fricke@gmail.com>

Signed-off-by: Silvio Fricke <silvio.fricke@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


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2014-07-10 14:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-10 14:19 [PATCH 0/3] some i2c patches Silvio Fricke
2014-07-10 14:19 ` [PATCH 1/3] commands: i2c: verbose option doesn't need argument Silvio Fricke
2014-07-10 14:19 ` Silvio Fricke [this message]
2014-07-10 14:19 ` [PATCH 3/3] commands: i2c: add message if write is not successful Silvio Fricke
2014-07-11  5:41 ` [PATCH 0/3] some i2c patches Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f59edce3b96b69577dbb8ff1aee1eeb74f25762e.1405001817.git.silvio.fricke@gmail.com \
    --to=silvio.fricke@gmail.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox