summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntony Pavlov <antonynpavlov@gmail.com>2018-04-17 06:58:29 +0300
committerSascha Hauer <s.hauer@pengutronix.de>2018-04-17 09:25:09 +0200
commitaea31bf35f569aca4ec2091d7050488c0182926a (patch)
treec7196aeffa5bbbf7a535858f275d64ddcc7faec7
parent6377d27b951bfddc67bba16e83f79ae1d9fa8eb9 (diff)
downloadbarebox-aea31bf35f569aca4ec2091d7050488c0182926a.tar.gz
barebox-aea31bf35f569aca4ec2091d7050488c0182926a.tar.xz
commands: i2c_write: enable reg == 0 too
This commit fixes the mistake introduced in the commit 34fadb685905 ('commands: i2c_write: enable raw write to address'). The intended behaviour for i2c_write command is "use raw i2c write only if reg address is not defined". Before the commit 34fadb685905 reg address == 0 was acceptable. After the commit 34fadb685905 reg address == 0 became unacceptable ("undefined") and will lead to raw i2c write. Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--commands/i2c.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/commands/i2c.c b/commands/i2c.c
index 21c39fe5af..f0d16af0cb 100644
--- a/commands/i2c.c
+++ b/commands/i2c.c
@@ -131,7 +131,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, 0);
- if (reg > 0) {
+ if (reg >= 0) {
ret = i2c_write_reg(&client, reg | wide, buf, count);
} else {
ret = i2c_master_send(&client, buf, count);