summaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-dapm.c
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2012-02-16 11:07:13 -0800
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-02-17 08:09:56 -0800
commit5ba06fc969d068dee9a59f1fa3dbe58e235fa913 (patch)
treeaf5ab93d1688cd99bad814bb4c1075171c0af033 /sound/soc/soc-dapm.c
parentce0e9f0ede349097c849db9c3aa7e947fc443552 (diff)
downloadblackbird-op-linux-5ba06fc969d068dee9a59f1fa3dbe58e235fa913.tar.gz
blackbird-op-linux-5ba06fc969d068dee9a59f1fa3dbe58e235fa913.zip
ASoC: dapm: Refactor snd_soc_dapm_new_widget() to return the widget
Let the caller fiddle with the widget after we're done in order to facilitate further refactoring. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Liam Girdwood <lrg@ti.com>
Diffstat (limited to 'sound/soc/soc-dapm.c')
-rw-r--r--sound/soc/soc-dapm.c35
1 files changed, 14 insertions, 21 deletions
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 1bcce75058f7..295fa91d9d03 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -2698,24 +2698,16 @@ int snd_soc_dapm_put_pin_switch(struct snd_kcontrol *kcontrol,
}
EXPORT_SYMBOL_GPL(snd_soc_dapm_put_pin_switch);
-/**
- * snd_soc_dapm_new_control - create new dapm control
- * @dapm: DAPM context
- * @widget: widget template
- *
- * Creates a new dapm control based upon the template.
- *
- * Returns 0 for success else error.
- */
-static int snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
- const struct snd_soc_dapm_widget *widget)
+static struct snd_soc_dapm_widget *
+snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
+ const struct snd_soc_dapm_widget *widget)
{
struct snd_soc_dapm_widget *w;
size_t name_len;
int ret;
if ((w = dapm_cnew_widget(widget)) == NULL)
- return -ENOMEM;
+ return NULL;
switch (w->id) {
case snd_soc_dapm_regulator_supply:
@@ -2724,7 +2716,7 @@ static int snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
ret = PTR_ERR(w->priv);
dev_err(dapm->dev, "Failed to request %s: %d\n",
w->name, ret);
- return ret;
+ return NULL;
}
break;
default:
@@ -2737,7 +2729,7 @@ static int snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
w->name = kmalloc(name_len, GFP_KERNEL);
if (w->name == NULL) {
kfree(w);
- return -ENOMEM;
+ return NULL;
}
if (dapm->codec && dapm->codec->name_prefix)
snprintf(w->name, name_len, "%s %s",
@@ -2796,7 +2788,7 @@ static int snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
/* machine layer set ups unconnected pins and insertions */
w->connected = 1;
- return 0;
+ return w;
}
/**
@@ -2813,15 +2805,16 @@ int snd_soc_dapm_new_controls(struct snd_soc_dapm_context *dapm,
const struct snd_soc_dapm_widget *widget,
int num)
{
- int i, ret;
+ struct snd_soc_dapm_widget *w;
+ int i;
for (i = 0; i < num; i++) {
- ret = snd_soc_dapm_new_control(dapm, widget);
- if (ret < 0) {
+ w = snd_soc_dapm_new_control(dapm, widget);
+ if (!w) {
dev_err(dapm->dev,
- "ASoC: Failed to create DAPM control %s: %d\n",
- widget->name, ret);
- return ret;
+ "ASoC: Failed to create DAPM control %s\n",
+ widget->name);
+ return -ENOMEM;
}
widget++;
}
OpenPOWER on IntegriCloud