gpio: add helper GPIOD_FLAGS_OUTPUT
Add a macro to provide the GPIO output value according
the dir flags content.
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index b5cebfd..29c8c0f 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -542,12 +542,9 @@
}
if (flags & GPIOD_IS_OUT) {
- int value = flags & GPIOD_IS_OUT_ACTIVE ? 1 : 0;
-
- if (flags & GPIOD_ACTIVE_LOW)
- value = !value;
- ret = ops->direction_output(dev, desc->offset, value);
- } else if (flags & GPIOD_IS_IN) {
+ ret = ops->direction_output(dev, desc->offset,
+ GPIOD_FLAGS_OUTPUT(flags));
+ } else if (flags & GPIOD_IS_IN) {
ret = ops->direction_input(dev, desc->offset);
}