Thread (8 messages) 8 messages, 4 authors, 2014-03-05

Re: [PATCH] gpio: clamp returned values to the boolean range

From: Alexandre Courbot <hidden>
Date: 2014-03-05 02:14:48
Also in: lkml

On Wed, Mar 5, 2014 at 11:04 AM, Joe Perches [off-list ref] wrote:
On Wed, 2014-03-05 at 09:49 +0800, Linus Walleij wrote:
quoted
On Wed, Feb 26, 2014 at 9:40 AM, Alexandre Courbot [off-list ref] wrote:
quoted
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. So in the end it is probably safer to perform this
change the way Linus suggested.

Alex.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help