From 7989f5cd6b2a88d79cc16ff27e881c0e917a7626 Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Mon, 23 Sep 2019 17:47:31 -0500 Subject: [PATCH] drivers: gpio_mcux: Fix interrupt handling Change when we clear interrupt status to happen before we handle the callbacks. As the callbacks might manipluate the GPIO state and cause a GPIO interrupt. If we clear interrupt status after than we might miss an interrupt. Also only clear interrupts for interrupts that are we have enabled and that were reported when we read from the interrupt status. Signed-off-by: Kumar Gala --- drivers/gpio/gpio_mcux.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpio/gpio_mcux.c b/drivers/gpio/gpio_mcux.c index 8d6ab367b75..cd18c81af61 100644 --- a/drivers/gpio/gpio_mcux.c +++ b/drivers/gpio/gpio_mcux.c @@ -348,10 +348,10 @@ static void gpio_mcux_port_isr(void *arg) int_status = config->port_base->ISFR; enabled_int = int_status & data->pin_callback_enables; - gpio_fire_callbacks(&data->callbacks, dev, enabled_int); - /* Clear the port interrupts */ - config->port_base->ISFR = 0xFFFFFFFF; + config->port_base->ISFR = enabled_int; + + gpio_fire_callbacks(&data->callbacks, dev, enabled_int); }