summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-08-05 12:49:58 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2013-08-05 12:49:58 +0200
commitfeefc3ef3b4d201845480b17cb9e6c6729eb1a96 (patch)
tree355bae733a4bb876425a06549b8e1bdd393a5020 /commands
parent9ebb0554cd0e19f3757f4f5eea723eaf3b6dab78 (diff)
parentae5eeb06ed37914d6a47a1f414a9165763ac5677 (diff)
downloadbarebox-feefc3ef3b4d201845480b17cb9e6c6729eb1a96.tar.gz
barebox-feefc3ef3b4d201845480b17cb9e6c6729eb1a96.tar.xz
Merge branch 'for-next/mtd'
Diffstat (limited to 'commands')
-rw-r--r--commands/Kconfig6
-rw-r--r--commands/ubi.c39
2 files changed, 38 insertions, 7 deletions
diff --git a/commands/Kconfig b/commands/Kconfig
index 7cc71298b7..ede1b3aa7e 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -401,13 +401,13 @@ config CMD_FLASH
config CMD_UBI
tristate
- default y if UBI
- depends on UBI
+ default y if MTD_UBI
+ depends on MTD_UBI
prompt "ubimkvol, ubirmvol, ubiattach"
config CMD_UBIFORMAT
tristate
- depends on UBI
+ depends on MTD_UBI
select LIBMTD
select LIBSCAN
select LIBUBIGEN
diff --git a/commands/ubi.c b/commands/ubi.c
index 73483948b7..2041df3fd5 100644
--- a/commands/ubi.c
+++ b/commands/ubi.c
@@ -71,12 +71,17 @@ static int do_ubiattach(int argc, char *argv[])
}
ret = ioctl(fd, MEMGETINFO, &user);
- if (!ret)
- ret = ubi_attach_mtd_dev(user.mtd, UBI_DEV_NUM_AUTO, 0);
+ if (ret) {
+ printf("MEMGETINFO failed: %s\n", strerror(-ret));
+ goto err;
+ }
- if (ret)
+ ret = ubi_attach_mtd_dev(user.mtd, UBI_DEV_NUM_AUTO, 0, 20);
+ if (ret < 0)
printf("failed to attach: %s\n", strerror(-ret));
-
+ else
+ ret = 0;
+err:
close(fd);
return ret ? 1 : 0;
@@ -92,6 +97,32 @@ BAREBOX_CMD_START(ubiattach)
BAREBOX_CMD_HELP(cmd_ubiattach_help)
BAREBOX_CMD_END
+static int do_ubidetach(int argc, char *argv[])
+{
+ int ubi_num, ret;
+
+ if (argc != 2)
+ return COMMAND_ERROR_USAGE;
+
+ ubi_num = simple_strtoul(argv[1], NULL, 0);
+ ret = ubi_detach_mtd_dev(ubi_num, 1);
+
+ if (ret)
+ printf("failed to detach: %s\n", strerror(-ret));
+
+ return ret;
+}
+
+static const __maybe_unused char cmd_ubidetach_help[] =
+"Usage: ubidetach <ubinum>\n"
+"Detach <ubinum> from ubi\n";
+
+BAREBOX_CMD_START(ubidetach)
+ .cmd = do_ubidetach,
+ .usage = "detach an ubi dev",
+ BAREBOX_CMD_HELP(cmd_ubidetach_help)
+BAREBOX_CMD_END
+
static int do_ubirmvol(int argc, char *argv[])
{
struct ubi_mkvol_req req;