Skip to content

Commit 98ff5c2

Browse files
lyakhbroonie
authored andcommitted
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 <[email protected]> Signed-off-by: Pierre-Louis Bossart <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent bd01cf3 commit 98ff5c2

File tree

5 files changed

+37
-35
lines changed

5 files changed

+37
-35
lines changed

sound/soc/intel/boards/bxt_da7219_max98357a.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -617,12 +617,15 @@ static int bxt_card_late_probe(struct snd_soc_card *card)
617617
snd_soc_dapm_add_routes(&card->dapm, broxton_map,
618618
ARRAY_SIZE(broxton_map));
619619

620-
pcm = list_first_entry(&ctx->hdmi_pcm_list, struct bxt_hdmi_pcm,
621-
head);
622-
component = pcm->codec_dai->component;
620+
if (list_empty(&ctx->hdmi_pcm_list))
621+
return -EINVAL;
623622

624-
if (ctx->common_hdmi_codec_drv)
623+
if (ctx->common_hdmi_codec_drv) {
624+
pcm = list_first_entry(&ctx->hdmi_pcm_list, struct bxt_hdmi_pcm,
625+
head);
626+
component = pcm->codec_dai->component;
625627
return hda_dsp_hdmi_build_controls(card, component);
628+
}
626629

627630
list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
628631
component = pcm->codec_dai->component;
@@ -643,9 +646,6 @@ static int bxt_card_late_probe(struct snd_soc_card *card)
643646
i++;
644647
}
645648

646-
if (!component)
647-
return -EINVAL;
648-
649649
return hdac_hdmi_jack_port_init(component, &card->dapm);
650650
}
651651

sound/soc/intel/boards/bxt_rt298.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -529,12 +529,15 @@ static int bxt_card_late_probe(struct snd_soc_card *card)
529529
int err, i = 0;
530530
char jack_name[NAME_SIZE];
531531

532-
pcm = list_first_entry(&ctx->hdmi_pcm_list, struct bxt_hdmi_pcm,
533-
head);
534-
component = pcm->codec_dai->component;
532+
if (list_empty(&ctx->hdmi_pcm_list))
533+
return -EINVAL;
535534

536-
if (ctx->common_hdmi_codec_drv)
535+
if (ctx->common_hdmi_codec_drv) {
536+
pcm = list_first_entry(&ctx->hdmi_pcm_list, struct bxt_hdmi_pcm,
537+
head);
538+
component = pcm->codec_dai->component;
537539
return hda_dsp_hdmi_build_controls(card, component);
540+
}
538541

539542
list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
540543
component = pcm->codec_dai->component;
@@ -555,9 +558,6 @@ static int bxt_card_late_probe(struct snd_soc_card *card)
555558
i++;
556559
}
557560

558-
if (!component)
559-
return -EINVAL;
560-
561561
return hdac_hdmi_jack_port_init(component, &card->dapm);
562562
}
563563

sound/soc/intel/boards/cml_rt1011_rt5682.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,15 @@ static int sof_card_late_probe(struct snd_soc_card *card)
241241
struct hdmi_pcm *pcm;
242242
int ret, i = 0;
243243

244-
pcm = list_first_entry(&ctx->hdmi_pcm_list, struct hdmi_pcm,
245-
head);
246-
component = pcm->codec_dai->component;
244+
if (list_empty(&ctx->hdmi_pcm_list))
245+
return -EINVAL;
247246

248-
if (ctx->common_hdmi_codec_drv)
247+
if (ctx->common_hdmi_codec_drv) {
248+
pcm = list_first_entry(&ctx->hdmi_pcm_list, struct hdmi_pcm,
249+
head);
250+
component = pcm->codec_dai->component;
249251
return hda_dsp_hdmi_build_controls(card, component);
252+
}
250253

251254
list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
252255
component = pcm->codec_dai->component;
@@ -265,8 +268,6 @@ static int sof_card_late_probe(struct snd_soc_card *card)
265268

266269
i++;
267270
}
268-
if (!component)
269-
return -EINVAL;
270271

271272
return hdac_hdmi_jack_port_init(component, &card->dapm);
272273
}

sound/soc/intel/boards/glk_rt5682_max98357a.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -534,15 +534,18 @@ static int glk_card_late_probe(struct snd_soc_card *card)
534534
struct snd_soc_component *component = NULL;
535535
char jack_name[NAME_SIZE];
536536
struct glk_hdmi_pcm *pcm;
537-
int err = 0;
537+
int err;
538538
int i = 0;
539539

540-
pcm = list_first_entry(&ctx->hdmi_pcm_list, struct glk_hdmi_pcm,
541-
head);
542-
component = pcm->codec_dai->component;
540+
if (list_empty(&ctx->hdmi_pcm_list))
541+
return -EINVAL;
543542

544-
if (ctx->common_hdmi_codec_drv)
543+
if (ctx->common_hdmi_codec_drv) {
544+
pcm = list_first_entry(&ctx->hdmi_pcm_list, struct glk_hdmi_pcm,
545+
head);
546+
component = pcm->codec_dai->component;
545547
return hda_dsp_hdmi_build_controls(card, component);
548+
}
546549

547550
list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
548551
component = pcm->codec_dai->component;
@@ -563,9 +566,6 @@ static int glk_card_late_probe(struct snd_soc_card *card)
563566
i++;
564567
}
565568

566-
if (!component)
567-
return -EINVAL;
568-
569569
return hdac_hdmi_jack_port_init(component, &card->dapm);
570570
}
571571

sound/soc/intel/boards/sof_rt5682.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -273,19 +273,22 @@ static int sof_card_late_probe(struct snd_soc_card *card)
273273
struct snd_soc_component *component = NULL;
274274
char jack_name[NAME_SIZE];
275275
struct sof_hdmi_pcm *pcm;
276-
int err = 0;
276+
int err;
277277
int i = 0;
278278

279279
/* HDMI is not supported by SOF on Baytrail/CherryTrail */
280280
if (is_legacy_cpu)
281281
return 0;
282282

283-
pcm = list_first_entry(&ctx->hdmi_pcm_list, struct sof_hdmi_pcm,
284-
head);
285-
component = pcm->codec_dai->component;
283+
if (list_empty(&ctx->hdmi_pcm_list))
284+
return -EINVAL;
286285

287-
if (ctx->common_hdmi_codec_drv)
286+
if (ctx->common_hdmi_codec_drv) {
287+
pcm = list_first_entry(&ctx->hdmi_pcm_list, struct sof_hdmi_pcm,
288+
head);
289+
component = pcm->codec_dai->component;
288290
return hda_dsp_hdmi_build_controls(card, component);
291+
}
289292

290293
list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
291294
component = pcm->codec_dai->component;
@@ -305,8 +308,6 @@ static int sof_card_late_probe(struct snd_soc_card *card)
305308

306309
i++;
307310
}
308-
if (!component)
309-
return -EINVAL;
310311

311312
return hdac_hdmi_jack_port_init(component, &card->dapm);
312313
}

0 commit comments

Comments
 (0)