summaryrefslogtreecommitdiff
path: root/sound/core
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2017-06-09 00:37:02 +0300
committerTakashi Iwai <tiwai@suse.de>2017-06-09 00:40:32 +0300
commit0d4e399965738bb90dcee2fd5aeb15c1ccc81b42 (patch)
tree7fcb590bd6efcb633ca1838c8e28f5a853a5de7d /sound/core
parent9cc07f55d42be47ad2b06dae9541d9fd964c3287 (diff)
downloadlinux-0d4e399965738bb90dcee2fd5aeb15c1ccc81b42.tar.xz
ALSA: pcm: use goto statement instead of while statement to reduce indentation
In a process to calculate parameters of PCM substream, application of all rules is iterated several times till parameter dependencies are satisfied. In current implementation, two loops are used for the design, however this brings two-level indentation and decline readability. This commit attempts to reduce the indentation by using goto statement, instead of outer while loop. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core')
-rw-r--r--sound/core/pcm_native.c86
1 files changed, 44 insertions, 42 deletions
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 000e6e9a0c2b..41aeb6facdec 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -337,54 +337,56 @@ static int constrain_params_by_rules(struct snd_pcm_substream *substream,
rstamps[k] = 0;
for (k = 0; k <= SNDRV_PCM_HW_PARAM_LAST_INTERVAL; k++)
vstamps[k] = (params->rmask & (1 << k)) ? 1 : 0;
- do {
- again = 0;
- for (k = 0; k < constrs->rules_num; k++) {
- struct snd_pcm_hw_rule *r = &constrs->rules[k];
- unsigned int d;
- int doit = 0;
- if (r->cond && !(r->cond & params->flags))
- continue;
- for (d = 0; r->deps[d] >= 0; d++) {
- if (vstamps[r->deps[d]] > rstamps[k]) {
- doit = 1;
- break;
- }
+retry:
+ again = 0;
+ for (k = 0; k < constrs->rules_num; k++) {
+ struct snd_pcm_hw_rule *r = &constrs->rules[k];
+ unsigned int d;
+ int doit = 0;
+ if (r->cond && !(r->cond & params->flags))
+ continue;
+ for (d = 0; r->deps[d] >= 0; d++) {
+ if (vstamps[r->deps[d]] > rstamps[k]) {
+ doit = 1;
+ break;
}
- if (!doit)
- continue;
+ }
+ if (!doit)
+ continue;
- if (trace_hw_mask_param_enabled()) {
- if (hw_is_mask(r->var))
- old_mask = *hw_param_mask(params, r->var);
- }
- if (trace_hw_interval_param_enabled()) {
- if (hw_is_interval(r->var))
- old_interval = *hw_param_interval(params, r->var);
- }
+ if (trace_hw_mask_param_enabled()) {
+ if (hw_is_mask(r->var))
+ old_mask = *hw_param_mask(params, r->var);
+ }
+ if (trace_hw_interval_param_enabled()) {
+ if (hw_is_interval(r->var))
+ old_interval = *hw_param_interval(params, r->var);
+ }
- changed = r->func(params, r);
+ changed = r->func(params, r);
- if (hw_is_mask(r->var)) {
- trace_hw_mask_param(substream, r->var, k + 1,
- &old_mask, hw_param_mask(params, r->var));
- }
- if (hw_is_interval(r->var)) {
- trace_hw_interval_param(substream, r->var, k + 1,
- &old_interval, hw_param_interval(params, r->var));
- }
+ if (hw_is_mask(r->var)) {
+ trace_hw_mask_param(substream, r->var, k + 1,
+ &old_mask, hw_param_mask(params, r->var));
+ }
+ if (hw_is_interval(r->var)) {
+ trace_hw_interval_param(substream, r->var, k + 1,
+ &old_interval, hw_param_interval(params, r->var));
+ }
- rstamps[k] = stamp;
- if (changed && r->var >= 0) {
- params->cmask |= (1 << r->var);
- vstamps[r->var] = stamp;
- again = 1;
- }
- if (changed < 0)
- return changed;
- stamp++;
+ rstamps[k] = stamp;
+ if (changed && r->var >= 0) {
+ params->cmask |= (1 << r->var);
+ vstamps[r->var] = stamp;
+ again = 1;
}
- } while (again);
+ if (changed < 0)
+ return changed;
+ stamp++;
+ }
+
+ if (again)
+ goto retry;
return 0;
}