Skip to contentSkip to conversation

ASoC: Intel: avs: Use list_count_nodes() to simplify the code

PATCH In review Cezary Rojewski 2 participants 3 messages Sep 14

Subsystems (3)
lore
Share & tools
lore

Cezary Rojewski

author maintainer
#0 lore raw

PATCH 1/2 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.

---
 sound/soc/intel/avs/boards/hdaudio.c | 8 +++-----
 sound/soc/intel/avs/pcm.c            | 7 +++----
 2 files changed, 6 insertions(+), 9 deletions(-)
sound/soc/intel/avs/boards/hdaudio.c +3 -5
index 2e15a293298d..c1d2d0082b14 100644
@@ -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) {
sound/soc/intel/avs/pcm.c +3 -4
index ad25bd355769..8174d2ebfa99 100644
@@ -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);
Signature · 1 line
2.34.1
author maintainer
#1 lore raw

PATCH 2/2 ASoC: codecs: hda: 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.

---
 sound/soc/codecs/hda.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
sound/soc/codecs/hda.c +3 -4
index 237b0b060457..084659106d5d 100644
@@ -85,12 +85,11 @@ static int hda_codec_register_dais(struct hda_codec *codec, struct snd_soc_compo
 	struct snd_soc_dai_driver *drvs = NULL;
 	struct snd_soc_dapm_context *dapm;
 	struct hda_pcm *pcm;
-	int ret, pcm_count = 0;
+	int ret, pcm_count;
 
-	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++;
 
 	ret = hda_codec_create_dais(codec, pcm_count, &drvs);
 	if (ret < 0)
Signature · 1 line
2.34.1
maintainer
#2 lore raw
In reply to Cezary Rojewski
Quoted 1 line · Cezary Rojewski

ASoC: Intel: avs: Use list_count_nodes() to simplify the code

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.4

Thanks!

[1/2] ASoC: Intel: avs: Use list_count_nodes() to simplify the code

      https://git.kernel.org/broonie/sound/c/bb1719bd0caf
[2/2] ASoC: codecs: hda: Use list_count_nodes() to simplify the code
      https://git.kernel.org/broonie/sound/c/3411fcf7e1f7

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark