Input: omap-keypad - use guard notation when acquiring mutex
Subsystems (2)
Dmitry Torokhov
maintainerPATCH 1/1 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.
Signed-off-by Dmitry Torokhov <[email protected]>
--- drivers/input/keyboard/omap-keypad.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/input/keyboard/omap-keypad.c +8 -8
@@ -156,15 +156,15 @@ static ssize_t omap_kp_enable_store(struct device *dev, struct device_attributeif ((state !=1 ) && (state !=0 ))return -EINVAL ; -mutex_lock (&kp_enable_mutex); -if (state != kp_enable) { -if (state) -enable_irq (omap_kp->irq); -else -disable_irq (omap_kp->irq); - kp_enable = state; + scoped_guard(mutex, &kp_enable_mutex) { +if (state != kp_enable) { +if (state) +enable_irq (omap_kp->irq); +else +disable_irq (omap_kp->irq); + kp_enable = state; + } } -mutex_unlock (&kp_enable_mutex);return strnlen (buf, count); }
Signature · 5 lines
2.47.0.163.g1226f6d8fa-goog -- Dmitry
Quoted 5 lines · Dmitry Torokhov
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.
Signed-off-by Dmitry Torokhov <[email protected]>
Reviewed-by Linus Walleij <[email protected]>
Yours,
Linus Walleij