Skip to content

Commit cc660a4

Browse files
committed
ASoC: codecs: fix widget name comparisons
Merge series from Krzysztof Kozlowski <[email protected]>: Some codec drivers compare widget names with strcmp, ignoring the component name prefix. If prefix is used, the comparisons start failing. Add a helper to fix the issue.
2 parents e182212 + c29e526 commit cc660a4

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

include/sound/soc-dapm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@ void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card);
469469

470470
int snd_soc_dapm_update_dai(struct snd_pcm_substream *substream,
471471
struct snd_pcm_hw_params *params, struct snd_soc_dai *dai);
472+
int snd_soc_dapm_widget_name_cmp(struct snd_soc_dapm_widget *widget, const char *s);
472473

473474
/* dapm path setup */
474475
int snd_soc_dapm_new_widgets(struct snd_soc_card *card);

sound/soc/codecs/lpass-wsa-macro.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1675,12 +1675,12 @@ static int wsa_macro_spk_boost_event(struct snd_soc_dapm_widget *w,
16751675
u16 boost_path_ctl, boost_path_cfg1;
16761676
u16 reg, reg_mix;
16771677

1678-
if (!strcmp(w->name, "WSA_RX INT0 CHAIN")) {
1678+
if (!snd_soc_dapm_widget_name_cmp(w, "WSA_RX INT0 CHAIN")) {
16791679
boost_path_ctl = CDC_WSA_BOOST0_BOOST_PATH_CTL;
16801680
boost_path_cfg1 = CDC_WSA_RX0_RX_PATH_CFG1;
16811681
reg = CDC_WSA_RX0_RX_PATH_CTL;
16821682
reg_mix = CDC_WSA_RX0_RX_PATH_MIX_CTL;
1683-
} else if (!strcmp(w->name, "WSA_RX INT1 CHAIN")) {
1683+
} else if (!snd_soc_dapm_widget_name_cmp(w, "WSA_RX INT1 CHAIN")) {
16841684
boost_path_ctl = CDC_WSA_BOOST1_BOOST_PATH_CTL;
16851685
boost_path_cfg1 = CDC_WSA_RX1_RX_PATH_CFG1;
16861686
reg = CDC_WSA_RX1_RX_PATH_CTL;

sound/soc/soc-component.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ int snd_soc_component_notify_control(struct snd_soc_component *component,
242242
char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
243243
struct snd_kcontrol *kctl;
244244

245+
/* When updating, change also snd_soc_dapm_widget_name_cmp() */
245246
if (component->name_prefix)
246247
snprintf(name, ARRAY_SIZE(name), "%s %s", component->name_prefix, ctl);
247248
else

sound/soc/soc-dapm.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2728,6 +2728,18 @@ int snd_soc_dapm_update_dai(struct snd_pcm_substream *substream,
27282728
}
27292729
EXPORT_SYMBOL_GPL(snd_soc_dapm_update_dai);
27302730

2731+
int snd_soc_dapm_widget_name_cmp(struct snd_soc_dapm_widget *widget, const char *s)
2732+
{
2733+
struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm);
2734+
const char *wname = widget->name;
2735+
2736+
if (component->name_prefix)
2737+
wname += strlen(component->name_prefix) + 1; /* plus space */
2738+
2739+
return strcmp(wname, s);
2740+
}
2741+
EXPORT_SYMBOL_GPL(snd_soc_dapm_widget_name_cmp);
2742+
27312743
/*
27322744
* dapm_update_widget_flags() - Re-compute widget sink and source flags
27332745
* @w: The widget for which to update the flags

0 commit comments

Comments
 (0)