Commit f1e5f682 authored by Dmitry Torokhov's avatar Dmitry Torokhov
Browse files

Input: samsung-keypad - use guard notation to acquire mutex



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

Reviewed-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20240819045813.2154642-7-dmitry.torokhov@gmail.com


Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 5658439a
Loading
Loading
Loading
Loading
+2 −6
Original line number Diff line number Diff line
@@ -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;
}