mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] ubi: add setting devnum to ubiattach
@ 2014-08-28 11:01 Michael Grzeschik
  2014-08-28 11:27 ` Antony Pavlov
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Grzeschik @ 2014-08-28 11:01 UTC (permalink / raw)
  To: barebox

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ubi: add setting devnum to ubiattach
  2014-08-28 11:01 [PATCH] ubi: add setting devnum to ubiattach Michael Grzeschik
@ 2014-08-28 11:27 ` Antony Pavlov
  2014-09-01  7:52   ` Sascha Hauer
  0 siblings, 1 reply; 3+ messages in thread
From: Antony Pavlov @ 2014-08-28 11:27 UTC (permalink / raw)
  To: Michael Grzeschik; +Cc: barebox

On Thu, 28 Aug 2014 13:01:41 +0200
Michael Grzeschik <m.grzeschik@pengutronix.de> wrote:

> 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")

Can we use a more accurate variant? Something like this one:

+	BAREBOX_CMD_OPTS("[-d DEVNUM] [-O OFFS] MTDDEV")

>  	BAREBOX_CMD_GROUP(CMD_GRP_PART)
>  	BAREBOX_CMD_HELP(cmd_ubiattach_help)
>  BAREBOX_CMD_END
> -- 
> 2.1.0.rc1


-- 
-- 
Best regards,
  Antony Pavlov

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ubi: add setting devnum to ubiattach
  2014-08-28 11:27 ` Antony Pavlov
@ 2014-09-01  7:52   ` Sascha Hauer
  0 siblings, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2014-09-01  7:52 UTC (permalink / raw)
  To: Antony Pavlov; +Cc: barebox

On Thu, Aug 28, 2014 at 03:27:11PM +0400, Antony Pavlov wrote:
> >  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")
> 
> Can we use a more accurate variant? Something like this one:

BAREBOX_CMD_OPTS for other commands look like Michael did it. The full
option semantics is still in the full help text.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-09-01  7:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-28 11:01 [PATCH] ubi: add setting devnum to ubiattach Michael Grzeschik
2014-08-28 11:27 ` Antony Pavlov
2014-09-01  7:52   ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox