mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sam Ravnborg <sam@ravnborg.org>
To: Andrey Smirnov <andrew.smirnov@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/9] gpiolib: Fix buggy flag detection code
Date: Mon, 24 Jul 2017 17:36:37 +0200	[thread overview]
Message-ID: <20170724153637.GA18294@ravnborg.org> (raw)
In-Reply-To: <20170724145400.2279-2-andrew.smirnov@gmail.com>

Hi Andrey.

On Mon, Jul 24, 2017 at 07:53:52AM -0700, Andrey Smirnov wrote:
> Both GPIOF_ACTIVE_LOW and GPIOF_INIT_ACTIVE are multi-bit constants so
> detecting their assertion using simple bit-wise and is incorrect and
> would lead to false positives.
> 
> Fixes: bbc499914 ("gpiolib: Add code to support "active low" GPIOs")
> 
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>

When looking at the resulting code there is now two ways to check
flags in gpiolib.
One where assume the flags are one bit values, and one where
we make sure to check the resuting value for > 1 bit values.
When revisitng this code in years from now this will look
inconsistent and only if you look up gpio.h you will see
why this is done in different ways.

I dunno if this should be consistent, but as I noted this when
reading the code I commented on this.

The use of "const bool" also baffeled me, but it makes
good sense to say that this bool value are not changed
after it is initialised.
And we use "const bool" in a few other places already.
This was just the first time I noticed.

So despite the comments:
Acked-by: Sam Ravnborg <sam@ravnborg.org>

	Sam


The two ways flags are tested:
> +	const bool active_low = (flags & GPIOF_ACTIVE_LOW) == GPIOF_ACTIVE_LOW;

>  	if (flags & GPIOF_DIR_IN) {

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

  reply	other threads:[~2017-07-24 15:43 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-24 14:53 [PATCH 0/9] i.MX7 SabreSD support Andrey Smirnov
2017-07-24 14:53 ` [PATCH 1/9] gpiolib: Fix buggy flag detection code Andrey Smirnov
2017-07-24 15:36   ` Sam Ravnborg [this message]
2017-07-24 19:30     ` Andrey Smirnov
2017-07-24 14:53 ` [PATCH 2/9] clk: i.MX7: Remove unused UART clocks array Andrey Smirnov
2017-07-24 14:53 ` [PATCH 3/9] ARM: i.MX: Import mx7d_pins.h from U-Boot Andrey Smirnov
2017-07-24 14:53 ` [PATCH 4/9] ARM: i.MX: Add mx7_setup_pad() Andrey Smirnov
2017-07-24 14:53 ` [PATCH 5/9] ARM: i.MX: Add imx7_uart_setup_ll() Andrey Smirnov
2017-07-24 14:53 ` [PATCH 6/9] ARM: i.MX: Add minimal imx7-ccm-regs.h Andrey Smirnov
2017-07-24 14:53 ` [PATCH 7/9] ARM: i.MX: Add ARCH_HAD_FEC_IMX to ARCH_IMX7 Andrey Smirnov
2017-07-24 14:53 ` [PATCH 8/9] ARM: i.MX: Import imx7-iomuxc-gpr.h from Linux kernel Andrey Smirnov
2017-07-24 14:54 ` [PATCH 9/9] ARM: i.MX: Add support for NXP i.MX7 SABRESD board Andrey Smirnov
2017-07-24 15:59   ` Sam Ravnborg
2017-07-24 19:20     ` Andrey Smirnov
2017-07-24 19:03   ` Stefan Lengfeld
2017-07-24 19:23     ` Andrey Smirnov
2017-07-24 16:01 ` [PATCH 0/9] i.MX7 SabreSD support Sam Ravnborg
2017-07-24 19:29   ` Andrey Smirnov

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=20170724153637.GA18294@ravnborg.org \
    --to=sam@ravnborg.org \
    --cc=andrew.smirnov@gmail.com \
    --cc=barebox@lists.infradead.org \
    /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