From: Takashi Iwai <tiwai@suse.de>
Subject: ALSA: pcm: fix hw_rule deps kABI
Patch-mainline: Never, SLE15-SP2 only
References: bsc#1181014
The recent fix for increasing the hw_rule dependencies breaks the kABI.
For keeping the kABI compatibility, revert the change and adds some
hack to allow the fourth element as the extra dependency without a
sentinel.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
include/sound/pcm.h | 2 +-
sound/core/pcm_lib.c | 5 +++--
sound/core/pcm_native.c | 9 ++++-----
3 files changed, 8 insertions(+), 8 deletions(-)
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -223,7 +223,7 @@ typedef int (*snd_pcm_hw_rule_func_t)(st
struct snd_pcm_hw_rule {
unsigned int cond;
int var;
- int deps[5];
+ int deps[4];
snd_pcm_hw_rule_func_t func;
void *private;
--- a/sound/core/pcm_lib.c
+++ b/sound/core/pcm_lib.c
@@ -1135,11 +1135,12 @@ int snd_pcm_hw_rule_add(struct snd_pcm_r
c->private = private;
k = 0;
while (1) {
- if (snd_BUG_ON(k >= ARRAY_SIZE(c->deps))) {
+ if (k < ARRAY_SIZE(c->deps)) {
+ c->deps[k++] = dep;
+ } else if (snd_BUG_ON(dep >= 0)) { /* overflow? */
va_end(args);
return -EINVAL;
}
- c->deps[k++] = dep;
if (dep < 0)
break;
dep = va_arg(args, int);
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -382,19 +382,18 @@ retry:
/*
* The 'deps' array includes maximum four dependencies
- * to SNDRV_PCM_HW_PARAM_XXXs for this rule. The fifth
- * member of this array is a sentinel and should be
- * negative value.
+ * to SNDRV_PCM_HW_PARAM_XXXs for this rule. It's terminated
+ * by a sentinel (-1) or fully filled to four items.
*
* This rule should be processed in this time when dependent
* parameters were changed at former applications of the other
* rules.
*/
- for (d = 0; r->deps[d] >= 0; d++) {
+ for (d = 0; d < ARRAY_SIZE(r->deps) && r->deps[d] >= 0; d++) {
if (vstamps[r->deps[d]] > rstamps[k])
break;
}
- if (r->deps[d] < 0)
+ if (d >= ARRAY_SIZE(r->deps) || r->deps[d] < 0)
continue;
if (trace_hw_mask_param_enabled()) {