]> code.ossystems Code Review - openembedded-core.git/blob
cbc0a4ceab547f418656bb5152d028af0917363a
[openembedded-core.git] /
1 From 976f8f62238f0d837584adc7c31035bdb29b6d6f Mon Sep 17 00:00:00 2001
2 From: Hans de Goede <hdegoede@redhat.com>
3 Date: Tue, 3 Dec 2019 18:27:39 +0100
4 Subject: [PATCH 5/5] ucm: Do not fail to parse configs on cards with an empty
5  CardComponents lists
6
7 Since the UCM profiles for all Bay- and Cherry-Trail SST cards have been
8 moved over to UCM2, parsing them fails with:
9
10 ALSA lib ucm_subs.c:220:(uc_mgr_get_substituted_value) variable '${CardComponents}' is not defined in this context!
11
12 This completely breaks audio support on all Bay- and Cherry-Trail devices.
13
14 This is caused by these non-SOF ASoC using cards having an empty
15 CardComponents list. Which in itself is fine, but is rejected by
16 the ucm_subs.c code. This commit changes the ucm_subs code to accept
17 an empty string as a valid value for CardComponents restoring audio
18 functionality on these boards.
19
20 Signed-off-by: Hans de Goede <hdegoede@redhat.com>
21 Signed-off-by: Jaroslav Kysela <perex@perex.cz>
22
23 Upstream-Status: Backport
24 Signed-off-by: Tanu Kaskinen <tanuk@iki.fi>
25 ---
26  src/ucm/ucm_subs.c | 20 ++++++++++++--------
27  1 file changed, 12 insertions(+), 8 deletions(-)
28
29 diff --git a/src/ucm/ucm_subs.c b/src/ucm/ucm_subs.c
30 index 00afa9e3..90e395f0 100644
31 --- a/src/ucm/ucm_subs.c
32 +++ b/src/ucm/ucm_subs.c
33 @@ -25,6 +25,7 @@
34   */
35  
36  #include "ucm_local.h"
37 +#include <stdbool.h>
38  #include <sys/stat.h>
39  #include <limits.h>
40  
41 @@ -145,10 +146,11 @@ static char *rval_sysfs(snd_use_case_mgr_t *uc_mgr ATTRIBUTE_UNUSED, const char
42         return strdup(path);
43  }
44  
45 -#define MATCH_VARIABLE(name, id, fcn)                                  \
46 +#define MATCH_VARIABLE(name, id, fcn, empty_ok)                                \
47         if (strncmp((name), (id), sizeof(id) - 1) == 0) {               \
48                 rval = fcn(uc_mgr);                                     \
49                 idsize = sizeof(id) - 1;                                \
50 +               allow_empty = (empty_ok);                               \
51                 goto __rval;                                            \
52         }
53  
54 @@ -189,12 +191,14 @@ int uc_mgr_get_substituted_value(snd_use_case_mgr_t *uc_mgr,
55  
56         while (*value) {
57                 if (*value == '$' && *(value+1) == '{') {
58 -                       MATCH_VARIABLE(value, "${ConfName}", rval_conf_name);
59 -                       MATCH_VARIABLE(value, "${CardId}", rval_card_id);
60 -                       MATCH_VARIABLE(value, "${CardDriver}", rval_card_driver);
61 -                       MATCH_VARIABLE(value, "${CardName}", rval_card_name);
62 -                       MATCH_VARIABLE(value, "${CardLongName}", rval_card_longname);
63 -                       MATCH_VARIABLE(value, "${CardComponents}", rval_card_components);
64 +                       bool allow_empty = false;
65 +
66 +                       MATCH_VARIABLE(value, "${ConfName}", rval_conf_name, false);
67 +                       MATCH_VARIABLE(value, "${CardId}", rval_card_id, false);
68 +                       MATCH_VARIABLE(value, "${CardDriver}", rval_card_driver, false);
69 +                       MATCH_VARIABLE(value, "${CardName}", rval_card_name, false);
70 +                       MATCH_VARIABLE(value, "${CardLongName}", rval_card_longname, false);
71 +                       MATCH_VARIABLE(value, "${CardComponents}", rval_card_components, true);
72                         MATCH_VARIABLE2(value, "${env:", rval_env);
73                         MATCH_VARIABLE2(value, "${sys:", rval_sysfs);
74                         err = -EINVAL;
75 @@ -208,7 +212,7 @@ int uc_mgr_get_substituted_value(snd_use_case_mgr_t *uc_mgr,
76                         }
77                         goto __error;
78  __rval:
79 -                       if (rval == NULL || rval[0] == '\0') {
80 +                       if (rval == NULL || (!allow_empty && rval[0] == '\0')) {
81                                 free(rval);
82                                 strncpy(r, value, idsize);
83                                 r[idsize] = '\0';
84 -- 
85 2.20.1
86