Commit 98ff5c26 authored by Guennadi Liakhovetski's avatar Guennadi Liakhovetski Committed by Mark Brown

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: default avatarGuennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20200124213625.30186-8-pierre-louis.bossart@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent bd01cf38
...@@ -617,12 +617,15 @@ static int bxt_card_late_probe(struct snd_soc_card *card) ...@@ -617,12 +617,15 @@ static int bxt_card_late_probe(struct snd_soc_card *card)
snd_soc_dapm_add_routes(&card->dapm, broxton_map, snd_soc_dapm_add_routes(&card->dapm, broxton_map,
ARRAY_SIZE(broxton_map)); ARRAY_SIZE(broxton_map));
if (list_empty(&ctx->hdmi_pcm_list))
return -EINVAL;
if (ctx->common_hdmi_codec_drv) {
pcm = list_first_entry(&ctx->hdmi_pcm_list, struct bxt_hdmi_pcm, pcm = list_first_entry(&ctx->hdmi_pcm_list, struct bxt_hdmi_pcm,
head); head);
component = pcm->codec_dai->component; component = pcm->codec_dai->component;
if (ctx->common_hdmi_codec_drv)
return hda_dsp_hdmi_build_controls(card, component); return hda_dsp_hdmi_build_controls(card, component);
}
list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
component = pcm->codec_dai->component; component = pcm->codec_dai->component;
...@@ -643,9 +646,6 @@ static int bxt_card_late_probe(struct snd_soc_card *card) ...@@ -643,9 +646,6 @@ static int bxt_card_late_probe(struct snd_soc_card *card)
i++; i++;
} }
if (!component)
return -EINVAL;
return hdac_hdmi_jack_port_init(component, &card->dapm); return hdac_hdmi_jack_port_init(component, &card->dapm);
} }
......
...@@ -529,12 +529,15 @@ static int bxt_card_late_probe(struct snd_soc_card *card) ...@@ -529,12 +529,15 @@ static int bxt_card_late_probe(struct snd_soc_card *card)
int err, i = 0; int err, i = 0;
char jack_name[NAME_SIZE]; char jack_name[NAME_SIZE];
if (list_empty(&ctx->hdmi_pcm_list))
return -EINVAL;
if (ctx->common_hdmi_codec_drv) {
pcm = list_first_entry(&ctx->hdmi_pcm_list, struct bxt_hdmi_pcm, pcm = list_first_entry(&ctx->hdmi_pcm_list, struct bxt_hdmi_pcm,
head); head);
component = pcm->codec_dai->component; component = pcm->codec_dai->component;
if (ctx->common_hdmi_codec_drv)
return hda_dsp_hdmi_build_controls(card, component); return hda_dsp_hdmi_build_controls(card, component);
}
list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
component = pcm->codec_dai->component; component = pcm->codec_dai->component;
...@@ -555,9 +558,6 @@ static int bxt_card_late_probe(struct snd_soc_card *card) ...@@ -555,9 +558,6 @@ static int bxt_card_late_probe(struct snd_soc_card *card)
i++; i++;
} }
if (!component)
return -EINVAL;
return hdac_hdmi_jack_port_init(component, &card->dapm); return hdac_hdmi_jack_port_init(component, &card->dapm);
} }
......
...@@ -241,12 +241,15 @@ static int sof_card_late_probe(struct snd_soc_card *card) ...@@ -241,12 +241,15 @@ static int sof_card_late_probe(struct snd_soc_card *card)
struct hdmi_pcm *pcm; struct hdmi_pcm *pcm;
int ret, i = 0; int ret, i = 0;
if (list_empty(&ctx->hdmi_pcm_list))
return -EINVAL;
if (ctx->common_hdmi_codec_drv) {
pcm = list_first_entry(&ctx->hdmi_pcm_list, struct hdmi_pcm, pcm = list_first_entry(&ctx->hdmi_pcm_list, struct hdmi_pcm,
head); head);
component = pcm->codec_dai->component; component = pcm->codec_dai->component;
if (ctx->common_hdmi_codec_drv)
return hda_dsp_hdmi_build_controls(card, component); return hda_dsp_hdmi_build_controls(card, component);
}
list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
component = pcm->codec_dai->component; component = pcm->codec_dai->component;
...@@ -265,8 +268,6 @@ static int sof_card_late_probe(struct snd_soc_card *card) ...@@ -265,8 +268,6 @@ static int sof_card_late_probe(struct snd_soc_card *card)
i++; i++;
} }
if (!component)
return -EINVAL;
return hdac_hdmi_jack_port_init(component, &card->dapm); return hdac_hdmi_jack_port_init(component, &card->dapm);
} }
......
...@@ -534,15 +534,18 @@ static int glk_card_late_probe(struct snd_soc_card *card) ...@@ -534,15 +534,18 @@ static int glk_card_late_probe(struct snd_soc_card *card)
struct snd_soc_component *component = NULL; struct snd_soc_component *component = NULL;
char jack_name[NAME_SIZE]; char jack_name[NAME_SIZE];
struct glk_hdmi_pcm *pcm; struct glk_hdmi_pcm *pcm;
int err = 0; int err;
int i = 0; int i = 0;
if (list_empty(&ctx->hdmi_pcm_list))
return -EINVAL;
if (ctx->common_hdmi_codec_drv) {
pcm = list_first_entry(&ctx->hdmi_pcm_list, struct glk_hdmi_pcm, pcm = list_first_entry(&ctx->hdmi_pcm_list, struct glk_hdmi_pcm,
head); head);
component = pcm->codec_dai->component; component = pcm->codec_dai->component;
if (ctx->common_hdmi_codec_drv)
return hda_dsp_hdmi_build_controls(card, component); return hda_dsp_hdmi_build_controls(card, component);
}
list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
component = pcm->codec_dai->component; component = pcm->codec_dai->component;
...@@ -563,9 +566,6 @@ static int glk_card_late_probe(struct snd_soc_card *card) ...@@ -563,9 +566,6 @@ static int glk_card_late_probe(struct snd_soc_card *card)
i++; i++;
} }
if (!component)
return -EINVAL;
return hdac_hdmi_jack_port_init(component, &card->dapm); return hdac_hdmi_jack_port_init(component, &card->dapm);
} }
......
...@@ -273,19 +273,22 @@ static int sof_card_late_probe(struct snd_soc_card *card) ...@@ -273,19 +273,22 @@ static int sof_card_late_probe(struct snd_soc_card *card)
struct snd_soc_component *component = NULL; struct snd_soc_component *component = NULL;
char jack_name[NAME_SIZE]; char jack_name[NAME_SIZE];
struct sof_hdmi_pcm *pcm; struct sof_hdmi_pcm *pcm;
int err = 0; int err;
int i = 0; int i = 0;
/* HDMI is not supported by SOF on Baytrail/CherryTrail */ /* HDMI is not supported by SOF on Baytrail/CherryTrail */
if (is_legacy_cpu) if (is_legacy_cpu)
return 0; return 0;
if (list_empty(&ctx->hdmi_pcm_list))
return -EINVAL;
if (ctx->common_hdmi_codec_drv) {
pcm = list_first_entry(&ctx->hdmi_pcm_list, struct sof_hdmi_pcm, pcm = list_first_entry(&ctx->hdmi_pcm_list, struct sof_hdmi_pcm,
head); head);
component = pcm->codec_dai->component; component = pcm->codec_dai->component;
if (ctx->common_hdmi_codec_drv)
return hda_dsp_hdmi_build_controls(card, component); return hda_dsp_hdmi_build_controls(card, component);
}
list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
component = pcm->codec_dai->component; component = pcm->codec_dai->component;
...@@ -305,8 +308,6 @@ static int sof_card_late_probe(struct snd_soc_card *card) ...@@ -305,8 +308,6 @@ static int sof_card_late_probe(struct snd_soc_card *card)
i++; i++;
} }
if (!component)
return -EINVAL;
return hdac_hdmi_jack_port_init(component, &card->dapm); return hdac_hdmi_jack_port_init(component, &card->dapm);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment