summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
Diffstat (limited to 'commands')
-rw-r--r--commands/global.c2
-rw-r--r--commands/i2c.c2
-rw-r--r--commands/miitool.c9
-rw-r--r--commands/nv.c47
-rw-r--r--commands/spi.c2
5 files changed, 39 insertions, 23 deletions
diff --git a/commands/global.c b/commands/global.c
index fc687169a7..c66bf6e539 100644
--- a/commands/global.c
+++ b/commands/global.c
@@ -78,5 +78,5 @@ BAREBOX_CMD_START(global)
BAREBOX_CMD_OPTS("[-r] VAR[=VALUE] ...")
BAREBOX_CMD_GROUP(CMD_GRP_ENV)
BAREBOX_CMD_HELP(cmd_global_help)
- BAREBOX_CMD_COMPLETE(nv_global_complete)
+ BAREBOX_CMD_COMPLETE(global_complete)
BAREBOX_CMD_END
diff --git a/commands/i2c.c b/commands/i2c.c
index 573032ab15..b74c53509f 100644
--- a/commands/i2c.c
+++ b/commands/i2c.c
@@ -129,7 +129,7 @@ static int do_i2c_write(int argc, char *argv[])
buf = xmalloc(count);
for (i = 0; i < count; i++)
- *(buf + i) = (char) simple_strtol(argv[optind+i], NULL, 16);
+ *(buf + i) = (char) simple_strtol(argv[optind+i], NULL, 0);
ret = i2c_write_reg(&client, reg | wide, buf, count);
if (ret != count) {
diff --git a/commands/miitool.c b/commands/miitool.c
index 07bce18651..dea4f853ce 100644
--- a/commands/miitool.c
+++ b/commands/miitool.c
@@ -225,7 +225,8 @@ static int show_basic_mii(struct mii_bus *mii, struct phy_device *phydev,
return 0;
}
-static void mdiobus_show(struct device_d *dev, char *phydevname, int verbose)
+static void mdiobus_show(struct device_d *dev, const char *phydevname,
+ int verbose)
{
struct mii_bus *mii = to_mii_bus(dev);
int i;
@@ -337,7 +338,9 @@ static int do_miitool(int argc, char *argv[])
case MIITOOL_SHOW:
for_each_mii_bus(mii) {
mdiobus_detect(&mii->dev);
- mdiobus_show(&mii->dev, phydevname, verbose);
+ mdiobus_show(&mii->dev,
+ devpath_to_name(phydevname),
+ verbose);
}
break;
}
@@ -357,7 +360,7 @@ BAREBOX_CMD_HELP_TEXT("adapters use an MII to autonegotiate link speed and duple
BAREBOX_CMD_HELP_TEXT("")
BAREBOX_CMD_HELP_TEXT("Options:")
BAREBOX_CMD_HELP_OPT("-v", "increase verbosity")
-BAREBOX_CMD_HELP_OPT("-s <devname>", "show PHY status (not providing PHY prints status of all)")
+BAREBOX_CMD_HELP_OPT("-s <devpath/devname>", "show PHY status (not providing PHY prints status of all)")
BAREBOX_CMD_HELP_OPT("-r <busno>:<adr>", "register a PHY")
BAREBOX_CMD_HELP_END
diff --git a/commands/nv.c b/commands/nv.c
index 37cdb96647..01c25a108f 100644
--- a/commands/nv.c
+++ b/commands/nv.c
@@ -28,7 +28,7 @@ static int do_nv(int argc, char *argv[])
{
int opt;
int do_remove = 0, do_save = 0;
- int ret, i;
+ int failed = 0, i;
char *value;
while ((opt = getopt(argc, argv, "rs")) > 0) {
@@ -44,52 +44,65 @@ static int do_nv(int argc, char *argv[])
}
}
- if (do_save)
- return nvvar_save();
-
- if (argc == optind) {
+ if (argc == 1) {
nvvar_print();
return 0;
}
+ if (do_save) {
+ return nvvar_save();
+ }
+
argc -= optind;
argv += optind;
- if (argc < 1)
+ if (argc < 1) {
+ printf("Invalid usage: Missing argument");
return COMMAND_ERROR_USAGE;
+ }
for (i = 0; i < argc; i++) {
+ int ret;
value = strchr(argv[0], '=');
if (value) {
*value = 0;
value++;
}
- if (do_remove)
+ if (do_remove) {
ret = nvvar_remove(argv[i]);
- else
+ if (ret) {
+ printf("Failed removing %s: %s\n", argv[i], strerror(-ret));
+ failed = 1;
+ }
+ } else {
ret = nvvar_add(argv[i], value);
+ if (ret) {
+ printf("Failed adding %s: %s\n", argv[i], strerror(-ret));
+ failed = 1;
+ }
+ }
}
- return ret;
+ return failed;
}
BAREBOX_CMD_HELP_START(nv)
-BAREBOX_CMD_HELP_TEXT("Add a new non volatile variable named VAR, optionally set to VALUE.")
-BAREBOX_CMD_HELP_TEXT("non volatile variables are persistent variables that overwrite the")
-BAREBOX_CMD_HELP_TEXT("global variables of the same name. Their value is saved implicitly with")
-BAREBOX_CMD_HELP_TEXT("'saveenv' or explicitly with 'nv -s'")
+BAREBOX_CMD_HELP_TEXT("Add a new non volatile (NV) variable named VAR, optionally set to VALUE.")
+BAREBOX_CMD_HELP_TEXT("NV variables are persistent variables that overwrite the global variables")
+BAREBOX_CMD_HELP_TEXT("of the same name.")
+BAREBOX_CMD_HELP_TEXT("Their value is saved implicitly with 'saveenv' or explicitly with 'nv -s'")
BAREBOX_CMD_HELP_TEXT("")
BAREBOX_CMD_HELP_TEXT("Options:")
-BAREBOX_CMD_HELP_OPT("-r", "remove non volatile variables")
-BAREBOX_CMD_HELP_OPT("-s", "Save NV variables")
+BAREBOX_CMD_HELP_OPT("-r VAR1 ...", "remove NV variable(s)")
+BAREBOX_CMD_HELP_OPT("-s\t", "save NV variables")
BAREBOX_CMD_HELP_END
BAREBOX_CMD_START(nv)
.cmd = do_nv,
- BAREBOX_CMD_DESC("create or set non volatile variables")
+ BAREBOX_CMD_DESC("create, set or remove non volatile (NV) variables")
BAREBOX_CMD_OPTS("[-r] VAR[=VALUE] ...")
BAREBOX_CMD_GROUP(CMD_GRP_ENV)
BAREBOX_CMD_HELP(cmd_nv_help)
- BAREBOX_CMD_COMPLETE(nv_global_complete)
+ BAREBOX_CMD_COMPLETE(nv_complete)
BAREBOX_CMD_END
diff --git a/commands/spi.c b/commands/spi.c
index 6603b34b67..7bf193b0bb 100644
--- a/commands/spi.c
+++ b/commands/spi.c
@@ -84,7 +84,7 @@ static int do_spi(int argc, char *argv[])
rx_buf = xmalloc(read);
for (i = 0; i < count; i++)
- tx_buf[i] = (u8) simple_strtol(argv[optind + i], NULL, 16);
+ tx_buf[i] = (u8) simple_strtol(argv[optind + i], NULL, 0);
ret = spi_write_then_read(&spi, tx_buf, count, rx_buf, read);
if (ret)