Skip to contentSkip to conversation

ASoC: SDCA: fix finding wrong entity

PATCH In review [email protected] 2 participants 3 messages Mar 25

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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
index 0b7d97dcb236..0787bf024d21 100644
@@ -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
maintainer
#1 lore raw
Quoted 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.

Could use a fixes tag:

Fixes 48fa77af2f4a ("ASoC: SDCA: Add terminal type into input/output widget name")

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
index 0b7d97dcb236..0787bf024d21 100644
@@ -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

#2 lore raw
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.

Could use a fixes tag:

Fixes 48fa77af2f4a ("ASoC: SDCA: Add terminal type into input/output widget

name")

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.c index 0b7d97dcb236..0787bf024d21 100644

sound/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 -0
                                                   const 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