mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Lucas Stach <l.stach@pengutronix.de>
To: "Barbier, Renaud" <renaud.barbier@abaco.com>,
	"barebox@lists.infradead.org" <barebox@lists.infradead.org>
Subject: Re: gpio generic driver
Date: Fri, 24 Jul 2020 10:20:16 +0200	[thread overview]
Message-ID: <795d7b96dea1b9f6ab60020f9725c185d9f0822c.camel@pengutronix.de> (raw)
In-Reply-To: <MN2PR16MB313535B92C50776EC02EBD6191760@MN2PR16MB3135.namprd16.prod.outlook.com>

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

  reply	other threads:[~2020-07-24  8:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-23 19:51 Barbier, Renaud
2020-07-24  8:20 ` Lucas Stach [this message]
2020-07-24  8:40   ` Barbier, Renaud

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=795d7b96dea1b9f6ab60020f9725c185d9f0822c.camel@pengutronix.de \
    --to=l.stach@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=renaud.barbier@abaco.com \
    /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