This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 826aa4f732 imx_gpio: use small lock in arch/arm/src/imx6/imx_gpio.c
826aa4f732 is described below
commit 826aa4f732a717c974f349d01e47c9b47bd659e0
Author: hujun5 <[email protected]>
AuthorDate: Wed Dec 18 17:12:51 2024 +0800
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 <[email protected]>
---
arch/arm/src/imx6/imx_gpio.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
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;
}