ALSA: ASoC: Refactor DAPM event handler
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Thu, 17 Jul 2008 14:06:50 +0000 (15:06 +0100)
committerTakashi Iwai <tiwai@suse.de>
Thu, 17 Jul 2008 14:17:16 +0000 (16:17 +0200)
The DAPM event callback code has many layers of indentation, taking it
over 80 columns. Refactor the code to give less indentation in order to
avoid checkpatch issues on further changes and exploding indentation.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/soc/soc-dapm.c

index 2c87061c2a6b4d7b9c35d7479d782462a0d8b3c1..17698ef58dfb5ab707c4cca31158ea8fac4d87f8 100644 (file)
@@ -586,45 +586,48 @@ static int dapm_power_widgets(struct snd_soc_codec *codec, int event)
                        power_change = (w->power == power) ? 0: 1;
                        w->power = power;
 
+                       if (!power_change)
+                               continue;
+
                        /* call any power change event handlers */
-                       if (power_change) {
-                               if (w->event) {
-                                       pr_debug("power %s event for %s flags %x\n",
-                                                w->power ? "on" : "off", w->name, w->event_flags);
-                                       if (power) {
-                                               /* power up event */
-                                               if (w->event_flags & SND_SOC_DAPM_PRE_PMU) {
-                                                       ret = w->event(w,
-                                                               NULL, SND_SOC_DAPM_PRE_PMU);
-                                                       if (ret < 0)
-                                                               return ret;
-                                               }
-                                               dapm_update_bits(w);
-                                               if (w->event_flags & SND_SOC_DAPM_POST_PMU){
-                                                       ret = w->event(w,
-                                                               NULL, SND_SOC_DAPM_POST_PMU);
-                                                       if (ret < 0)
-                                                               return ret;
-                                               }
-                                       } else {
-                                               /* power down event */
-                                               if (w->event_flags & SND_SOC_DAPM_PRE_PMD) {
-                                                       ret = w->event(w,
-                                                               NULL, SND_SOC_DAPM_PRE_PMD);
-                                                       if (ret < 0)
-                                                               return ret;
-                                               }
-                                               dapm_update_bits(w);
-                                               if (w->event_flags & SND_SOC_DAPM_POST_PMD) {
-                                                       ret = w->event(w,
-                                                               NULL, SND_SOC_DAPM_POST_PMD);
-                                                       if (ret < 0)
-                                                               return ret;
-                                               }
-                                       }
-                               } else
-                                       /* no event handler */
-                                       dapm_update_bits(w);
+                       if (w->event)
+                               pr_debug("power %s event for %s flags %x\n",
+                                        w->power ? "on" : "off",
+                                        w->name, w->event_flags);
+
+                       /* power up pre event */
+                       if (power && w->event &&
+                           (w->event_flags & SND_SOC_DAPM_PRE_PMU)) {
+                               ret = w->event(w, NULL, SND_SOC_DAPM_PRE_PMU);
+                               if (ret < 0)
+                                       return ret;
+                       }
+
+                       /* power down pre event */
+                       if (!power && w->event &&
+                           (w->event_flags & SND_SOC_DAPM_PRE_PMD)) {
+                               ret = w->event(w, NULL, SND_SOC_DAPM_PRE_PMD);
+                               if (ret < 0)
+                                       return ret;
+                       }
+
+                       dapm_update_bits(w);
+
+                       /* power up post event */
+                       if (power && w->event &&
+                           (w->event_flags & SND_SOC_DAPM_POST_PMU)) {
+                               ret = w->event(w,
+                                              NULL, SND_SOC_DAPM_POST_PMU);
+                               if (ret < 0)
+                                       return ret;
+                       }
+
+                       /* power down post event */
+                       if (!power && w->event &&
+                           (w->event_flags & SND_SOC_DAPM_POST_PMD)) {
+                               ret = w->event(w, NULL, SND_SOC_DAPM_POST_PMD);
+                               if (ret < 0)
+                                       return ret;
                        }
                }
        }