From 209fcf625880cd1128bc98ca835d4cb5c3b8e136 Mon Sep 17 00:00:00 2001 From: Ridham Khurana Date: Tue, 22 Sep 2026 21:16:58 +0000 Subject: [PATCH] gpio: siox: normalize return value of gpio_get() gpio_siox_get() returns the masked bit from the cached input or output byte, so for most lines a high level reads back as a value between 2 and 128 instead of 1. The GPIO get callback is expected to return 0 or 1 (or a negative error code). Since commit 86ef402d805d ("gpiolib: sanitize the return value of gpio_chip::get()"), gpiolib rejected such values with -EBADE and reads of a high line failed. Commit ec2cceadfae7 ("gpiolib: normalize the return value of gc->get() on behalf of buggy drivers") made gpiolib clamp the value instead, but it now warns on every such read. Normalize the value returned by gpio_siox_get() to the [0, 1] range. Signed-off-by: Ridham Khurana Link: https://patch.msgid.link/20260922211702.1480614-1-khurana.ridham222@gmail.com Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpio-siox.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpio-siox.c b/drivers/gpio/gpio-siox.c index 958034b9f3f3..d60680ace144 100644 --- a/drivers/gpio/gpio-siox.c +++ b/drivers/gpio/gpio-siox.c @@ -148,11 +148,11 @@ static int gpio_siox_get(struct gpio_chip *chip, unsigned int offset) if (offset >= 12) { unsigned int bitpos = 19 - offset; - ret = ddata->setdata[0] & (1 << bitpos); + ret = !!(ddata->setdata[0] & (1 << bitpos)); } else { unsigned int bitpos = 11 - offset; - ret = ddata->getdata[bitpos / 8] & (1 << (bitpos % 8)); + ret = !!(ddata->getdata[bitpos / 8] & (1 << (bitpos % 8))); } mutex_unlock(&ddata->lock);