[PATCH 06/14] Input: samsung-keypad - use guard notation to acquire mutex

Dmitry Torokhov
2024-08-19T04:58:33Z

Guard notation is more compact and ensures that the mutex will be
released when control leaves the function.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/keyboard/samsung-keypad.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/input/keyboard/samsung-keypad.c b/drivers/input/keyboard/samsung-keypad.c
index 924327de4d8f..71f5b85b02bd 100644
--- a/drivers/input/keyboard/samsung-keypad.c
+++ b/drivers/input/keyboard/samsung-keypad.c
@@ -519,15 +519,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;
}

@@ -537,15 +535,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;
}

--
2.46.0.184.g6999bdac58-goog