Skip to content

Commit 9d9b182

Browse files
AngeloGioacchino Del Regnobroonie
authored andcommitted
ASoC: mediatek: Add common mtk_afe_component_probe callback
Multiple MediaTek AFE PCM component drivers are using their own .probe() callback, but most of those are simply duplicated functions as they are doing exactly the same thing over and over. Add a common probe callback for this component to reduce duplication. Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Link: https://lore.kernel.org/r/20240416071410.75620-12-angelogioacchino.delregno@collabora.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent f103ce4 commit 9d9b182

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

sound/soc/mediatek/common/mtk-afe-platform-driver.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,28 @@ int mtk_afe_pcm_new(struct snd_soc_component *component,
126126
}
127127
EXPORT_SYMBOL_GPL(mtk_afe_pcm_new);
128128

129+
static int mtk_afe_component_probe(struct snd_soc_component *component)
130+
{
131+
struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
132+
int ret;
133+
134+
snd_soc_component_init_regmap(component, afe->regmap);
135+
136+
/* If the list was never initialized there are no sub-DAIs */
137+
if (afe->sub_dais.next && afe->sub_dais.prev) {
138+
ret = mtk_afe_add_sub_dai_control(component);
139+
if (ret)
140+
return ret;
141+
}
142+
143+
return 0;
144+
}
145+
129146
const struct snd_soc_component_driver mtk_afe_pcm_platform = {
130147
.name = AFE_PCM_NAME,
131148
.pointer = mtk_afe_pcm_pointer,
132149
.pcm_construct = mtk_afe_pcm_new,
150+
.probe = mtk_afe_component_probe,
133151
};
134152
EXPORT_SYMBOL_GPL(mtk_afe_pcm_platform);
135153

0 commit comments

Comments
 (0)