aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2012-02-16 14:07:13 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-02-17 11:09:56 -0500
commit5ba06fc969d068dee9a59f1fa3dbe58e235fa913 (patch)
treeaf5ab93d1688cd99bad814bb4c1075171c0af033
parentce0e9f0ede349097c849db9c3aa7e947fc443552 (diff)
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>
-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,
2698} 2698}
2699EXPORT_SYMBOL_GPL(snd_soc_dapm_put_pin_switch); 2699EXPORT_SYMBOL_GPL(snd_soc_dapm_put_pin_switch);
2700 2700
2701/** 2701static struct snd_soc_dapm_widget *
2702 * snd_soc_dapm_new_control - create new dapm control 2702snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
2703 * @dapm: DAPM context 2703 const struct snd_soc_dapm_widget *widget)
2704 * @widget: widget template
2705 *
2706 * Creates a new dapm control based upon the template.
2707 *
2708 * Returns 0 for success else error.
2709 */
2710static int snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
2711 const struct snd_soc_dapm_widget *widget)
2712{ 2704{
2713 struct snd_soc_dapm_widget *w; 2705 struct snd_soc_dapm_widget *w;
2714 size_t name_len; 2706 size_t name_len;
2715 int ret; 2707 int ret;
2716 2708
2717 if ((w = dapm_cnew_widget(widget)) == NULL) 2709 if ((w = dapm_cnew_widget(widget)) == NULL)
2718 return -ENOMEM; 2710 return NULL;
2719 2711
2720 switch (w->id) { 2712 switch (w->id) {
2721 case snd_soc_dapm_regulator_supply: 2713 case snd_soc_dapm_regulator_supply:
@@ -2724,7 +2716,7 @@ static int snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
2724 ret = PTR_ERR(w->priv); 2716 ret = PTR_ERR(w->priv);
2725 dev_err(dapm->dev, "Failed to request %s: %d\n", 2717 dev_err(dapm->dev, "Failed to request %s: %d\n",
2726 w->name, ret); 2718 w->name, ret);
2727 return ret; 2719 return NULL;
2728 } 2720 }
2729 break; 2721 break;
2730 default: 2722 default:
@@ -2737,7 +2729,7 @@ static int snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
2737 w->name = kmalloc(name_len, GFP_KERNEL); 2729 w->name = kmalloc(name_len, GFP_KERNEL);
2738 if (w->name == NULL) { 2730 if (w->name == NULL) {
2739 kfree(w); 2731 kfree(w);
2740 return -ENOMEM; 2732 return NULL;
2741 } 2733 }
2742 if (dapm->codec && dapm->codec->name_prefix) 2734 if (dapm->codec && dapm->codec->name_prefix)
2743 snprintf(w->name, name_len, "%s %s", 2735 snprintf(w->name, name_len, "%s %s",
@@ -2796,7 +2788,7 @@ static int snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
2796 2788
2797 /* machine layer set ups unconnected pins and insertions */ 2789 /* machine layer set ups unconnected pins and insertions */
2798 w->connected = 1; 2790 w->connected = 1;
2799 return 0; 2791 return w;
2800} 2792}
2801 2793
2802/** 2794/**
@@ -2813,15 +2805,16 @@ int snd_soc_dapm_new_controls(struct snd_soc_dapm_context *dapm,
2813 const struct snd_soc_dapm_widget *widget, 2805 const struct snd_soc_dapm_widget *widget,
2814 int num) 2806 int num)
2815{ 2807{
2816 int i, ret; 2808 struct snd_soc_dapm_widget *w;
2809 int i;
2817 2810
2818 for (i = 0; i < num; i++) { 2811 for (i = 0; i < num; i++) {
2819 ret = snd_soc_dapm_new_control(dapm, widget); 2812 w = snd_soc_dapm_new_control(dapm, widget);
2820 if (ret < 0) { 2813 if (!w) {
2821 dev_err(dapm->dev, 2814 dev_err(dapm->dev,
2822 "ASoC: Failed to create DAPM control %s: %d\n", 2815 "ASoC: Failed to create DAPM control %s\n",
2823 widget->name, ret); 2816 widget->name);
2824 return ret; 2817 return -ENOMEM;
2825 } 2818 }
2826 widget++; 2819 widget++;
2827 } 2820 }