mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Michael Grzeschik <m.grzeschik@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH] ubi: add setting devnum to ubiattach
Date: Thu, 28 Aug 2014 13:01:41 +0200	[thread overview]
Message-ID: <1409223701-1124-1-git-send-email-m.grzeschik@pengutronix.de> (raw)

Sometimes we need to have a defined devicenumber for the ubi partitions.
This patch adds the option to ubiattach.

Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
---
 commands/ubi.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/commands/ubi.c b/commands/ubi.c
index d593e71..94da799 100644
--- a/commands/ubi.c
+++ b/commands/ubi.c
@@ -65,9 +65,13 @@ static int do_ubiattach(int argc, char *argv[])
 	struct mtd_info_user user;
 	int fd, ret;
 	int vid_hdr_offset = 0;
+	int devnum = UBI_DEV_NUM_AUTO;
 
-	while((opt = getopt(argc, argv, "O:")) > 0) {
+	while((opt = getopt(argc, argv, "d:O:")) > 0) {
 		switch(opt) {
+		case 'd':
+			devnum = simple_strtoul(optarg, NULL, 0);
+			break;
 		case 'O':
 			vid_hdr_offset = simple_strtoul(optarg, NULL, 0);
 			break;
@@ -91,7 +95,7 @@ static int do_ubiattach(int argc, char *argv[])
 		goto err;
 	}
 
-	ret = ubi_attach_mtd_dev(user.mtd, UBI_DEV_NUM_AUTO, vid_hdr_offset, 20);
+	ret = ubi_attach_mtd_dev(user.mtd, devnum, vid_hdr_offset, 20);
 	if (ret < 0)
 		printf("failed to attach: %s\n", strerror(-ret));
 	else
@@ -104,13 +108,14 @@ err:
 
 BAREBOX_CMD_HELP_START(ubiattach)
 BAREBOX_CMD_HELP_TEXT("Options:")
+BAREBOX_CMD_HELP_OPT ("-d DEVNUM",  "device number")
 BAREBOX_CMD_HELP_OPT ("-O OFFS",  "VID header offset")
 BAREBOX_CMD_HELP_END
 
 BAREBOX_CMD_START(ubiattach)
 	.cmd		= do_ubiattach,
 	BAREBOX_CMD_DESC("attach mtd device to UBI")
-	BAREBOX_CMD_OPTS("[-O] MTDDEV")
+	BAREBOX_CMD_OPTS("[-dO] MTDDEV")
 	BAREBOX_CMD_GROUP(CMD_GRP_PART)
 	BAREBOX_CMD_HELP(cmd_ubiattach_help)
 BAREBOX_CMD_END
-- 
2.1.0.rc1


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

             reply	other threads:[~2014-08-28 11:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-28 11:01 Michael Grzeschik [this message]
2014-08-28 11:27 ` Antony Pavlov
2014-09-01  7:52   ` 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=1409223701-1124-1-git-send-email-m.grzeschik@pengutronix.de \
    --to=m.grzeschik@pengutronix.de \
    --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