add add for_each_xx() macro
Subsystems (12)
Kuninori Morimoto
maintainercover add add for_each_xx() macro
Hi Mark
Current ALSA SoC is using many list_for_each_entry() and/or for() loop for each lists.
But, these need to use same pattern, and it is not readable.
Now, "codec list loop for rtd", and "codec list loop for dai_link" had been replaced to for_each_xxx() macro.
These patches replace "xxx list loop for yyy" by using for_each_yyy_xxx() macro.
# Maybe some of them are overkill replacement, and/or
# using not good naming. I'm happy to get feedback
1) - 2) : fixup previous for_each_xxx() macro patch
3) - 11) : new for_each_xxx() macro
Kuninori Morimoto (11):
1) ASoC: convert for_each_rtd_codec_dai() for missing part
2) ASoC: rename for_each_rtd_codec_dai_reverse to rollback
3) ASoC: add for_each_card_prelinks() macro
4) ASoC: add for_each_card_links() macro
5) ASoC: add for_each_card_rtds() macro
6) ASoC: add for_each_card_components() macro
7) ASoC: add for_each_component_all() macro
8) ASoC: add for_each_component_dais() macro
9) ASoC: add for_each_comp_order() macro
10) ASoC: add for_each_dpcm_fe() macro
11) ASoC: add for_each_dpcm_be() macro
include/sound/soc-dpcm.h | 10 ++ include/sound/soc.h | 29 ++++- sound/soc/codecs/hdac_hdmi.c | 2 +- sound/soc/fsl/fsl_asrc_dma.c | 2 +- sound/soc/fsl/pcm030-audio-fabric.c | 5 +- sound/soc/generic/simple-card-utils.c | 6 +- sound/soc/intel/atom/sst-mfld-platform-pcm.c | 4 +- sound/soc/intel/boards/broadwell.c | 4 +- sound/soc/intel/boards/bytcr_rt5640.c | 4 +- sound/soc/intel/boards/bytcr_rt5651.c | 4 +- sound/soc/intel/boards/cht_bsw_rt5672.c | 4 +- sound/soc/intel/boards/skl_hda_dsp_generic.c | 5 +- sound/soc/mediatek/mt2701/mt2701-cs42448.c | 13 +-- sound/soc/mediatek/mt2701/mt2701-wm8960.c | 13 +-- sound/soc/mediatek/mt6797/mt6797-mt6351.c | 13 +-- sound/soc/mediatek/mt8173/mt8173-max98090.c | 13 +-- sound/soc/mediatek/mt8173/mt8173-rt5650-rt5514.c | 7 +- sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c | 7 +- sound/soc/mediatek/mt8173/mt8173-rt5650.c | 7 +- sound/soc/meson/axg-card.c | 3 +- sound/soc/qcom/apq8096.c | 7 +- sound/soc/qcom/sdm845.c | 7 +- sound/soc/samsung/tm2_wm5110.c | 13 +-- sound/soc/sh/rcar/ctu.c | 2 +- sound/soc/sh/rcar/src.c | 2 +- sound/soc/soc-compress.c | 4 +- sound/soc/soc-core.c | 130 +++++++++++------------ sound/soc/soc-dapm.c | 2 +- sound/soc/soc-pcm.c | 101 +++++++++--------- 29 files changed, 230 insertions(+), 193 deletions(-)
Signature · 1 line
2.7.4
Kuninori Morimoto
maintainerPATCH 1/11 ASoC: convert for_each_rtd_codec_dai() for missing part
From: Kuninori Morimoto <[email protected]>
commit 0b7990e38971 ("ASoC: add for_each_rtd_codec_dai() macro") added for_each_rtd_codec_dai(), but it didn't convert few loop which is not using "rtd". This patch fixup it.
--- sound/soc/soc-pcm.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-)
sound/soc/soc-pcm.c +15 -16
@@ -1301,6 +1301,7 @@ static struct snd_soc_pcm_runtime *dpcm_get_be(struct snd_soc_card *card, struct snd_soc_dapm_widget *widget, int stream) {struct snd_soc_pcm_runtime *be; +struct snd_soc_dai *dai;int i;dev_dbg (card->dev,"ASoC: find BE for widget %s\n" , widget->name);
@@ -1318,8 +1319,7 @@ static struct snd_soc_pcm_runtime *dpcm_get_be(struct snd_soc_card *card,if (be->cpu_dai->playback_widget == widget)return be; -for (i =0 ; i < be->num_codecs; i++) { -struct snd_soc_dai *dai = be->codec_dais[i]; +for_each_rtd_codec_dai (be, i, dai) {if (dai->playback_widget == widget)return be; }
@@ -1338,8 +1338,7 @@ static struct snd_soc_pcm_runtime *dpcm_get_be(struct snd_soc_card *card,if (be->cpu_dai->capture_widget == widget)return be; -for (i =0 ; i < be->num_codecs; i++) { -struct snd_soc_dai *dai = be->codec_dais[i]; +for_each_rtd_codec_dai (be, i, dai) {if (dai->capture_widget == widget)return be; }
@@ -1435,6 +1434,7 @@ static int dpcm_prune_paths(struct snd_soc_pcm_runtime *fe, int stream,struct snd_soc_dpcm *dpcm;struct snd_soc_dapm_widget_list *list = *list_;struct snd_soc_dapm_widget *widget; +struct snd_soc_dai *dai;int prune =0 ;/* Destroy any old FE <--> BE connections */
@@ -1449,8 +1449,7 @@ static int dpcm_prune_paths(struct snd_soc_pcm_runtime *fe, int stream,continue ;/* is there a valid CODEC DAI widget for this BE */ -for (i =0 ; i < dpcm->be->num_codecs; i++) { -struct snd_soc_dai *dai = dpcm->be->codec_dais[i]; +for_each_rtd_codec_dai (dpcm->be, i, dai) { widget =dai_get_widget (dai, stream);/* prune the BE if it's no longer in our active list */
@@ -1685,6 +1684,7 @@ static void dpcm_runtime_merge_format(struct snd_pcm_substream *substream, {struct snd_soc_pcm_runtime *fe = substream->private_data;struct snd_soc_dpcm *dpcm; +struct snd_soc_dai *dai;int stream = substream->stream;if (!fe->dai_link->dpcm_merged_format)
@@ -1701,16 +1701,15 @@ static void dpcm_runtime_merge_format(struct snd_pcm_substream *substream,struct snd_soc_pcm_stream *codec_stream;int i; -for (i =0 ; i < be->num_codecs; i++) { +for_each_rtd_codec_dai (be, i, dai) {/* * Skip CODECs which don't support the current stream * type. See soc_pcm_init_runtime_hw() for more details */ -if (!snd_soc_dai_stream_valid (be->codec_dais[i], - stream)) +if (!snd_soc_dai_stream_valid (dai, stream))continue ; - codec_dai_drv = be->codec_dais[i]->driver; + codec_dai_drv = dai->driver;if (stream ==SNDRV_PCM_STREAM_PLAYBACK ) codec_stream = &codec_dai_drv->playback;else
@@ -1795,6 +1794,7 @@ static void dpcm_runtime_merge_rate(struct snd_pcm_substream *substream,struct snd_soc_dai_driver *codec_dai_drv;struct snd_soc_pcm_stream *codec_stream;struct snd_soc_pcm_stream *cpu_stream; +struct snd_soc_dai *dai;int i;if (stream ==SNDRV_PCM_STREAM_PLAYBACK )
@@ -1806,16 +1806,15 @@ static void dpcm_runtime_merge_rate(struct snd_pcm_substream *substream, *rate_max =min_not_zero (*rate_max, cpu_stream->rate_max); *rates =snd_pcm_rate_mask_intersect (*rates, cpu_stream->rates); -for (i =0 ; i < be->num_codecs; i++) { +for_each_rtd_codec_dai (be, i, dai) {/* * Skip CODECs which don't support the current stream * type. See soc_pcm_init_runtime_hw() for more details */ -if (!snd_soc_dai_stream_valid (be->codec_dais[i], - stream)) +if (!snd_soc_dai_stream_valid (dai, stream))continue ; - codec_dai_drv = be->codec_dais[i]->driver; + codec_dai_drv = dai->driver;if (stream ==SNDRV_PCM_STREAM_PLAYBACK ) codec_stream = &codec_dai_drv->playback;else
@@ -2784,6 +2783,7 @@ int soc_dpcm_be_digital_mute(struct snd_soc_pcm_runtime *fe, int mute)struct snd_soc_dpcm *dpcm;struct list_head *clients = &fe->dpcm[SNDRV_PCM_STREAM_PLAYBACK ].be_clients; +struct snd_soc_dai *dai;list_for_each_entry (dpcm, clients, list_be) {
@@ -2793,8 +2793,7 @@ int soc_dpcm_be_digital_mute(struct snd_soc_pcm_runtime *fe, int mute)if (be->dai_link->ignore_suspend)continue ; -for (i =0 ; i < be->num_codecs; i++) { -struct snd_soc_dai *dai = be->codec_dais[i]; +for_each_rtd_codec_dai (be, i, dai) {struct snd_soc_dai_driver *drv = dai->driver; dev_dbg(be->dev, "ASoC: BE digital mute %s\n",
Signature · 1 line
2.7.4
Mark Brown
maintainerApplied "ASoC: convert for_each_rtd_codec_dai() for missing part" to the asoc tree
The patch
ASoC: convert for_each_rtd_codec_dai() for missing part
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
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
Quoted 1 line
From
7afecb3073e357ebfe4087e4ab8bb493c32bb652Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto <[email protected]>
Date: Tue, 18 Sep 2018 01:28:04 +0000
Subject: [PATCH] ASoC: convert for_each_rtd_codec_dai() for missing part
commit 0b7990e38971 ("ASoC: add for_each_rtd_codec_dai() macro") added for_each_rtd_codec_dai(), but it didn't convert few loop which is not using "rtd". This patch fixup it.
--- sound/soc/soc-pcm.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-)
sound/soc/soc-pcm.c +15 -16
@@ -1301,6 +1301,7 @@ static struct snd_soc_pcm_runtime *dpcm_get_be(struct snd_soc_card *card, struct snd_soc_dapm_widget *widget, int stream) {struct snd_soc_pcm_runtime *be; +struct snd_soc_dai *dai;int i;dev_dbg (card->dev,"ASoC: find BE for widget %s\n" , widget->name);
@@ -1318,8 +1319,7 @@ static struct snd_soc_pcm_runtime *dpcm_get_be(struct snd_soc_card *card,if (be->cpu_dai->playback_widget == widget)return be; -for (i =0 ; i < be->num_codecs; i++) { -struct snd_soc_dai *dai = be->codec_dais[i]; +for_each_rtd_codec_dai (be, i, dai) {if (dai->playback_widget == widget)return be; }
@@ -1338,8 +1338,7 @@ static struct snd_soc_pcm_runtime *dpcm_get_be(struct snd_soc_card *card,if (be->cpu_dai->capture_widget == widget)return be; -for (i =0 ; i < be->num_codecs; i++) { -struct snd_soc_dai *dai = be->codec_dais[i]; +for_each_rtd_codec_dai (be, i, dai) {if (dai->capture_widget == widget)return be; }
@@ -1435,6 +1434,7 @@ static int dpcm_prune_paths(struct snd_soc_pcm_runtime *fe, int stream,struct snd_soc_dpcm *dpcm;struct snd_soc_dapm_widget_list *list = *list_;struct snd_soc_dapm_widget *widget; +struct snd_soc_dai *dai;int prune =0 ;/* Destroy any old FE <--> BE connections */
@@ -1449,8 +1449,7 @@ static int dpcm_prune_paths(struct snd_soc_pcm_runtime *fe, int stream,continue ;/* is there a valid CODEC DAI widget for this BE */ -for (i =0 ; i < dpcm->be->num_codecs; i++) { -struct snd_soc_dai *dai = dpcm->be->codec_dais[i]; +for_each_rtd_codec_dai (dpcm->be, i, dai) { widget =dai_get_widget (dai, stream);/* prune the BE if it's no longer in our active list */
@@ -1685,6 +1684,7 @@ static void dpcm_runtime_merge_format(struct snd_pcm_substream *substream, {struct snd_soc_pcm_runtime *fe = substream->private_data;struct snd_soc_dpcm *dpcm; +struct snd_soc_dai *dai;int stream = substream->stream;if (!fe->dai_link->dpcm_merged_format)
@@ -1701,16 +1701,15 @@ static void dpcm_runtime_merge_format(struct snd_pcm_substream *substream,struct snd_soc_pcm_stream *codec_stream;int i; -for (i =0 ; i < be->num_codecs; i++) { +for_each_rtd_codec_dai (be, i, dai) {/* * Skip CODECs which don't support the current stream * type. See soc_pcm_init_runtime_hw() for more details */ -if (!snd_soc_dai_stream_valid (be->codec_dais[i], - stream)) +if (!snd_soc_dai_stream_valid (dai, stream))continue ; - codec_dai_drv = be->codec_dais[i]->driver; + codec_dai_drv = dai->driver;if (stream ==SNDRV_PCM_STREAM_PLAYBACK ) codec_stream = &codec_dai_drv->playback;else
@@ -1795,6 +1794,7 @@ static void dpcm_runtime_merge_rate(struct snd_pcm_substream *substream,struct snd_soc_dai_driver *codec_dai_drv;struct snd_soc_pcm_stream *codec_stream;struct snd_soc_pcm_stream *cpu_stream; +struct snd_soc_dai *dai;int i;if (stream ==SNDRV_PCM_STREAM_PLAYBACK )
@@ -1806,16 +1806,15 @@ static void dpcm_runtime_merge_rate(struct snd_pcm_substream *substream, *rate_max =min_not_zero (*rate_max, cpu_stream->rate_max); *rates =snd_pcm_rate_mask_intersect (*rates, cpu_stream->rates); -for (i =0 ; i < be->num_codecs; i++) { +for_each_rtd_codec_dai (be, i, dai) {/* * Skip CODECs which don't support the current stream * type. See soc_pcm_init_runtime_hw() for more details */ -if (!snd_soc_dai_stream_valid (be->codec_dais[i], - stream)) +if (!snd_soc_dai_stream_valid (dai, stream))continue ; - codec_dai_drv = be->codec_dais[i]->driver; + codec_dai_drv = dai->driver;if (stream ==SNDRV_PCM_STREAM_PLAYBACK ) codec_stream = &codec_dai_drv->playback;else
@@ -2784,6 +2783,7 @@ int soc_dpcm_be_digital_mute(struct snd_soc_pcm_runtime *fe, int mute)struct snd_soc_dpcm *dpcm;struct list_head *clients = &fe->dpcm[SNDRV_PCM_STREAM_PLAYBACK ].be_clients; +struct snd_soc_dai *dai;list_for_each_entry (dpcm, clients, list_be) {
@@ -2793,8 +2793,7 @@ int soc_dpcm_be_digital_mute(struct snd_soc_pcm_runtime *fe, int mute)if (be->dai_link->ignore_suspend)continue ; -for (i =0 ; i < be->num_codecs; i++) { -struct snd_soc_dai *dai = be->codec_dais[i]; +for_each_rtd_codec_dai (be, i, dai) {struct snd_soc_dai_driver *drv = dai->driver; dev_dbg(be->dev, "ASoC: BE digital mute %s\n",
Signature · 1 line
2.19.0
Kuninori Morimoto
maintainerPATCH 2/11 ASoC: rename for_each_rtd_codec_dai_reverse to rollback
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
commit 0b7990e38971 ("ASoC: add for_each_rtd_codec_dai() macro") added for_each_rtd_codec_dai_reverse(). but _rollback() is better naming than _reverse(). This patch rename it.
--- include/sound/soc.h | 2 +- sound/soc/soc-pcm.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
include/sound/soc.h +1 -1
@@ -1164,7 +1164,7 @@ struct snd_soc_pcm_runtime {for ((i) =0 ; \ ((i) < rtd->num_codecs) && ((dai) = rtd->codec_dais[i]); \ (i)++) -#define for_each_rtd_codec_dai_reverse (rtd, i, dai) \ +#define for_each_rtd_codec_dai_rollback (rtd, i, dai) \ for (; ((i--) >= 0) && ((dai) = rtd->codec_dais[i]);)
sound/soc/soc-pcm.c +2 -2
@@ -621,7 +621,7 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) i = rtd->num_codecs; codec_dai_err: -for_each_rtd_codec_dai_reverse (rtd, i, codec_dai) { +for_each_rtd_codec_dai_rollback (rtd, i, codec_dai) {if (codec_dai->driver->ops->shutdown) codec_dai->driver->ops->shutdown (substream, codec_dai); }
@@ -1015,7 +1015,7 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, i = rtd->num_codecs; codec_err: -for_each_rtd_codec_dai_reverse (rtd, i, codec_dai) { +for_each_rtd_codec_dai_rollback (rtd, i, codec_dai) {if (codec_dai->driver->ops->hw_free) codec_dai->driver->ops->hw_free (substream, codec_dai); codec_dai->rate =0 ;
Signature · 1 line
2.7.4
Mark Brown
maintainerApplied "ASoC: rename for_each_rtd_codec_dai_reverse to rollback" to the asoc tree
The patch
ASoC: rename for_each_rtd_codec_dai_reverse to rollback
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
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
Quoted 1 line
From
6d11b12879144da5f5aa08071a8a7f95f3b5a4e8Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto <[email protected]>
Date: Tue, 18 Sep 2018 01:28:30 +0000
Subject: [PATCH] ASoC: rename for_each_rtd_codec_dai_reverse to rollback
commit 0b7990e38971 ("ASoC: add for_each_rtd_codec_dai() macro") added for_each_rtd_codec_dai_reverse(). but _rollback() is better naming than _reverse(). This patch rename it.
--- include/sound/soc.h | 2 +- sound/soc/soc-pcm.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
include/sound/soc.h +1 -1
@@ -1164,7 +1164,7 @@ struct snd_soc_pcm_runtime {for ((i) =0 ; \ ((i) < rtd->num_codecs) && ((dai) = rtd->codec_dais[i]); \ (i)++) -#define for_each_rtd_codec_dai_reverse (rtd, i, dai) \ +#define for_each_rtd_codec_dai_rollback (rtd, i, dai) \ for (; ((i--) >= 0) && ((dai) = rtd->codec_dais[i]);)
sound/soc/soc-pcm.c +2 -2
@@ -621,7 +621,7 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) i = rtd->num_codecs; codec_dai_err: -for_each_rtd_codec_dai_reverse (rtd, i, codec_dai) { +for_each_rtd_codec_dai_rollback (rtd, i, codec_dai) {if (codec_dai->driver->ops->shutdown) codec_dai->driver->ops->shutdown (substream, codec_dai); }
@@ -1015,7 +1015,7 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, i = rtd->num_codecs; codec_err: -for_each_rtd_codec_dai_reverse (rtd, i, codec_dai) { +for_each_rtd_codec_dai_rollback (rtd, i, codec_dai) {if (codec_dai->driver->ops->hw_free) codec_dai->driver->ops->hw_free (substream, codec_dai); codec_dai->rate =0 ;
Signature · 1 line
2.19.0
Kuninori Morimoto
maintainerPATCH 3/11 ASoC: add for_each_card_prelinks() macro
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
To be more readable code, this patch adds
new for_each_card_prelinks() macro, and replace existing code to it.
--- include/sound/soc.h | 4 ++++ sound/soc/fsl/pcm030-audio-fabric.c | 5 +++-- sound/soc/generic/simple-card-utils.c | 6 ++---- sound/soc/intel/boards/skl_hda_dsp_generic.c | 5 +++-- sound/soc/mediatek/mt2701/mt2701-cs42448.c | 13 +++++++------ sound/soc/mediatek/mt2701/mt2701-wm8960.c | 13 +++++++------ sound/soc/mediatek/mt6797/mt6797-mt6351.c | 13 +++++++------ sound/soc/mediatek/mt8173/mt8173-max98090.c | 13 +++++++------ sound/soc/mediatek/mt8173/mt8173-rt5650-rt5514.c | 7 ++++--- sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c | 7 ++++--- sound/soc/mediatek/mt8173/mt8173-rt5650.c | 7 ++++--- sound/soc/meson/axg-card.c | 3 +-- sound/soc/qcom/apq8096.c | 7 +++---- sound/soc/qcom/sdm845.c | 7 +++---- sound/soc/samsung/tm2_wm5110.c | 13 +++++++------ sound/soc/soc-core.c | 16 +++++++--------- 16 files changed, 73 insertions(+), 66 deletions(-)
include/sound/soc.h +4 -0
@@ -1120,6 +1120,10 @@ struct snd_soc_card {void *drvdata; }; +#define for_each_card_prelinks (card, i, link) \ + for ((i) = 0; \ + ((i) < (card)->num_links) && ((link) = &(card)->dai_link[i]); \ + (i)++)/* SoC machine DAI configuration, glues a codec and cpu DAI together */ struct snd_soc_pcm_runtime {
sound/soc/fsl/pcm030-audio-fabric.c +3 -2
@@ -57,6 +57,7 @@ static int pcm030_fabric_probe(struct platform_device *op)struct device_node *platform_np;struct snd_soc_card *card = &pcm030_card;struct pcm030_audio_data *pdata; +struct snd_soc_dai_link *dai_link;int ret;int i;
@@ -78,8 +79,8 @@ static int pcm030_fabric_probe(struct platform_device *op)return -ENODEV ; } -for (i =0 ; i < card->num_links; i++) - card->dai_link[i].platform_of_node = platform_np; +for_each_card_prelinks (card, i, dai_link) + dai_link->platform_of_node = platform_np; ret =request_module ("snd-soc-wm9712" );if (ret)
sound/soc/generic/simple-card-utils.c +2 -4
@@ -404,11 +404,9 @@ EXPORT_SYMBOL_GPL(asoc_simple_card_canonicalize_cpu);int asoc_simple_card_clean_reference (struct snd_soc_card *card) {struct snd_soc_dai_link *dai_link; -int num_links; +int i; -for (num_links =0 , dai_link = card->dai_link; - num_links < card->num_links; - num_links++, dai_link++) { +for_each_card_prelinks (card, i, dai_link) {of_node_put (dai_link->cpu_of_node);of_node_put (dai_link->codecs->of_node); }
sound/soc/intel/boards/skl_hda_dsp_generic.c +3 -2
@@ -104,6 +104,7 @@ static struct snd_soc_card hda_soc_card = {static int skl_hda_fill_card_info (struct skl_machine_pdata *pdata) {struct snd_soc_card *card = &hda_soc_card; +struct snd_soc_dai_link *dai_link;u32 codec_count, codec_mask;int i, num_links, num_route;
@@ -125,8 +126,8 @@ static int skl_hda_fill_card_info(struct skl_machine_pdata *pdata) card->num_links = num_links; card->num_dapm_routes = num_route; -for (i =0 ; i < num_links; i++) - skl_hda_be_dai_links[i].platform_name = pdata->platform; +for_each_card_prelinks (card, i, dai_link) + dai_link->platform_name = pdata->platform;return 0 ; }
sound/soc/mediatek/mt2701/mt2701-cs42448.c +7 -6
@@ -299,6 +299,7 @@ static int mt2701_cs42448_machine_probe(struct platform_device *pdev)devm_kzalloc (&pdev->dev,sizeof (struct mt2701_cs42448_private ),GFP_KERNEL );struct device *dev = &pdev->dev; +struct snd_soc_dai_link *dai_link;if (!priv)return -ENOMEM ;
@@ -309,10 +310,10 @@ static int mt2701_cs42448_machine_probe(struct platform_device *pdev)dev_err (&pdev->dev,"Property 'platform' missing or invalid\n" );return -EINVAL ; } -for (i =0 ; i < card->num_links; i++) { -if (mt2701_cs42448_dai_links[i].platform_name) +for_each_card_prelinks (card, i, dai_link) { +if (dai_links->platform_name)continue ; - mt2701_cs42448_dai_links[i].platform_of_node = platform_node; + dai_links->platform_of_node = platform_node; } card->dev = dev;
@@ -324,10 +325,10 @@ static int mt2701_cs42448_machine_probe(struct platform_device *pdev) "Property 'audio-codec' missing or invalid\n");return -EINVAL ; } -for (i =0 ; i < card->num_links; i++) { -if (mt2701_cs42448_dai_links[i].codec_name) +for_each_card_prelinks (card, i, dai_link) { +if (dai_links->codec_name)continue ; - mt2701_cs42448_dai_links[i].codec_of_node = codec_node; + dai_links->codec_of_node = codec_node; } codec_node_bt_mrg = of_parse_phandle(pdev->dev.of_node,
sound/soc/mediatek/mt2701/mt2701-wm8960.c +7 -6
@@ -97,6 +97,7 @@ static int mt2701_wm8960_machine_probe(struct platform_device *pdev) {struct snd_soc_card *card = &mt2701_wm8960_card;struct device_node *platform_node, *codec_node; +struct snd_soc_dai_link *dai_link;int ret, i; platform_node = of_parse_phandle(pdev->dev.of_node,
@@ -105,10 +106,10 @@ static int mt2701_wm8960_machine_probe(struct platform_device *pdev)dev_err (&pdev->dev,"Property 'platform' missing or invalid\n" );return -EINVAL ; } -for (i =0 ; i < card->num_links; i++) { -if (mt2701_wm8960_dai_links[i].platform_name) +for_each_card_prelinks (card, i, dai_link) { +if (dai_links->platform_name)continue ; - mt2701_wm8960_dai_links[i].platform_of_node = platform_node; + dai_links->platform_of_node = platform_node; } card->dev = &pdev->dev;
@@ -120,10 +121,10 @@ static int mt2701_wm8960_machine_probe(struct platform_device *pdev) "Property 'audio-codec' missing or invalid\n");return -EINVAL ; } -for (i =0 ; i < card->num_links; i++) { -if (mt2701_wm8960_dai_links[i].codec_name) +for_each_card_prelinks (card, i, dai_link) { +if (dai_links->codec_name)continue ; - mt2701_wm8960_dai_links[i].codec_of_node = codec_node; + dai_links->codec_of_node = codec_node; } ret =snd_soc_of_parse_audio_routing (card,"audio-routing" );
sound/soc/mediatek/mt6797/mt6797-mt6351.c +7 -6
@@ -158,6 +158,7 @@ static int mt6797_mt6351_dev_probe(struct platform_device *pdev) {struct snd_soc_card *card = &mt6797_mt6351_card;struct device_node *platform_node, *codec_node; +struct snd_soc_dai_link *dai_link;int ret, i; card->dev = &pdev->dev;
@@ -168,10 +169,10 @@ static int mt6797_mt6351_dev_probe(struct platform_device *pdev)dev_err (&pdev->dev,"Property 'platform' missing or invalid\n" );return -EINVAL ; } -for (i =0 ; i < card->num_links; i++) { -if (mt6797_mt6351_dai_links[i].platform_name) +for_each_card_prelinks (card, i, dai_link) { +if (dai_link->platform_name)continue ; - mt6797_mt6351_dai_links[i].platform_of_node = platform_node; + dai_links->platform_of_node = platform_node; } codec_node = of_parse_phandle(pdev->dev.of_node,
@@ -181,10 +182,10 @@ static int mt6797_mt6351_dev_probe(struct platform_device *pdev) "Property 'audio-codec' missing or invalid\n");return -EINVAL ; } -for (i =0 ; i < card->num_links; i++) { -if (mt6797_mt6351_dai_links[i].codec_name) +for_each_card_prelinks (card, i, dai_link) { +if (dai_links->codec_name)continue ; - mt6797_mt6351_dai_links[i].codec_of_node = codec_node; + dai_links->codec_of_node = codec_node; } ret =devm_snd_soc_register_card (&pdev->dev, card);
sound/soc/mediatek/mt8173/mt8173-max98090.c +7 -6
@@ -137,6 +137,7 @@ static int mt8173_max98090_dev_probe(struct platform_device *pdev) {struct snd_soc_card *card = &mt8173_max98090_card;struct device_node *codec_node, *platform_node; +struct snd_soc_dai_link *dai_link;int ret, i; platform_node = of_parse_phandle(pdev->dev.of_node,
@@ -145,10 +146,10 @@ static int mt8173_max98090_dev_probe(struct platform_device *pdev)dev_err (&pdev->dev,"Property 'platform' missing or invalid\n" );return -EINVAL ; } -for (i =0 ; i < card->num_links; i++) { -if (mt8173_max98090_dais[i].platform_name) +for_each_card_prelinks (card, i, dai_link) { +if (dai_link->platform_name)continue ; - mt8173_max98090_dais[i].platform_of_node = platform_node; + dai_link->platform_of_node = platform_node; } codec_node = of_parse_phandle(pdev->dev.of_node,
@@ -158,10 +159,10 @@ static int mt8173_max98090_dev_probe(struct platform_device *pdev) "Property 'audio-codec' missing or invalid\n");return -EINVAL ; } -for (i =0 ; i < card->num_links; i++) { -if (mt8173_max98090_dais[i].codec_name) +for_each_card_prelinks (card, i, dai_link) { +if (dai_link->codec_name)continue ; - mt8173_max98090_dais[i].codec_of_node = codec_node; + dai_link->codec_of_node = codec_node; } card->dev = &pdev->dev;
sound/soc/mediatek/mt8173/mt8173-rt5650-rt5514.c +4 -3
@@ -178,6 +178,7 @@ static int mt8173_rt5650_rt5514_dev_probe(struct platform_device *pdev) {struct snd_soc_card *card = &mt8173_rt5650_rt5514_card;struct device_node *platform_node; +struct snd_soc_dai_link *dai_link;int i, ret; platform_node = of_parse_phandle(pdev->dev.of_node,
@@ -187,10 +188,10 @@ static int mt8173_rt5650_rt5514_dev_probe(struct platform_device *pdev)return -EINVAL ; } -for (i =0 ; i < card->num_links; i++) { -if (mt8173_rt5650_rt5514_dais[i].platform_name) +for_each_card_prelinks (card, i, dai_link) { +if (dai_link->platform_name)continue ; - mt8173_rt5650_rt5514_dais[i].platform_of_node = platform_node; + dai_link->platform_of_node = platform_node; } mt8173_rt5650_rt5514_codecs[0].of_node =
sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c +4 -3
@@ -224,6 +224,7 @@ static int mt8173_rt5650_rt5676_dev_probe(struct platform_device *pdev) {struct snd_soc_card *card = &mt8173_rt5650_rt5676_card;struct device_node *platform_node; +struct snd_soc_dai_link *dai_link;int i, ret; platform_node = of_parse_phandle(pdev->dev.of_node,
@@ -233,10 +234,10 @@ static int mt8173_rt5650_rt5676_dev_probe(struct platform_device *pdev)return -EINVAL ; } -for (i =0 ; i < card->num_links; i++) { -if (mt8173_rt5650_rt5676_dais[i].platform_name) +for_each_card_prelinks (card, i, dai_link) { +if (dai_link->platform_name)continue ; - mt8173_rt5650_rt5676_dais[i].platform_of_node = platform_node; + dai_link->platform_of_node = platform_node; } mt8173_rt5650_rt5676_codecs[0].of_node =
sound/soc/mediatek/mt8173/mt8173-rt5650.c +4 -3
@@ -239,6 +239,7 @@ static int mt8173_rt5650_dev_probe(struct platform_device *pdev)struct device_node *platform_node;struct device_node *np;const char *codec_capture_dai; +struct snd_soc_dai_link *dai_link;int i, ret; platform_node = of_parse_phandle(pdev->dev.of_node,
@@ -248,10 +249,10 @@ static int mt8173_rt5650_dev_probe(struct platform_device *pdev)return -EINVAL ; } -for (i =0 ; i < card->num_links; i++) { -if (mt8173_rt5650_dais[i].platform_name) +for_each_card_prelinks (card, i, dai_link) { +if (dai_link->platform_name)continue ; - mt8173_rt5650_dais[i].platform_of_node = platform_node; + dai_link->platform_of_node = platform_node; } mt8173_rt5650_codecs[0].of_node =
sound/soc/meson/axg-card.c +1 -2
@@ -101,8 +101,7 @@ static void axg_card_clean_references(struct axg_card *priv)int i, j;if (card->dai_link) { -for (i =0 ; i < card->num_links; i++) { - link = &card->dai_link[i]; +for_each_card_prelinks (card, i, link) {of_node_put (link->cpu_of_node);for_each_link_codecs (link, j, codec)of_node_put (codec->of_node);
sound/soc/qcom/apq8096.c +3 -4
@@ -25,13 +25,12 @@ static int apq8096_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,static void apq8096_add_be_ops (struct snd_soc_card *card) { -struct snd_soc_dai_link *link = card->dai_link; -int i, num_links = card->num_links; +struct snd_soc_dai_link *link; +int i; -for (i =0 ; i < num_links; i++) { +for_each_card_prelinks (card, i, link) {if (link->no_pcm ==1 ) link->be_hw_params_fixup = apq8096_be_hw_params_fixup; - link++; } }
sound/soc/qcom/sdm845.c +3 -4
@@ -195,15 +195,14 @@ static int sdm845_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,static void sdm845_add_be_ops (struct snd_soc_card *card) { -struct snd_soc_dai_link *link = card->dai_link; -int i, num_links = card->num_links; +struct snd_soc_dai_link *link; +int i; -for (i =0 ; i < num_links; i++) { +for_each_card_prelinks (card, i, link) {if (link->no_pcm ==1 ) { link->ops = &sdm845_be_ops; link->be_hw_params_fixup = sdm845_be_hw_params_fixup; } - link++; } }
sound/soc/samsung/tm2_wm5110.c +7 -6
@@ -491,6 +491,7 @@ static int tm2_probe(struct platform_device *pdev)struct snd_soc_card *card = &tm2_card;struct tm2_machine_priv *priv;struct of_phandle_args args; +struct snd_soc_dai_link *dai_link;int num_codecs, ret, i; priv =devm_kzalloc (dev,sizeof (*priv),GFP_KERNEL );
@@ -558,18 +559,18 @@ static int tm2_probe(struct platform_device *pdev) }/* Initialize WM5110 - I2S and HDMI - I2S1 DAI links */ -for (i =0 ; i < card->num_links; i++) { +for_each_card_prelinks (card, i, dai_link) {unsigned int dai_index =0 ;/* WM5110 */ - card->dai_link[i].cpu_name =NULL ; - card->dai_link[i].platform_name =NULL ; + dai_link->cpu_name =NULL ; + dai_link->platform_name =NULL ;if (num_codecs >1 && i == card->num_links -1 ) dai_index =1 ;/* HDMI */ - card->dai_link[i].codec_of_node = codec_dai_node[dai_index]; - card->dai_link[i].cpu_of_node = cpu_dai_node[dai_index]; - card->dai_link[i].platform_of_node = cpu_dai_node[dai_index]; + dai_link->codec_of_node = codec_dai_node[dai_index]; + dai_link->cpu_of_node = cpu_dai_node[dai_index]; + dai_link->platform_of_node = cpu_dai_node[dai_index]; }if (num_codecs >1 ) {
sound/soc/soc-core.c +7 -9
@@ -1889,9 +1889,7 @@ static void soc_check_tplg_fes(struct snd_soc_card *card)continue ;/* machine matches, so override the rtd data */ -for (i =0 ; i < card->num_links; i++) { - - dai_link = &card->dai_link[i]; +for_each_card_prelinks (card, i, dai_link) {/* ignore this FE */ if (dai_link->dynamic) {
@@ -1955,8 +1953,8 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)soc_check_tplg_fes (card);/* bind DAIs */ -for (i =0 ; i < card->num_links; i++) { - ret =soc_bind_dai_link (card, &card->dai_link[i]); +for_each_card_prelinks (card, i, dai_link) { + ret =soc_bind_dai_link (card, dai_link);if (ret !=0 ) goto base_error; }
@@ -1969,8 +1967,8 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) }/* add predefined DAI links to the list */ -for (i =0 ; i < card->num_links; i++) -snd_soc_add_dai_link (card, card->dai_link+i); +for_each_card_prelinks (card, i, dai_link) +snd_soc_add_dai_link (card, dai_link);/* card bind complete so register a sound card */ ret = snd_card_new(card->dev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
@@ -2714,12 +2712,12 @@ static int snd_soc_bind_card(struct snd_soc_card *card)int snd_soc_register_card (struct snd_soc_card *card) {int i, ret; +struct snd_soc_dai_link *link;if (!card->name || !card->dev)return -EINVAL ; -for (i =0 ; i < card->num_links; i++) { -struct snd_soc_dai_link *link = &card->dai_link[i]; +for_each_card_prelinks (card, i, link) { ret =soc_init_dai_link (card, link);if (ret) {
Signature · 1 line
2.7.4
Mark Brown
maintainerApplied "ASoC: add for_each_card_prelinks() macro" to the asoc tree
The patch
ASoC: add for_each_card_prelinks() macro
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
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
Quoted 1 line
From
7fe072b4df5d0cc832eb758c1eed243c145a2dfcMon Sep 17 00:00:00 2001
From: Kuninori Morimoto <[email protected]>
Date: Tue, 18 Sep 2018 01:28:49 +0000
Subject: [PATCH] ASoC: add for_each_card_prelinks() macro
To be more readable code, this patch adds
new for_each_card_prelinks() macro, and replace existing code to it.
--- include/sound/soc.h | 4 ++++ sound/soc/fsl/pcm030-audio-fabric.c | 5 +++-- sound/soc/generic/simple-card-utils.c | 6 ++---- sound/soc/intel/boards/skl_hda_dsp_generic.c | 5 +++-- sound/soc/mediatek/mt2701/mt2701-cs42448.c | 13 +++++++------ sound/soc/mediatek/mt2701/mt2701-wm8960.c | 13 +++++++------ sound/soc/mediatek/mt6797/mt6797-mt6351.c | 13 +++++++------ sound/soc/mediatek/mt8173/mt8173-max98090.c | 13 +++++++------ sound/soc/mediatek/mt8173/mt8173-rt5650-rt5514.c | 7 ++++--- sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c | 7 ++++--- sound/soc/mediatek/mt8173/mt8173-rt5650.c | 7 ++++--- sound/soc/meson/axg-card.c | 3 +-- sound/soc/qcom/apq8096.c | 7 +++---- sound/soc/qcom/sdm845.c | 7 +++---- sound/soc/samsung/tm2_wm5110.c | 13 +++++++------ sound/soc/soc-core.c | 16 +++++++--------- 16 files changed, 73 insertions(+), 66 deletions(-)
include/sound/soc.h +4 -0
@@ -1120,6 +1120,10 @@ struct snd_soc_card {void *drvdata; }; +#define for_each_card_prelinks (card, i, link) \ + for ((i) = 0; \ + ((i) < (card)->num_links) && ((link) = &(card)->dai_link[i]); \ + (i)++)/* SoC machine DAI configuration, glues a codec and cpu DAI together */ struct snd_soc_pcm_runtime {
sound/soc/fsl/pcm030-audio-fabric.c +3 -2
@@ -57,6 +57,7 @@ static int pcm030_fabric_probe(struct platform_device *op)struct device_node *platform_np;struct snd_soc_card *card = &pcm030_card;struct pcm030_audio_data *pdata; +struct snd_soc_dai_link *dai_link;int ret;int i;
@@ -78,8 +79,8 @@ static int pcm030_fabric_probe(struct platform_device *op)return -ENODEV ; } -for (i =0 ; i < card->num_links; i++) - card->dai_link[i].platform_of_node = platform_np; +for_each_card_prelinks (card, i, dai_link) + dai_link->platform_of_node = platform_np; ret =request_module ("snd-soc-wm9712" );if (ret)
sound/soc/generic/simple-card-utils.c +2 -4
@@ -404,11 +404,9 @@ EXPORT_SYMBOL_GPL(asoc_simple_card_canonicalize_cpu);int asoc_simple_card_clean_reference (struct snd_soc_card *card) {struct snd_soc_dai_link *dai_link; -int num_links; +int i; -for (num_links =0 , dai_link = card->dai_link; - num_links < card->num_links; - num_links++, dai_link++) { +for_each_card_prelinks (card, i, dai_link) {of_node_put (dai_link->cpu_of_node);of_node_put (dai_link->codecs->of_node); }
sound/soc/intel/boards/skl_hda_dsp_generic.c +3 -2
@@ -104,6 +104,7 @@ static struct snd_soc_card hda_soc_card = {static int skl_hda_fill_card_info (struct skl_machine_pdata *pdata) {struct snd_soc_card *card = &hda_soc_card; +struct snd_soc_dai_link *dai_link;u32 codec_count, codec_mask;int i, num_links, num_route;
@@ -125,8 +126,8 @@ static int skl_hda_fill_card_info(struct skl_machine_pdata *pdata) card->num_links = num_links; card->num_dapm_routes = num_route; -for (i =0 ; i < num_links; i++) - skl_hda_be_dai_links[i].platform_name = pdata->platform; +for_each_card_prelinks (card, i, dai_link) + dai_link->platform_name = pdata->platform;return 0 ; }
sound/soc/mediatek/mt2701/mt2701-cs42448.c +7 -6
@@ -299,6 +299,7 @@ static int mt2701_cs42448_machine_probe(struct platform_device *pdev)devm_kzalloc (&pdev->dev,sizeof (struct mt2701_cs42448_private ),GFP_KERNEL );struct device *dev = &pdev->dev; +struct snd_soc_dai_link *dai_link;if (!priv)return -ENOMEM ;
@@ -309,10 +310,10 @@ static int mt2701_cs42448_machine_probe(struct platform_device *pdev)dev_err (&pdev->dev,"Property 'platform' missing or invalid\n" );return -EINVAL ; } -for (i =0 ; i < card->num_links; i++) { -if (mt2701_cs42448_dai_links[i].platform_name) +for_each_card_prelinks (card, i, dai_link) { +if (dai_links->platform_name)continue ; - mt2701_cs42448_dai_links[i].platform_of_node = platform_node; + dai_links->platform_of_node = platform_node; } card->dev = dev;
@@ -324,10 +325,10 @@ static int mt2701_cs42448_machine_probe(struct platform_device *pdev) "Property 'audio-codec' missing or invalid\n");return -EINVAL ; } -for (i =0 ; i < card->num_links; i++) { -if (mt2701_cs42448_dai_links[i].codec_name) +for_each_card_prelinks (card, i, dai_link) { +if (dai_links->codec_name)continue ; - mt2701_cs42448_dai_links[i].codec_of_node = codec_node; + dai_links->codec_of_node = codec_node; } codec_node_bt_mrg = of_parse_phandle(pdev->dev.of_node,
sound/soc/mediatek/mt2701/mt2701-wm8960.c +7 -6
@@ -97,6 +97,7 @@ static int mt2701_wm8960_machine_probe(struct platform_device *pdev) {struct snd_soc_card *card = &mt2701_wm8960_card;struct device_node *platform_node, *codec_node; +struct snd_soc_dai_link *dai_link;int ret, i; platform_node = of_parse_phandle(pdev->dev.of_node,
@@ -105,10 +106,10 @@ static int mt2701_wm8960_machine_probe(struct platform_device *pdev)dev_err (&pdev->dev,"Property 'platform' missing or invalid\n" );return -EINVAL ; } -for (i =0 ; i < card->num_links; i++) { -if (mt2701_wm8960_dai_links[i].platform_name) +for_each_card_prelinks (card, i, dai_link) { +if (dai_links->platform_name)continue ; - mt2701_wm8960_dai_links[i].platform_of_node = platform_node; + dai_links->platform_of_node = platform_node; } card->dev = &pdev->dev;
@@ -120,10 +121,10 @@ static int mt2701_wm8960_machine_probe(struct platform_device *pdev) "Property 'audio-codec' missing or invalid\n");return -EINVAL ; } -for (i =0 ; i < card->num_links; i++) { -if (mt2701_wm8960_dai_links[i].codec_name) +for_each_card_prelinks (card, i, dai_link) { +if (dai_links->codec_name)continue ; - mt2701_wm8960_dai_links[i].codec_of_node = codec_node; + dai_links->codec_of_node = codec_node; } ret =snd_soc_of_parse_audio_routing (card,"audio-routing" );
sound/soc/mediatek/mt6797/mt6797-mt6351.c +7 -6
@@ -158,6 +158,7 @@ static int mt6797_mt6351_dev_probe(struct platform_device *pdev) {struct snd_soc_card *card = &mt6797_mt6351_card;struct device_node *platform_node, *codec_node; +struct snd_soc_dai_link *dai_link;int ret, i; card->dev = &pdev->dev;
@@ -168,10 +169,10 @@ static int mt6797_mt6351_dev_probe(struct platform_device *pdev)dev_err (&pdev->dev,"Property 'platform' missing or invalid\n" );return -EINVAL ; } -for (i =0 ; i < card->num_links; i++) { -if (mt6797_mt6351_dai_links[i].platform_name) +for_each_card_prelinks (card, i, dai_link) { +if (dai_link->platform_name)continue ; - mt6797_mt6351_dai_links[i].platform_of_node = platform_node; + dai_links->platform_of_node = platform_node; } codec_node = of_parse_phandle(pdev->dev.of_node,
@@ -181,10 +182,10 @@ static int mt6797_mt6351_dev_probe(struct platform_device *pdev) "Property 'audio-codec' missing or invalid\n");return -EINVAL ; } -for (i =0 ; i < card->num_links; i++) { -if (mt6797_mt6351_dai_links[i].codec_name) +for_each_card_prelinks (card, i, dai_link) { +if (dai_links->codec_name)continue ; - mt6797_mt6351_dai_links[i].codec_of_node = codec_node; + dai_links->codec_of_node = codec_node; } ret =devm_snd_soc_register_card (&pdev->dev, card);
sound/soc/mediatek/mt8173/mt8173-max98090.c +7 -6
@@ -137,6 +137,7 @@ static int mt8173_max98090_dev_probe(struct platform_device *pdev) {struct snd_soc_card *card = &mt8173_max98090_card;struct device_node *codec_node, *platform_node; +struct snd_soc_dai_link *dai_link;int ret, i; platform_node = of_parse_phandle(pdev->dev.of_node,
@@ -145,10 +146,10 @@ static int mt8173_max98090_dev_probe(struct platform_device *pdev)dev_err (&pdev->dev,"Property 'platform' missing or invalid\n" );return -EINVAL ; } -for (i =0 ; i < card->num_links; i++) { -if (mt8173_max98090_dais[i].platform_name) +for_each_card_prelinks (card, i, dai_link) { +if (dai_link->platform_name)continue ; - mt8173_max98090_dais[i].platform_of_node = platform_node; + dai_link->platform_of_node = platform_node; } codec_node = of_parse_phandle(pdev->dev.of_node,
@@ -158,10 +159,10 @@ static int mt8173_max98090_dev_probe(struct platform_device *pdev) "Property 'audio-codec' missing or invalid\n");return -EINVAL ; } -for (i =0 ; i < card->num_links; i++) { -if (mt8173_max98090_dais[i].codec_name) +for_each_card_prelinks (card, i, dai_link) { +if (dai_link->codec_name)continue ; - mt8173_max98090_dais[i].codec_of_node = codec_node; + dai_link->codec_of_node = codec_node; } card->dev = &pdev->dev;
sound/soc/mediatek/mt8173/mt8173-rt5650-rt5514.c +4 -3
@@ -178,6 +178,7 @@ static int mt8173_rt5650_rt5514_dev_probe(struct platform_device *pdev) {struct snd_soc_card *card = &mt8173_rt5650_rt5514_card;struct device_node *platform_node; +struct snd_soc_dai_link *dai_link;int i, ret; platform_node = of_parse_phandle(pdev->dev.of_node,
@@ -187,10 +188,10 @@ static int mt8173_rt5650_rt5514_dev_probe(struct platform_device *pdev)return -EINVAL ; } -for (i =0 ; i < card->num_links; i++) { -if (mt8173_rt5650_rt5514_dais[i].platform_name) +for_each_card_prelinks (card, i, dai_link) { +if (dai_link->platform_name)continue ; - mt8173_rt5650_rt5514_dais[i].platform_of_node = platform_node; + dai_link->platform_of_node = platform_node; } mt8173_rt5650_rt5514_codecs[0].of_node =
sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c +4 -3
@@ -224,6 +224,7 @@ static int mt8173_rt5650_rt5676_dev_probe(struct platform_device *pdev) {struct snd_soc_card *card = &mt8173_rt5650_rt5676_card;struct device_node *platform_node; +struct snd_soc_dai_link *dai_link;int i, ret; platform_node = of_parse_phandle(pdev->dev.of_node,
@@ -233,10 +234,10 @@ static int mt8173_rt5650_rt5676_dev_probe(struct platform_device *pdev)return -EINVAL ; } -for (i =0 ; i < card->num_links; i++) { -if (mt8173_rt5650_rt5676_dais[i].platform_name) +for_each_card_prelinks (card, i, dai_link) { +if (dai_link->platform_name)continue ; - mt8173_rt5650_rt5676_dais[i].platform_of_node = platform_node; + dai_link->platform_of_node = platform_node; } mt8173_rt5650_rt5676_codecs[0].of_node =
sound/soc/mediatek/mt8173/mt8173-rt5650.c +4 -3
@@ -239,6 +239,7 @@ static int mt8173_rt5650_dev_probe(struct platform_device *pdev)struct device_node *platform_node;struct device_node *np;const char *codec_capture_dai; +struct snd_soc_dai_link *dai_link;int i, ret; platform_node = of_parse_phandle(pdev->dev.of_node,
@@ -248,10 +249,10 @@ static int mt8173_rt5650_dev_probe(struct platform_device *pdev)return -EINVAL ; } -for (i =0 ; i < card->num_links; i++) { -if (mt8173_rt5650_dais[i].platform_name) +for_each_card_prelinks (card, i, dai_link) { +if (dai_link->platform_name)continue ; - mt8173_rt5650_dais[i].platform_of_node = platform_node; + dai_link->platform_of_node = platform_node; } mt8173_rt5650_codecs[0].of_node =
sound/soc/meson/axg-card.c +1 -2
@@ -101,8 +101,7 @@ static void axg_card_clean_references(struct axg_card *priv)int i, j;if (card->dai_link) { -for (i =0 ; i < card->num_links; i++) { - link = &card->dai_link[i]; +for_each_card_prelinks (card, i, link) {of_node_put (link->cpu_of_node);for_each_link_codecs (link, j, codec)of_node_put (codec->of_node);
sound/soc/qcom/apq8096.c +3 -4
@@ -25,13 +25,12 @@ static int apq8096_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,static void apq8096_add_be_ops (struct snd_soc_card *card) { -struct snd_soc_dai_link *link = card->dai_link; -int i, num_links = card->num_links; +struct snd_soc_dai_link *link; +int i; -for (i =0 ; i < num_links; i++) { +for_each_card_prelinks (card, i, link) {if (link->no_pcm ==1 ) link->be_hw_params_fixup = apq8096_be_hw_params_fixup; - link++; } }
sound/soc/qcom/sdm845.c +3 -4
@@ -195,15 +195,14 @@ static int sdm845_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,static void sdm845_add_be_ops (struct snd_soc_card *card) { -struct snd_soc_dai_link *link = card->dai_link; -int i, num_links = card->num_links; +struct snd_soc_dai_link *link; +int i; -for (i =0 ; i < num_links; i++) { +for_each_card_prelinks (card, i, link) {if (link->no_pcm ==1 ) { link->ops = &sdm845_be_ops; link->be_hw_params_fixup = sdm845_be_hw_params_fixup; } - link++; } }
sound/soc/samsung/tm2_wm5110.c +7 -6
@@ -491,6 +491,7 @@ static int tm2_probe(struct platform_device *pdev)struct snd_soc_card *card = &tm2_card;struct tm2_machine_priv *priv;struct of_phandle_args args; +struct snd_soc_dai_link *dai_link;int num_codecs, ret, i; priv =devm_kzalloc (dev,sizeof (*priv),GFP_KERNEL );
@@ -558,18 +559,18 @@ static int tm2_probe(struct platform_device *pdev) }/* Initialize WM5110 - I2S and HDMI - I2S1 DAI links */ -for (i =0 ; i < card->num_links; i++) { +for_each_card_prelinks (card, i, dai_link) {unsigned int dai_index =0 ;/* WM5110 */ - card->dai_link[i].cpu_name =NULL ; - card->dai_link[i].platform_name =NULL ; + dai_link->cpu_name =NULL ; + dai_link->platform_name =NULL ;if (num_codecs >1 && i == card->num_links -1 ) dai_index =1 ;/* HDMI */ - card->dai_link[i].codec_of_node = codec_dai_node[dai_index]; - card->dai_link[i].cpu_of_node = cpu_dai_node[dai_index]; - card->dai_link[i].platform_of_node = cpu_dai_node[dai_index]; + dai_link->codec_of_node = codec_dai_node[dai_index]; + dai_link->cpu_of_node = cpu_dai_node[dai_index]; + dai_link->platform_of_node = cpu_dai_node[dai_index]; }if (num_codecs >1 ) {
sound/soc/soc-core.c +7 -9
@@ -1889,9 +1889,7 @@ static void soc_check_tplg_fes(struct snd_soc_card *card)continue ;/* machine matches, so override the rtd data */ -for (i =0 ; i < card->num_links; i++) { - - dai_link = &card->dai_link[i]; +for_each_card_prelinks (card, i, dai_link) {/* ignore this FE */ if (dai_link->dynamic) {
@@ -1955,8 +1953,8 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)soc_check_tplg_fes (card);/* bind DAIs */ -for (i =0 ; i < card->num_links; i++) { - ret =soc_bind_dai_link (card, &card->dai_link[i]); +for_each_card_prelinks (card, i, dai_link) { + ret =soc_bind_dai_link (card, dai_link);if (ret !=0 ) goto base_error; }
@@ -1969,8 +1967,8 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) }/* add predefined DAI links to the list */ -for (i =0 ; i < card->num_links; i++) -snd_soc_add_dai_link (card, card->dai_link+i); +for_each_card_prelinks (card, i, dai_link) +snd_soc_add_dai_link (card, dai_link);/* card bind complete so register a sound card */ ret = snd_card_new(card->dev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
@@ -2714,12 +2712,12 @@ static int snd_soc_bind_card(struct snd_soc_card *card)int snd_soc_register_card (struct snd_soc_card *card) {int i, ret; +struct snd_soc_dai_link *link;if (!card->name || !card->dev)return -EINVAL ; -for (i =0 ; i < card->num_links; i++) { -struct snd_soc_dai_link *link = &card->dai_link[i]; +for_each_card_prelinks (card, i, link) { ret =soc_init_dai_link (card, link);if (ret) {
Signature · 1 line
2.19.0
Kuninori Morimoto
maintainerPATCH 4/11 ASoC: add for_each_card_links() macro
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
To be more readable code, this patch adds
new for_each_card_links() macro, and replace existing code to it.
--- include/sound/soc.h | 6 ++++++ sound/soc/soc-core.c | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-)
include/sound/soc.h +6 -0
@@ -1125,6 +1125,12 @@ struct snd_soc_card { ((i) < (card)->num_links) && ((link) = &(card)->dai_link[i]); \ (i)++) +#define for_each_card_links (card, link) \ + list_for_each_entry(dai_link, &(card)->dai_link_list, list) +#define for_each_card_links_safe (card, link, _link) \ + list_for_each_entry_safe(link, _link, &(card)->dai_link_list, list) + +/* SoC machine DAI configuration, glues a codec and cpu DAI together */ struct snd_soc_pcm_runtime {struct device *dev;
sound/soc/soc-core.c +4 -4
@@ -816,7 +816,7 @@ struct snd_soc_dai_link *snd_soc_find_dai_link(struct snd_soc_card *card,lockdep_assert_held (&client_mutex); -list_for_each_entry_safe (link, _link, &card->dai_link_list, list) { +for_each_card_links_safe (card, link, _link) {if (link->id != id)continue ;
@@ -1004,7 +1004,7 @@ static void soc_remove_dai_links(struct snd_soc_card *card)soc_remove_link_components (card, rtd, order); } -list_for_each_entry_safe (link, _link, &card->dai_link_list, list) { +for_each_card_links_safe (card, link, _link) {if (link->dobj.type ==SND_SOC_DOBJ_DAI_LINK )dev_warn (card->dev,"Topology forgot to remove link %s?\n" , link->name);
@@ -1219,7 +1219,7 @@ void snd_soc_remove_dai_link(struct snd_soc_card *card,if (dai_link->dobj.type && card->remove_dai_link) card->remove_dai_link (card, dai_link); -list_for_each_entry_safe (link, _link, &card->dai_link_list, list) { +for_each_card_links_safe (card, link, _link) {if (link == dai_link) {list_del (&link->list);return ;
@@ -2033,7 +2033,7 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)/* Find new DAI links added during probing components and bind them. * Components with topology may bring new DAIs and DAI links. */ -list_for_each_entry (dai_link, &card->dai_link_list, list) { +for_each_card_links (card, dai_link) {if (soc_is_dai_link_bound (card, dai_link))continue ;
Signature · 1 line
2.7.4
Mark Brown
maintainerApplied "ASoC: add for_each_card_links() macro" to the asoc tree
The patch
ASoC: add for_each_card_links() macro
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
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
Quoted 1 line
From
98061fdbfccc02aa0fd6637c67a0524aab385b8dMon Sep 17 00:00:00 2001
From: Kuninori Morimoto <[email protected]>
Date: Tue, 18 Sep 2018 01:29:16 +0000
Subject: [PATCH] ASoC: add for_each_card_links() macro
To be more readable code, this patch adds
new for_each_card_links() macro, and replace existing code to it.
--- include/sound/soc.h | 6 ++++++ sound/soc/soc-core.c | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-)
include/sound/soc.h +6 -0
@@ -1125,6 +1125,12 @@ struct snd_soc_card { ((i) < (card)->num_links) && ((link) = &(card)->dai_link[i]); \ (i)++) +#define for_each_card_links (card, link) \ + list_for_each_entry(dai_link, &(card)->dai_link_list, list) +#define for_each_card_links_safe (card, link, _link) \ + list_for_each_entry_safe(link, _link, &(card)->dai_link_list, list) + +/* SoC machine DAI configuration, glues a codec and cpu DAI together */ struct snd_soc_pcm_runtime {struct device *dev;
sound/soc/soc-core.c +4 -4
@@ -816,7 +816,7 @@ struct snd_soc_dai_link *snd_soc_find_dai_link(struct snd_soc_card *card,lockdep_assert_held (&client_mutex); -list_for_each_entry_safe (link, _link, &card->dai_link_list, list) { +for_each_card_links_safe (card, link, _link) {if (link->id != id)continue ;
@@ -1004,7 +1004,7 @@ static void soc_remove_dai_links(struct snd_soc_card *card)soc_remove_link_components (card, rtd, order); } -list_for_each_entry_safe (link, _link, &card->dai_link_list, list) { +for_each_card_links_safe (card, link, _link) {if (link->dobj.type ==SND_SOC_DOBJ_DAI_LINK )dev_warn (card->dev,"Topology forgot to remove link %s?\n" , link->name);
@@ -1219,7 +1219,7 @@ void snd_soc_remove_dai_link(struct snd_soc_card *card,if (dai_link->dobj.type && card->remove_dai_link) card->remove_dai_link (card, dai_link); -list_for_each_entry_safe (link, _link, &card->dai_link_list, list) { +for_each_card_links_safe (card, link, _link) {if (link == dai_link) {list_del (&link->list);return ;
@@ -2033,7 +2033,7 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)/* Find new DAI links added during probing components and bind them. * Components with topology may bring new DAIs and DAI links. */ -list_for_each_entry (dai_link, &card->dai_link_list, list) { +for_each_card_links (card, dai_link) {if (soc_is_dai_link_bound (card, dai_link))continue ;
Signature · 1 line
2.19.0
Kuninori Morimoto
maintainerPATCH 5/11 ASoC: add for_each_card_rtds() macro
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
To be more readable code, this patch adds
new for_each_card_rtds() macro, and replace existing code to it.
--- include/sound/soc.h | 4 +++ sound/soc/codecs/hdac_hdmi.c | 2 +- sound/soc/intel/atom/sst-mfld-platform-pcm.c | 4 +-- sound/soc/soc-core.c | 48 ++++++++++++++-------------- sound/soc/soc-dapm.c | 2 +- sound/soc/soc-pcm.c | 12 +++---- 6 files changed, 38 insertions(+), 34 deletions(-)
include/sound/soc.h +4 -0
@@ -1130,6 +1130,10 @@ struct snd_soc_card {#define for_each_card_links_safe (card, link, _link) \ list_for_each_entry_safe(link, _link, &(card)->dai_link_list, list) +#define for_each_card_rtds (card, rtd) \ + list_for_each_entry(rtd, &(card)->rtd_list, list) +#define for_each_card_rtds_safe (card, rtd, _rtd) \ + list_for_each_entry_safe(rtd, _rtd, &(card)->rtd_list, list)/* SoC machine DAI configuration, glues a codec and cpu DAI together */ struct snd_soc_pcm_runtime {
sound/soc/codecs/hdac_hdmi.c +1 -1
@@ -1604,7 +1604,7 @@ static struct snd_pcm *hdac_hdmi_get_pcm_from_id(struct snd_soc_card *card, {struct snd_soc_pcm_runtime *rtd; -list_for_each_entry (rtd, &card->rtd_list, list) { +for_each_card_rtds (card, rtd) {if (rtd->pcm && (rtd->pcm->device == device))return rtd->pcm; }
sound/soc/intel/atom/sst-mfld-platform-pcm.c +2 -2
@@ -765,7 +765,7 @@ static int sst_soc_prepare(struct device *dev)snd_soc_poweroff (drv->soc_card->dev);/* set the SSPs to idle */ -list_for_each_entry (rtd, &drv->soc_card->rtd_list, list) { +for_each_card_rtds (drv->soc_card, rtd) {struct snd_soc_dai *dai = rtd->cpu_dai;if (dai->active) {
@@ -786,7 +786,7 @@ static void sst_soc_complete(struct device *dev)return ;/* restart SSPs */ -list_for_each_entry (rtd, &drv->soc_card->rtd_list, list) { +for_each_card_rtds (drv->soc_card, rtd) {struct snd_soc_dai *dai = rtd->cpu_dai;if (dai->active) {
sound/soc/soc-core.c +24 -24
186 lines not on this page · raw message
sound/soc/soc-dapm.c +1 -1
@@ -4184,7 +4184,7 @@ void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card)struct snd_soc_pcm_runtime *rtd;/* for each BE DAI link... */ -list_for_each_entry (rtd, &card->rtd_list, list) { +for_each_card_rtds (card, rtd) {/* * dynamic FE links have no fixed DAI mapping. * CODEC<->CODEC links have no direct connection.
sound/soc/soc-pcm.c +6 -6
@@ -1307,7 +1307,7 @@ static struct snd_soc_pcm_runtime *dpcm_get_be(struct snd_soc_card *card,dev_dbg (card->dev,"ASoC: find BE for widget %s\n" , widget->name);if (stream ==SNDRV_PCM_STREAM_PLAYBACK ) { -list_for_each_entry (be, &card->rtd_list, list) { +for_each_card_rtds (card, be) {if (!be->dai_link->no_pcm)continue ;
@@ -1326,7 +1326,7 @@ static struct snd_soc_pcm_runtime *dpcm_get_be(struct snd_soc_card *card, } }else { -list_for_each_entry (be, &card->rtd_list, list) { +for_each_card_rtds (card, be) {if (!be->dai_link->no_pcm)continue ;
@@ -1382,7 +1382,7 @@ static bool dpcm_end_walk_at_be(struct snd_soc_dapm_widget *widget,int i;if (dir ==SND_SOC_DAPM_DIR_OUT ) { -list_for_each_entry (rtd, &card->rtd_list, list) { +for_each_card_rtds (card, rtd) {if (!rtd->dai_link->no_pcm)continue ;
@@ -1395,7 +1395,7 @@ static bool dpcm_end_walk_at_be(struct snd_soc_dapm_widget *widget, } } }else {/* SND_SOC_DAPM_DIR_IN */ -list_for_each_entry (rtd, &card->rtd_list, list) { +for_each_card_rtds (card, rtd) {if (!rtd->dai_link->no_pcm)continue ;
@@ -2761,14 +2761,14 @@ int soc_dpcm_runtime_update(struct snd_soc_card *card)mutex_lock_nested (&card->mutex,SND_SOC_CARD_CLASS_RUNTIME );/* shutdown all old paths first */ -list_for_each_entry (fe, &card->rtd_list, list) { +for_each_card_rtds (card, fe) { ret =soc_dpcm_fe_runtime_update (fe,0 );if (ret) goto out; }/* bring new paths up */ -list_for_each_entry (fe, &card->rtd_list, list) { +for_each_card_rtds (card, fe) { ret =soc_dpcm_fe_runtime_update (fe,1 );if (ret) goto out;
Signature · 1 line
2.7.4
Mark Brown
maintainerApplied "ASoC: add for_each_card_rtds() macro" to the asoc tree
The patch
ASoC: add for_each_card_rtds() macro
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
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
Quoted 1 line
From
bcb1fd1fcd6507ba5a1f8610550135dc367aedb7Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto <[email protected]>
Date: Tue, 18 Sep 2018 01:29:35 +0000
Subject: [PATCH] ASoC: add for_each_card_rtds() macro
To be more readable code, this patch adds
new for_each_card_rtds() macro, and replace existing code to it.
--- include/sound/soc.h | 4 ++ sound/soc/codecs/hdac_hdmi.c | 2 +- sound/soc/intel/atom/sst-mfld-platform-pcm.c | 4 +- sound/soc/soc-core.c | 48 ++++++++++---------- sound/soc/soc-dapm.c | 2 +- sound/soc/soc-pcm.c | 12 ++--- 6 files changed, 38 insertions(+), 34 deletions(-)
include/sound/soc.h +4 -0
@@ -1130,6 +1130,10 @@ struct snd_soc_card {#define for_each_card_links_safe (card, link, _link) \ list_for_each_entry_safe(link, _link, &(card)->dai_link_list, list) +#define for_each_card_rtds (card, rtd) \ + list_for_each_entry(rtd, &(card)->rtd_list, list) +#define for_each_card_rtds_safe (card, rtd, _rtd) \ + list_for_each_entry_safe(rtd, _rtd, &(card)->rtd_list, list)/* SoC machine DAI configuration, glues a codec and cpu DAI together */ struct snd_soc_pcm_runtime {
sound/soc/codecs/hdac_hdmi.c +1 -1
@@ -1604,7 +1604,7 @@ static struct snd_pcm *hdac_hdmi_get_pcm_from_id(struct snd_soc_card *card, {struct snd_soc_pcm_runtime *rtd; -list_for_each_entry (rtd, &card->rtd_list, list) { +for_each_card_rtds (card, rtd) {if (rtd->pcm && (rtd->pcm->device == device))return rtd->pcm; }
sound/soc/intel/atom/sst-mfld-platform-pcm.c +2 -2
@@ -765,7 +765,7 @@ static int sst_soc_prepare(struct device *dev)snd_soc_poweroff (drv->soc_card->dev);/* set the SSPs to idle */ -list_for_each_entry (rtd, &drv->soc_card->rtd_list, list) { +for_each_card_rtds (drv->soc_card, rtd) {struct snd_soc_dai *dai = rtd->cpu_dai;if (dai->active) {
@@ -786,7 +786,7 @@ static void sst_soc_complete(struct device *dev)return ;/* restart SSPs */ -list_for_each_entry (rtd, &drv->soc_card->rtd_list, list) { +for_each_card_rtds (drv->soc_card, rtd) {struct snd_soc_dai *dai = rtd->cpu_dai;if (dai->active) {
sound/soc/soc-core.c +24 -24
186 lines not on this page · raw message
sound/soc/soc-dapm.c +1 -1
@@ -4183,7 +4183,7 @@ void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card)struct snd_soc_pcm_runtime *rtd;/* for each BE DAI link... */ -list_for_each_entry (rtd, &card->rtd_list, list) { +for_each_card_rtds (card, rtd) {/* * dynamic FE links have no fixed DAI mapping. * CODEC<->CODEC links have no direct connection.
sound/soc/soc-pcm.c +6 -6
@@ -1307,7 +1307,7 @@ static struct snd_soc_pcm_runtime *dpcm_get_be(struct snd_soc_card *card,dev_dbg (card->dev,"ASoC: find BE for widget %s\n" , widget->name);if (stream ==SNDRV_PCM_STREAM_PLAYBACK ) { -list_for_each_entry (be, &card->rtd_list, list) { +for_each_card_rtds (card, be) {if (!be->dai_link->no_pcm)continue ;
@@ -1326,7 +1326,7 @@ static struct snd_soc_pcm_runtime *dpcm_get_be(struct snd_soc_card *card, } }else { -list_for_each_entry (be, &card->rtd_list, list) { +for_each_card_rtds (card, be) {if (!be->dai_link->no_pcm)continue ;
@@ -1382,7 +1382,7 @@ static bool dpcm_end_walk_at_be(struct snd_soc_dapm_widget *widget,int i;if (dir ==SND_SOC_DAPM_DIR_OUT ) { -list_for_each_entry (rtd, &card->rtd_list, list) { +for_each_card_rtds (card, rtd) {if (!rtd->dai_link->no_pcm)continue ;
@@ -1395,7 +1395,7 @@ static bool dpcm_end_walk_at_be(struct snd_soc_dapm_widget *widget, } } }else {/* SND_SOC_DAPM_DIR_IN */ -list_for_each_entry (rtd, &card->rtd_list, list) { +for_each_card_rtds (card, rtd) {if (!rtd->dai_link->no_pcm)continue ;
@@ -2761,14 +2761,14 @@ int soc_dpcm_runtime_update(struct snd_soc_card *card)mutex_lock_nested (&card->mutex,SND_SOC_CARD_CLASS_RUNTIME );/* shutdown all old paths first */ -list_for_each_entry (fe, &card->rtd_list, list) { +for_each_card_rtds (card, fe) { ret =soc_dpcm_fe_runtime_update (fe,0 );if (ret) goto out; }/* bring new paths up */ -list_for_each_entry (fe, &card->rtd_list, list) { +for_each_card_rtds (card, fe) { ret =soc_dpcm_fe_runtime_update (fe,1 );if (ret) goto out;
Signature · 1 line
2.19.0
Kuninori Morimoto
maintainerPATCH 6/11 ASoC: add for_each_card_components() macro
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
To be more readable code, this patch adds
new for_each_card_components() macro, and replace existing code to it.
--- include/sound/soc.h | 3 +++ sound/soc/intel/boards/broadwell.c | 4 ++-- sound/soc/intel/boards/bytcr_rt5640.c | 4 ++-- sound/soc/intel/boards/bytcr_rt5651.c | 4 ++-- sound/soc/intel/boards/cht_bsw_rt5672.c | 4 ++-- sound/soc/soc-core.c | 5 +++-- 6 files changed, 14 insertions(+), 10 deletions(-)
include/sound/soc.h +3 -0
@@ -1135,6 +1135,9 @@ struct snd_soc_card {#define for_each_card_rtds_safe (card, rtd, _rtd) \ list_for_each_entry_safe(rtd, _rtd, &(card)->rtd_list, list) +#define for_each_card_components (card, component) \ + list_for_each_entry(component, &(card)->component_dev_list, card_list) +/* SoC machine DAI configuration, glues a codec and cpu DAI together */ struct snd_soc_pcm_runtime {struct device *dev;
sound/soc/intel/boards/broadwell.c +2 -2
@@ -223,7 +223,7 @@ static struct snd_soc_dai_link broadwell_rt286_dais[] = {static int broadwell_suspend (struct snd_soc_card *card){struct snd_soc_component *component; -list_for_each_entry (component, &card->component_dev_list, card_list) { +for_each_card_components (card, component) {if (!strcmp (component->name,"i2c-INT343A:00" )) {dev_dbg (component->dev,"disabling jack detect before going to suspend.\n" );
@@ -237,7 +237,7 @@ static int broadwell_suspend(struct snd_soc_card *card){static int broadwell_resume (struct snd_soc_card *card){struct snd_soc_component *component; -list_for_each_entry (component, &card->component_dev_list, card_list) { +for_each_card_components (card, component) {if (!strcmp (component->name,"i2c-INT343A:00" )) {dev_dbg (component->dev,"enabling jack detect for resume.\n" );
sound/soc/intel/boards/bytcr_rt5640.c +2 -2
@@ -1048,7 +1048,7 @@ static int byt_rt5640_suspend(struct snd_soc_card *card)if (!BYT_RT5640_JDSRC (byt_rt5640_quirk))return 0 ; -list_for_each_entry (component, &card->component_dev_list, card_list) { +for_each_card_components (card, component) {if (!strcmp (component->name, byt_rt5640_codec_name)) {dev_dbg (component->dev,"disabling jack detect before suspend\n" );snd_soc_component_set_jack (component,NULL ,NULL );
@@ -1067,7 +1067,7 @@ static int byt_rt5640_resume(struct snd_soc_card *card)if (!BYT_RT5640_JDSRC (byt_rt5640_quirk))return 0 ; -list_for_each_entry (component, &card->component_dev_list, card_list) { +for_each_card_components (card, component) {if (!strcmp (component->name, byt_rt5640_codec_name)) {dev_dbg (component->dev,"re-enabling jack detect after resume\n" );snd_soc_component_set_jack (component, &priv->jack,NULL );
sound/soc/intel/boards/bytcr_rt5651.c +2 -2
@@ -742,7 +742,7 @@ static int byt_rt5651_suspend(struct snd_soc_card *card)if (!BYT_RT5651_JDSRC (byt_rt5651_quirk))return 0 ; -list_for_each_entry (component, &card->component_dev_list, card_list) { +for_each_card_components (card, component) {if (!strcmp (component->name, byt_rt5651_codec_name)) {dev_dbg (component->dev,"disabling jack detect before suspend\n" );snd_soc_component_set_jack (component,NULL ,NULL );
@@ -761,7 +761,7 @@ static int byt_rt5651_resume(struct snd_soc_card *card)if (!BYT_RT5651_JDSRC (byt_rt5651_quirk))return 0 ; -list_for_each_entry (component, &card->component_dev_list, card_list) { +for_each_card_components (card, component) {if (!strcmp (component->name, byt_rt5651_codec_name)) {dev_dbg (component->dev,"re-enabling jack detect after resume\n" );snd_soc_component_set_jack (component, &priv->jack,NULL );
sound/soc/intel/boards/cht_bsw_rt5672.c +2 -2
@@ -347,7 +347,7 @@ static int cht_suspend_pre(struct snd_soc_card *card)struct snd_soc_component *component;struct cht_mc_private *ctx =snd_soc_card_get_drvdata (card); -list_for_each_entry (component, &card->component_dev_list, card_list) { +for_each_card_components (card, component) {if (!strncmp (component->name, ctx->codec_name,sizeof (ctx->codec_name))) {
@@ -364,7 +364,7 @@ static int cht_resume_post(struct snd_soc_card *card)struct snd_soc_component *component;struct cht_mc_private *ctx =snd_soc_card_get_drvdata (card); -list_for_each_entry (component, &card->component_dev_list, card_list) { +for_each_card_components (card, component) {if (!strncmp (component->name, ctx->codec_name,sizeof (ctx->codec_name))) {
sound/soc/soc-core.c +3 -2
@@ -510,7 +510,7 @@ int snd_soc_suspend(struct device *dev)snd_soc_dapm_sync (&card->dapm);/* suspend all COMPONENTs */ -list_for_each_entry (component, &card->component_dev_list, card_list) { +for_each_card_components (card, component) {struct snd_soc_dapm_context *dapm =snd_soc_component_get_dapm (component);/* If there are paths active then the COMPONENT will be held with
@@ -602,7 +602,7 @@ static void soc_resume_deferred(struct work_struct *work) cpu_dai->driver->resume (cpu_dai); } -list_for_each_entry (component, &card->component_dev_list, card_list) { +for_each_card_components (card, component) {if (component->suspended) {if (component->driver->resume) component->driver->resume (component);
@@ -1354,6 +1354,7 @@ static int soc_probe_component(struct snd_soc_card *card, component->driver->num_dapm_routes);list_add (&dapm->list, &card->dapm_list); +/* see for_each_card_components */ list_add (&component->card_list, &card->component_dev_list);return 0 ;
Signature · 1 line
2.7.4
Mark Brown
maintainerApplied "ASoC: add for_each_card_components() macro" to the asoc tree
The patch
ASoC: add for_each_card_components() macro
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
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
Quoted 1 line
From
f70f18f7d459b7958a4d3944396e2bc4a9f7ed72Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto <[email protected]>
Date: Tue, 18 Sep 2018 01:29:55 +0000
Subject: [PATCH] ASoC: add for_each_card_components() macro
To be more readable code, this patch adds
new for_each_card_components() macro, and replace existing code to it.
--- include/sound/soc.h | 3 +++ sound/soc/intel/boards/broadwell.c | 4 ++-- sound/soc/intel/boards/bytcr_rt5640.c | 4 ++-- sound/soc/intel/boards/bytcr_rt5651.c | 4 ++-- sound/soc/intel/boards/cht_bsw_rt5672.c | 4 ++-- sound/soc/soc-core.c | 5 +++-- 6 files changed, 14 insertions(+), 10 deletions(-)
include/sound/soc.h +3 -0
@@ -1135,6 +1135,9 @@ struct snd_soc_card {#define for_each_card_rtds_safe (card, rtd, _rtd) \ list_for_each_entry_safe(rtd, _rtd, &(card)->rtd_list, list) +#define for_each_card_components (card, component) \ + list_for_each_entry(component, &(card)->component_dev_list, card_list) +/* SoC machine DAI configuration, glues a codec and cpu DAI together */ struct snd_soc_pcm_runtime {struct device *dev;
sound/soc/intel/boards/broadwell.c +2 -2
@@ -223,7 +223,7 @@ static struct snd_soc_dai_link broadwell_rt286_dais[] = {static int broadwell_suspend (struct snd_soc_card *card){struct snd_soc_component *component; -list_for_each_entry (component, &card->component_dev_list, card_list) { +for_each_card_components (card, component) {if (!strcmp (component->name,"i2c-INT343A:00" )) {dev_dbg (component->dev,"disabling jack detect before going to suspend.\n" );
@@ -237,7 +237,7 @@ static int broadwell_suspend(struct snd_soc_card *card){static int broadwell_resume (struct snd_soc_card *card){struct snd_soc_component *component; -list_for_each_entry (component, &card->component_dev_list, card_list) { +for_each_card_components (card, component) {if (!strcmp (component->name,"i2c-INT343A:00" )) {dev_dbg (component->dev,"enabling jack detect for resume.\n" );
sound/soc/intel/boards/bytcr_rt5640.c +2 -2
@@ -1048,7 +1048,7 @@ static int byt_rt5640_suspend(struct snd_soc_card *card)if (!BYT_RT5640_JDSRC (byt_rt5640_quirk))return 0 ; -list_for_each_entry (component, &card->component_dev_list, card_list) { +for_each_card_components (card, component) {if (!strcmp (component->name, byt_rt5640_codec_name)) {dev_dbg (component->dev,"disabling jack detect before suspend\n" );snd_soc_component_set_jack (component,NULL ,NULL );
@@ -1067,7 +1067,7 @@ static int byt_rt5640_resume(struct snd_soc_card *card)if (!BYT_RT5640_JDSRC (byt_rt5640_quirk))return 0 ; -list_for_each_entry (component, &card->component_dev_list, card_list) { +for_each_card_components (card, component) {if (!strcmp (component->name, byt_rt5640_codec_name)) {dev_dbg (component->dev,"re-enabling jack detect after resume\n" );snd_soc_component_set_jack (component, &priv->jack,NULL );
sound/soc/intel/boards/bytcr_rt5651.c +2 -2
@@ -742,7 +742,7 @@ static int byt_rt5651_suspend(struct snd_soc_card *card)if (!BYT_RT5651_JDSRC (byt_rt5651_quirk))return 0 ; -list_for_each_entry (component, &card->component_dev_list, card_list) { +for_each_card_components (card, component) {if (!strcmp (component->name, byt_rt5651_codec_name)) {dev_dbg (component->dev,"disabling jack detect before suspend\n" );snd_soc_component_set_jack (component,NULL ,NULL );
@@ -761,7 +761,7 @@ static int byt_rt5651_resume(struct snd_soc_card *card)if (!BYT_RT5651_JDSRC (byt_rt5651_quirk))return 0 ; -list_for_each_entry (component, &card->component_dev_list, card_list) { +for_each_card_components (card, component) {if (!strcmp (component->name, byt_rt5651_codec_name)) {dev_dbg (component->dev,"re-enabling jack detect after resume\n" );snd_soc_component_set_jack (component, &priv->jack,NULL );
sound/soc/intel/boards/cht_bsw_rt5672.c +2 -2
@@ -347,7 +347,7 @@ static int cht_suspend_pre(struct snd_soc_card *card)struct snd_soc_component *component;struct cht_mc_private *ctx =snd_soc_card_get_drvdata (card); -list_for_each_entry (component, &card->component_dev_list, card_list) { +for_each_card_components (card, component) {if (!strncmp (component->name, ctx->codec_name,sizeof (ctx->codec_name))) {
@@ -364,7 +364,7 @@ static int cht_resume_post(struct snd_soc_card *card)struct snd_soc_component *component;struct cht_mc_private *ctx =snd_soc_card_get_drvdata (card); -list_for_each_entry (component, &card->component_dev_list, card_list) { +for_each_card_components (card, component) {if (!strncmp (component->name, ctx->codec_name,sizeof (ctx->codec_name))) {
sound/soc/soc-core.c +3 -2
@@ -510,7 +510,7 @@ int snd_soc_suspend(struct device *dev)snd_soc_dapm_sync (&card->dapm);/* suspend all COMPONENTs */ -list_for_each_entry (component, &card->component_dev_list, card_list) { +for_each_card_components (card, component) {struct snd_soc_dapm_context *dapm =snd_soc_component_get_dapm (component);/* If there are paths active then the COMPONENT will be held with
@@ -602,7 +602,7 @@ static void soc_resume_deferred(struct work_struct *work) cpu_dai->driver->resume (cpu_dai); } -list_for_each_entry (component, &card->component_dev_list, card_list) { +for_each_card_components (card, component) {if (component->suspended) {if (component->driver->resume) component->driver->resume (component);
@@ -1354,6 +1354,7 @@ static int soc_probe_component(struct snd_soc_card *card, component->driver->num_dapm_routes);list_add (&dapm->list, &card->dapm_list); +/* see for_each_card_components */ list_add (&component->card_list, &card->component_dev_list);return 0 ;
Signature · 1 line
2.19.0
Kuninori Morimoto
maintainerPATCH 7/11 ASoC: add for_each_component_all() macro
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
To be more readable code, this patch adds
new for_each_component_all() macro, and replace existing code to it.
--- sound/soc/soc-core.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-)
sound/soc/soc-core.c +14 -10
@@ -54,6 +54,9 @@ static DEFINE_MUTEX(client_mutex);static LIST_HEAD (component_list);static LIST_HEAD (unbind_card_list); +#define for_each_component_all (component) \ + list_for_each_entry(component, &component_list, list) +/* * This is a timeout to do a DAPM powerdown after a stream is closed(). * It can be used to eliminate pops between different playback streams, e.g.
@@ -176,7 +179,7 @@ static int dai_list_show(struct seq_file *m, void *v)mutex_lock (&client_mutex); -list_for_each_entry (component, &component_list, list) +for_each_component_all (component)list_for_each_entry (dai, &component->dai_list, list)seq_printf (m,"%s\n" , dai->name);
@@ -192,7 +195,7 @@ static int component_list_show(struct seq_file *m, void *v)mutex_lock (&client_mutex); -list_for_each_entry (component, &component_list, list) +for_each_component_all (component)seq_printf (m,"%s\n" , component->name);mutex_unlock (&client_mutex);
@@ -725,7 +728,7 @@ static struct snd_soc_component *soc_find_component(lockdep_assert_held (&client_mutex); -list_for_each_entry (component, &component_list, list) { +for_each_component_all (component) {if (of_node) {if (component->dev->of_node == of_node)return component;
@@ -775,7 +778,7 @@ struct snd_soc_dai *snd_soc_find_dai(lockdep_assert_held (&client_mutex);/* Find CPU DAI from registered DAIs*/ -list_for_each_entry (component, &component_list, list) { +for_each_component_all (component) {if (!snd_soc_is_matching_component (dlc, component))continue ;list_for_each_entry (dai, &component->dai_list, list) {
@@ -902,7 +905,7 @@ static int soc_bind_dai_link(struct snd_soc_card *card, rtd->codec_dai = codec_dais[0 ];/* find one from the set of registered platforms */ -list_for_each_entry (component, &component_list, list) { +for_each_component_all (component) {if (!snd_soc_is_matching_component (dai_link->platform, component))continue ;
@@ -1878,7 +1881,7 @@ static void soc_check_tplg_fes(struct snd_soc_card *card)struct snd_soc_dai_link *dai_link;int i; -list_for_each_entry (component, &component_list, list) { +for_each_component_all (component) {/* does this component override FEs ? */ if (!component->driver->ignore_machine)
@@ -3097,6 +3100,7 @@ static void snd_soc_component_add(struct snd_soc_component *component)snd_soc_component_setup_regmap (component); } +/* see for_each_component_all */ list_add (&component->list, &component_list);INIT_LIST_HEAD (&component->dobj_list);
@@ -3232,7 +3236,7 @@ static int __snd_soc_unregister_component(struct device *dev)int found =0 ;mutex_lock (&client_mutex); -list_for_each_entry (component, &component_list, list) { +for_each_component_all (component) {if (dev != component->dev)continue ;
@@ -3264,7 +3268,7 @@ struct snd_soc_component *snd_soc_lookup_component(struct device *dev, ret =NULL ;mutex_lock (&client_mutex); -list_for_each_entry (component, &component_list, list) { +for_each_component_all (component) {if (dev != component->dev)continue ;
@@ -3664,7 +3668,7 @@ int snd_soc_get_dai_id(struct device_node *ep)*/ ret = -ENOTSUPP ;mutex_lock (&client_mutex); -list_for_each_entry (pos, &component_list, list) { +for_each_component_all (pos) {struct device_node *component_of_node = pos->dev->of_node;if (!component_of_node && pos->dev->parent)
@@ -3694,7 +3698,7 @@ int snd_soc_get_dai_name(struct of_phandle_args *args,int ret = -EPROBE_DEFER ;mutex_lock (&client_mutex); -list_for_each_entry (pos, &component_list, list) { +for_each_component_all (pos) { component_of_node = pos->dev->of_node;if (!component_of_node && pos->dev->parent) component_of_node = pos->dev->parent->of_node;
Signature · 1 line
2.7.4
Mark Brown
maintainerRe: [PATCH 07/11] ASoC: add for_each_component_all() macro
Quoted 5 lines · Kuninori Morimoto
From: Kuninori Morimoto <[email protected]>
To be more readable code, this patch adds
newfor_each_component_all()macro, and replace existing code to it.
I think this one might be better named as just for_each_component() - I don't think there's much risk of confusion with the more specific iterators for specific types of components and it sounds less awkward. I'll skip this and one subsequent patch that depended on it then apply the rest, they all look good.
Kuninori Morimoto
maintainerPATCH 8/11 ASoC: add for_each_component_dais() macro
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
To be more readable code, this patch adds
new for_each_component_dais() macro, and replace existing code to it.
--- include/sound/soc.h | 5 +++++ sound/soc/soc-core.c | 11 ++++++----- 2 files changed, 11 insertions(+), 5 deletions(-)
include/sound/soc.h +5 -0
@@ -859,6 +859,11 @@ struct snd_soc_component {#endif }; +#define for_each_component_dais (component, dai)\ + list_for_each_entry(dai, &(component)->dai_list, list) +#define for_each_component_dais_safe (component, dai, _dai)\ + list_for_each_entry_safe(dai, _dai, &(component)->dai_list, list) +struct snd_soc_rtdcom_list {struct snd_soc_component *component;struct list_head list;/* rtd::component_list */
sound/soc/soc-core.c +6 -5
@@ -180,7 +180,7 @@ static int dai_list_show(struct seq_file *m, void *v)mutex_lock (&client_mutex);for_each_component_all (component) -list_for_each_entry (dai, &component->dai_list, list) +for_each_component_dais (component, dai)seq_printf (m,"%s\n" , dai->name);mutex_unlock (&client_mutex);
@@ -781,7 +781,7 @@ struct snd_soc_dai *snd_soc_find_dai(for_each_component_all (component) {if (!snd_soc_is_matching_component (dlc, component))continue ; -list_for_each_entry (dai, &component->dai_list, list) { +for_each_component_dais (component, dai) {if (dlc->dai_name &&strcmp (dai->name, dlc->dai_name) && (!dai->driver->name ||strcmp (dai->driver->name, dlc->dai_name)))
@@ -1314,7 +1314,7 @@ static int soc_probe_component(struct snd_soc_card *card, } } -list_for_each_entry (dai, &component->dai_list, list) { +for_each_component_dais (component, dai) { ret =snd_soc_dapm_new_dai_widgets (dapm, dai);if (ret !=0 ) { dev_err(component->dev,
@@ -2848,7 +2848,7 @@ static void snd_soc_unregister_dais(struct snd_soc_component *component) {struct snd_soc_dai *dai, *_dai; -list_for_each_entry_safe (dai, _dai, &component->dai_list, list) { +for_each_component_dais_safe (component, dai, _dai) {dev_dbg (component->dev,"ASoC: Unregistered DAI '%s'\n" , dai->name);list_del (&dai->list);
@@ -2900,6 +2900,7 @@ static struct snd_soc_dai *soc_add_dai(struct snd_soc_component *component,if (!dai->driver->ops) dai->driver->ops = &null_dai_ops; +/* see for_each_component_dais */ list_add_tail (&dai->list, &component->dai_list); component->num_dai++;
@@ -3734,7 +3735,7 @@ int snd_soc_get_dai_name(struct of_phandle_args *args, ret =0 ;/* find target DAI */ -list_for_each_entry (dai, &pos->dai_list, list) { +for_each_component_dais (pos, dai) {if (id ==0 )break ; id--;
Signature · 1 line
2.7.4
Kuninori Morimoto
maintainerPATCH 9/11 ASoC: add for_each_comp_order() macro
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
To be more readable code, this patch adds
new for_each_comp_order() macro, and replace existing code to it.
--- include/sound/soc.h | 5 +++++ sound/soc/soc-core.c | 18 ++++++------------ 2 files changed, 11 insertions(+), 12 deletions(-)
include/sound/soc.h +5 -0
@@ -372,6 +372,11 @@#define SND_SOC_COMP_ORDER_LATE 1#define SND_SOC_COMP_ORDER_LAST 2 +#define for_each_comp_order (order) \ + for (order = SND_SOC_COMP_ORDER_FIRST; \ + order <= SND_SOC_COMP_ORDER_LAST; \ + order++) +/* * Bias levels *
sound/soc/soc-core.c +6 -12
@@ -995,14 +995,12 @@ static void soc_remove_dai_links(struct snd_soc_card *card)struct snd_soc_pcm_runtime *rtd;struct snd_soc_dai_link *link, *_link; -for (order =SND_SOC_COMP_ORDER_FIRST ; order <=SND_SOC_COMP_ORDER_LAST ; - order++) { +for_each_comp_order (order) {for_each_card_rtds (card, rtd)soc_remove_link_dais (card, rtd, order); } -for (order =SND_SOC_COMP_ORDER_FIRST ; order <=SND_SOC_COMP_ORDER_LAST ; - order++) { +for_each_comp_order (order) {for_each_card_rtds (card, rtd)soc_remove_link_components (card, rtd, order); }
@@ -1620,8 +1618,7 @@ static int soc_probe_aux_devices(struct snd_soc_card *card)int order;int ret; -for (order =SND_SOC_COMP_ORDER_FIRST ; order <=SND_SOC_COMP_ORDER_LAST ; - order++) { +for_each_comp_order (order) {list_for_each_entry (comp, &card->aux_comp_list, card_aux_list) {if (comp->driver->probe_order == order) { ret =soc_probe_component (card, comp);
@@ -1643,8 +1640,7 @@ static void soc_remove_aux_devices(struct snd_soc_card *card)struct snd_soc_component *comp, *_comp;int order; -for (order =SND_SOC_COMP_ORDER_FIRST ; order <=SND_SOC_COMP_ORDER_LAST ; - order++) { +for_each_comp_order (order) {list_for_each_entry_safe (comp, _comp, &card->aux_comp_list, card_aux_list) {
@@ -2016,8 +2012,7 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) }/* probe all components used by DAI links on this card */ -for (order =SND_SOC_COMP_ORDER_FIRST ; order <=SND_SOC_COMP_ORDER_LAST ; - order++) { +for_each_comp_order (order) {for_each_card_rtds (card, rtd) { ret =soc_probe_link_components (card, rtd, order);if (ret <0 ) {
@@ -2050,8 +2045,7 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) }/* probe all DAI links on this card */ -for (order =SND_SOC_COMP_ORDER_FIRST ; order <=SND_SOC_COMP_ORDER_LAST ; - order++) { +for_each_comp_order (order) {for_each_card_rtds (card, rtd) { ret =soc_probe_link_dais (card, rtd, order);if (ret <0 ) {
Signature · 1 line
2.7.4
Mark Brown
maintainerApplied "ASoC: add for_each_comp_order() macro" to the asoc tree
The patch
ASoC: add for_each_comp_order() macro
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
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
Quoted 1 line
From
1a1035a9854fd893d487a84edccc1d5804e1d716Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto <[email protected]>
Date: Tue, 18 Sep 2018 01:30:41 +0000
Subject: [PATCH] ASoC: add for_each_comp_order() macro
To be more readable code, this patch adds
new for_each_comp_order() macro, and replace existing code to it.
--- include/sound/soc.h | 5 +++++ sound/soc/soc-core.c | 18 ++++++------------ 2 files changed, 11 insertions(+), 12 deletions(-)
include/sound/soc.h +5 -0
@@ -372,6 +372,11 @@#define SND_SOC_COMP_ORDER_LATE 1#define SND_SOC_COMP_ORDER_LAST 2 +#define for_each_comp_order (order) \ + for (order = SND_SOC_COMP_ORDER_FIRST; \ + order <= SND_SOC_COMP_ORDER_LAST; \ + order++) +/* * Bias levels *
sound/soc/soc-core.c +6 -12
@@ -992,14 +992,12 @@ static void soc_remove_dai_links(struct snd_soc_card *card)struct snd_soc_pcm_runtime *rtd;struct snd_soc_dai_link *link, *_link; -for (order =SND_SOC_COMP_ORDER_FIRST ; order <=SND_SOC_COMP_ORDER_LAST ; - order++) { +for_each_comp_order (order) {for_each_card_rtds (card, rtd)soc_remove_link_dais (card, rtd, order); } -for (order =SND_SOC_COMP_ORDER_FIRST ; order <=SND_SOC_COMP_ORDER_LAST ; - order++) { +for_each_comp_order (order) {for_each_card_rtds (card, rtd)soc_remove_link_components (card, rtd, order); }
@@ -1617,8 +1615,7 @@ static int soc_probe_aux_devices(struct snd_soc_card *card)int order;int ret; -for (order =SND_SOC_COMP_ORDER_FIRST ; order <=SND_SOC_COMP_ORDER_LAST ; - order++) { +for_each_comp_order (order) {list_for_each_entry (comp, &card->aux_comp_list, card_aux_list) {if (comp->driver->probe_order == order) { ret =soc_probe_component (card, comp);
@@ -1640,8 +1637,7 @@ static void soc_remove_aux_devices(struct snd_soc_card *card)struct snd_soc_component *comp, *_comp;int order; -for (order =SND_SOC_COMP_ORDER_FIRST ; order <=SND_SOC_COMP_ORDER_LAST ; - order++) { +for_each_comp_order (order) {list_for_each_entry_safe (comp, _comp, &card->aux_comp_list, card_aux_list) {
@@ -2013,8 +2009,7 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) }/* probe all components used by DAI links on this card */ -for (order =SND_SOC_COMP_ORDER_FIRST ; order <=SND_SOC_COMP_ORDER_LAST ; - order++) { +for_each_comp_order (order) {for_each_card_rtds (card, rtd) { ret =soc_probe_link_components (card, rtd, order);if (ret <0 ) {
@@ -2047,8 +2042,7 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) }/* probe all DAI links on this card */ -for (order =SND_SOC_COMP_ORDER_FIRST ; order <=SND_SOC_COMP_ORDER_LAST ; - order++) { +for_each_comp_order (order) {for_each_card_rtds (card, rtd) { ret =soc_probe_link_dais (card, rtd, order);if (ret <0 ) {
Signature · 1 line
2.19.0
Kuninori Morimoto
maintainerPATCH 10/11 ASoC: add for_each_dpcm_fe() macro
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
To be more readable code, this patch adds
new for_each_dpcm_fe() macro, and replace existing code to it.
--- include/sound/soc-dpcm.h | 3 +++ sound/soc/soc-pcm.c | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-)
include/sound/soc-dpcm.h +3 -0
@@ -103,6 +103,9 @@ struct snd_soc_dpcm_runtime {int trigger_pending;/* trigger cmd + 1 if pending, 0 if not */ }; +#define for_each_dpcm_fe (be, stream, dpcm) \ + list_for_each_entry(dpcm, &(be)->dpcm[stream].fe_clients, list_fe) +/* can this BE stop and free */ int snd_soc_dpcm_can_be_free_stop (struct snd_soc_pcm_runtime *fe,struct snd_soc_pcm_runtime *be,int stream);
sound/soc/soc-pcm.c +3 -3
@@ -1252,7 +1252,7 @@ static void dpcm_be_reparent(struct snd_soc_pcm_runtime *fe, be_substream =snd_soc_dpcm_get_substream (be, stream); -list_for_each_entry (dpcm, &be->dpcm[stream].fe_clients, list_fe) { +for_each_dpcm_fe (be, stream, dpcm) {if (dpcm->fe == fe)continue ;
@@ -3219,7 +3219,7 @@ int snd_soc_dpcm_can_be_free_stop(struct snd_soc_pcm_runtime *fe,struct snd_soc_dpcm *dpcm;int state; -list_for_each_entry (dpcm, &be->dpcm[stream].fe_clients, list_fe) { +for_each_dpcm_fe (be, stream, dpcm) {if (dpcm->fe == fe)continue ;
@@ -3246,7 +3246,7 @@ int snd_soc_dpcm_can_be_params(struct snd_soc_pcm_runtime *fe,struct snd_soc_dpcm *dpcm;int state; -list_for_each_entry (dpcm, &be->dpcm[stream].fe_clients, list_fe) { +for_each_dpcm_fe (be, stream, dpcm) {if (dpcm->fe == fe)continue ;
Signature · 1 line
2.7.4
Mark Brown
maintainerApplied "ASoC: add for_each_dpcm_fe() macro" to the asoc tree
The patch
ASoC: add for_each_dpcm_fe() macro
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
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
Quoted 1 line
From
d2e24d64652bf9d272e5496ae8a562bc64facff3Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto <[email protected]>
Date: Tue, 18 Sep 2018 01:30:54 +0000
Subject: [PATCH] ASoC: add for_each_dpcm_fe() macro
To be more readable code, this patch adds
new for_each_dpcm_fe() macro, and replace existing code to it.
--- include/sound/soc-dpcm.h | 3 +++ sound/soc/soc-pcm.c | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-)
include/sound/soc-dpcm.h +3 -0
@@ -103,6 +103,9 @@ struct snd_soc_dpcm_runtime {int trigger_pending;/* trigger cmd + 1 if pending, 0 if not */ }; +#define for_each_dpcm_fe (be, stream, dpcm) \ + list_for_each_entry(dpcm, &(be)->dpcm[stream].fe_clients, list_fe) +/* can this BE stop and free */ int snd_soc_dpcm_can_be_free_stop (struct snd_soc_pcm_runtime *fe,struct snd_soc_pcm_runtime *be,int stream);
sound/soc/soc-pcm.c +3 -3
@@ -1252,7 +1252,7 @@ static void dpcm_be_reparent(struct snd_soc_pcm_runtime *fe, be_substream =snd_soc_dpcm_get_substream (be, stream); -list_for_each_entry (dpcm, &be->dpcm[stream].fe_clients, list_fe) { +for_each_dpcm_fe (be, stream, dpcm) {if (dpcm->fe == fe)continue ;
@@ -3219,7 +3219,7 @@ int snd_soc_dpcm_can_be_free_stop(struct snd_soc_pcm_runtime *fe,struct snd_soc_dpcm *dpcm;int state; -list_for_each_entry (dpcm, &be->dpcm[stream].fe_clients, list_fe) { +for_each_dpcm_fe (be, stream, dpcm) {if (dpcm->fe == fe)continue ;
@@ -3246,7 +3246,7 @@ int snd_soc_dpcm_can_be_params(struct snd_soc_pcm_runtime *fe,struct snd_soc_dpcm *dpcm;int state; -list_for_each_entry (dpcm, &be->dpcm[stream].fe_clients, list_fe) { +for_each_dpcm_fe (be, stream, dpcm) {if (dpcm->fe == fe)continue ;
Signature · 1 line
2.19.0
Kuninori Morimoto
maintainerPATCH 11/11 ASoC: add for_each_dpcm_be() macro
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
To be more readable code, this patch adds
new for_each_dpcm_be() macro, and replace existing code to it.
--- include/sound/soc-dpcm.h | 7 +++++++ sound/soc/fsl/fsl_asrc_dma.c | 2 +- sound/soc/sh/rcar/ctu.c | 2 +- sound/soc/sh/rcar/src.c | 2 +- sound/soc/soc-compress.c | 4 ++-- sound/soc/soc-pcm.c | 48 +++++++++++++++++++++----------------------- 6 files changed, 35 insertions(+), 30 deletions(-)
include/sound/soc-dpcm.h +7 -0
@@ -106,6 +106,13 @@ struct snd_soc_dpcm_runtime {#define for_each_dpcm_fe (be, stream, dpcm) \ list_for_each_entry(dpcm, &(be)->dpcm[stream].fe_clients, list_fe) +#define for_each_dpcm_be (fe, stream, dpcm) \ + list_for_each_entry(dpcm, &(fe)->dpcm[stream].be_clients, list_be) +#define for_each_dpcm_be_safe (fe, stream, dpcm, _dpcm) \ + list_for_each_entry_safe(dpcm, _dpcm, &(fe)->dpcm[stream].be_clients, list_be) +#define for_each_dpcm_be_rollback (fe, stream, dpcm) \ + list_for_each_entry_continue_reverse(dpcm, &(fe)->dpcm[stream].be_clients, list_be) +/* can this BE stop and free */ int snd_soc_dpcm_can_be_free_stop (struct snd_soc_pcm_runtime *fe,struct snd_soc_pcm_runtime *be,int stream);
sound/soc/fsl/fsl_asrc_dma.c +1 -1
@@ -151,7 +151,7 @@ static int fsl_asrc_dma_hw_params(struct snd_pcm_substream *substream,int ret;/* Fetch the Back-End dma_data from DPCM */ -list_for_each_entry (dpcm, &rtd->dpcm[stream].be_clients, list_be) { +for_each_dpcm_be (rtd, stream, dpcm) {struct snd_soc_pcm_runtime *be = dpcm->be;struct snd_pcm_substream *substream_be;struct snd_soc_dai *dai = be->cpu_dai;
sound/soc/sh/rcar/ctu.c +1 -1
@@ -258,7 +258,7 @@ static int rsnd_ctu_hw_params(struct rsnd_mod *mod,struct snd_pcm_hw_params *be_params;int stream = substream->stream; -list_for_each_entry (dpcm, &fe->dpcm[stream].be_clients, list_be) { +for_each_dpcm_be (fe, stream, dpcm) { be_params = &dpcm->hw_params;if (params_channels (fe_params) !=params_channels (be_params)) ctu->channels =params_channels (be_params);
sound/soc/sh/rcar/src.c +1 -1
@@ -158,7 +158,7 @@ static int rsnd_src_hw_params(struct rsnd_mod *mod,struct snd_soc_dpcm *dpcm;struct snd_pcm_hw_params *be_params; -list_for_each_entry (dpcm, &fe->dpcm[stream].be_clients, list_be) { +for_each_dpcm_be (fe, stream, dpcm) { be_params = &dpcm->hw_params;if (params_rate (fe_params) !=params_rate (be_params))
sound/soc/soc-compress.c +2 -2
@@ -157,7 +157,7 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream) ret =dpcm_be_dai_startup (fe, stream);if (ret <0 ) {/* clean up all links */ -list_for_each_entry (dpcm, &fe->dpcm[stream].be_clients, list_be) +for_each_dpcm_be (fe, stream, dpcm) dpcm->state =SND_SOC_DPCM_LINK_STATE_FREE ;dpcm_be_disconnect (fe, stream);
@@ -321,7 +321,7 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream) ret =dpcm_be_dai_shutdown (fe, stream);/* mark FE's links ready to prune */ -list_for_each_entry (dpcm, &fe->dpcm[stream].be_clients, list_be) +for_each_dpcm_be (fe, stream, dpcm) dpcm->state =SND_SOC_DPCM_LINK_STATE_FREE ;dpcm_dapm_stream_event (fe, stream,SND_SOC_DAPM_STREAM_STOP );
sound/soc/soc-pcm.c +23 -25
188 lines not on this page · raw message
Signature · 1 line
2.7.4
Mark Brown
maintainerApplied "ASoC: add for_each_dpcm_be() macro" to the asoc tree
The patch
ASoC: add for_each_dpcm_be() macro
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
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
Quoted 1 line
From
8d6258a4dd267838e2f10643c3d91b79fe75ef6eMon Sep 17 00:00:00 2001
From: Kuninori Morimoto <[email protected]>
Date: Tue, 18 Sep 2018 01:31:09 +0000
Subject: [PATCH] ASoC: add for_each_dpcm_be() macro
To be more readable code, this patch adds
new for_each_dpcm_be() macro, and replace existing code to it.
--- include/sound/soc-dpcm.h | 7 ++++++ sound/soc/fsl/fsl_asrc_dma.c | 2 +- sound/soc/sh/rcar/ctu.c | 2 +- sound/soc/sh/rcar/src.c | 2 +- sound/soc/soc-compress.c | 4 +-- sound/soc/soc-pcm.c | 48 +++++++++++++++++------------------- 6 files changed, 35 insertions(+), 30 deletions(-)
include/sound/soc-dpcm.h +7 -0
@@ -106,6 +106,13 @@ struct snd_soc_dpcm_runtime {#define for_each_dpcm_fe (be, stream, dpcm) \ list_for_each_entry(dpcm, &(be)->dpcm[stream].fe_clients, list_fe) +#define for_each_dpcm_be (fe, stream, dpcm) \ + list_for_each_entry(dpcm, &(fe)->dpcm[stream].be_clients, list_be) +#define for_each_dpcm_be_safe (fe, stream, dpcm, _dpcm) \ + list_for_each_entry_safe(dpcm, _dpcm, &(fe)->dpcm[stream].be_clients, list_be) +#define for_each_dpcm_be_rollback (fe, stream, dpcm) \ + list_for_each_entry_continue_reverse(dpcm, &(fe)->dpcm[stream].be_clients, list_be) +/* can this BE stop and free */ int snd_soc_dpcm_can_be_free_stop (struct snd_soc_pcm_runtime *fe,struct snd_soc_pcm_runtime *be,int stream);
sound/soc/fsl/fsl_asrc_dma.c +1 -1
@@ -151,7 +151,7 @@ static int fsl_asrc_dma_hw_params(struct snd_pcm_substream *substream,int ret;/* Fetch the Back-End dma_data from DPCM */ -list_for_each_entry (dpcm, &rtd->dpcm[stream].be_clients, list_be) { +for_each_dpcm_be (rtd, stream, dpcm) {struct snd_soc_pcm_runtime *be = dpcm->be;struct snd_pcm_substream *substream_be;struct snd_soc_dai *dai = be->cpu_dai;
sound/soc/sh/rcar/ctu.c +1 -1
@@ -258,7 +258,7 @@ static int rsnd_ctu_hw_params(struct rsnd_mod *mod,struct snd_pcm_hw_params *be_params;int stream = substream->stream; -list_for_each_entry (dpcm, &fe->dpcm[stream].be_clients, list_be) { +for_each_dpcm_be (fe, stream, dpcm) { be_params = &dpcm->hw_params;if (params_channels (fe_params) !=params_channels (be_params)) ctu->channels =params_channels (be_params);
sound/soc/sh/rcar/src.c +1 -1
@@ -158,7 +158,7 @@ static int rsnd_src_hw_params(struct rsnd_mod *mod,struct snd_soc_dpcm *dpcm;struct snd_pcm_hw_params *be_params; -list_for_each_entry (dpcm, &fe->dpcm[stream].be_clients, list_be) { +for_each_dpcm_be (fe, stream, dpcm) { be_params = &dpcm->hw_params;if (params_rate (fe_params) !=params_rate (be_params))
sound/soc/soc-compress.c +2 -2
@@ -157,7 +157,7 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream) ret =dpcm_be_dai_startup (fe, stream);if (ret <0 ) {/* clean up all links */ -list_for_each_entry (dpcm, &fe->dpcm[stream].be_clients, list_be) +for_each_dpcm_be (fe, stream, dpcm) dpcm->state =SND_SOC_DPCM_LINK_STATE_FREE ;dpcm_be_disconnect (fe, stream);
@@ -321,7 +321,7 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream) ret =dpcm_be_dai_shutdown (fe, stream);/* mark FE's links ready to prune */ -list_for_each_entry (dpcm, &fe->dpcm[stream].be_clients, list_be) +for_each_dpcm_be (fe, stream, dpcm) dpcm->state =SND_SOC_DPCM_LINK_STATE_FREE ;dpcm_dapm_stream_event (fe, stream,SND_SOC_DAPM_STREAM_STOP );
sound/soc/soc-pcm.c +23 -25
188 lines not on this page · raw message
Signature · 1 line
2.19.0