]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
Input: samsung-keypad - use guard notation to acquire mutex
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 19 Aug 2024 04:58:03 +0000 (21:58 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Tue, 1 Jul 2025 21:31:00 +0000 (14:31 -0700)
Guard notation is more compact and ensures that the mutex will be
released when control leaves the function.

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20240819045813.2154642-7-dmitry.torokhov@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/keyboard/samsung-keypad.c

index d8eda10d63ee2b6cacfb64f038da6b1231614c18..80a495e7e93a771849e02df3a983bf32d3574e32 100644 (file)
@@ -510,15 +510,13 @@ static int samsung_keypad_suspend(struct device *dev)
        struct samsung_keypad *keypad = platform_get_drvdata(pdev);
        struct input_dev *input_dev = keypad->input_dev;
 
-       mutex_lock(&input_dev->mutex);
+       guard(mutex)(&input_dev->mutex);
 
        if (input_device_enabled(input_dev))
                samsung_keypad_stop(keypad);
 
        samsung_keypad_toggle_wakeup(keypad, true);
 
-       mutex_unlock(&input_dev->mutex);
-
        return 0;
 }
 
@@ -528,15 +526,13 @@ static int samsung_keypad_resume(struct device *dev)
        struct samsung_keypad *keypad = platform_get_drvdata(pdev);
        struct input_dev *input_dev = keypad->input_dev;
 
-       mutex_lock(&input_dev->mutex);
+       guard(mutex)(&input_dev->mutex);
 
        samsung_keypad_toggle_wakeup(keypad, false);
 
        if (input_device_enabled(input_dev))
                samsung_keypad_start(keypad);
 
-       mutex_unlock(&input_dev->mutex);
-
        return 0;
 }