Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cdc4508b authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Mark Brown
Browse files

ASoC: dapm: Reduce number of checked paths in dapm_widget_in_card_paths()



Each widget has a list of all the paths that it is connected to. There is no
need to iterate over all paths when we are only interested in the paths of a
specific widget.

Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 98ad73c9
Loading
Loading
Loading
Loading
+42 −23
Original line number Original line Diff line number Diff line
@@ -3788,27 +3788,30 @@ int snd_soc_dapm_ignore_suspend(struct snd_soc_dapm_context *dapm,
}
}
EXPORT_SYMBOL_GPL(snd_soc_dapm_ignore_suspend);
EXPORT_SYMBOL_GPL(snd_soc_dapm_ignore_suspend);


static bool snd_soc_dapm_widget_in_card_paths(struct snd_soc_card *card,
/**
					      struct snd_soc_dapm_widget *w)
 * dapm_is_external_path() - Checks if a path is a external path
 * @card: The card the path belongs to
 * @path: The path to check
 *
 * Returns true if the path is either between two different DAPM contexts or
 * between two external pins of the same DAPM context. Otherwise returns
 * false.
 */
static bool dapm_is_external_path(struct snd_soc_card *card,
	struct snd_soc_dapm_path *path)
{
{
	struct snd_soc_dapm_path *p;

	list_for_each_entry(p, &card->paths, list) {
		if ((p->source == w) || (p->sink == w)) {
	dev_dbg(card->dev,
	dev_dbg(card->dev,
		"... Path %s(id:%d dapm:%p) - %s(id:%d dapm:%p)\n",
		"... Path %s(id:%d dapm:%p) - %s(id:%d dapm:%p)\n",
			    p->source->name, p->source->id, p->source->dapm,
		path->source->name, path->source->id, path->source->dapm,
			    p->sink->name, p->sink->id, p->sink->dapm);
		path->sink->name, path->sink->id, path->sink->dapm);


			/* Connected to something other than the codec */
	/* Connection between two different DAPM contexts */
			if (p->source->dapm != p->sink->dapm)
	if (path->source->dapm != path->sink->dapm)
		return true;
		return true;
			/*

			 * Loopback connection from codec external pin to
	/* Loopback connection from external pin to external pin */
			 * codec external pin
	if (path->sink->id == snd_soc_dapm_input) {
			 */
		switch (path->source->id) {
			if (p->sink->id == snd_soc_dapm_input) {
				switch (p->source->id) {
		case snd_soc_dapm_output:
		case snd_soc_dapm_output:
		case snd_soc_dapm_micbias:
		case snd_soc_dapm_micbias:
			return true;
			return true;
@@ -3816,7 +3819,23 @@ static bool snd_soc_dapm_widget_in_card_paths(struct snd_soc_card *card,
			break;
			break;
		}
		}
	}
	}

	return false;
}
}

static bool snd_soc_dapm_widget_in_card_paths(struct snd_soc_card *card,
					      struct snd_soc_dapm_widget *w)
{
	struct snd_soc_dapm_path *p;

	list_for_each_entry(p, &w->sources, list_sink) {
		if (dapm_is_external_path(card, p))
			return true;
	}

	list_for_each_entry(p, &w->sinks, list_source) {
		if (dapm_is_external_path(card, p))
			return true;
	}
	}


	return false;
	return false;