Re: [PATCH] ASoC: qcom: lpass-sc7180: Add system suspend/resume PM ops

From: Stephen Boyd
Date: Mon Nov 28 2022 - 14:40:19 EST


Quoting Srinivasa Rao Mandadapu (2022-11-27 23:49:02)
> Update lpass sc7180 platform driver with PM ops, such as
> system supend and resume callbacks.
> This update is required to disable clocks during supend and
> avoid XO shutdown issue.
>
> Signed-off-by: Srinivasa Rao Mandadapu <quic_srivasam@xxxxxxxxxxx>
> Tested-by: Rahul Ajmeriya <quic_rajmeriy@xxxxxxxxxxx>
> ---
> sound/soc/qcom/lpass-sc7180.c | 26 ++++++++++++++++++++++++++
> 1 file changed, 26 insertions(+)
>
> diff --git a/sound/soc/qcom/lpass-sc7180.c b/sound/soc/qcom/lpass-sc7180.c
> index 77a556b..6ad1c5b 100644
> --- a/sound/soc/qcom/lpass-sc7180.c
> +++ b/sound/soc/qcom/lpass-sc7180.c
> @@ -12,6 +12,7 @@
> #include <linux/module.h>
> #include <linux/of.h>
> #include <linux/platform_device.h>
> +#include <linux/pm_runtime.h>

Why is this include needed? Did you mean to include linux/pm.h?

> #include <dt-bindings/sound/sc7180-lpass.h>
> #include <sound/pcm.h>
> #include <sound/soc.h>
> @@ -156,10 +157,34 @@ static int sc7180_lpass_exit(struct platform_device *pdev)
> struct lpass_data *drvdata = platform_get_drvdata(pdev);
>
> clk_bulk_disable_unprepare(drvdata->num_clks, drvdata->clks);
> + return 0;
> +}
> +
> +static int sc7180_lpass_dev_resume(struct device *dev)
> +{
> + int ret = 0;

Please don't assign ret and then assign it again. It hides use before
true assignment bugs.

> + struct lpass_data *drvdata = dev_get_drvdata(dev);
>
> + ret = clk_bulk_prepare_enable(drvdata->num_clks, drvdata->clks);
> + if (ret) {
> + dev_err(dev, "sc7180 clk prepare and enable failed\n");
> + return ret;
> + }
> + return ret;

This could be simplified to

ret = clk_bulk_prepare_enable(...);
if (ret)
dev_err(dev, ...);

return ret;