ASoC: SDCA: fix finding wrong entity
Subsystems (3)
PATCH 2/2 ASoC: SDCA: fix finding wrong entity
From: Shuming Fan <[email protected]>
This patch fixes an issue like:
where searching for the entity 'FU 11' could incorrectly match 'FU 113' first. The driver should first perform an exact match on the full string name. If no exact match is found, it can then fall back to a partial match.
--- sound/soc/sdca/sdca_functions.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
sound/soc/sdca/sdca_functions.c +10 -1
@@ -1602,9 +1602,18 @@ static struct sdca_entity *find_sdca_entity_by_label(struct sdca_function_data * const char *entity_label) {int i; +struct sdca_entity *entity =NULL ;for (i =0 ; i < function->num_entities; i++) { -struct sdca_entity *entity = &function->entities[i]; + entity = &function->entities[i]; + +/* check whole string first*/ +if (!strcmp (entity->label, entity_label)) +return entity; + } + +for (i =0 ; i < function->num_entities; i++) { + entity = &function->entities[i];if (!strncmp (entity->label, entity_label,strlen (entity_label)))return entity;
Signature · 1 line
2.53.0
Charles Keepax
maintainerQuoted 8 lines · On Wed, Mar 25, 2026 at 05:20:28PM +0800, [email protected] wrote:
From: Shuming Fan <[email protected]>
This patch fixes an issue like:
where searching for the entity 'FU 11' could incorrectly match 'FU 113' first. The driver should first perform an exact match on the full string name. If no exact match is found, it can then fall back to a partial match.Signed-off-by Shuming Fan <[email protected]>
Could use a fixes tag:
sound/soc/sdca/sdca_functions.c static struct sdca_entity *find_sdca_entity_by_label(struct sdca_function_data * · line 1605
Quoted 13 lines
--- sound/soc/sdca/sdca_functions.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)sound/soc/sdca/sdca_functions.c +1
-0@@ -1602,9 +1602,18 @@ static struct sdca_entity *find_sdca_entity_by_label(struct sdca_function_data * const char *entity_label) {int i; +struct sdca_entity *entity =NULL ;
Minor nit put this above the int i;
But looks like a good fix, thanks for spotting that.
Thanks,
Charles
Quoted 11 lines
Quoted 6 lines
This patch fixes an issue like:
where searching for the entity 'FU 11' could incorrectly match 'FU 113' first. The driver should first perform an exact match on the full string name. If no exact match is found, it can then fall back to a partial match.Signed-off-by Shuming Fan <[email protected]>Could use a fixes tag:
Fixes 48fa77af2f4a ("ASoC: SDCA: Add terminal type into input/output widgetname")
Will add the fixed tag.
Quoted 11 lines
sound/soc/sdca/sdca_functions.c static struct sdca_entity
Quoted 10 lines
--- sound/soc/sdca/sdca_functions.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)(quoted diff) +0
-0
b/sound/soc/sdca/sdca_functions.cindex0b7d97dcb236..0787bf024d21100644sound/soc/sdca/sdca_functions.c +0
-0@@ -1602,9 +1602,18 @@ static struct sdca_entity*find_sdca_entity_by_label(struct
sdca_function_data*
Quoted 6 lines
sound/soc/sdca/sdca_functions.c static struct sdca_entity *find_sdca_entity_by_label(struct sdca_function_data * · line 1605
Quoted 4 lines
sound/soc/sdca/sdca_functions.c +1
-0const char *entity_label) {int i; +struct sdca_entity *entity =NULL ;Minor nit put this above the int i;
Sure, will fix
Quoted 4 lines
But looks like a good fix, thanks for spotting that.
Thanks,
Charles