aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2014-07-01 16:13:47 -0400
committerMark Brown <broonie@linaro.org>2014-07-02 16:24:10 -0400
commit44c69bb13905c3b2281a920c0b44059e88819993 (patch)
treef0c5c6d6f77613b8c8c2948ecd44d8a66cbdc357
parent48f466d112c9ca735ee765d8f5148d07a8c7bb1d (diff)
ASoC: core: Bind aux devs early
Currently in snd_soc_instantiate_card() we only check if the aux dev exists, but do not yet assign it to its rtd. This means that we need to lookup the aux dev again in soc_probe_aux_dev(). This patch changes the behavior to assign the aux dev to the rtd in soc_check_aux_dev() (and renames it to soc_bind_aux_dev()). This simplifies the implementation a bit and also removes the need for soc_post_component_init() to know about the specific CODEC that was assigned to the rtd. The later is necessary for componentization as the code should work for all types of components not just CODECs. This new behavior is also more in sync with how soc_bind_dai_link()/soc_probe_link_dais() works. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--sound/soc/soc-core.c67
1 files changed, 25 insertions, 42 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index c8bdac2db377..b1600cdcdc14 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1286,9 +1286,7 @@ static void rtd_release(struct device *dev)
1286 kfree(dev); 1286 kfree(dev);
1287} 1287}
1288 1288
1289static int soc_aux_dev_init(struct snd_soc_card *card, 1289static int soc_aux_dev_init(struct snd_soc_card *card, int num)
1290 struct snd_soc_codec *codec,
1291 int num)
1292{ 1290{
1293 struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num]; 1291 struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num];
1294 struct snd_soc_pcm_runtime *rtd = &card->rtd_aux[num]; 1292 struct snd_soc_pcm_runtime *rtd = &card->rtd_aux[num];
@@ -1298,13 +1296,11 @@ static int soc_aux_dev_init(struct snd_soc_card *card,
1298 1296
1299 /* do machine specific initialization */ 1297 /* do machine specific initialization */
1300 if (aux_dev->init) { 1298 if (aux_dev->init) {
1301 ret = aux_dev->init(&codec->dapm); 1299 ret = aux_dev->init(&rtd->codec->dapm);
1302 if (ret < 0) 1300 if (ret < 0)
1303 return ret; 1301 return ret;
1304 } 1302 }
1305 1303
1306 rtd->codec = codec;
1307
1308 return 0; 1304 return 0;
1309} 1305}
1310 1306
@@ -1327,7 +1323,6 @@ static int soc_dai_link_init(struct snd_soc_card *card, int num)
1327} 1323}
1328 1324
1329static int soc_post_component_init(struct snd_soc_card *card, 1325static int soc_post_component_init(struct snd_soc_card *card,
1330 struct snd_soc_codec *codec,
1331 int num, int dailess) 1326 int num, int dailess)
1332{ 1327{
1333 struct snd_soc_dai_link *dai_link = NULL; 1328 struct snd_soc_dai_link *dai_link = NULL;
@@ -1345,7 +1340,7 @@ static int soc_post_component_init(struct snd_soc_card *card,
1345 aux_dev = &card->aux_dev[num]; 1340 aux_dev = &card->aux_dev[num];
1346 rtd = &card->rtd_aux[num]; 1341 rtd = &card->rtd_aux[num];
1347 name = aux_dev->name; 1342 name = aux_dev->name;
1348 ret = soc_aux_dev_init(card, codec, num); 1343 ret = soc_aux_dev_init(card, num);
1349 } 1344 }
1350 1345
1351 if (ret < 0) { 1346 if (ret < 0) {
@@ -1380,13 +1375,13 @@ static int soc_post_component_init(struct snd_soc_card *card,
1380 /* add DAPM sysfs entries for this codec */ 1375 /* add DAPM sysfs entries for this codec */
1381 ret = snd_soc_dapm_sys_add(rtd->dev); 1376 ret = snd_soc_dapm_sys_add(rtd->dev);
1382 if (ret < 0) 1377 if (ret < 0)
1383 dev_err(codec->dev, 1378 dev_err(rtd->dev,
1384 "ASoC: failed to add codec dapm sysfs entries: %d\n", ret); 1379 "ASoC: failed to add codec dapm sysfs entries: %d\n", ret);
1385 1380
1386 /* add codec sysfs entries */ 1381 /* add codec sysfs entries */
1387 ret = device_create_file(rtd->dev, &dev_attr_codec_reg); 1382 ret = device_create_file(rtd->dev, &dev_attr_codec_reg);
1388 if (ret < 0) 1383 if (ret < 0)
1389 dev_err(codec->dev, 1384 dev_err(rtd->dev,
1390 "ASoC: failed to add codec sysfs files: %d\n", ret); 1385 "ASoC: failed to add codec sysfs files: %d\n", ret);
1391 1386
1392#ifdef CONFIG_DEBUG_FS 1387#ifdef CONFIG_DEBUG_FS
@@ -1551,7 +1546,7 @@ static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order)
1551 if (order != SND_SOC_COMP_ORDER_LAST) 1546 if (order != SND_SOC_COMP_ORDER_LAST)
1552 return 0; 1547 return 0;
1553 1548
1554 ret = soc_post_component_init(card, codec, num, 0); 1549 ret = soc_post_component_init(card, num, 0);
1555 if (ret) 1550 if (ret)
1556 return ret; 1551 return ret;
1557 1552
@@ -1649,51 +1644,39 @@ static void soc_unregister_ac97_dai_link(struct snd_soc_pcm_runtime *rtd)
1649} 1644}
1650#endif 1645#endif
1651 1646
1652static int soc_check_aux_dev(struct snd_soc_card *card, int num) 1647static int soc_bind_aux_dev(struct snd_soc_card *card, int num)
1653{
1654 struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num];
1655 const char *codecname = aux_dev->codec_name;
1656 struct snd_soc_codec *codec;
1657
1658 codec = soc_find_codec(aux_dev->codec_of_node, aux_dev->codec_name);
1659 if (codec)
1660 return 0;
1661 if (aux_dev->codec_of_node)
1662 codecname = of_node_full_name(aux_dev->codec_of_node);
1663
1664 dev_err(card->dev, "ASoC: %s not registered\n", codecname);
1665 return -EPROBE_DEFER;
1666}
1667
1668static int soc_probe_aux_dev(struct snd_soc_card *card, int num)
1669{ 1648{
1649 struct snd_soc_pcm_runtime *rtd = &card->rtd_aux[num];
1670 struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num]; 1650 struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num];
1671 const char *codecname = aux_dev->codec_name; 1651 const char *codecname = aux_dev->codec_name;
1672 int ret = -ENODEV;
1673 struct snd_soc_codec *codec;
1674 1652
1675 codec = soc_find_codec(aux_dev->codec_of_node, aux_dev->codec_name); 1653 rtd->codec = soc_find_codec(aux_dev->codec_of_node, codecname);
1676 if (!codec) { 1654 if (!rtd->codec) {
1677 if (aux_dev->codec_of_node) 1655 if (aux_dev->codec_of_node)
1678 codecname = of_node_full_name(aux_dev->codec_of_node); 1656 codecname = of_node_full_name(aux_dev->codec_of_node);
1679 1657
1680 /* codec not found */ 1658 dev_err(card->dev, "ASoC: %s not registered\n", codecname);
1681 dev_err(card->dev, "ASoC: codec %s not found", codecname);
1682 return -EPROBE_DEFER; 1659 return -EPROBE_DEFER;
1683 } 1660 }
1684 1661
1685 if (codec->probed) { 1662 return 0;
1686 dev_err(codec->dev, "ASoC: codec already probed"); 1663}
1664
1665static int soc_probe_aux_dev(struct snd_soc_card *card, int num)
1666{
1667 struct snd_soc_pcm_runtime *rtd = &card->rtd_aux[num];
1668 int ret;
1669
1670 if (rtd->codec->probed) {
1671 dev_err(rtd->codec->dev, "ASoC: codec already probed\n");
1687 return -EBUSY; 1672 return -EBUSY;
1688 } 1673 }
1689 1674
1690 ret = soc_probe_codec(card, codec); 1675 ret = soc_probe_codec(card, rtd->codec);
1691 if (ret < 0) 1676 if (ret < 0)
1692 return ret; 1677 return ret;
1693 1678
1694 ret = soc_post_component_init(card, codec, num, 1); 1679 return soc_post_component_init(card, num, 1);
1695
1696 return ret;
1697} 1680}
1698 1681
1699static void soc_remove_aux_dev(struct snd_soc_card *card, int num) 1682static void soc_remove_aux_dev(struct snd_soc_card *card, int num)
@@ -1745,9 +1728,9 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
1745 goto base_error; 1728 goto base_error;
1746 } 1729 }
1747 1730
1748 /* check aux_devs too */ 1731 /* bind aux_devs too */
1749 for (i = 0; i < card->num_aux_devs; i++) { 1732 for (i = 0; i < card->num_aux_devs; i++) {
1750 ret = soc_check_aux_dev(card, i); 1733 ret = soc_bind_aux_dev(card, i);
1751 if (ret != 0) 1734 if (ret != 0)
1752 goto base_error; 1735 goto base_error;
1753 } 1736 }