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: stable@vger.kernel.org # 4.3+
Cc: kernel@pengutronix.de
Cc: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Fixes: e20538b82f1f ("gpio: Propagate errors from chip->get()")
Reported-by: Clemens Gruber <clemens.gruber@pqgruber.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

+2 -2
+2 -2
drivers/gpio/gpio-generic.c
··· 141 unsigned long pinmask = bgc->pin2mask(bgc, gpio); 142 143 if (bgc->dir & pinmask) 144 - return bgc->read_reg(bgc->reg_set) & pinmask; 145 else 146 - return bgc->read_reg(bgc->reg_dat) & pinmask; 147 } 148 149 static int bgpio_get(struct gpio_chip *gc, unsigned int gpio)
··· 141 unsigned long pinmask = bgc->pin2mask(bgc, gpio); 142 143 if (bgc->dir & pinmask) 144 + return !!(bgc->read_reg(bgc->reg_set) & pinmask); 145 else 146 + return !!(bgc->read_reg(bgc->reg_dat) & pinmask); 147 } 148 149 static int bgpio_get(struct gpio_chip *gc, unsigned int gpio)