From: Alexandre Courbot <gnurou@gmail.com>
To: Joe Perches <joe@perches.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
Alexandre Courbot <acourbot@nvidia.com>,
"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] gpio: clamp returned values to the boolean range
Date: Wed, 5 Mar 2014 11:22:30 +0900 [thread overview]
Message-ID: <CAAVeFuKwLJ5-Q1_u4e_o6tp1F-AKaVQG0ph1GdqjBqFiMCQvPQ@mail.gmail.com> (raw)
In-Reply-To: <1393985959.3271.25.camel@joe-AO722>
On Wed, Mar 5, 2014 at 11:19 AM, Joe Perches <joe@perches.com> wrote:
> On Wed, 2014-03-05 at 11:14 +0900, Alexandre Courbot wrote:
>> On Wed, Mar 5, 2014 at 11:04 AM, Joe Perches <joe@perches.com> wrote:
>> > On Wed, 2014-03-05 at 09:49 +0800, Linus Walleij wrote:
>> >> On Wed, Feb 26, 2014 at 9:40 AM, Alexandre Courbot <acourbot@nvidia.com> wrote:
>> >>
>> >> > Nothing prevents GPIO drivers from returning values outside the
>> >> > boolean range, and as it turns out a few drivers are actually doing so.
>> >> > These values were passed as-is to unsuspecting consumers and created
>> >> > confusion.
>> >> >
>> >> > This patch makes the internal _gpiod_get_raw_value() function return a
>> >> > bool, effectively clamping the GPIO value to the boolean range no
>> >> > matter what the driver does.
>> >>
>> >> No, that will not be the semantic effect of this patch, bool is just
>> >> another name for an int, maybe some static checkers will be able
>> >> to use it however.
>> >
>> > No, a bool is not an int.
>> >
>> > It's really different.
>> > include/linux/types.h:typedef _Bool bool;
>>
>> It indeed seems that _Bool is an actual boolean type in C99. However I
>> could not find in the C99 standard how ints are supposed to be
>> converted to it.
>
> 6.3.1.2 Boolean type
>
> When any scalar value is converted to _Bool, the result is 0 if the
> value compares equal to 0; otherwise, the result is 1.
>
>> So in the end it is probably safer to perform this
>> change the way Linus suggested.
>
> Not really.
Ok, you are obviously correct here. Linus, what do you think?
next prev parent reply other threads:[~2014-03-05 2:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-26 1:40 [PATCH] gpio: clamp returned values to the boolean range Alexandre Courbot
2014-03-05 1:49 ` Linus Walleij
2014-03-05 2:04 ` Joe Perches
2014-03-05 2:14 ` Alexandre Courbot
2014-03-05 2:19 ` Joe Perches
2014-03-05 2:22 ` Alexandre Courbot [this message]
2014-03-05 2:33 ` Linus Walleij
2014-03-05 3:09 ` Joe Perches
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=CAAVeFuKwLJ5-Q1_u4e_o6tp1F-AKaVQG0ph1GdqjBqFiMCQvPQ@mail.gmail.com \
--to=gnurou@gmail.com \
--cc=acourbot@nvidia.com \
--cc=joe@perches.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).