[alsa-devel] [PATCH 02/11] ASoC: core: Add method snd_soc_dapm_get_regulator_status
Add method to get the status of a regulator supply widget.
Signed-off-by: Ola Lilja ola.o.lilja@stericsson.com --- include/sound/soc-dapm.h | 3 +++ sound/soc/soc-dapm.c | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h index 8da3c24..1649ef2 100644 --- a/include/sound/soc-dapm.h +++ b/include/sound/soc-dapm.h @@ -399,6 +399,9 @@ int snd_soc_dapm_ignore_suspend(struct snd_soc_dapm_context *dapm, const char *pin); void snd_soc_dapm_auto_nc_codec_pins(struct snd_soc_codec *codec);
+int snd_soc_dapm_get_regulator_status(struct snd_soc_dapm_context *dapm, + const char *pin); + /* Mostly internal - should not normally be used */ void dapm_mark_dirty(struct snd_soc_dapm_widget *w, const char *reason);
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 5cbd2d7..b6c9df5 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -3092,6 +3092,29 @@ int snd_soc_dapm_get_pin_status(struct snd_soc_dapm_context *dapm, EXPORT_SYMBOL_GPL(snd_soc_dapm_get_pin_status);
/** + * snd_soc_dapm_get_regulator_status - get regulator supply status + * @dapm: DAPM context + * @pin: Regulator supply name + * + * Get regulator supply status - Enabled or disabled. + * + * Returns -1 for failure. + * Returns 0 if disabled. + * Returns 1 if enabled. + */ +int snd_soc_dapm_get_regulator_status(struct snd_soc_dapm_context *dapm, + const char *pin) +{ + struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true); + + if (!w) + return -1; + + return regulator_is_enabled((struct regulator *)w->priv); +} +EXPORT_SYMBOL_GPL(snd_soc_dapm_get_regulator_status); + +/** * snd_soc_dapm_ignore_suspend - ignore suspend status for DAPM endpoint * @dapm: DAPM context * @pin: audio signal pin endpoint (or start point)
participants (2)
-
Mark Brown
-
Ola Lilja