summaryrefslogtreecommitdiff
path: root/drivers/input
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2024-08-24 22:16:17 -0700
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2024-10-03 08:58:57 -0700
commit9e09354cb6f6858e3e54627c2e4f49d07bfae45e (patch)
tree0962264a7b1a14e87f3eb629435131d8b4d97acc /drivers/input
parenta49e229319b1dd7007ede184884cefdf0da6df48 (diff)
downloadlwn-9e09354cb6f6858e3e54627c2e4f49d07bfae45e.tar.gz
lwn-9e09354cb6f6858e3e54627c2e4f49d07bfae45e.zip
Input: pmic8xxx-keypad - use guard notation when acquiring mutex
This 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/20240825051627.2848495-14-dmitry.torokhov@gmail.com Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/keyboard/pmic8xxx-keypad.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/drivers/input/keyboard/pmic8xxx-keypad.c b/drivers/input/keyboard/pmic8xxx-keypad.c
index 26a005f9ace3..35d1aa2a22a5 100644
--- a/drivers/input/keyboard/pmic8xxx-keypad.c
+++ b/drivers/input/keyboard/pmic8xxx-keypad.c
@@ -630,12 +630,10 @@ static int pmic8xxx_kp_suspend(struct device *dev)
if (device_may_wakeup(dev)) {
enable_irq_wake(kp->key_sense_irq);
} else {
- mutex_lock(&input_dev->mutex);
+ guard(mutex)(&input_dev->mutex);
if (input_device_enabled(input_dev))
pmic8xxx_kp_disable(kp);
-
- mutex_unlock(&input_dev->mutex);
}
return 0;
@@ -650,12 +648,10 @@ static int pmic8xxx_kp_resume(struct device *dev)
if (device_may_wakeup(dev)) {
disable_irq_wake(kp->key_sense_irq);
} else {
- mutex_lock(&input_dev->mutex);
+ guard(mutex)(&input_dev->mutex);
if (input_device_enabled(input_dev))
pmic8xxx_kp_enable(kp);
-
- mutex_unlock(&input_dev->mutex);
}
return 0;