[PATCH 3/4] gpiolib: make gpiolib command more verbose

Alexander Aring alex.aring at gmail.com
Mon Nov 11 03:12:40 EST 2013


On Mon, Nov 11, 2013 at 09:07:27AM +0100, Sascha Hauer wrote:
> On Mon, Nov 11, 2013 at 02:30:20AM +0100, Alexander Aring wrote:
> > Hi Sebastian,
> > 
> > On Sat, Nov 09, 2013 at 02:24:08PM +0100, Sebastian Hesselbarth wrote:
> > > This adds some more printf information to gpiolib command, like the
> > > gpiochip handling a specific gpio. Also, current direction and value
> > > of the gpio are printed, if the gpiochip provides the corresponding
> > > callbacks.
> > > 
> > > Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth at gmail.com>
> > > ---
> > > Cc: barebox at lists.infradead.org
> > > ---
> > >  drivers/gpio/gpiolib.c | 24 +++++++++++++++++++++---
> > >  1 file changed, 21 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> > > index ca6e8ad..c12ebe6 100644
> > > --- a/drivers/gpio/gpiolib.c
> > > +++ b/drivers/gpio/gpiolib.c
> > > @@ -228,16 +228,34 @@ static int do_gpiolib(int argc, char *argv[])
> > >  	int i;
> > >  
> > >  	printf("gpiolib: gpio lists\n");
> > > -	printf("%*crequested  label\n", 11, ' ');
> > >  
> > >  	for (i = 0; i < ARCH_NR_GPIOS; i++) {
> > >  		struct gpio_info *gi = &gpio_desc[i];
> > > +		int val = -1, dir = -1;
> > >  
> > >  		if (!gi->chip)
> > >  			continue;
> > >  
> > > -		printf("gpio %*d: %*s  %s\n", 4,
> > > -			i, 9, gi->requested ? "true" : "false",
> > > +		/* print chip information and header on first gpio */
> > > +		if (gi->chip->base == i) {
> > > +			printf("\ngpios %u-%u, chip %s:\n",
> > > +				gi->chip->base,
> > > +				gi->chip->base + gi->chip->ngpio,
> > 
> > I think this should be "gi->chip->base + gi->chip->ngpio - 1", because
> > we starting at zero on base.
> 
> Indeed. Otherwise I get the following for my 32bit gpio bank:
> 
> gpios 0-31, chip 209c000.gpio:
>              dir val requested  label
>   gpio    0: unk  lo     false  
>   gpio    1: unk  lo     false  
> ...
> 
> Fixed this while applying.

detected by starring, watching and thinking. Yea and maybe I used the
force. :-)

Thanks Sascha.

- Alex



More information about the barebox mailing list