[RFC PATCH 2/2] ASoC: SOF: Use multi PM domains helpers
Daniel Baluta
daniel.baluta at oss.nxp.com
Mon Mar 2 21:57:00 CET 2020
From: Daniel Baluta <daniel.baluta at nxp.com>
Use dev_multi_pm_attach / dev_multi_pm_detach instead of the hardcoded
version.
Signed-off-by: Daniel Baluta <daniel.baluta at nxp.com>
---
sound/soc/sof/imx/imx8.c | 54 +++++-----------------------------------
1 file changed, 6 insertions(+), 48 deletions(-)
diff --git a/sound/soc/sof/imx/imx8.c b/sound/soc/sof/imx/imx8.c
index b692752b2178..ca740538a2d5 100644
--- a/sound/soc/sof/imx/imx8.c
+++ b/sound/soc/sof/imx/imx8.c
@@ -51,10 +51,7 @@ struct imx8_priv {
struct imx_sc_ipc *sc_ipc;
/* Power domain handling */
- int num_domains;
- struct device **pd_dev;
- struct device_link **link;
-
+ struct dev_multi_pm_domain_data *mpd;
};
static void imx8_get_reply(struct snd_sof_dev *sdev)
@@ -207,7 +204,6 @@ static int imx8_probe(struct snd_sof_dev *sdev)
struct resource res;
u32 base, size;
int ret = 0;
- int i;
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
@@ -218,39 +214,9 @@ static int imx8_probe(struct snd_sof_dev *sdev)
priv->sdev = sdev;
/* power up device associated power domains */
- priv->num_domains = of_count_phandle_with_args(np, "power-domains",
- "#power-domain-cells");
- if (priv->num_domains < 0) {
- dev_err(sdev->dev, "no power-domains property in %pOF\n", np);
- return priv->num_domains;
- }
-
- priv->pd_dev = devm_kmalloc_array(&pdev->dev, priv->num_domains,
- sizeof(*priv->pd_dev), GFP_KERNEL);
- if (!priv->pd_dev)
- return -ENOMEM;
-
- priv->link = devm_kmalloc_array(&pdev->dev, priv->num_domains,
- sizeof(*priv->link), GFP_KERNEL);
- if (!priv->link)
- return -ENOMEM;
-
- for (i = 0; i < priv->num_domains; i++) {
- priv->pd_dev[i] = dev_pm_domain_attach_by_id(&pdev->dev, i);
- if (IS_ERR(priv->pd_dev[i])) {
- ret = PTR_ERR(priv->pd_dev[i]);
- goto exit_unroll_pm;
- }
- priv->link[i] = device_link_add(&pdev->dev, priv->pd_dev[i],
- DL_FLAG_STATELESS |
- DL_FLAG_PM_RUNTIME |
- DL_FLAG_RPM_ACTIVE);
- if (!priv->link[i]) {
- ret = -ENOMEM;
- dev_pm_domain_detach(priv->pd_dev[i], false);
- goto exit_unroll_pm;
- }
- }
+ priv->mpd = dev_multi_pm_attach(&pdev->dev);
+ if (IS_ERR(priv->mpd))
+ return PTR_ERR(priv->mpd);
ret = imx_scu_get_handle(&priv->sc_ipc);
if (ret) {
@@ -329,25 +295,17 @@ static int imx8_probe(struct snd_sof_dev *sdev)
exit_pdev_unregister:
platform_device_unregister(priv->ipc_dev);
exit_unroll_pm:
- while (--i >= 0) {
- device_link_del(priv->link[i]);
- dev_pm_domain_detach(priv->pd_dev[i], false);
- }
-
+ dev_multi_pm_detach(priv->mpd);
return ret;
}
static int imx8_remove(struct snd_sof_dev *sdev)
{
struct imx8_priv *priv = (struct imx8_priv *)sdev->private;
- int i;
platform_device_unregister(priv->ipc_dev);
- for (i = 0; i < priv->num_domains; i++) {
- device_link_del(priv->link[i]);
- dev_pm_domain_detach(priv->pd_dev[i], false);
- }
+ dev_multi_pm_detach(priv->mpd);
return 0;
}
--
2.17.1
More information about the Alsa-devel
mailing list