diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2014-10-25 17:42:02 +0200 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2014-10-28 00:19:59 +0000 |
commit | e409dfbfccf9a49409197afc677a21e1c11ba015 (patch) | |
tree | d6a6a29be0475aa5aa8d42ab8fc918f802e5af18 /sound/soc/soc-dapm.c | |
parent | 8be4da29cf5b8ec65e974c36e7ae4d90b381ac5e (diff) | |
download | linux-e409dfbfccf9a49409197afc677a21e1c11ba015.tar.gz linux-e409dfbfccf9a49409197afc677a21e1c11ba015.tar.bz2 linux-e409dfbfccf9a49409197afc677a21e1c11ba015.zip |
ASoC: dapm: Add a few supply widget sanity checks
Supply widgets are somewhat special and not all kinds of paths to or from
supply widgets make sense. This patch adds a few sanity checks that errors
out during the path instantiation for those invalid paths. This will prevent
drivers to depend on weird behavior resulting from such paths as well as
will allow the DAPM algorithms to assume that they never see such paths.
This patch adds checks for the following three invalid types of paths:
* A path with a non-supply widget as a source connected to a supply
widget as a sink. Such a path has no effect on either of the two
connected widgets.
* Paths with a connected() callback that have a non-supply widget as the
source. The DAPM algorithm only uses the conneceted() callback for
supply widget power checks. And since it prevents caching of the DAPM
state there is no intention to make it more generic as it has
negative performance implications.
* Paths which connect a supply to a mixer or mux via a control. Controls
are only meant to affect the routing of audio data.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/soc-dapm.c')
-rw-r--r-- | sound/soc/soc-dapm.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index ffcda7ecd832..8e26c2bc7fdf 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -2194,6 +2194,27 @@ static int snd_soc_dapm_add_path(struct snd_soc_dapm_context *dapm, struct snd_soc_dapm_path *path; int ret; + if (wsink->is_supply && !wsource->is_supply) { + dev_err(dapm->dev, + "Connecting non-supply widget to supply widget is not supported (%s -> %s)\n", + wsource->name, wsink->name); + return -EINVAL; + } + + if (connected && !wsource->is_supply) { + dev_err(dapm->dev, + "connected() callback only supported for supply widgets (%s -> %s)\n", + wsource->name, wsink->name); + return -EINVAL; + } + + if (wsource->is_supply && control) { + dev_err(dapm->dev, + "Conditional paths are not supported for supply widgets (%s -> [%s] -> %s)\n", + wsource->name, control, wsink->name); + return -EINVAL; + } + path = kzalloc(sizeof(struct snd_soc_dapm_path), GFP_KERNEL); if (!path) return -ENOMEM; |