gpio: generic: clamp values from bgpio_get_set()

The bgpio_get_set() call should return a value clamped to [0,1],
the current code will return a negative value if reading
bit 31, which turns the value negative as this is a signed value
and thus gets interpreted as an error by the gpiolib core.
Found on the gpio-mxc but applies to any MMIO driver.

Cc: # 4.3+
Cc: Vladimir Zapolskiy <>
Fixes:  e20538b82f1f ("gpio: Propagate errors from chip->get()")
Reported-by: Clemens Gruber <>
Signed-off-by: Linus Walleij <>
1 file changed