mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] commands: rename "gpiolib" -> "gpioinfo"
@ 2014-05-15  9:08 Holger Schurig
  2014-05-15  9:08 ` [PATCH] magicvars: can now also list values Holger Schurig
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Holger Schurig @ 2014-05-15  9:08 UTC (permalink / raw)
  To: barebox

Signed-off-by: Holger Schurig <holgerschurig@gmail.com>
---
 drivers/gpio/gpiolib.c |    8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 54ec5a6..611e41e 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -305,8 +305,6 @@ static int do_gpiolib(int argc, char *argv[])
 {
 	int i;
 
-	printf("gpiolib: gpio lists\n");
-
 	for (i = 0; i < ARCH_NR_GPIOS; i++) {
 		struct gpio_info *gi = &gpio_desc[i];
 		int val = -1, dir = -1;
@@ -316,7 +314,7 @@ static int do_gpiolib(int argc, char *argv[])
 
 		/* print chip information and header on first gpio */
 		if (gi->chip->base == i) {
-			printf("\ngpios %u-%u, chip %s:\n",
+			printf("\nGPIOs %u-%u, chip %s:\n",
 				gi->chip->base,
 				gi->chip->base + gi->chip->ngpio - 1,
 				gi->chip->dev->name);
@@ -330,7 +328,7 @@ static int do_gpiolib(int argc, char *argv[])
 			val = gi->chip->ops->get(gi->chip,
 						i - gi->chip->base);
 
-		printf("  gpio %*d: %*s %*s %*s  %s\n", 4, i,
+		printf("  GPIO %*d: %*s %*s %*s  %s\n", 4, i,
 			3, (dir < 0) ? "unk" : ((dir == GPIOF_DIR_IN) ? "in" : "out"),
 			3, (val < 0) ? "unk" : ((val == 0) ? "lo" : "hi"),
 			9, gi->requested ? "true" : "false",
@@ -340,7 +338,7 @@ static int do_gpiolib(int argc, char *argv[])
 	return 0;
 }
 
-BAREBOX_CMD_START(gpiolib)
+BAREBOX_CMD_START(gpioinfo)
 	.cmd		= do_gpiolib,
 	BAREBOX_CMD_DESC("list registered GPIOs")
 	BAREBOX_CMD_GROUP(CMD_GRP_INFO)
-- 
1.7.10.4


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

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

* [PATCH] magicvars: can now also list values
  2014-05-15  9:08 [PATCH] commands: rename "gpiolib" -> "gpioinfo" Holger Schurig
@ 2014-05-15  9:08 ` Holger Schurig
  2014-05-15  9:08 ` Holger Schurig
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Holger Schurig @ 2014-05-15  9:08 UTC (permalink / raw)
  To: barebox

Also uppercased the abbreviation GPIO in printf.

Signed-off-by: Holger Schurig <holgerschurig@gmail.com>
---
 commands/magicvar.c |   30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/commands/magicvar.c b/commands/magicvar.c
index d92788a..cf1fe45 100644
--- a/commands/magicvar.c
+++ b/commands/magicvar.c
@@ -1,21 +1,49 @@
 #include <common.h>
 #include <command.h>
+#include <getopt.h>
+#include <environment.h>
 #include <magicvar.h>
 
 static int do_magicvar(int argc, char *argv[])
 {
 	struct magicvar *m;
+	int opt;
+	int verbose = 0;
+
+	while ((opt = getopt(argc, argv, "v")) > 0) {
+		switch (opt) {
+		case 'v':
+			verbose = 1;
+			break;
+		default:
+			return COMMAND_ERROR_USAGE;
+		}
+	}
 
 	for (m = &__barebox_magicvar_start;
 			m != &__barebox_magicvar_end;
-			m++)
+			m++) {
 		printf("%-32s %s\n", m->name, m->description);
+		if (verbose) {
+			const char *val = getenv(m->name);
+			if (val && strlen(val))
+				printf("  %s\n", val);
+		}
+	}
 
 	return 0;
 }
 
+
+BAREBOX_CMD_HELP_START(magicvar)
+BAREBOX_CMD_HELP_TEXT("Options:")
+BAREBOX_CMD_HELP_OPT ("-v", "verbose (list all value if there is one)")
+BAREBOX_CMD_HELP_END
+
 BAREBOX_CMD_START(magicvar)
 	.cmd		= do_magicvar,
 	BAREBOX_CMD_DESC("list information about magic variables")
+	BAREBOX_CMD_OPTS("[-v]")
+	BAREBOX_CMD_HELP(cmd_magicvar_help)
 	BAREBOX_CMD_GROUP(CMD_GRP_ENV)
 BAREBOX_CMD_END
-- 
1.7.10.4


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

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

* [PATCH] magicvars: can now also list values
  2014-05-15  9:08 [PATCH] commands: rename "gpiolib" -> "gpioinfo" Holger Schurig
  2014-05-15  9:08 ` [PATCH] magicvars: can now also list values Holger Schurig
@ 2014-05-15  9:08 ` Holger Schurig
  2014-05-15  9:20 ` [PATCH] commands: rename "gpiolib" -> "gpioinfo" Sebastian Hesselbarth
  2014-05-15 13:01 ` Sascha Hauer
  3 siblings, 0 replies; 8+ messages in thread
From: Holger Schurig @ 2014-05-15  9:08 UTC (permalink / raw)
  To: barebox

Also uppercased the abbreviation GPIO in printf.

Signed-off-by: Holger Schurig <holgerschurig@gmail.com>
---
 commands/magicvar.c |   30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/commands/magicvar.c b/commands/magicvar.c
index d92788a..cf1fe45 100644
--- a/commands/magicvar.c
+++ b/commands/magicvar.c
@@ -1,21 +1,49 @@
 #include <common.h>
 #include <command.h>
+#include <getopt.h>
+#include <environment.h>
 #include <magicvar.h>
 
 static int do_magicvar(int argc, char *argv[])
 {
 	struct magicvar *m;
+	int opt;
+	int verbose = 0;
+
+	while ((opt = getopt(argc, argv, "v")) > 0) {
+		switch (opt) {
+		case 'v':
+			verbose = 1;
+			break;
+		default:
+			return COMMAND_ERROR_USAGE;
+		}
+	}
 
 	for (m = &__barebox_magicvar_start;
 			m != &__barebox_magicvar_end;
-			m++)
+			m++) {
 		printf("%-32s %s\n", m->name, m->description);
+		if (verbose) {
+			const char *val = getenv(m->name);
+			if (val && strlen(val))
+				printf("  %s\n", val);
+		}
+	}
 
 	return 0;
 }
 
+
+BAREBOX_CMD_HELP_START(magicvar)
+BAREBOX_CMD_HELP_TEXT("Options:")
+BAREBOX_CMD_HELP_OPT ("-v", "verbose (list all value if there is one)")
+BAREBOX_CMD_HELP_END
+
 BAREBOX_CMD_START(magicvar)
 	.cmd		= do_magicvar,
 	BAREBOX_CMD_DESC("list information about magic variables")
+	BAREBOX_CMD_OPTS("[-v]")
+	BAREBOX_CMD_HELP(cmd_magicvar_help)
 	BAREBOX_CMD_GROUP(CMD_GRP_ENV)
 BAREBOX_CMD_END
-- 
1.7.10.4


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

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

* Re: [PATCH] commands: rename "gpiolib" -> "gpioinfo"
  2014-05-15  9:08 [PATCH] commands: rename "gpiolib" -> "gpioinfo" Holger Schurig
  2014-05-15  9:08 ` [PATCH] magicvars: can now also list values Holger Schurig
  2014-05-15  9:08 ` Holger Schurig
@ 2014-05-15  9:20 ` Sebastian Hesselbarth
  2014-05-15  9:49   ` Holger Schurig
  2014-05-15 12:40   ` Sascha Hauer
  2014-05-15 13:01 ` Sascha Hauer
  3 siblings, 2 replies; 8+ messages in thread
From: Sebastian Hesselbarth @ 2014-05-15  9:20 UTC (permalink / raw)
  To: Holger Schurig, barebox

On 05/15/2014 11:08 AM, Holger Schurig wrote:
> Signed-off-by: Holger Schurig <holgerschurig@gmail.com>

Subject: rename "gpiolib" -> "gpioinfo"

How about joining the gpio related commands to "gpio"
and use e.g. -l for list?

Sebastian

> ---
>   drivers/gpio/gpiolib.c |    8 +++-----
>   1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index 54ec5a6..611e41e 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -305,8 +305,6 @@ static int do_gpiolib(int argc, char *argv[])
>   {
>   	int i;
>
> -	printf("gpiolib: gpio lists\n");
> -
>   	for (i = 0; i < ARCH_NR_GPIOS; i++) {
>   		struct gpio_info *gi = &gpio_desc[i];
>   		int val = -1, dir = -1;
> @@ -316,7 +314,7 @@ static int do_gpiolib(int argc, char *argv[])
>
>   		/* print chip information and header on first gpio */
>   		if (gi->chip->base == i) {
> -			printf("\ngpios %u-%u, chip %s:\n",
> +			printf("\nGPIOs %u-%u, chip %s:\n",
>   				gi->chip->base,
>   				gi->chip->base + gi->chip->ngpio - 1,
>   				gi->chip->dev->name);
> @@ -330,7 +328,7 @@ static int do_gpiolib(int argc, char *argv[])
>   			val = gi->chip->ops->get(gi->chip,
>   						i - gi->chip->base);
>
> -		printf("  gpio %*d: %*s %*s %*s  %s\n", 4, i,
> +		printf("  GPIO %*d: %*s %*s %*s  %s\n", 4, i,
>   			3, (dir < 0) ? "unk" : ((dir == GPIOF_DIR_IN) ? "in" : "out"),
>   			3, (val < 0) ? "unk" : ((val == 0) ? "lo" : "hi"),
>   			9, gi->requested ? "true" : "false",
> @@ -340,7 +338,7 @@ static int do_gpiolib(int argc, char *argv[])
>   	return 0;
>   }
>
> -BAREBOX_CMD_START(gpiolib)
> +BAREBOX_CMD_START(gpioinfo)
>   	.cmd		= do_gpiolib,
>   	BAREBOX_CMD_DESC("list registered GPIOs")
>   	BAREBOX_CMD_GROUP(CMD_GRP_INFO)
>


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

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

* Re: [PATCH] commands: rename "gpiolib" -> "gpioinfo"
  2014-05-15  9:20 ` [PATCH] commands: rename "gpiolib" -> "gpioinfo" Sebastian Hesselbarth
@ 2014-05-15  9:49   ` Holger Schurig
  2014-05-15 12:40   ` Sascha Hauer
  1 sibling, 0 replies; 8+ messages in thread
From: Holger Schurig @ 2014-05-15  9:49 UTC (permalink / raw)
  To: Sebastian Hesselbarth; +Cc: barebox

I'm not sure about this monster commands, e.g. look at "menu", it does
everything and than more.

But if you make a patch, maybe it get's accepted. No strong feelings!

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

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

* Re: [PATCH] commands: rename "gpiolib" -> "gpioinfo"
  2014-05-15  9:20 ` [PATCH] commands: rename "gpiolib" -> "gpioinfo" Sebastian Hesselbarth
  2014-05-15  9:49   ` Holger Schurig
@ 2014-05-15 12:40   ` Sascha Hauer
  2014-05-15 12:52     ` Sebastian Hesselbarth
  1 sibling, 1 reply; 8+ messages in thread
From: Sascha Hauer @ 2014-05-15 12:40 UTC (permalink / raw)
  To: Sebastian Hesselbarth; +Cc: barebox

On Thu, May 15, 2014 at 11:20:27AM +0200, Sebastian Hesselbarth wrote:
> On 05/15/2014 11:08 AM, Holger Schurig wrote:
> >Signed-off-by: Holger Schurig <holgerschurig@gmail.com>
> 
> Subject: rename "gpiolib" -> "gpioinfo"
> 
> How about joining the gpio related commands to "gpio"
> and use e.g. -l for list?

Which commands do you mean? gpio_direction_output / gpio_set_value
and friends? I wouldn't change these as we would end up with four
single letter options (for direction_output, set_value, direction_input,
get_value) which are hard to memorize.

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] 8+ messages in thread

* Re: [PATCH] commands: rename "gpiolib" -> "gpioinfo"
  2014-05-15 12:40   ` Sascha Hauer
@ 2014-05-15 12:52     ` Sebastian Hesselbarth
  0 siblings, 0 replies; 8+ messages in thread
From: Sebastian Hesselbarth @ 2014-05-15 12:52 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On 05/15/2014 02:40 PM, Sascha Hauer wrote:
> On Thu, May 15, 2014 at 11:20:27AM +0200, Sebastian Hesselbarth wrote:
>> On 05/15/2014 11:08 AM, Holger Schurig wrote:
>>> Signed-off-by: Holger Schurig <holgerschurig@gmail.com>
>>
>> Subject: rename "gpiolib" -> "gpioinfo"
>>
>> How about joining the gpio related commands to "gpio"
>> and use e.g. -l for list?
>
> Which commands do you mean? gpio_direction_output / gpio_set_value
> and friends? I wouldn't change these as we would end up with four
> single letter options (for direction_output, set_value, direction_input,
> get_value) which are hard to memorize.

Maybe I was just irritated by the simple rename of gpiolib to
gpioinfo - which could also be gpiolist or gpio_info to match
the other gpio friends.

Just the first idea that came into my mind when I saw a patch
for the rename - no show-stopper of course.

Sebastian


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

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

* Re: [PATCH] commands: rename "gpiolib" -> "gpioinfo"
  2014-05-15  9:08 [PATCH] commands: rename "gpiolib" -> "gpioinfo" Holger Schurig
                   ` (2 preceding siblings ...)
  2014-05-15  9:20 ` [PATCH] commands: rename "gpiolib" -> "gpioinfo" Sebastian Hesselbarth
@ 2014-05-15 13:01 ` Sascha Hauer
  3 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2014-05-15 13:01 UTC (permalink / raw)
  To: Holger Schurig; +Cc: barebox

On Thu, May 15, 2014 at 11:08:55AM +0200, Holger Schurig wrote:
> Signed-off-by: Holger Schurig <holgerschurig@gmail.com>

Applied, thanks

Sascha

> ---
>  drivers/gpio/gpiolib.c |    8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index 54ec5a6..611e41e 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -305,8 +305,6 @@ static int do_gpiolib(int argc, char *argv[])
>  {
>  	int i;
>  
> -	printf("gpiolib: gpio lists\n");
> -
>  	for (i = 0; i < ARCH_NR_GPIOS; i++) {
>  		struct gpio_info *gi = &gpio_desc[i];
>  		int val = -1, dir = -1;
> @@ -316,7 +314,7 @@ static int do_gpiolib(int argc, char *argv[])
>  
>  		/* print chip information and header on first gpio */
>  		if (gi->chip->base == i) {
> -			printf("\ngpios %u-%u, chip %s:\n",
> +			printf("\nGPIOs %u-%u, chip %s:\n",
>  				gi->chip->base,
>  				gi->chip->base + gi->chip->ngpio - 1,
>  				gi->chip->dev->name);
> @@ -330,7 +328,7 @@ static int do_gpiolib(int argc, char *argv[])
>  			val = gi->chip->ops->get(gi->chip,
>  						i - gi->chip->base);
>  
> -		printf("  gpio %*d: %*s %*s %*s  %s\n", 4, i,
> +		printf("  GPIO %*d: %*s %*s %*s  %s\n", 4, i,
>  			3, (dir < 0) ? "unk" : ((dir == GPIOF_DIR_IN) ? "in" : "out"),
>  			3, (val < 0) ? "unk" : ((val == 0) ? "lo" : "hi"),
>  			9, gi->requested ? "true" : "false",
> @@ -340,7 +338,7 @@ static int do_gpiolib(int argc, char *argv[])
>  	return 0;
>  }
>  
> -BAREBOX_CMD_START(gpiolib)
> +BAREBOX_CMD_START(gpioinfo)
>  	.cmd		= do_gpiolib,
>  	BAREBOX_CMD_DESC("list registered GPIOs")
>  	BAREBOX_CMD_GROUP(CMD_GRP_INFO)
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
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] 8+ messages in thread

end of thread, other threads:[~2014-05-15 13:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-15  9:08 [PATCH] commands: rename "gpiolib" -> "gpioinfo" Holger Schurig
2014-05-15  9:08 ` [PATCH] magicvars: can now also list values Holger Schurig
2014-05-15  9:08 ` Holger Schurig
2014-05-15  9:20 ` [PATCH] commands: rename "gpiolib" -> "gpioinfo" Sebastian Hesselbarth
2014-05-15  9:49   ` Holger Schurig
2014-05-15 12:40   ` Sascha Hauer
2014-05-15 12:52     ` Sebastian Hesselbarth
2014-05-15 13:01 ` Sascha Hauer

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