Unverified Commit c673efd5 authored by Shuming Fan's avatar Shuming Fan Committed by Mark Brown
Browse files

ASoC: SDCA: fix finding wrong entity



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.

Fixes: 48fa77af ("ASoC: SDCA: Add terminal type into input/output widget name")
Reviewed-by: default avatarCharles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: default avatarShuming Fan <shumingf@realtek.com>
Link: https://patch.msgid.link/20260325110406.3232420-1-shumingf@realtek.com


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent c991ca32
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -1601,10 +1601,19 @@ static int find_sdca_entities(struct device *dev, struct sdw_slave *sdw,
static struct sdca_entity *find_sdca_entity_by_label(struct sdca_function_data *function,
						     const char *entity_label)
{
	struct sdca_entity *entity = NULL;
	int i;

	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;