提交 9360bb06 编写于 作者: P Patrick Delaunay 提交者: Tom Rini

gpio: add helper GPIOD_FLAGS_OUTPUT

Add a macro to provide the GPIO output value according
the dir flags content.
Signed-off-by: NPatrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: NSimon Glass <sjg@chromium.org>
上级 4292fb16
......@@ -542,12 +542,9 @@ static int _dm_gpio_set_dir_flags(struct gpio_desc *desc, ulong flags)
}
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);
}
......
......@@ -129,6 +129,12 @@ struct gpio_desc {
*/
};
/* helper to compute the value of the gpio output */
#define GPIOD_FLAGS_OUTPUT_MASK (GPIOD_ACTIVE_LOW | GPIOD_IS_OUT_ACTIVE)
#define GPIOD_FLAGS_OUTPUT(flags) \
(((((flags) & GPIOD_FLAGS_OUTPUT_MASK) == GPIOD_IS_OUT_ACTIVE) || \
(((flags) & GPIOD_FLAGS_OUTPUT_MASK) == GPIOD_ACTIVE_LOW)))
/**
* dm_gpio_is_valid() - Check if a GPIO is valid
*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册