ASoC: dapm: Simplify list creation in dapm_dai_get_connected_widgets()
authorLars-Peter Clausen <lars@metafoo.de>
Sun, 26 Jul 2015 17:04:59 +0000 (19:04 +0200)
committerMark Brown <broonie@kernel.org>
Wed, 29 Jul 2015 13:01:38 +0000 (14:01 +0100)
commit1ce43acff0c078fd560ee0f2a4ae10b8da28e388
treee162557def119e3f5c643b6abcb5d308dbfaa8fa
parent787126ebdb9821f1a19b1dfd1ab1bbb74b8c80b8
ASoC: dapm: Simplify list creation in dapm_dai_get_connected_widgets()

When running dapm_dai_get_connected_widgets() currently in
is_connected_{input,output}_ep() for each widget that gets added the array
is resized and the code also loops over all existing entries to avoid
adding a widget multiple times.

The former can be avoided by collecting the widgets in a linked list and
only once we have all widgets allocate the array.

The later can be avoided by changing when the widget is added. Currently it
is added when walking the neighbor lists of a widget. Since a widget can be
neighbors with multiple other widgets it could get added twice and hence
the check is necessary. But the main body of is_connected_{input,output}_ep
is guaranteed to be only executed at most once per widget. So adding the
widget to the list at the beginning of the function automatically makes
sure that each widget gets only added once. The only difference is that
using this method the starting point itself will also end up on the list,
but it can easily be skipped when creating the array.

Overall this reduces the code size and speeds things slightly up.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/soc-dapm.c
sound/soc/soc-pcm.c