Merge branch 'for-5.6' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie...
[platform/kernel/linux-rpi.git] / sound / soc / soc-dapm.c
index 9b13056..58c318c 100644 (file)
@@ -1105,6 +1105,11 @@ static int snd_soc_dapm_suspend_check(struct snd_soc_dapm_widget *widget)
        }
 }
 
+static void dapm_widget_list_free(struct snd_soc_dapm_widget_list **list)
+{
+       kfree(*list);
+}
+
 static int dapm_widget_list_create(struct snd_soc_dapm_widget_list **list,
        struct list_head *widgets)
 {
@@ -1310,6 +1315,11 @@ int snd_soc_dapm_dai_get_connected_widgets(struct snd_soc_dai *dai, int stream,
        return paths;
 }
 
+void snd_soc_dapm_dai_free_widgets(struct snd_soc_dapm_widget_list **list)
+{
+       dapm_widget_list_free(list);
+}
+
 /*
  * Handler for regulator supply widget.
  */
@@ -1724,9 +1734,7 @@ static void dapm_widget_update(struct snd_soc_card *card)
 
        wlist = dapm_kcontrol_get_wlist(update->kcontrol);
 
-       for (wi = 0; wi < wlist->num_widgets; wi++) {
-               w = wlist->widgets[wi];
-
+       for_each_dapm_widgets(wlist, wi, w) {
                if (w->event && (w->event_flags & SND_SOC_DAPM_PRE_REG)) {
                        ret = w->event(w, update->kcontrol, SND_SOC_DAPM_PRE_REG);
                        if (ret != 0)
@@ -1753,9 +1761,7 @@ static void dapm_widget_update(struct snd_soc_card *card)
                                w->name, ret);
        }
 
-       for (wi = 0; wi < wlist->num_widgets; wi++) {
-               w = wlist->widgets[wi];
-
+       for_each_dapm_widgets(wlist, wi, w) {
                if (w->event && (w->event_flags & SND_SOC_DAPM_POST_REG)) {
                        ret = w->event(w, update->kcontrol, SND_SOC_DAPM_POST_REG);
                        if (ret != 0)
@@ -2624,10 +2630,7 @@ static int dapm_update_dai_unlocked(struct snd_pcm_substream *substream,
        struct snd_soc_dapm_widget *w;
        int ret;
 
-       if (dir == SNDRV_PCM_STREAM_PLAYBACK)
-               w = dai->playback_widget;
-       else
-               w = dai->capture_widget;
+       w = snd_soc_dai_get_widget(dai, dir);
 
        if (!w)
                return 0;
@@ -3604,6 +3607,9 @@ snd_soc_dapm_new_control_unlocked(struct snd_soc_dapm_context *dapm,
                        ret = PTR_ERR(w->pinctrl);
                        goto request_failed;
                }
+
+               /* set to sleep_state when initializing */
+               dapm_pinctrl_event(w, NULL, SND_SOC_DAPM_POST_PMD);
                break;
        case snd_soc_dapm_clock_supply:
                w->clk = devm_clk_get(dapm->dev, w->name);
@@ -4359,10 +4365,7 @@ static void soc_dapm_dai_stream_event(struct snd_soc_dai *dai, int stream,
        struct snd_soc_dapm_widget *w;
        unsigned int ep;
 
-       if (stream == SNDRV_PCM_STREAM_PLAYBACK)
-               w = dai->playback_widget;
-       else
-               w = dai->capture_widget;
+       w = snd_soc_dai_get_widget(dai, stream);
 
        if (w) {
                dapm_mark_dirty(w, "stream event");