From 3632815e2e124c0c4b1ed09cd91f60ecbd2fda83 Mon Sep 17 00:00:00 2001 From: Piotr Mienkowski Date: Fri, 30 Apr 2021 23:43:35 +0200 Subject: [PATCH] api: gpio: do not support INT flags in gpio_pin_configure To keep compatibility between the old GPIO API implementation and a new one introduced in the Zephyr 2.2.0 release the gpio_pin_configure() function was accepting interrupt flags. In the new API implementation interrupt flags are only accepted by gpio_pin_interrupt_configure() function. This temporary support for INT flags in gpio_pin_configure should have been removed in the Zephyr 2.4.0 release. Signed-off-by: Piotr Mienkowski --- doc/releases/release-notes-2.6.rst | 4 +++ drivers/gpio/gpio_handlers.c | 11 +++++--- include/drivers/gpio.h | 45 ++++++++++++------------------ 3 files changed, 29 insertions(+), 31 deletions(-) diff --git a/doc/releases/release-notes-2.6.rst b/doc/releases/release-notes-2.6.rst index 757855d4535..97a63757356 100644 --- a/doc/releases/release-notes-2.6.rst +++ b/doc/releases/release-notes-2.6.rst @@ -247,6 +247,10 @@ Drivers and Sensors :c:macro:`GPIO_DT_SPEC_INST_GET`, and :c:macro:`GPIO_DT_SPEC_INST_GET_OR` * New helper functions for using ``gpio_dt_spec`` values: :c:func:`gpio_pin_configure_dt`, :c:func:`gpio_pin_interrupt_configure_dt` + * Remove support for ``GPIO_INT_*`` flags in :c:func:`gpio_pin_configure()`. + The feature has been deprecated in the Zephyr 2.2 release. The interrupt + flags are now accepted by :c:func:`gpio_pin_interrupt_configure()` + function only. * Hardware Info diff --git a/drivers/gpio/gpio_handlers.c b/drivers/gpio/gpio_handlers.c index 0a835165e26..62fb8f5fc9d 100644 --- a/drivers/gpio/gpio_handlers.c +++ b/drivers/gpio/gpio_handlers.c @@ -7,13 +7,16 @@ #include #include -static inline int z_vrfy_gpio_config(const struct device *port, - gpio_pin_t pin, gpio_flags_t flags) +static inline int z_vrfy_gpio_pin_configure(const struct device *port, + gpio_pin_t pin, + gpio_flags_t flags) { Z_OOPS(Z_SYSCALL_DRIVER_GPIO(port, pin_configure)); - return z_impl_gpio_config((const struct device *)port, pin, flags); + return z_impl_gpio_pin_configure((const struct device *)port, + pin, + flags); } -#include +#include static inline int z_vrfy_gpio_port_get_raw(const struct device *port, gpio_port_value_t *value) diff --git a/include/drivers/gpio.h b/include/drivers/gpio.h index c85c9bc2f90..021a4e5e018 100644 --- a/include/drivers/gpio.h +++ b/include/drivers/gpio.h @@ -127,6 +127,13 @@ extern "C" { */ #define GPIO_INT_HIGH_1 (1U << 18) +#define GPIO_INT_MASK (GPIO_INT_DISABLE | \ + GPIO_INT_ENABLE | \ + GPIO_INT_LEVELS_LOGICAL | \ + GPIO_INT_EDGE | \ + GPIO_INT_LOW_0 | \ + GPIO_INT_HIGH_1) + /** @endcond */ /** Configures GPIO interrupt to be triggered on pin rising edge and enables it. @@ -583,18 +590,6 @@ __subsystem struct gpio_driver_api { uint32_t (*get_pending_int)(const struct device *dev); }; -__syscall int gpio_config(const struct device *port, gpio_pin_t pin, - gpio_flags_t flags); - -static inline int z_impl_gpio_config(const struct device *port, - gpio_pin_t pin, gpio_flags_t flags) -{ - const struct gpio_driver_api *api = - (const struct gpio_driver_api *)port->api; - - return api->pin_configure(port, pin, flags); -} - /** * @endcond */ @@ -708,9 +703,13 @@ static inline int gpio_pin_interrupt_configure_dt(const struct gpio_dt_spec *spe * @retval -EIO I/O error when accessing an external GPIO chip. * @retval -EWOULDBLOCK if operation would block. */ -static inline int gpio_pin_configure(const struct device *port, - gpio_pin_t pin, - gpio_flags_t flags) +__syscall int gpio_pin_configure(const struct device *port, + gpio_pin_t pin, + gpio_flags_t flags); + +static inline int z_impl_gpio_pin_configure(const struct device *port, + gpio_pin_t pin, + gpio_flags_t flags) { const struct gpio_driver_api *api = (const struct gpio_driver_api *)port->api; @@ -718,7 +717,9 @@ static inline int gpio_pin_configure(const struct device *port, (const struct gpio_driver_config *)port->config; struct gpio_driver_data *data = (struct gpio_driver_data *)port->data; - int ret; + + __ASSERT((flags & GPIO_INT_MASK) == 0, + "Interrupt flags are not supported"); __ASSERT((flags & (GPIO_PULL_UP | GPIO_PULL_DOWN)) != (GPIO_PULL_UP | GPIO_PULL_DOWN), @@ -751,23 +752,13 @@ static inline int gpio_pin_configure(const struct device *port, __ASSERT((cfg->port_pin_mask & (gpio_port_pins_t)BIT(pin)) != 0U, "Unsupported pin"); - ret = gpio_config(port, pin, flags); - if (ret != 0) { - return ret; - } - if ((flags & GPIO_ACTIVE_LOW) != 0) { data->invert |= (gpio_port_pins_t)BIT(pin); } else { data->invert &= ~(gpio_port_pins_t)BIT(pin); } - if (((flags & (GPIO_INT_DISABLE | GPIO_INT_ENABLE)) != 0U) - && (api->pin_interrupt_configure != NULL)) { - flags &= ~GPIO_INT_DEBOUNCE; - ret = z_impl_gpio_pin_interrupt_configure(port, pin, flags); - } - return ret; + return api->pin_configure(port, pin, flags); } /**