From 2befa6a251614a60fb14ff6bd7cd39f4ed3de2af Mon Sep 17 00:00:00 2001 From: Peter Bigot Date: Tue, 28 Jan 2020 10:02:25 -0600 Subject: [PATCH] gpio: deprecate legacy gpio pin read/write functions These have been replaced by get/set functions in both raw and active-sensitive variants. Signed-off-by: Peter Bigot --- drivers/gpio/gpio_handlers.c | 18 ---------- include/drivers/gpio.h | 66 ++++++++++++------------------------ 2 files changed, 21 insertions(+), 63 deletions(-) diff --git a/drivers/gpio/gpio_handlers.c b/drivers/gpio/gpio_handlers.c index 1e945b6127f..24687e55e8e 100644 --- a/drivers/gpio/gpio_handlers.c +++ b/drivers/gpio/gpio_handlers.c @@ -15,24 +15,6 @@ static inline int z_vrfy_gpio_config(struct device *port, int access_op, } #include -static inline int z_vrfy_gpio_write(struct device *port, int access_op, - u32_t pin, u32_t value) -{ - Z_OOPS(Z_SYSCALL_DRIVER_GPIO(port, write)); - return z_impl_gpio_write((struct device *)port, access_op, pin, value); -} -#include - -static inline int z_vrfy_gpio_read(struct device *port, int access_op, - u32_t pin, u32_t *value) -{ - Z_OOPS(Z_SYSCALL_DRIVER_GPIO(port, read)); - Z_OOPS(Z_SYSCALL_MEMORY_WRITE(value, sizeof(u32_t))); - return z_impl_gpio_read((struct device *)port, access_op, pin, - (u32_t *)value); -} -#include - static inline int z_vrfy_gpio_port_get_raw(struct device *port, gpio_port_value_t *value) { diff --git a/include/drivers/gpio.h b/include/drivers/gpio.h index 07d6224a67b..7eefb06853f 100644 --- a/include/drivers/gpio.h +++ b/include/drivers/gpio.h @@ -569,30 +569,6 @@ static inline int z_impl_gpio_config(struct device *port, int access_op, return api->config(port, access_op, pin, (int)flags); } -__syscall int gpio_write(struct device *port, int access_op, u32_t pin, - u32_t value); - -static inline int z_impl_gpio_write(struct device *port, int access_op, - u32_t pin, u32_t value) -{ - const struct gpio_driver_api *api = - (const struct gpio_driver_api *)port->driver_api; - - return api->write(port, access_op, pin, value); -} - -__syscall int gpio_read(struct device *port, int access_op, u32_t pin, - u32_t *value); - -static inline int z_impl_gpio_read(struct device *port, int access_op, - u32_t pin, u32_t *value) -{ - const struct gpio_driver_api *api = - (const struct gpio_driver_api *)port->driver_api; - - return api->read(port, access_op, pin, value); -} - __syscall int gpio_enable_callback(struct device *port, int access_op, u32_t pin); @@ -1217,19 +1193,16 @@ static inline int gpio_pin_toggle(struct device *port, unsigned int pin) * @param value Value set on the pin. * @return 0 if successful, negative errno code on failure. * - * @deprecated Replace with gpio_pin_set_raw() or gpio_pin_set(). + * @deprecated Replace with gpio_pin_set assuming active level is + * handled correctly. gpio_pin_set_raw() may be more correct for some + * drivers. */ -static inline int gpio_pin_write(struct device *port, u32_t pin, - u32_t value) +/* Deprecated in 2.2 release */ +__deprecated static inline int gpio_pin_write(struct device *port, + gpio_pin_t pin, + u32_t value) { - const struct gpio_driver_config *const cfg = - (const struct gpio_driver_config *)port->config->config_info; - - (void)cfg; - __ASSERT((cfg->port_pin_mask & (gpio_port_pins_t)BIT(pin)) != 0U, - "Unsupported pin"); - - return gpio_write(port, GPIO_ACCESS_BY_PIN, pin, value); + return gpio_pin_set(port, pin, value != 0); } /** @@ -1242,19 +1215,22 @@ static inline int gpio_pin_write(struct device *port, u32_t pin, * @param value Integer pointer to receive the data values from the pin. * @return 0 if successful, negative errno code on failure. * - * @deprecated Replace with gpio_pin_get_raw() or gpio_pin_get(). + * @deprecated Replace with gpio_pin_get() assuming active level is + * handled correctly. gpio_pin_get_raw() may be more correct for some + * drivers. */ -static inline int gpio_pin_read(struct device *port, u32_t pin, - u32_t *value) +/* Deprecated in 2.2 release */ +__deprecated static inline int gpio_pin_read(struct device *port, + gpio_pin_t pin, + u32_t *value) { - const struct gpio_driver_config *const cfg = - (const struct gpio_driver_config *)port->config->config_info; + int rv = gpio_pin_get(port, pin); - (void)cfg; - __ASSERT((cfg->port_pin_mask & (gpio_port_pins_t)BIT(pin)) != 0U, - "Unsupported pin"); - - return gpio_read(port, GPIO_ACCESS_BY_PIN, pin, value); + if (rv >= 0) { + *value = rv; + rv = 0; + } + return rv; } /**