[PATCH 6.18 408/752] net: phy: qcom: qca807x: normalize return value of gpio_get

Sasha Levin
2026-02-28T17:53:50Z

From: Dmitry Torokhov <dmitry.torokhov@gmail.com>

[ Upstream commit 2bb995e6155cb4f254574598cbd6fe1dcc99766a ]

The GPIO get callback is expected to return 0 or 1 (or a negative error
code). Ensure that the value returned by qca807x_gpio_get() is
normalized to the [0, 1] range.

Fixes: 86ef402d805d ("gpiolib: sanitize the return value of gpio_chip::get()")
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Link: https://patch.msgid.link/aZZeyr2ysqqk2GqA@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/phy/qcom/qca807x.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/phy/qcom/qca807x.c b/drivers/net/phy/qcom/qca807x.c
index 1be8295a95cb5..511cde345e089 100644
--- a/drivers/net/phy/qcom/qca807x.c
+++ b/drivers/net/phy/qcom/qca807x.c
@@ -375,7 +375,7 @@ static int qca807x_gpio_get(struct gpio_chip *gc, unsigned int offset)
reg = QCA807X_MMD7_LED_FORCE_CTRL(offset);
val = phy_read_mmd(priv->phy, MDIO_MMD_AN, reg);

- return FIELD_GET(QCA807X_GPIO_FORCE_MODE_MASK, val);
+ return !!FIELD_GET(QCA807X_GPIO_FORCE_MODE_MASK, val);
}

static int qca807x_gpio_set(struct gpio_chip *gc, unsigned int offset, int value)
--
2.51.0