Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+2 -6
+2 -6
drivers/input/keyboard/pmic8xxx-keypad.c
··· 630 630 if (device_may_wakeup(dev)) { 631 631 enable_irq_wake(kp->key_sense_irq); 632 632 } else { 633 - mutex_lock(&input_dev->mutex); 633 + guard(mutex)(&input_dev->mutex); 634 634 635 635 if (input_device_enabled(input_dev)) 636 636 pmic8xxx_kp_disable(kp); 637 - 638 - mutex_unlock(&input_dev->mutex); 639 637 } 640 638 641 639 return 0; ··· 648 650 if (device_may_wakeup(dev)) { 649 651 disable_irq_wake(kp->key_sense_irq); 650 652 } else { 651 - mutex_lock(&input_dev->mutex); 653 + guard(mutex)(&input_dev->mutex); 652 654 653 655 if (input_device_enabled(input_dev)) 654 656 pmic8xxx_kp_enable(kp); 655 - 656 - mutex_unlock(&input_dev->mutex); 657 657 } 658 658 659 659 return 0;