mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 20:08:15 +08:00
use small lock in following files
arch/xtensa/src/esp32s3/esp32s3_rtc_lowerhalf.c arch/z16/src/z16f/z16f_serial.c arch/z80/src/z8/z8_serial.c boards/arm/max326xx/max32660-evsys/src/max326_button.c boards/arm/stm32/stm32f4discovery/src/stm32_gs2200m.c drivers/i2c/i2c_bitbang.c drivers/power/supply/act8945a.c drivers/serial/uart_pci_16550.c drivers/serial/uart_pl011.c drivers/wireless/bluetooth/bt_uart_shim.c Signed-off-by: hujun5 <hujun5@xiaomi.com>
This commit is contained in:
@@ -298,6 +298,7 @@ struct regulator_act8945a_priv
|
||||
int i2c_freq;
|
||||
FAR const struct regulator_desc_s *regulators;
|
||||
FAR struct regulator_dev_s *rdev;
|
||||
spinlock_t lock;
|
||||
};
|
||||
|
||||
struct act8945a_dev_s
|
||||
@@ -457,9 +458,9 @@ static int act8945a_getreg(FAR struct regulator_act8945a_priv *priv,
|
||||
|
||||
/* Write the register address */
|
||||
|
||||
flags = spin_lock_irqsave(NULL);
|
||||
flags = spin_lock_irqsave(&priv->lock);
|
||||
ret = i2c_write(priv->i2c, &config, ®addr, sizeof(regaddr));
|
||||
spin_unlock_irqrestore(NULL, flags);
|
||||
spin_unlock_irqrestore(&priv->lock, flags);
|
||||
if (ret < 0)
|
||||
{
|
||||
act8945a_err("ERROR: i2c_write failed: %d\n", ret);
|
||||
@@ -468,9 +469,9 @@ static int act8945a_getreg(FAR struct regulator_act8945a_priv *priv,
|
||||
|
||||
/* Restart and read 8 bits from the register */
|
||||
|
||||
flags = spin_lock_irqsave(NULL);
|
||||
flags = spin_lock_irqsave(&priv->lock);
|
||||
ret = i2c_read(priv->i2c, &config, regval, sizeof(*regval));
|
||||
spin_unlock_irqrestore(NULL, flags);
|
||||
spin_unlock_irqrestore(&priv->lock, flags);
|
||||
if (ret < 0)
|
||||
{
|
||||
act8945a_err("ERROR: i2c_read failed: %d\n", ret);
|
||||
@@ -525,9 +526,9 @@ static int act8945a_putreg(FAR struct regulator_act8945a_priv *priv,
|
||||
|
||||
/* Write the register address followed by the data (no RESTART) */
|
||||
|
||||
flags = spin_lock_irqsave(NULL);
|
||||
flags = spin_lock_irqsave(&priv->lock);
|
||||
ret = i2c_write(priv->i2c, &config, buffer, sizeof(buffer));
|
||||
spin_unlock_irqrestore(NULL, flags);
|
||||
spin_unlock_irqrestore(&priv->lock, flags);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
@@ -1031,6 +1032,8 @@ int act8945a_initialize(FAR struct i2c_master_s *i2c, unsigned int vsel)
|
||||
priv->i2c_addr = ACT8945A_SLAVE_ADDRESS;
|
||||
priv->i2c_freq = ACT8945A_BUS_SPEED;
|
||||
|
||||
spin_lock_init(&priv->lock);
|
||||
|
||||
/* Early test to see if we can read the ACT8945A.
|
||||
*
|
||||
* We do this by writing a data pattern into the 4 scratch bits of SYS1
|
||||
|
||||
Reference in New Issue
Block a user