mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-04 04:06:26 +00:00
Input: ad714x - use guard notation when acquiring mutex
Using guard notation makes the code more compact and error handling more robust by ensuring that mutexes are released in all code paths when control leaves critical section. Reviewed-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Link: https://lore.kernel.org/r/20240904044244.1042174-2-dmitry.torokhov@gmail.com Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
This commit is contained in:
parent
45a8145972
commit
f9f37373ff
@ -941,7 +941,7 @@ static irqreturn_t ad714x_interrupt_thread(int irq, void *data)
|
||||
struct ad714x_chip *ad714x = data;
|
||||
int i;
|
||||
|
||||
mutex_lock(&ad714x->mutex);
|
||||
guard(mutex)(&ad714x->mutex);
|
||||
|
||||
ad714x->read(ad714x, STG_LOW_INT_STA_REG, &ad714x->l_state, 3);
|
||||
|
||||
@ -954,8 +954,6 @@ static irqreturn_t ad714x_interrupt_thread(int irq, void *data)
|
||||
for (i = 0; i < ad714x->hw->touchpad_num; i++)
|
||||
ad714x_touchpad_state_machine(ad714x, i);
|
||||
|
||||
mutex_unlock(&ad714x->mutex);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
@ -1169,13 +1167,11 @@ static int ad714x_suspend(struct device *dev)
|
||||
|
||||
dev_dbg(ad714x->dev, "%s enter\n", __func__);
|
||||
|
||||
mutex_lock(&ad714x->mutex);
|
||||
guard(mutex)(&ad714x->mutex);
|
||||
|
||||
data = ad714x->hw->sys_cfg_reg[AD714X_PWR_CTRL] | 0x3;
|
||||
ad714x->write(ad714x, AD714X_PWR_CTRL, data);
|
||||
|
||||
mutex_unlock(&ad714x->mutex);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1184,7 +1180,7 @@ static int ad714x_resume(struct device *dev)
|
||||
struct ad714x_chip *ad714x = dev_get_drvdata(dev);
|
||||
dev_dbg(ad714x->dev, "%s enter\n", __func__);
|
||||
|
||||
mutex_lock(&ad714x->mutex);
|
||||
guard(mutex)(&ad714x->mutex);
|
||||
|
||||
/* resume to non-shutdown mode */
|
||||
|
||||
@ -1197,8 +1193,6 @@ static int ad714x_resume(struct device *dev)
|
||||
|
||||
ad714x->read(ad714x, STG_LOW_INT_STA_REG, &ad714x->l_state, 3);
|
||||
|
||||
mutex_unlock(&ad714x->mutex);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user