Skip to content

Commit 31b6b9a

Browse files
committed
Input: ps2-gpio - 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. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent 7dc406b commit 31b6b9a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/input/serio/ps2-gpio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,12 @@ static int ps2_gpio_write(struct serio *serio, unsigned char val)
133133
int ret = 0;
134134

135135
if (in_task()) {
136-
mutex_lock(&drvdata->tx.mutex);
136+
guard(mutex)(&drvdata->tx.mutex);
137+
137138
__ps2_gpio_write(serio, val);
138139
if (!wait_for_completion_timeout(&drvdata->tx.complete,
139140
msecs_to_jiffies(10000)))
140141
ret = SERIO_TIMEOUT;
141-
mutex_unlock(&drvdata->tx.mutex);
142142
} else {
143143
__ps2_gpio_write(serio, val);
144144
}

0 commit comments

Comments
 (0)