imx_gpio: use small lock in arch/arm/src/imx6/imx_gpio.c

reason:
We would like to replace the big lock with a small lock.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
This commit is contained in:
hujun5 2024-12-18 17:12:51 +08:00 committed by Xiang Xiao
parent 58e232863d
commit 826aa4f732

View file

@ -48,6 +48,8 @@
* Private Data * Private Data
****************************************************************************/ ****************************************************************************/
static spinlock_t g_imx_gpio_lock = SP_UNLOCKED;
static const uint8_t g_gpio1_padmux[IMX_GPIO_NPINS] = static const uint8_t g_gpio1_padmux[IMX_GPIO_NPINS] =
{ {
IMX_PADMUX_GPIO00_INDEX, /* GPIO1 Pin 0 */ 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 */ /* 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 */ /* Configure based upon the pin mode */
@ -558,7 +560,7 @@ int imx_config_gpio(gpio_pinset_t pinset)
break; break;
} }
spin_unlock_irqrestore(NULL, flags); spin_unlock_irqrestore(&g_imx_gpio_lock, flags);
return ret; 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 port = (pinset & GPIO_PORT_MASK) >> GPIO_PORT_SHIFT;
int pin = (pinset & GPIO_PIN_MASK) >> GPIO_PIN_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); 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; int pin = (pinset & GPIO_PIN_MASK) >> GPIO_PIN_SHIFT;
bool value; bool value;
flags = enter_critical_section(); flags = spin_lock_irqsave(&g_imx_gpio_lock);
value = imx_gpio_getinput(port, pin); value = imx_gpio_getinput(port, pin);
leave_critical_section(flags); spin_unlock_irqrestore(&g_imx_gpio_lock, flags);
return value; return value;
} }