Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Cezary Rojewski <cezary.rojewski@intel.com>
To: alsa-devel@alsa-project.org, broonie@kernel.org
Cc: Cezary Rojewski <cezary.rojewski@intel.com>,
	pierre-louis.bossart@linux.intel.com, tiwai@suse.com,
	hdegoede@redhat.com, amadeuszx.slawinski@linux.intel.com
Subject: [PATCH 3/3] ASoC: core: Propagate component suspend/resume errors
Date: Fri,  4 Nov 2022 14:12:44 +0100	[thread overview]
Message-ID: <20221104131244.3920179-4-cezary.rojewski@intel.com> (raw)
In-Reply-To: <20221104131244.3920179-1-cezary.rojewski@intel.com>

From: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>

In case there is a failure during component suspend/resume, error should
be propagated back to callers.

Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
 sound/soc/soc-core.c | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 5f7e0735f0c1..931b4dc95234 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -550,6 +550,7 @@ int snd_soc_suspend(struct device *dev)
 	struct snd_soc_card *card = dev_get_drvdata(dev);
 	struct snd_soc_component *component;
 	struct snd_soc_pcm_runtime *rtd;
+	int ret = 0;
 	int i;
 
 	/* If the card is not initialized yet there is nothing to do */
@@ -623,7 +624,14 @@ int snd_soc_suspend(struct device *dev)
 				fallthrough;
 
 			case SND_SOC_BIAS_OFF:
-				snd_soc_component_suspend(component);
+				ret = snd_soc_component_suspend(component);
+				if (ret) {
+					dev_err(component->dev,
+						"ASoC: Suspend component %s failed: %d\n",
+						component->name, ret);
+					goto exit;
+				}
+
 				if (component->regmap)
 					regcache_mark_dirty(component->regmap);
 				/* deactivate pins to sleep state */
@@ -639,7 +647,8 @@ int snd_soc_suspend(struct device *dev)
 
 	snd_soc_card_suspend_post(card);
 
-	return 0;
+exit:
+	return ret;
 }
 EXPORT_SYMBOL_GPL(snd_soc_suspend);
 
@@ -648,6 +657,7 @@ int snd_soc_resume(struct device *dev)
 {
 	struct snd_soc_card *card = dev_get_drvdata(dev);
 	struct snd_soc_component *component;
+	int ret = 0;
 
 	/* If the card is not initialized yet there is nothing to do */
 	if (!card->instantiated)
@@ -671,8 +681,14 @@ int snd_soc_resume(struct device *dev)
 	snd_soc_card_resume_pre(card);
 
 	for_each_card_components(card, component) {
-		if (snd_soc_component_is_suspended(component))
-			snd_soc_component_resume(component);
+		if (snd_soc_component_is_suspended(component)) {
+			ret = snd_soc_component_resume(component);
+			if (ret) {
+				dev_err(component->dev, "ASoC: Resume component %s failed: %d\n",
+					component->name, ret);
+				goto exit;
+			}
+		}
 	}
 
 	soc_dapm_suspend_resume(card, SND_SOC_DAPM_STREAM_RESUME);
@@ -691,7 +707,8 @@ int snd_soc_resume(struct device *dev)
 	/* userspace can access us now we are back as we were before */
 	snd_power_change_state(card->snd_card, SNDRV_CTL_POWER_D0);
 
-	return 0;
+exit:
+	return ret;
 }
 EXPORT_SYMBOL_GPL(snd_soc_resume);
 
-- 
2.25.1


      parent reply	other threads:[~2022-11-04 12:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-04 13:12 [PATCH 0/3] ASoC: core: Suspend/resume error propagation Cezary Rojewski
2022-11-04 13:12 ` [PATCH 1/3] ASoC: component: Propagate result of suspend and resume callbacks Cezary Rojewski
2022-11-04 14:00   ` Pierre-Louis Bossart
2022-11-07  8:51     ` Amadeusz Sławiński
2022-11-07 14:11       ` Pierre-Louis Bossart
2022-11-04 13:12 ` [PATCH 2/3] ASoC: core: Inline resume work back to resume function Cezary Rojewski
2022-11-04 13:58   ` Pierre-Louis Bossart
2022-11-04 23:54     ` Mark Brown
2022-11-07  9:26       ` Cezary Rojewski
2022-11-07 14:28         ` Mark Brown
2022-11-08 19:22           ` Cezary Rojewski
2022-11-04 13:12 ` Cezary Rojewski [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221104131244.3920179-4-cezary.rojewski@intel.com \
    --to=cezary.rojewski@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=amadeuszx.slawinski@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=hdegoede@redhat.com \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox