diff mbox series

[07/13] gpio: msm_gpio: add .set_flags op

Message ID 20240131-b4-qcom-livetree-v1-7-4071c0787db0@linaro.org
State New
Headers show
Series Qualcomm platform USB support | expand

Commit Message

Caleb Connolly Jan. 31, 2024, 3:16 p.m. UTC
The .direction_input and .direction_output ops are deprecated, and don't
seem to behave properly for us. Implement our own .set_flags op to
handle this correctly.

Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
---
 drivers/gpio/msm_gpio.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

Comments

Dan Carpenter Jan. 31, 2024, 3:35 p.m. UTC | #1
On Wed, Jan 31, 2024 at 03:16:59PM +0000, Caleb Connolly wrote:
> diff --git a/drivers/gpio/msm_gpio.c b/drivers/gpio/msm_gpio.c
> index 80cd28bb231f..0230305af299 100644
> --- a/drivers/gpio/msm_gpio.c
> +++ b/drivers/gpio/msm_gpio.c
> @@ -72,6 +72,23 @@ static int msm_gpio_direction_output(struct udevice *dev, unsigned int gpio,
>  	return 0;
>  }
>  
> +static int msm_gpio_set_flags(struct udevice *dev, unsigned int gpio, ulong flags)
> +{
> +	if (flags & GPIOD_IS_OUT_ACTIVE) {
> +		return msm_gpio_direction_output(dev, gpio, 1);
> +	} else if (flags & GPIOD_IS_OUT) {
> +		return msm_gpio_direction_output(dev, gpio, 0);
> +	} else if (flags & GPIOD_IS_IN) {
> +		return msm_gpio_direction_input(dev, gpio);
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

> +		if (flags & GPIOD_PULL_UP)
> +			return msm_gpio_set_value(dev, gpio, 1);
> +		else if (flags & GPIOD_PULL_DOWN)
> +			return msm_gpio_set_value(dev, gpio, 0);

These lines are unreachable code.

> +	}
> +
> +	return 0;
> +}

regards,
dan carpenter
diff mbox series

Patch

diff --git a/drivers/gpio/msm_gpio.c b/drivers/gpio/msm_gpio.c
index 80cd28bb231f..0230305af299 100644
--- a/drivers/gpio/msm_gpio.c
+++ b/drivers/gpio/msm_gpio.c
@@ -72,6 +72,23 @@  static int msm_gpio_direction_output(struct udevice *dev, unsigned int gpio,
 	return 0;
 }
 
+static int msm_gpio_set_flags(struct udevice *dev, unsigned int gpio, ulong flags)
+{
+	if (flags & GPIOD_IS_OUT_ACTIVE) {
+		return msm_gpio_direction_output(dev, gpio, 1);
+	} else if (flags & GPIOD_IS_OUT) {
+		return msm_gpio_direction_output(dev, gpio, 0);
+	} else if (flags & GPIOD_IS_IN) {
+		return msm_gpio_direction_input(dev, gpio);
+		if (flags & GPIOD_PULL_UP)
+			return msm_gpio_set_value(dev, gpio, 1);
+		else if (flags & GPIOD_PULL_DOWN)
+			return msm_gpio_set_value(dev, gpio, 0);
+	}
+
+	return 0;
+}
+
 static int msm_gpio_get_value(struct udevice *dev, unsigned int gpio)
 {
 	struct msm_gpio_bank *priv = dev_get_priv(dev);
@@ -90,10 +107,8 @@  static int msm_gpio_get_function(struct udevice *dev, unsigned int gpio)
 }
 
 static const struct dm_gpio_ops gpio_msm_ops = {
-	.direction_input	= msm_gpio_direction_input,
-	.direction_output	= msm_gpio_direction_output,
+	.set_flags		= msm_gpio_set_flags,
 	.get_value		= msm_gpio_get_value,
-	.set_value		= msm_gpio_set_value,
 	.get_function		= msm_gpio_get_function,
 };