Skip to content

Commit e1325e1

Browse files
committed
Input: omap-keypad - 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: Linus Walleij <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent b4badee commit e1325e1

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

drivers/input/keyboard/omap-keypad.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,15 @@ static ssize_t omap_kp_enable_store(struct device *dev, struct device_attribute
156156
if ((state != 1) && (state != 0))
157157
return -EINVAL;
158158

159-
mutex_lock(&kp_enable_mutex);
160-
if (state != kp_enable) {
161-
if (state)
162-
enable_irq(omap_kp->irq);
163-
else
164-
disable_irq(omap_kp->irq);
165-
kp_enable = state;
159+
scoped_guard(mutex, &kp_enable_mutex) {
160+
if (state != kp_enable) {
161+
if (state)
162+
enable_irq(omap_kp->irq);
163+
else
164+
disable_irq(omap_kp->irq);
165+
kp_enable = state;
166+
}
166167
}
167-
mutex_unlock(&kp_enable_mutex);
168168

169169
return strnlen(buf, count);
170170
}

0 commit comments

Comments
 (0)