CMD_I2C: make alen=0 work
Signed-off-by: Reinhard Meyer <u-boot@emk-elektronik.de>
diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c
index 371e022..1283c82 100644
--- a/common/cmd_i2c.c
+++ b/common/cmd_i2c.c
@@ -152,7 +152,7 @@
/*
* get_alen: small parser helper function to get address length
- * returns the address length,or 0 on error
+ * returns the address length
*/
static uint get_alen(char *arg)
{
@@ -163,9 +163,6 @@
for (j = 0; j < 8; j++) {
if (arg[j] == '.') {
alen = arg[j+1] - '0';
- if (alen > 3) {
- return 0;
- }
break;
} else if (arg[j] == '\0')
break;
@@ -198,7 +195,7 @@
*/
devaddr = simple_strtoul(argv[2], NULL, 16);
alen = get_alen(argv[2]);
- if (alen == 0)
+ if (alen > 3)
return cmd_usage(cmdtp);
/*
@@ -255,7 +252,7 @@
*/
addr = simple_strtoul(argv[2], NULL, 16);
alen = get_alen(argv[2]);
- if (alen == 0)
+ if (alen > 3)
return cmd_usage(cmdtp);
/*
@@ -337,7 +334,7 @@
*/
addr = simple_strtoul(argv[2], NULL, 16);
alen = get_alen(argv[2]);
- if (alen == 0)
+ if (alen > 3)
return cmd_usage(cmdtp);
/*
@@ -399,7 +396,7 @@
*/
addr = simple_strtoul(argv[2], NULL, 16);
alen = get_alen(argv[2]);
- if (alen == 0)
+ if (alen > 3)
return cmd_usage(cmdtp);
/*
@@ -477,7 +474,7 @@
*/
addr = simple_strtoul(argv[2], NULL, 16);
alen = get_alen(argv[2]);
- if (alen == 0)
+ if (alen > 3)
return cmd_usage(cmdtp);
}
@@ -621,7 +618,7 @@
*/
addr = simple_strtoul(argv[2], NULL, 16);
alen = get_alen(argv[2]);
- if (alen == 0)
+ if (alen > 3)
return cmd_usage(cmdtp);
/*