diff mbox series

dm: gpio: Return error when pull up/down is requested but set_flags ops is not implmentated

Message ID 20241021150451.1858427-1-admin@hifiphile.com
State New
Delegated to: Tom Rini
Headers show
Series dm: gpio: Return error when pull up/down is requested but set_flags ops is not implmentated | expand

Commit Message

Zixun LI Oct. 21, 2024, 3:04 p.m. UTC
Currently in _dm_gpio_set_flags() when set_flags ops is not implemented
direction_output()/_input() is used, but pull up/down is not supported by
these ops.

Signed-off-by: Zixun LI <admin@hifiphile.com>
---
We have updated our AT91 BSP to use DM, on field testing few boards
went into a failed state due to gpio pullup is not enabled. A floating
gpio doesn't always fail and can sometimes be hard to diagostic.
---
 drivers/gpio/gpio-uclass.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index 712119c341..a58513c946 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -661,6 +661,9 @@  static int _dm_gpio_set_flags(struct gpio_desc *desc, ulong flags)
 	if (ops->set_flags) {
 		ret = ops->set_flags(dev, desc->offset, flags);
 	} else {
+		if (flags & GPIOD_MASK_PULL)
+			return -EINVAL;
+
 		if (flags & GPIOD_IS_OUT) {
 			bool value = flags & GPIOD_IS_OUT_ACTIVE;