[PATCH 2/2] gpio: msm: return correct value return for special output pins

Neil Armstrong neil.armstrong at linaro.org
Tue Apr 1 09:45:20 CEST 2025


When a special pin is output only, the current code would return 0,
but if the pin is output only we can get the output value.

Try to return the output value and in all the other cases return
an error instead of 0.

Fixes: f9bb539460d ("gpio: msm: add support for special pins")
Signed-off-by: Neil Armstrong <neil.armstrong at linaro.org>
---
 drivers/gpio/msm_gpio.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/msm_gpio.c b/drivers/gpio/msm_gpio.c
index f208eec7e56170a9a79f8f021ceec85b7da0ed81..54afd44fbd3c53ccbe2c6c46ac1c9cf7bb0f7107 100644
--- a/drivers/gpio/msm_gpio.c
+++ b/drivers/gpio/msm_gpio.c
@@ -172,12 +172,19 @@ static int msm_gpio_get_value_special(struct msm_gpio_bank *priv, unsigned int g
 	const struct msm_special_pin_data *data;
 
 	if (!priv->pin_data->special_pins_data)
-		return 0;
+		return -EINVAL;
 
 	data = &priv->pin_data->special_pins_data[offset];
 
-	if (!data->io_reg || data->in_bit >= 31)
-		return 0;
+	if (!data->io_reg)
+		return -EINVAL;
+
+	if (data->in_bit >= 31) {
+		if (data->out_bit >= 31)
+			return -EINVAL;
+
+		return !!(readl(priv->base + data->io_reg) >> data->out_bit);
+	}
 
 	return !!(readl(priv->base + data->io_reg) >> data->in_bit);
 }

-- 
2.34.1



More information about the U-Boot mailing list