[PATCH net v2] net: phy: qcom: qca807x: normalize return value of gpio_get

Dmitry Torokhov posted 1 patch 1 month, 1 week ago
drivers/net/phy/qcom/qca807x.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH net v2] net: phy: qcom: qca807x: normalize return value of gpio_get
Posted by Dmitry Torokhov 1 month, 1 week ago
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>
---

v2: add correct netdev tree prefix and "fixes" tag.

 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 d8f1ce5a7128..6004da5741af 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.53.0.335.g19a08e0c02-goog


-- 
Dmitry
Re: [PATCH net v2] net: phy: qcom: qca807x: normalize return value of gpio_get
Posted by Linus Walleij 1 month, 1 week ago
On Thu, Feb 19, 2026 at 1:56 AM Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:

> 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: Linus Walleij <linusw@kernel.org>

Yours,
Linus Walleij
Re: [PATCH net v2] net: phy: qcom: qca807x: normalize return value of gpio_get
Posted by Bartosz Golaszewski 1 month, 1 week ago
On Thu, 19 Feb 2026 01:56:00 +0100, Dmitry Torokhov
<dmitry.torokhov@gmail.com> said:
> 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>
> ---
>
> v2: add correct netdev tree prefix and "fixes" tag.
>
>  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 d8f1ce5a7128..6004da5741af 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.53.0.335.g19a08e0c02-goog
>
>
> --
> Dmitry
>

Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>