aboutsummaryrefslogtreecommitdiff
path: root/drivers/gpio
diff options
context:
space:
mode:
authorPatrick Delaunay2020-01-13 11:35:03 +0100
committerTom Rini2020-04-16 23:06:54 -0400
commit788ea834124bd6169ea10b2d37d5de48a2dd28a0 (patch)
treef08ff1284d19e53a4d7b7fb4e9393135ce0faa06 /drivers/gpio
parent8a9140cd38c5571fc23d1e7b293ca22325d41afc (diff)
gpio: add function _dm_gpio_set_dir_flags
Introduce the function _dm_gpio_set_dir_flags to set dir flags without check if the GPIO is reserved. Separate the reserved check for "set_dir" and "set_dir_flags". This patch is a preliminary step to add new ops. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/gpio-uclass.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index 5c82a4a7dbf..3b505d070a9 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -510,15 +510,11 @@ int dm_gpio_set_value(const struct gpio_desc *desc, int value)
return 0;
}
-int dm_gpio_set_dir_flags(struct gpio_desc *desc, ulong flags)
+static int _dm_gpio_set_dir_flags(struct gpio_desc *desc, ulong flags)
{
struct udevice *dev = desc->dev;
struct dm_gpio_ops *ops = gpio_get_ops(dev);
- int ret;
-
- ret = check_reserved(desc, "set_dir");
- if (ret)
- return ret;
+ int ret = 0;
if (flags & GPIOD_IS_OUT) {
int value = flags & GPIOD_IS_OUT_ACTIVE ? 1 : 0;
@@ -529,20 +525,36 @@ int dm_gpio_set_dir_flags(struct gpio_desc *desc, ulong flags)
} else if (flags & GPIOD_IS_IN) {
ret = ops->direction_input(dev, desc->offset);
}
+
+ return ret;
+}
+
+int dm_gpio_set_dir_flags(struct gpio_desc *desc, ulong flags)
+{
+ int ret;
+
+ ret = check_reserved(desc, "set_dir_flags");
if (ret)
return ret;
- /*
- * Update desc->flags here, so that GPIO_ACTIVE_LOW is honoured in
- * futures
- */
- desc->flags = flags;
- return 0;
+ ret = _dm_gpio_set_dir_flags(desc, flags);
+
+ /* update the descriptor flags */
+ if (ret)
+ desc->flags = flags;
+
+ return ret;
}
int dm_gpio_set_dir(struct gpio_desc *desc)
{
- return dm_gpio_set_dir_flags(desc, desc->flags);
+ int ret;
+
+ ret = check_reserved(desc, "set_dir");
+ if (ret)
+ return ret;
+
+ return _dm_gpio_set_dir_flags(desc, desc->flags);
}
/**