From 33cf10b5b84755d372b9c59a12e8a8d29b87ead9 Mon Sep 17 00:00:00 2001 From: Peter Bigot Date: Wed, 2 Oct 2019 11:40:28 -0500 Subject: [PATCH] gpio: unify assert checks for pin and interrupt configuration gpio_pin_interrupt_configure() verified that the pin was within range, while gpio_pin_configure() did not. Make them consistent since they take the same set of flags. Signed-off-by: Peter Bigot --- include/drivers/gpio.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/drivers/gpio.h b/include/drivers/gpio.h index 98ce7b344c6..c8004c460b7 100644 --- a/include/drivers/gpio.h +++ b/include/drivers/gpio.h @@ -660,6 +660,8 @@ static inline int gpio_pin_configure(struct device *port, u32_t pin, (struct gpio_driver_data *)port->driver_data; int ret; + __ASSERT(pin < GPIO_MAX_PINS_PER_PORT, "Invalid pin number"); + __ASSERT((flags & (GPIO_PULL_UP | GPIO_PULL_DOWN)) != (GPIO_PULL_UP | GPIO_PULL_DOWN), "Pull Up and Pull Down should not be enabled simultaneously");