diff options
| author | Cezary Rojewski <cezary.rojewski@intel.com> | 2026-09-14 12:19:16 +0200 |
|---|---|---|
| committer | Mark Brown <broonie@kernel.org> | 2026-09-14 15:23:10 +0100 |
| commit | bb1719bd0caf84dc29ac227b01c368b7878d3095 (patch) | |
| tree | 52ba9469917362f48a8dd663715990fb3c10e6ff | |
| parent | d4158f3ee4f09c5001716765d135132e4b40b63a (diff) | |
| download | linux-next-bb1719bd0caf84dc29ac227b01c368b7878d3095.tar.gz linux-next-bb1719bd0caf84dc29ac227b01c368b7878d3095.zip | |
ASoC: Intel: avs: Use list_count_nodes() to simplify the code
By enlisting list_count_nodes(), a recent addition to the list.h, the
code responsible for manual counting of the HDAudio PCMs can be dropped.
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://patch.msgid.link/20260914101917.2969665-1-cezary.rojewski@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
| -rw-r--r-- | sound/soc/intel/avs/boards/hdaudio.c | 8 | ||||
| -rw-r--r-- | sound/soc/intel/avs/pcm.c | 7 |
2 files changed, 6 insertions, 9 deletions
diff --git a/sound/soc/intel/avs/boards/hdaudio.c b/sound/soc/intel/avs/boards/hdaudio.c index 2e15a293298d..c1d2d0082b14 100644 --- a/sound/soc/intel/avs/boards/hdaudio.c +++ b/sound/soc/intel/avs/boards/hdaudio.c @@ -147,17 +147,15 @@ static int avs_probing_link_init(struct snd_soc_pcm_runtime *rtm) struct snd_soc_dai_link *links = NULL; struct snd_soc_card *card = rtm->card; struct hda_codec *codec; - struct hda_pcm *pcm; - int ret, pcm_count = 0; + int ret, pcm_count; mach = dev_get_platdata(card->dev); pdata = mach->pdata; codec = pdata->codec; + pcm_count = list_count_nodes(&codec->pcm_list_head); - if (list_empty(&codec->pcm_list_head)) + if (!pcm_count) return -EINVAL; - list_for_each_entry(pcm, &codec->pcm_list_head, list) - pcm_count++; ret = avs_create_dai_links(card->dev, codec, pcm_count, &links); if (ret < 0) { diff --git a/sound/soc/intel/avs/pcm.c b/sound/soc/intel/avs/pcm.c index ad25bd355769..8174d2ebfa99 100644 --- a/sound/soc/intel/avs/pcm.c +++ b/sound/soc/intel/avs/pcm.c @@ -1614,7 +1614,7 @@ static int avs_component_hda_probe(struct snd_soc_component *component) struct hda_codec *codec; struct hda_pcm *pcm; const char *cname; - int pcm_count = 0, ret, i; + int pcm_count, ret, i; mach = dev_get_platdata(component->card->dev); if (!mach) @@ -1622,10 +1622,9 @@ static int avs_component_hda_probe(struct snd_soc_component *component) pdata = mach->pdata; codec = pdata->codec; - if (list_empty(&codec->pcm_list_head)) + pcm_count = list_count_nodes(&codec->pcm_list_head); + if (!pcm_count) return -EINVAL; - list_for_each_entry(pcm, &codec->pcm_list_head, list) - pcm_count++; dais = devm_kcalloc(component->dev, pcm_count, sizeof(*dais), GFP_KERNEL); |
