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

Configure Feed

Select the types of activity you want to include in your feed.

Input: pxa27x_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-15-dmitry.torokhov@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+8 -8
+8 -8
drivers/input/keyboard/pxa27x_keypad.c
··· 682 682 struct platform_device *pdev = to_platform_device(dev); 683 683 struct pxa27x_keypad *keypad = platform_get_drvdata(pdev); 684 684 struct input_dev *input_dev = keypad->input_dev; 685 - int ret = 0; 685 + int error; 686 686 687 687 /* 688 688 * If the keypad is used as wake up source, the clock is not turned ··· 691 691 if (device_may_wakeup(&pdev->dev)) { 692 692 disable_irq_wake(keypad->irq); 693 693 } else { 694 - mutex_lock(&input_dev->mutex); 694 + guard(mutex)(&input_dev->mutex); 695 695 696 696 if (input_device_enabled(input_dev)) { 697 697 /* Enable unit clock */ 698 - ret = clk_prepare_enable(keypad->clk); 699 - if (!ret) 700 - pxa27x_keypad_config(keypad); 701 - } 698 + error = clk_prepare_enable(keypad->clk); 699 + if (error) 700 + return error; 702 701 703 - mutex_unlock(&input_dev->mutex); 702 + pxa27x_keypad_config(keypad); 703 + } 704 704 } 705 705 706 - return ret; 706 + return 0; 707 707 } 708 708 709 709 static DEFINE_SIMPLE_DEV_PM_OPS(pxa27x_keypad_pm_ops,