forked from Minki/linux
ASoC: Intel: consistent HDMI codec probing code
Multiple Intel ASoC machine drivers repeat the same pattern in their .late_probe() methods: they first check whether the common HDMI codec driver is used, if not, they proceed by linking the legacy HDMI driver to each HDMI port. While doing that they use some inconsistent code: 1. after the loop they check, whether the list contained at least one element and if not, they return an error. However, the earlier code to use the common HDMI driver uses the first element of the same list without checking. To fix this we move the check to the top of the function. 2. some of those .late_probe() implementations execute code, only needed for the common HDMI driver, before checking, whether the driver is used. Move the code to after the check. 3. Some of those functions also perform a redundant initialisation of the "err" variable. This patch fixes those issues. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/20200124213625.30186-8-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
bd01cf38ee
commit
98ff5c262f
@ -617,12 +617,15 @@ static int bxt_card_late_probe(struct snd_soc_card *card)
|
||||
snd_soc_dapm_add_routes(&card->dapm, broxton_map,
|
||||
ARRAY_SIZE(broxton_map));
|
||||
|
||||
pcm = list_first_entry(&ctx->hdmi_pcm_list, struct bxt_hdmi_pcm,
|
||||
head);
|
||||
component = pcm->codec_dai->component;
|
||||
if (list_empty(&ctx->hdmi_pcm_list))
|
||||
return -EINVAL;
|
||||
|
||||
if (ctx->common_hdmi_codec_drv)
|
||||
if (ctx->common_hdmi_codec_drv) {
|
||||
pcm = list_first_entry(&ctx->hdmi_pcm_list, struct bxt_hdmi_pcm,
|
||||
head);
|
||||
component = pcm->codec_dai->component;
|
||||
return hda_dsp_hdmi_build_controls(card, component);
|
||||
}
|
||||
|
||||
list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
|
||||
component = pcm->codec_dai->component;
|
||||
@ -643,9 +646,6 @@ static int bxt_card_late_probe(struct snd_soc_card *card)
|
||||
i++;
|
||||
}
|
||||
|
||||
if (!component)
|
||||
return -EINVAL;
|
||||
|
||||
return hdac_hdmi_jack_port_init(component, &card->dapm);
|
||||
}
|
||||
|
||||
|
@ -529,12 +529,15 @@ static int bxt_card_late_probe(struct snd_soc_card *card)
|
||||
int err, i = 0;
|
||||
char jack_name[NAME_SIZE];
|
||||
|
||||
pcm = list_first_entry(&ctx->hdmi_pcm_list, struct bxt_hdmi_pcm,
|
||||
head);
|
||||
component = pcm->codec_dai->component;
|
||||
if (list_empty(&ctx->hdmi_pcm_list))
|
||||
return -EINVAL;
|
||||
|
||||
if (ctx->common_hdmi_codec_drv)
|
||||
if (ctx->common_hdmi_codec_drv) {
|
||||
pcm = list_first_entry(&ctx->hdmi_pcm_list, struct bxt_hdmi_pcm,
|
||||
head);
|
||||
component = pcm->codec_dai->component;
|
||||
return hda_dsp_hdmi_build_controls(card, component);
|
||||
}
|
||||
|
||||
list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
|
||||
component = pcm->codec_dai->component;
|
||||
@ -555,9 +558,6 @@ static int bxt_card_late_probe(struct snd_soc_card *card)
|
||||
i++;
|
||||
}
|
||||
|
||||
if (!component)
|
||||
return -EINVAL;
|
||||
|
||||
return hdac_hdmi_jack_port_init(component, &card->dapm);
|
||||
}
|
||||
|
||||
|
@ -241,12 +241,15 @@ static int sof_card_late_probe(struct snd_soc_card *card)
|
||||
struct hdmi_pcm *pcm;
|
||||
int ret, i = 0;
|
||||
|
||||
pcm = list_first_entry(&ctx->hdmi_pcm_list, struct hdmi_pcm,
|
||||
head);
|
||||
component = pcm->codec_dai->component;
|
||||
if (list_empty(&ctx->hdmi_pcm_list))
|
||||
return -EINVAL;
|
||||
|
||||
if (ctx->common_hdmi_codec_drv)
|
||||
if (ctx->common_hdmi_codec_drv) {
|
||||
pcm = list_first_entry(&ctx->hdmi_pcm_list, struct hdmi_pcm,
|
||||
head);
|
||||
component = pcm->codec_dai->component;
|
||||
return hda_dsp_hdmi_build_controls(card, component);
|
||||
}
|
||||
|
||||
list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
|
||||
component = pcm->codec_dai->component;
|
||||
@ -265,8 +268,6 @@ static int sof_card_late_probe(struct snd_soc_card *card)
|
||||
|
||||
i++;
|
||||
}
|
||||
if (!component)
|
||||
return -EINVAL;
|
||||
|
||||
return hdac_hdmi_jack_port_init(component, &card->dapm);
|
||||
}
|
||||
|
@ -534,15 +534,18 @@ static int glk_card_late_probe(struct snd_soc_card *card)
|
||||
struct snd_soc_component *component = NULL;
|
||||
char jack_name[NAME_SIZE];
|
||||
struct glk_hdmi_pcm *pcm;
|
||||
int err = 0;
|
||||
int err;
|
||||
int i = 0;
|
||||
|
||||
pcm = list_first_entry(&ctx->hdmi_pcm_list, struct glk_hdmi_pcm,
|
||||
head);
|
||||
component = pcm->codec_dai->component;
|
||||
if (list_empty(&ctx->hdmi_pcm_list))
|
||||
return -EINVAL;
|
||||
|
||||
if (ctx->common_hdmi_codec_drv)
|
||||
if (ctx->common_hdmi_codec_drv) {
|
||||
pcm = list_first_entry(&ctx->hdmi_pcm_list, struct glk_hdmi_pcm,
|
||||
head);
|
||||
component = pcm->codec_dai->component;
|
||||
return hda_dsp_hdmi_build_controls(card, component);
|
||||
}
|
||||
|
||||
list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
|
||||
component = pcm->codec_dai->component;
|
||||
@ -563,9 +566,6 @@ static int glk_card_late_probe(struct snd_soc_card *card)
|
||||
i++;
|
||||
}
|
||||
|
||||
if (!component)
|
||||
return -EINVAL;
|
||||
|
||||
return hdac_hdmi_jack_port_init(component, &card->dapm);
|
||||
}
|
||||
|
||||
|
@ -273,19 +273,22 @@ static int sof_card_late_probe(struct snd_soc_card *card)
|
||||
struct snd_soc_component *component = NULL;
|
||||
char jack_name[NAME_SIZE];
|
||||
struct sof_hdmi_pcm *pcm;
|
||||
int err = 0;
|
||||
int err;
|
||||
int i = 0;
|
||||
|
||||
/* HDMI is not supported by SOF on Baytrail/CherryTrail */
|
||||
if (is_legacy_cpu)
|
||||
return 0;
|
||||
|
||||
pcm = list_first_entry(&ctx->hdmi_pcm_list, struct sof_hdmi_pcm,
|
||||
head);
|
||||
component = pcm->codec_dai->component;
|
||||
if (list_empty(&ctx->hdmi_pcm_list))
|
||||
return -EINVAL;
|
||||
|
||||
if (ctx->common_hdmi_codec_drv)
|
||||
if (ctx->common_hdmi_codec_drv) {
|
||||
pcm = list_first_entry(&ctx->hdmi_pcm_list, struct sof_hdmi_pcm,
|
||||
head);
|
||||
component = pcm->codec_dai->component;
|
||||
return hda_dsp_hdmi_build_controls(card, component);
|
||||
}
|
||||
|
||||
list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
|
||||
component = pcm->codec_dai->component;
|
||||
@ -305,8 +308,6 @@ static int sof_card_late_probe(struct snd_soc_card *card)
|
||||
|
||||
i++;
|
||||
}
|
||||
if (!component)
|
||||
return -EINVAL;
|
||||
|
||||
return hdac_hdmi_jack_port_init(component, &card->dapm);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user