arch/xmc4 : fixed critical section in i2c_transfer
The critical section was declared at the wrong place. The critical section wasn't left if error returned.
This commit is contained in:
parent
f5df946676
commit
6ef8a73614
@ -813,6 +813,10 @@ static int i2c_transfer(struct i2c_master_s *dev,
|
||||
|
||||
nxmutex_lock(&priv->lock);
|
||||
|
||||
/* Enter critical section to avoid interrupts during i2c transfert */
|
||||
|
||||
irqstate_t state = enter_critical_section();
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
/* Check if frequency must be changed */
|
||||
@ -832,6 +836,7 @@ static int i2c_transfer(struct i2c_master_s *dev,
|
||||
else
|
||||
{
|
||||
i2cerr("Can't update frequency between Start & Stop symbols\n");
|
||||
leave_critical_section(state);
|
||||
nxmutex_unlock(&priv->lock);
|
||||
return -EINVAL;
|
||||
}
|
||||
@ -841,10 +846,6 @@ static int i2c_transfer(struct i2c_master_s *dev,
|
||||
|
||||
bool read = ((msgs[i].flags & I2C_M_READ) != 0);
|
||||
|
||||
/* Enter critical section to avoid interrupts during i2c transfert */
|
||||
|
||||
irqstate_t state = enter_critical_section();
|
||||
|
||||
/* Check if you should start or restart a new i2c frame */
|
||||
|
||||
if ((msgs[i].flags & I2C_M_NOSTART) == 0)
|
||||
|
Loading…
Reference in New Issue
Block a user