Re: [PATCH 05/14] Input: samsung-keypad - use devm to disable runtime PM

From: Krzysztof Kozlowski
Date: Mon Aug 19 2024 - 08:54:53 EST


On Sun, Aug 18, 2024 at 09:58:02PM -0700, Dmitry Torokhov wrote:
> To make sure that runtime PM is disabled at the right time relative
> to all other devm-managed resources use devm_add_action_or_reset()
> to register a handler that will disable it.
>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
> ---
> drivers/input/keyboard/samsung-keypad.c | 24 +++++++++++++-----------
> 1 file changed, 13 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/input/keyboard/samsung-keypad.c b/drivers/input/keyboard/samsung-keypad.c
> index 7adcd2657bca..924327de4d8f 100644
> --- a/drivers/input/keyboard/samsung-keypad.c
> +++ b/drivers/input/keyboard/samsung-keypad.c
> @@ -310,6 +310,13 @@ samsung_keypad_parse_dt(struct device *dev)
> }
> #endif
>
> +static void samsung_disable_runtime_pm(void *data)
> +{
> + struct samsung_keypad *keypad = data;
> +
> + pm_runtime_disable(&keypad->pdev->dev);
> +}
> +
> static int samsung_keypad_probe(struct platform_device *pdev)
> {
> const struct samsung_keypad_platdata *pdata;
> @@ -420,11 +427,16 @@ static int samsung_keypad_probe(struct platform_device *pdev)
>
> device_init_wakeup(&pdev->dev, pdata->wakeup);
> platform_set_drvdata(pdev, keypad);
> +
> pm_runtime_enable(&pdev->dev);
> + error = devm_add_action_or_reset(&pdev->dev, samsung_disable_runtime_pm,
> + keypad);
> + if (error)
> + return error;

I think you are open-coding devm_pm_runtime_enable().