diff mbox series

ASoC: soc-core: tidyup ret handling for card->disable_route_checks

Message ID 87wmg5tzra.wl-kuninori.morimoto.gx@renesas.com (mailing list archive)
State Accepted
Commit abf594ce914172e3bb640d02fc6e79569fa25b8e
Headers show
Series ASoC: soc-core: tidyup ret handling for card->disable_route_checks | expand

Commit Message

Kuninori Morimoto Dec. 12, 2024, 2:13 a.m. UTC
commit a22ae72b86a4 ("ASoC: soc-core: disable route checks for legacy
devices") added card->disable_route_checks to disable route checks
for legacy devices at soc_probe_component() and snd_soc_bind_card().

And commit 6974857c2b2c ("ASoC: topology: Do not ignore route checks
when parsing graphs") tidyup soc-topology for same reason.

In snd_soc_bind_card() case, if snd_soc_dapm_add_routes() (A) error,
but has card->disable_route_checks case (B), it will indicate
dev_info() only, and then, next function (C) will be called.
Thus, "ret" will be over written, and it is handled as non-error.

	static int snd_soc_bind_card(...)
	{
		...
(A)		ret = snd_soc_dapm_add_routes(...);
		if (ret < 0) {
(B)			if (card->disable_route_checks) {
				dev_info(...);
			} else {
				...
				goto probe_end;
			}
		}

(C)		ret = snd_soc_dapm_add_routes(...);
		...

In soc_probe_component() case, if snd_soc_dapm_add_routes() (a)
error, and has card->disable_route_checks case (b), it will indicate
dev_info(). But there is no next function after that, this means ret is
still indicating error, and will not be over written.
So error handline (c) will be handled, and will return error (d)

	static int soc_probe_component(...)
	{
		...
(a)		ret = snd_soc_dapm_add_routes(...);
		if (ret < 0) {
(b)			if (card->disable_route_checks) {
				dev_info(...);
			} else {
				...
				goto err_probe;
			}
		}

		/* see for_each_card_components */
		list_add(...);

	err_probe:
(c)		if (ret < 0)
			soc_remove_component(...);

(d)		return ret;
	}

In soc_tplg_dapm_graph_elems_load() case, snd_soc_dapm_add_routes()
is called in for loop (1). if it was error (2), and doesn't have
card->disable_route_checks case flag (3), it will break from loop.
If card has flag, it will indicate dev_info() and handled as non-error.
But ret is still indicating error in this case. If this error happen
in last of loop, if will return error (4).

	static int soc_tplg_dapm_graph_elems_load(...)
	{
		...
(1)		for (i = 0; i < count; i++) {
			...
(2)			ret = snd_soc_dapm_add_routes(...);
			if (ret) {
(3)				if (!dapm->card->disable_route_checks) {
					dev_err(...);
					break;
				}
				dev_info(...);
			}
		}

(4)		return ret;
	}

This patch set "ret = 0" for each case.

Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>
Cc: Cezary Rojewski <cezary.rojewski@intel.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-core.c     | 2 ++
 sound/soc/soc-topology.c | 8 +++++---
 2 files changed, 7 insertions(+), 3 deletions(-)

Comments

Mark Brown Dec. 16, 2024, 3:12 p.m. UTC | #1
On Thu, 12 Dec 2024 02:13:13 +0000, Kuninori Morimoto wrote:
> commit a22ae72b86a4 ("ASoC: soc-core: disable route checks for legacy
> devices") added card->disable_route_checks to disable route checks
> for legacy devices at soc_probe_component() and snd_soc_bind_card().
> 
> And commit 6974857c2b2c ("ASoC: topology: Do not ignore route checks
> when parsing graphs") tidyup soc-topology for same reason.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: soc-core: tidyup ret handling for card->disable_route_checks
      commit: abf594ce914172e3bb640d02fc6e79569fa25b8e

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark
diff mbox series

Patch

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index a1dace4bb6166..c8b7f78b02f0a 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1646,6 +1646,7 @@  static int soc_probe_component(struct snd_soc_card *card,
 				      component->driver->num_dapm_routes);
 	if (ret < 0) {
 		if (card->disable_route_checks) {
+			ret = 0;
 			dev_info(card->dev,
 				 "%s: disable_route_checks set, ignoring errors on add_routes\n",
 				 __func__);
@@ -2236,6 +2237,7 @@  static int snd_soc_bind_card(struct snd_soc_card *card)
 				      card->num_dapm_routes);
 	if (ret < 0) {
 		if (card->disable_route_checks) {
+			ret = 0;
 			dev_info(card->dev,
 				 "%s: disable_route_checks set, ignoring errors on add_routes\n",
 				 __func__);
diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index 43003d2d36667..ae2d6802cce05 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -1102,12 +1102,14 @@  static int soc_tplg_dapm_graph_elems_load(struct soc_tplg *tplg,
 
 		ret = snd_soc_dapm_add_routes(dapm, route, 1);
 		if (ret) {
-			if (!dapm->card->disable_route_checks) {
+			if (dapm->card->disable_route_checks) {
+				ret = 0;
+				dev_info(tplg->dev,
+					 "ASoC: disable_route_checks set, ignoring dapm_add_routes errors\n");
+			} else {
 				dev_err(tplg->dev, "ASoC: dapm_add_routes failed: %d\n", ret);
 				break;
 			}
-			dev_info(tplg->dev,
-				 "ASoC: disable_route_checks set, ignoring dapm_add_routes errors\n");
 		}
 	}