* gpio generic driver
@ 2020-07-23 19:51 Barbier, Renaud
2020-07-24 8:20 ` Lucas Stach
0 siblings, 1 reply; 3+ messages in thread
From: Barbier, Renaud @ 2020-07-23 19:51 UTC (permalink / raw)
To: barebox
Question regarding the function below:
static int bgpio_get(struct gpio_chip *gc, unsigned int gpio)
{
struct bgpio_chip *bgc = to_bgpio_chip(gc);
~ return bgc->read_reg(bgc->reg_dat) & bgc->pin2mask(bgc, gpio);
}
This returns the value from the register i.e the value as in 0x01000000 for bit 3BE or 28LE. This is what I see using the drivers/gpio/gpio-mpc8xxx.c driver.
Is it not supposed to return just 0 or 1?
Linux has
return !!(gc->read_reg(gc->reg_dat) & bgpio_line2mask(gc, gpio));
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: gpio generic driver
2020-07-23 19:51 gpio generic driver Barbier, Renaud
@ 2020-07-24 8:20 ` Lucas Stach
2020-07-24 8:40 ` Barbier, Renaud
0 siblings, 1 reply; 3+ messages in thread
From: Lucas Stach @ 2020-07-24 8:20 UTC (permalink / raw)
To: Barbier, Renaud, barebox
Am Donnerstag, den 23.07.2020, 19:51 +0000 schrieb Barbier, Renaud:
> Question regarding the function below:
>
> static int bgpio_get(struct gpio_chip *gc, unsigned int gpio)
> {
> struct bgpio_chip *bgc = to_bgpio_chip(gc);
>
> ~ return bgc->read_reg(bgc->reg_dat) & bgc->pin2mask(bgc, gpio);
> }
>
> This returns the value from the register i.e the value as in 0x01000000 for bit 3BE or 28LE. This is what I see using the drivers/gpio/gpio-mpc8xxx.c driver.
>
> Is it not supposed to return just 0 or 1?
>
> Linux has
>
> return !!(gc->read_reg(gc->reg_dat) & bgpio_line2mask(gc, gpio));
This shouldn't make a difference when the return value is just used in
a condition, but it may confuse other uses which expect the normalized
1/0 form.
Care to send a patch to change this to the more correct Linux version?
Regards,
Lucas
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: gpio generic driver
2020-07-24 8:20 ` Lucas Stach
@ 2020-07-24 8:40 ` Barbier, Renaud
0 siblings, 0 replies; 3+ messages in thread
From: Barbier, Renaud @ 2020-07-24 8:40 UTC (permalink / raw)
To: Lucas Stach, barebox
Of course. Preparing a patch
> -----Original Message-----
> From: Lucas Stach [mailto:l.stach@pengutronix.de]
> Sent: 24 July 2020 09:20
> To: Barbier, Renaud <renaud.barbier@abaco.com>;
> barebox@lists.infradead.org
> Subject: Re: gpio generic driver
>
>
>
> [**EXTERNAL SOURCE**]:Please verify the source before clicking link or
> opening attachment.
>
> Am Donnerstag, den 23.07.2020, 19:51 +0000 schrieb Barbier, Renaud:
> > Question regarding the function below:
> >
> > static int bgpio_get(struct gpio_chip *gc, unsigned int gpio)
> > {
> > struct bgpio_chip *bgc = to_bgpio_chip(gc);
> >
> > ~ return bgc->read_reg(bgc->reg_dat) & bgc->pin2mask(bgc, gpio);
> > }
> >
> > This returns the value from the register i.e the value as in 0x01000000 for
> bit 3BE or 28LE. This is what I see using the drivers/gpio/gpio-mpc8xxx.c
> driver.
> >
> > Is it not supposed to return just 0 or 1?
> >
> > Linux has
> >
> > return !!(gc->read_reg(gc->reg_dat) & bgpio_line2mask(gc, gpio));
>
> This shouldn't make a difference when the return value is just used in
> a condition, but it may confuse other uses which expect the normalized
> 1/0 form.
>
> Care to send a patch to change this to the more correct Linux version?
>
> Regards,
> Lucas
_______________________________________________
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:[~2020-07-24 8:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-23 19:51 gpio generic driver Barbier, Renaud
2020-07-24 8:20 ` Lucas Stach
2020-07-24 8:40 ` Barbier, Renaud
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox