Commit f70f18f7 authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

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.
Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent bcb1fd1f
...@@ -1135,6 +1135,9 @@ struct snd_soc_card { ...@@ -1135,6 +1135,9 @@ struct snd_soc_card {
#define for_each_card_rtds_safe(card, rtd, _rtd) \ #define for_each_card_rtds_safe(card, rtd, _rtd) \
list_for_each_entry_safe(rtd, _rtd, &(card)->rtd_list, list) 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 */ /* SoC machine DAI configuration, glues a codec and cpu DAI together */
struct snd_soc_pcm_runtime { struct snd_soc_pcm_runtime {
struct device *dev; struct device *dev;
......
...@@ -223,7 +223,7 @@ static struct snd_soc_dai_link broadwell_rt286_dais[] = { ...@@ -223,7 +223,7 @@ static struct snd_soc_dai_link broadwell_rt286_dais[] = {
static int broadwell_suspend(struct snd_soc_card *card){ static int broadwell_suspend(struct snd_soc_card *card){
struct snd_soc_component *component; 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")) { if (!strcmp(component->name, "i2c-INT343A:00")) {
dev_dbg(component->dev, "disabling jack detect before going to suspend.\n"); 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){ ...@@ -237,7 +237,7 @@ static int broadwell_suspend(struct snd_soc_card *card){
static int broadwell_resume(struct snd_soc_card *card){ static int broadwell_resume(struct snd_soc_card *card){
struct snd_soc_component *component; 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")) { if (!strcmp(component->name, "i2c-INT343A:00")) {
dev_dbg(component->dev, "enabling jack detect for resume.\n"); dev_dbg(component->dev, "enabling jack detect for resume.\n");
......
...@@ -1048,7 +1048,7 @@ static int byt_rt5640_suspend(struct snd_soc_card *card) ...@@ -1048,7 +1048,7 @@ static int byt_rt5640_suspend(struct snd_soc_card *card)
if (!BYT_RT5640_JDSRC(byt_rt5640_quirk)) if (!BYT_RT5640_JDSRC(byt_rt5640_quirk))
return 0; 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)) { if (!strcmp(component->name, byt_rt5640_codec_name)) {
dev_dbg(component->dev, "disabling jack detect before suspend\n"); dev_dbg(component->dev, "disabling jack detect before suspend\n");
snd_soc_component_set_jack(component, NULL, NULL); snd_soc_component_set_jack(component, NULL, NULL);
...@@ -1067,7 +1067,7 @@ static int byt_rt5640_resume(struct snd_soc_card *card) ...@@ -1067,7 +1067,7 @@ static int byt_rt5640_resume(struct snd_soc_card *card)
if (!BYT_RT5640_JDSRC(byt_rt5640_quirk)) if (!BYT_RT5640_JDSRC(byt_rt5640_quirk))
return 0; 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)) { if (!strcmp(component->name, byt_rt5640_codec_name)) {
dev_dbg(component->dev, "re-enabling jack detect after resume\n"); dev_dbg(component->dev, "re-enabling jack detect after resume\n");
snd_soc_component_set_jack(component, &priv->jack, NULL); snd_soc_component_set_jack(component, &priv->jack, NULL);
......
...@@ -742,7 +742,7 @@ static int byt_rt5651_suspend(struct snd_soc_card *card) ...@@ -742,7 +742,7 @@ static int byt_rt5651_suspend(struct snd_soc_card *card)
if (!BYT_RT5651_JDSRC(byt_rt5651_quirk)) if (!BYT_RT5651_JDSRC(byt_rt5651_quirk))
return 0; 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)) { if (!strcmp(component->name, byt_rt5651_codec_name)) {
dev_dbg(component->dev, "disabling jack detect before suspend\n"); dev_dbg(component->dev, "disabling jack detect before suspend\n");
snd_soc_component_set_jack(component, NULL, NULL); snd_soc_component_set_jack(component, NULL, NULL);
...@@ -761,7 +761,7 @@ static int byt_rt5651_resume(struct snd_soc_card *card) ...@@ -761,7 +761,7 @@ static int byt_rt5651_resume(struct snd_soc_card *card)
if (!BYT_RT5651_JDSRC(byt_rt5651_quirk)) if (!BYT_RT5651_JDSRC(byt_rt5651_quirk))
return 0; 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)) { if (!strcmp(component->name, byt_rt5651_codec_name)) {
dev_dbg(component->dev, "re-enabling jack detect after resume\n"); dev_dbg(component->dev, "re-enabling jack detect after resume\n");
snd_soc_component_set_jack(component, &priv->jack, NULL); snd_soc_component_set_jack(component, &priv->jack, NULL);
......
...@@ -347,7 +347,7 @@ static int cht_suspend_pre(struct snd_soc_card *card) ...@@ -347,7 +347,7 @@ static int cht_suspend_pre(struct snd_soc_card *card)
struct snd_soc_component *component; struct snd_soc_component *component;
struct cht_mc_private *ctx = snd_soc_card_get_drvdata(card); 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, if (!strncmp(component->name,
ctx->codec_name, sizeof(ctx->codec_name))) { ctx->codec_name, sizeof(ctx->codec_name))) {
...@@ -364,7 +364,7 @@ static int cht_resume_post(struct snd_soc_card *card) ...@@ -364,7 +364,7 @@ static int cht_resume_post(struct snd_soc_card *card)
struct snd_soc_component *component; struct snd_soc_component *component;
struct cht_mc_private *ctx = snd_soc_card_get_drvdata(card); 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, if (!strncmp(component->name,
ctx->codec_name, sizeof(ctx->codec_name))) { ctx->codec_name, sizeof(ctx->codec_name))) {
......
...@@ -510,7 +510,7 @@ int snd_soc_suspend(struct device *dev) ...@@ -510,7 +510,7 @@ int snd_soc_suspend(struct device *dev)
snd_soc_dapm_sync(&card->dapm); snd_soc_dapm_sync(&card->dapm);
/* suspend all COMPONENTs */ /* 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); struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
/* If there are paths active then the COMPONENT will be held with /* 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) ...@@ -602,7 +602,7 @@ static void soc_resume_deferred(struct work_struct *work)
cpu_dai->driver->resume(cpu_dai); 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->suspended) {
if (component->driver->resume) if (component->driver->resume)
component->driver->resume(component); component->driver->resume(component);
...@@ -1354,6 +1354,7 @@ static int soc_probe_component(struct snd_soc_card *card, ...@@ -1354,6 +1354,7 @@ static int soc_probe_component(struct snd_soc_card *card,
component->driver->num_dapm_routes); component->driver->num_dapm_routes);
list_add(&dapm->list, &card->dapm_list); list_add(&dapm->list, &card->dapm_list);
/* see for_each_card_components */
list_add(&component->card_list, &card->component_dev_list); list_add(&component->card_list, &card->component_dev_list);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment