The imx-rpmsg machine driver currently implements its own logic to
parse ignore-suspend-widgets from Device Tree and manually traverse
DAPM widgets to mark them as ignore_suspend.

It also has a potential issue that some widgets listed in the property
(e.g. "Headphone Jack") belong to card or CPU DAI DAPM context.

Switch to use snd_soc_of_parse_ignore_suspend_widgets() with the
introduction of a generic ignore-suspend-widgets mechanism in the ASoC
core.

Signed-off-by: Chancel Liu <[email protected]>
---
 sound/soc/fsl/imx-rpmsg.c | 26 +++++++++-----------------
 1 file changed, 9 insertions(+), 17 deletions(-)

diff --git a/sound/soc/fsl/imx-rpmsg.c b/sound/soc/fsl/imx-rpmsg.c
index 40e0043cfe15..fd4624786b62 100644
--- a/sound/soc/fsl/imx-rpmsg.c
+++ b/sound/soc/fsl/imx-rpmsg.c
@@ -87,7 +87,6 @@ static int imx_rpmsg_late_probe(struct snd_soc_card *card)
        int ret;
 
        if (data->lpa) {
-               struct snd_soc_component *codec_comp;
                struct device_node *codec_np;
                struct device_driver *codec_drv;
                struct device *codec_dev = NULL;
@@ -107,22 +106,6 @@ static int imx_rpmsg_late_probe(struct snd_soc_card *card)
                        }
                }
                if (codec_dev) {
-                       codec_comp = 
snd_soc_lookup_component_nolocked(codec_dev, NULL);
-                       if (codec_comp) {
-                               int i, num_widgets;
-                               const char *widgets;
-                               struct snd_soc_dapm_context *dapm;
-
-                               num_widgets = 
of_property_count_strings(data->card.dev->of_node,
-                                                                       
"ignore-suspend-widgets");
-                               for (i = 0; i < num_widgets; i++) {
-                                       
of_property_read_string_index(data->card.dev->of_node,
-                                                                     
"ignore-suspend-widgets",
-                                                                     i, 
&widgets);
-                                       dapm = 
snd_soc_component_to_dapm(codec_comp);
-                                       snd_soc_dapm_ignore_suspend(dapm, 
widgets);
-                               }
-                       }
                        codec_drv = codec_dev->driver;
                        if (codec_drv->pm) {
                                memcpy(&lpa_pm, codec_drv->pm, sizeof(lpa_pm));
@@ -274,6 +257,15 @@ static int imx_rpmsg_probe(struct platform_device *pdev)
                }
        }
 
+       if (data->lpa && of_property_present(np, "ignore-suspend-widgets")) {
+               ret = snd_soc_of_parse_ignore_suspend_widgets(&data->card,
+                                                             
"ignore-suspend-widgets");
+               if (ret) {
+                       dev_err(&pdev->dev, "failed to parse 
ignore-suspend-widgets: %d\n", ret);
+                       goto fail;
+               }
+       }
+
        platform_set_drvdata(pdev, &data->card);
        snd_soc_card_set_drvdata(&data->card, data);
        ret = devm_snd_soc_register_card(&pdev->dev, &data->card);
-- 
2.50.1


Reply via email to