diff --git a/arch/arm/src/imx6/imx_gpio.c b/arch/arm/src/imx6/imx_gpio.c index a37879e823..9e163fc1f0 100644 --- a/arch/arm/src/imx6/imx_gpio.c +++ b/arch/arm/src/imx6/imx_gpio.c @@ -48,6 +48,8 @@ * Private Data ****************************************************************************/ +static spinlock_t g_imx_gpio_lock = SP_UNLOCKED; + static const uint8_t g_gpio1_padmux[IMX_GPIO_NPINS] = { IMX_PADMUX_GPIO00_INDEX, /* GPIO1 Pin 0 */ @@ -515,7 +517,7 @@ int imx_config_gpio(gpio_pinset_t pinset) /* Configure the pin as an input initially to avoid any spurious outputs */ - flags = spin_lock_irqsave(NULL); + flags = spin_lock_irqsave(&g_imx_gpio_lock); /* Configure based upon the pin mode */ @@ -558,7 +560,7 @@ int imx_config_gpio(gpio_pinset_t pinset) break; } - spin_unlock_irqrestore(NULL, flags); + spin_unlock_irqrestore(&g_imx_gpio_lock, flags); return ret; } @@ -576,9 +578,9 @@ void imx_gpio_write(gpio_pinset_t pinset, bool value) int port = (pinset & GPIO_PORT_MASK) >> GPIO_PORT_SHIFT; int pin = (pinset & GPIO_PIN_MASK) >> GPIO_PIN_SHIFT; - flags = enter_critical_section(); + flags = spin_lock_irqsave(&g_imx_gpio_lock); imx_gpio_setoutput(port, pin, value); - leave_critical_section(flags); + spin_unlock_irqrestore(&g_imx_gpio_lock, flags); } /**************************************************************************** @@ -596,8 +598,8 @@ bool imx_gpio_read(gpio_pinset_t pinset) int pin = (pinset & GPIO_PIN_MASK) >> GPIO_PIN_SHIFT; bool value; - flags = enter_critical_section(); + flags = spin_lock_irqsave(&g_imx_gpio_lock); value = imx_gpio_getinput(port, pin); - leave_critical_section(flags); + spin_unlock_irqrestore(&g_imx_gpio_lock, flags); return value; }