Re: [PATCH v2 02/11] ASoC: SDCA: export PM helpers keyed on sdca_class_drv

From: Charles Keepax

Date: Tue Sep 08 2026 - 13:48:59 EST


On Mon, Sep 07, 2026 at 09:37:16AM +0100, Srinivas Kandagatla wrote:
> The class PM callbacks pull sdca_class_drv out of drvdata, so the
> built-in class_sdw_driver owns the drvdata slot. That works for the
> generic case but blocks codec drivers that want to embed
> sdca_class_drv in their own private struct -- they need drvdata for
> their codec priv.
>
> Split the four callbacks into exported helpers that take a
> struct sdca_class_drv * directly:
>
> sdca_class_system_suspend()
> sdca_class_system_resume()
> sdca_class_runtime_suspend()
> sdca_class_runtime_resume()
>
> Codec drivers can now compose these into their own dev_pm_ops without
> going through drvdata.
>
> For the built-in class_sdw_driver, add small dev_pm_ops wrappers that
> fetch drv from drvdata, wire them into sdca_class_pm_ops, and export
> the ops so any generic SDCA slave can pick them up as-is.
>
> No functional change: the built-in class_sdw_driver keeps the same PM
> semantics; only the internal plumbing shifts to operate on
> sdca_class_drv instead of struct device *dev.
>
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@xxxxxxxxxxxxxxxx>
> ---
> +/*
> + * PM helpers. Codec drivers embed sdca_class_drv in their own priv,
> + * own dev_set_drvdata(), and compose these into their own dev_pm_ops:
> + *
> + * static int wcd_runtime_suspend(struct device *dev) {
> + * struct wcd_priv *priv = dev_get_drvdata(dev);
> + * return sdca_class_runtime_suspend(&priv->class);
> + * }
> + *
> + * The built-in class_sdw_driver in sdca_class.c uses sdca_class_pm_ops
> + * directly because it stashes the sdca_class_drv in drvdata itself.
> + */
> +int sdca_class_runtime_suspend(struct sdca_class_drv *drv);
> +int sdca_class_runtime_resume(struct sdca_class_drv *drv);
> +int sdca_class_system_suspend(struct sdca_class_drv *drv);
> +int sdca_class_system_resume(struct sdca_class_drv *drv);
> +extern const struct dev_pm_ops sdca_class_pm_ops;

I don't think we use sdca_class_pm_ops outside the class driver
here, I would leave that internal unless we have a need for it.

Thanks,
Charles