aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2019-08-08 01:54:44 -0400
committerMark Brown <broonie@kernel.org>2019-08-09 13:13:58 -0400
commitc2b71c71037bea7765aa6ff37824520d19108769 (patch)
tree38f96c77c57dd99f53dcee439b04cadf55ea3fb3 /sound
parentb812cd5864548bd9718879896fdd2822d3cb3d76 (diff)
ASoC: soc-core: add for_each_xxx macro for aux_dev
To be more readable code, this patch adds new for_each_xxx() macro for aux_dev. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87ftmc6w8s.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/meson/axg-card.c7
-rw-r--r--sound/soc/soc-core.c15
2 files changed, 12 insertions, 10 deletions
diff --git a/sound/soc/meson/axg-card.c b/sound/soc/meson/axg-card.c
index 6283e5025548..1f698adde506 100644
--- a/sound/soc/meson/axg-card.c
+++ b/sound/soc/meson/axg-card.c
@@ -111,6 +111,7 @@ static void axg_card_clean_references(struct axg_card *priv)
111 struct snd_soc_card *card = &priv->card; 111 struct snd_soc_card *card = &priv->card;
112 struct snd_soc_dai_link *link; 112 struct snd_soc_dai_link *link;
113 struct snd_soc_dai_link_component *codec; 113 struct snd_soc_dai_link_component *codec;
114 struct snd_soc_aux_dev *aux;
114 int i, j; 115 int i, j;
115 116
116 if (card->dai_link) { 117 if (card->dai_link) {
@@ -123,8 +124,8 @@ static void axg_card_clean_references(struct axg_card *priv)
123 } 124 }
124 125
125 if (card->aux_dev) { 126 if (card->aux_dev) {
126 for (i = 0; i < card->num_aux_devs; i++) 127 for_each_card_pre_auxs(card, i, aux)
127 of_node_put(card->aux_dev[i].dlc.of_node); 128 of_node_put(aux->dlc.of_node);
128 } 129 }
129 130
130 kfree(card->dai_link); 131 kfree(card->dai_link);
@@ -157,7 +158,7 @@ static int axg_card_add_aux_devices(struct snd_soc_card *card)
157 card->aux_dev = aux; 158 card->aux_dev = aux;
158 card->num_aux_devs = num; 159 card->num_aux_devs = num;
159 160
160 for (i = 0; i < card->num_aux_devs; i++, aux++) { 161 for_each_card_pre_auxs(card, i, aux) {
161 aux->dlc.of_node = 162 aux->dlc.of_node =
162 of_parse_phandle(node, "audio-aux-devs", i); 163 of_parse_phandle(node, "audio-aux-devs", i);
163 if (!aux->dlc.of_node) 164 if (!aux->dlc.of_node)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 4af382d52675..e9f44505cc3e 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1533,9 +1533,9 @@ static int soc_probe_link_dais(struct snd_soc_card *card,
1533 return ret; 1533 return ret;
1534} 1534}
1535 1535
1536static int soc_bind_aux_dev(struct snd_soc_card *card, int num) 1536static int soc_bind_aux_dev(struct snd_soc_card *card,
1537 struct snd_soc_aux_dev *aux_dev)
1537{ 1538{
1538 struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num];
1539 struct snd_soc_component *component; 1539 struct snd_soc_component *component;
1540 1540
1541 /* codecs, usually analog devices */ 1541 /* codecs, usually analog devices */
@@ -1544,6 +1544,7 @@ static int soc_bind_aux_dev(struct snd_soc_card *card, int num)
1544 return -EPROBE_DEFER; 1544 return -EPROBE_DEFER;
1545 1545
1546 component->init = aux_dev->init; 1546 component->init = aux_dev->init;
1547 /* see for_each_card_auxs */
1547 list_add(&component->card_aux_list, &card->aux_comp_list); 1548 list_add(&component->card_aux_list, &card->aux_comp_list);
1548 1549
1549 return 0; 1550 return 0;
@@ -1556,7 +1557,7 @@ static int soc_probe_aux_devices(struct snd_soc_card *card)
1556 int ret; 1557 int ret;
1557 1558
1558 for_each_comp_order(order) { 1559 for_each_comp_order(order) {
1559 list_for_each_entry(comp, &card->aux_comp_list, card_aux_list) { 1560 for_each_card_auxs(card, comp) {
1560 if (comp->driver->probe_order == order) { 1561 if (comp->driver->probe_order == order) {
1561 ret = soc_probe_component(card, comp); 1562 ret = soc_probe_component(card, comp);
1562 if (ret < 0) { 1563 if (ret < 0) {
@@ -1578,8 +1579,7 @@ static void soc_remove_aux_devices(struct snd_soc_card *card)
1578 int order; 1579 int order;
1579 1580
1580 for_each_comp_order(order) { 1581 for_each_comp_order(order) {
1581 list_for_each_entry_safe(comp, _comp, 1582 for_each_card_auxs_safe(card, comp, _comp) {
1582 &card->aux_comp_list, card_aux_list) {
1583 1583
1584 if (comp->driver->remove_order == order) { 1584 if (comp->driver->remove_order == order) {
1585 soc_remove_component(comp); 1585 soc_remove_component(comp);
@@ -1913,6 +1913,7 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
1913{ 1913{
1914 struct snd_soc_pcm_runtime *rtd; 1914 struct snd_soc_pcm_runtime *rtd;
1915 struct snd_soc_dai_link *dai_link; 1915 struct snd_soc_dai_link *dai_link;
1916 struct snd_soc_aux_dev *aux;
1916 int ret, i, order; 1917 int ret, i, order;
1917 1918
1918 mutex_lock(&client_mutex); 1919 mutex_lock(&client_mutex);
@@ -1943,8 +1944,8 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
1943 } 1944 }
1944 1945
1945 /* bind aux_devs too */ 1946 /* bind aux_devs too */
1946 for (i = 0; i < card->num_aux_devs; i++) { 1947 for_each_card_pre_auxs(card, i, aux) {
1947 ret = soc_bind_aux_dev(card, i); 1948 ret = soc_bind_aux_dev(card, aux);
1948 if (ret != 0) 1949 if (ret != 0)
1949 goto probe_end; 1950 goto probe_end;
1950 } 1951 }