aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/soc/soc-core.c146
1 files changed, 88 insertions, 58 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 62e8e36062df..6ddcf12bc030 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -66,8 +66,9 @@ static int pmdown_time = 5000;
66module_param(pmdown_time, int, 0); 66module_param(pmdown_time, int, 0);
67MODULE_PARM_DESC(pmdown_time, "DAPM stream powerdown time (msecs)"); 67MODULE_PARM_DESC(pmdown_time, "DAPM stream powerdown time (msecs)");
68 68
69/* If a DMI filed contain strings in this blacklist (e.g. 69/*
70 * "Type2 - Board Manufacturer" or "Type1 - TBD by OEM"), it will be taken 70 * If a DMI filed contain strings in this blacklist (e.g.
71 * "Type2 - Board Manufacturer" or "Type1 - TBD by OEM"), it will be taken
71 * as invalid and dropped when setting the card long name from DMI info. 72 * as invalid and dropped when setting the card long name from DMI info.
72 */ 73 */
73static const char * const dmi_blacklist[] = { 74static const char * const dmi_blacklist[] = {
@@ -222,7 +223,7 @@ static void soc_init_card_debugfs(struct snd_soc_card *card)
222 &card->pop_time); 223 &card->pop_time);
223 if (!card->debugfs_pop_time) 224 if (!card->debugfs_pop_time)
224 dev_warn(card->dev, 225 dev_warn(card->dev,
225 "ASoC: Failed to create pop time debugfs file\n"); 226 "ASoC: Failed to create pop time debugfs file\n");
226} 227}
227 228
228static void soc_cleanup_card_debugfs(struct snd_soc_card *card) 229static void soc_cleanup_card_debugfs(struct snd_soc_card *card)
@@ -426,7 +427,8 @@ EXPORT_SYMBOL_GPL(snd_soc_get_pcm_runtime);
426 427
427static void codec2codec_close_delayed_work(struct work_struct *work) 428static void codec2codec_close_delayed_work(struct work_struct *work)
428{ 429{
429 /* Currently nothing to do for c2c links 430 /*
431 * Currently nothing to do for c2c links
430 * Since c2c links are internal nodes in the DAPM graph and 432 * Since c2c links are internal nodes in the DAPM graph and
431 * don't interface with the outside world or application layer 433 * don't interface with the outside world or application layer
432 * we don't have to do any special handling on close. 434 * we don't have to do any special handling on close.
@@ -446,8 +448,9 @@ int snd_soc_suspend(struct device *dev)
446 if (!card->instantiated) 448 if (!card->instantiated)
447 return 0; 449 return 0;
448 450
449 /* Due to the resume being scheduled into a workqueue we could 451 /*
450 * suspend before that's finished - wait for it to complete. 452 * Due to the resume being scheduled into a workqueue we could
453 * suspend before that's finished - wait for it to complete.
451 */ 454 */
452 snd_power_wait(card->snd_card, SNDRV_CTL_POWER_D0); 455 snd_power_wait(card->snd_card, SNDRV_CTL_POWER_D0);
453 456
@@ -514,10 +517,13 @@ int snd_soc_suspend(struct device *dev)
514 517
515 /* suspend all COMPONENTs */ 518 /* suspend all COMPONENTs */
516 for_each_card_components(card, component) { 519 for_each_card_components(card, component) {
517 struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); 520 struct snd_soc_dapm_context *dapm =
521 snd_soc_component_get_dapm(component);
518 522
519 /* If there are paths active then the COMPONENT will be held with 523 /*
520 * bias _ON and should not be suspended. */ 524 * If there are paths active then the COMPONENT will be held
525 * with bias _ON and should not be suspended.
526 */
521 if (!component->suspended) { 527 if (!component->suspended) {
522 switch (snd_soc_dapm_get_bias_level(dapm)) { 528 switch (snd_soc_dapm_get_bias_level(dapm)) {
523 case SND_SOC_BIAS_STANDBY: 529 case SND_SOC_BIAS_STANDBY:
@@ -571,18 +577,21 @@ int snd_soc_suspend(struct device *dev)
571} 577}
572EXPORT_SYMBOL_GPL(snd_soc_suspend); 578EXPORT_SYMBOL_GPL(snd_soc_suspend);
573 579
574/* deferred resume work, so resume can complete before we finished 580/*
581 * deferred resume work, so resume can complete before we finished
575 * setting our codec back up, which can be very slow on I2C 582 * setting our codec back up, which can be very slow on I2C
576 */ 583 */
577static void soc_resume_deferred(struct work_struct *work) 584static void soc_resume_deferred(struct work_struct *work)
578{ 585{
579 struct snd_soc_card *card = 586 struct snd_soc_card *card =
580 container_of(work, struct snd_soc_card, deferred_resume_work); 587 container_of(work, struct snd_soc_card,
588 deferred_resume_work);
581 struct snd_soc_pcm_runtime *rtd; 589 struct snd_soc_pcm_runtime *rtd;
582 struct snd_soc_component *component; 590 struct snd_soc_component *component;
583 int i; 591 int i;
584 592
585 /* our power state is still SNDRV_CTL_POWER_D3hot from suspend time, 593 /*
594 * our power state is still SNDRV_CTL_POWER_D3hot from suspend time,
586 * so userspace apps are blocked from touching us 595 * so userspace apps are blocked from touching us
587 */ 596 */
588 597
@@ -699,6 +708,7 @@ int snd_soc_resume(struct device *dev)
699 */ 708 */
700 for_each_card_rtds(card, rtd) { 709 for_each_card_rtds(card, rtd) {
701 struct snd_soc_dai *cpu_dai = rtd->cpu_dai; 710 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
711
702 bus_control |= cpu_dai->driver->bus_control; 712 bus_control |= cpu_dai->driver->bus_control;
703 } 713 }
704 if (bus_control) { 714 if (bus_control) {
@@ -777,7 +787,7 @@ struct snd_soc_dai *snd_soc_find_dai(
777 787
778 lockdep_assert_held(&client_mutex); 788 lockdep_assert_held(&client_mutex);
779 789
780 /* Find CPU DAI from registered DAIs*/ 790 /* Find CPU DAI from registered DAIs */
781 for_each_component(component) { 791 for_each_component(component) {
782 if (!snd_soc_is_matching_component(dlc, component)) 792 if (!snd_soc_is_matching_component(dlc, component))
783 continue; 793 continue;
@@ -795,7 +805,6 @@ struct snd_soc_dai *snd_soc_find_dai(
795} 805}
796EXPORT_SYMBOL_GPL(snd_soc_find_dai); 806EXPORT_SYMBOL_GPL(snd_soc_find_dai);
797 807
798
799/** 808/**
800 * snd_soc_find_dai_link - Find a DAI link 809 * snd_soc_find_dai_link - Find a DAI link
801 * 810 *
@@ -918,7 +927,7 @@ static int soc_bind_dai_link(struct snd_soc_card *card,
918 927
919_err_defer: 928_err_defer:
920 soc_free_pcm_runtime(rtd); 929 soc_free_pcm_runtime(rtd);
921 return -EPROBE_DEFER; 930 return -EPROBE_DEFER;
922} 931}
923 932
924static void soc_remove_component(struct snd_soc_component *component) 933static void soc_remove_component(struct snd_soc_component *component)
@@ -1074,7 +1083,7 @@ static int snd_soc_init_multicodec(struct snd_soc_card *card,
1074} 1083}
1075 1084
1076static int soc_init_dai_link(struct snd_soc_card *card, 1085static int soc_init_dai_link(struct snd_soc_card *card,
1077 struct snd_soc_dai_link *link) 1086 struct snd_soc_dai_link *link)
1078{ 1087{
1079 int i, ret; 1088 int i, ret;
1080 struct snd_soc_dai_link_component *codec; 1089 struct snd_soc_dai_link_component *codec;
@@ -1148,7 +1157,8 @@ static int soc_init_dai_link(struct snd_soc_card *card,
1148 1157
1149void snd_soc_disconnect_sync(struct device *dev) 1158void snd_soc_disconnect_sync(struct device *dev)
1150{ 1159{
1151 struct snd_soc_component *component = snd_soc_lookup_component(dev, NULL); 1160 struct snd_soc_component *component =
1161 snd_soc_lookup_component(dev, NULL);
1152 1162
1153 if (!component || !component->card) 1163 if (!component || !component->card)
1154 return; 1164 return;
@@ -1179,7 +1189,8 @@ int snd_soc_add_dai_link(struct snd_soc_card *card,
1179 } 1189 }
1180 1190
1181 lockdep_assert_held(&client_mutex); 1191 lockdep_assert_held(&client_mutex);
1182 /* Notify the machine driver for extra initialization 1192 /*
1193 * Notify the machine driver for extra initialization
1183 * on the link created by topology. 1194 * on the link created by topology.
1184 */ 1195 */
1185 if (dai_link->dobj.type && card->add_dai_link) 1196 if (dai_link->dobj.type && card->add_dai_link)
@@ -1214,7 +1225,8 @@ void snd_soc_remove_dai_link(struct snd_soc_card *card,
1214 } 1225 }
1215 1226
1216 lockdep_assert_held(&client_mutex); 1227 lockdep_assert_held(&client_mutex);
1217 /* Notify the machine driver for extra destruction 1228 /*
1229 * Notify the machine driver for extra destruction
1218 * on the link created by topology. 1230 * on the link created by topology.
1219 */ 1231 */
1220 if (dai_link->dobj.type && card->remove_dai_link) 1232 if (dai_link->dobj.type && card->remove_dai_link)
@@ -1274,7 +1286,8 @@ static void soc_set_name_prefix(struct snd_soc_card *card,
1274static int soc_probe_component(struct snd_soc_card *card, 1286static int soc_probe_component(struct snd_soc_card *card,
1275 struct snd_soc_component *component) 1287 struct snd_soc_component *component)
1276{ 1288{
1277 struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); 1289 struct snd_soc_dapm_context *dapm =
1290 snd_soc_component_get_dapm(component);
1278 struct snd_soc_dai *dai; 1291 struct snd_soc_dai *dai;
1279 int ret; 1292 int ret;
1280 1293
@@ -1406,8 +1419,7 @@ static int soc_post_component_init(struct snd_soc_pcm_runtime *rtd,
1406} 1419}
1407 1420
1408static int soc_probe_link_components(struct snd_soc_card *card, 1421static int soc_probe_link_components(struct snd_soc_card *card,
1409 struct snd_soc_pcm_runtime *rtd, 1422 struct snd_soc_pcm_runtime *rtd, int order)
1410 int order)
1411{ 1423{
1412 struct snd_soc_component *component; 1424 struct snd_soc_component *component;
1413 struct snd_soc_rtdcom_list *rtdcom; 1425 struct snd_soc_rtdcom_list *rtdcom;
@@ -1434,6 +1446,7 @@ static int soc_probe_dai(struct snd_soc_dai *dai, int order)
1434 1446
1435 if (dai->driver->probe) { 1447 if (dai->driver->probe) {
1436 int ret = dai->driver->probe(dai); 1448 int ret = dai->driver->probe(dai);
1449
1437 if (ret < 0) { 1450 if (ret < 0) {
1438 dev_err(dai->dev, "ASoC: failed to probe DAI %s: %d\n", 1451 dev_err(dai->dev, "ASoC: failed to probe DAI %s: %d\n",
1439 dai->name, ret); 1452 dai->name, ret);
@@ -1541,7 +1554,7 @@ static int soc_probe_link_dais(struct snd_soc_card *card,
1541 } 1554 }
1542 1555
1543 if (cpu_dai->driver->compress_new) { 1556 if (cpu_dai->driver->compress_new) {
1544 /*create compress_device"*/ 1557 /* create compress_device" */
1545 ret = cpu_dai->driver->compress_new(rtd, num); 1558 ret = cpu_dai->driver->compress_new(rtd, num);
1546 if (ret < 0) { 1559 if (ret < 0) {
1547 dev_err(card->dev, "ASoC: can't create compress %s\n", 1560 dev_err(card->dev, "ASoC: can't create compress %s\n",
@@ -1555,7 +1568,7 @@ static int soc_probe_link_dais(struct snd_soc_card *card,
1555 ret = soc_new_pcm(rtd, num); 1568 ret = soc_new_pcm(rtd, num);
1556 if (ret < 0) { 1569 if (ret < 0) {
1557 dev_err(card->dev, "ASoC: can't create pcm %s :%d\n", 1570 dev_err(card->dev, "ASoC: can't create pcm %s :%d\n",
1558 dai_link->stream_name, ret); 1571 dai_link->stream_name, ret);
1559 return ret; 1572 return ret;
1560 } 1573 }
1561 ret = soc_link_dai_pcm_new(&cpu_dai, 1, rtd); 1574 ret = soc_link_dai_pcm_new(&cpu_dai, 1, rtd);
@@ -1683,8 +1696,10 @@ int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
1683 } 1696 }
1684 } 1697 }
1685 1698
1686 /* Flip the polarity for the "CPU" end of a CODEC<->CODEC link */ 1699 /*
1687 /* the component which has non_legacy_dai_naming is Codec */ 1700 * Flip the polarity for the "CPU" end of a CODEC<->CODEC link
1701 * the component which has non_legacy_dai_naming is Codec
1702 */
1688 if (cpu_dai->component->driver->non_legacy_dai_naming) { 1703 if (cpu_dai->component->driver->non_legacy_dai_naming) {
1689 unsigned int inv_dai_fmt; 1704 unsigned int inv_dai_fmt;
1690 1705
@@ -1718,9 +1733,9 @@ int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
1718} 1733}
1719EXPORT_SYMBOL_GPL(snd_soc_runtime_set_dai_fmt); 1734EXPORT_SYMBOL_GPL(snd_soc_runtime_set_dai_fmt);
1720 1735
1721
1722#ifdef CONFIG_DMI 1736#ifdef CONFIG_DMI
1723/* Trim special characters, and replace '-' with '_' since '-' is used to 1737/*
1738 * Trim special characters, and replace '-' with '_' since '-' is used to
1724 * separate different DMI fields in the card long name. Only number and 1739 * separate different DMI fields in the card long name. Only number and
1725 * alphabet characters and a few separator characters are kept. 1740 * alphabet characters and a few separator characters are kept.
1726 */ 1741 */
@@ -1739,7 +1754,8 @@ static void cleanup_dmi_name(char *name)
1739 name[j] = '\0'; 1754 name[j] = '\0';
1740} 1755}
1741 1756
1742/* Check if a DMI field is valid, i.e. not containing any string 1757/*
1758 * Check if a DMI field is valid, i.e. not containing any string
1743 * in the black list. 1759 * in the black list.
1744 */ 1760 */
1745static int is_dmi_valid(const char *field) 1761static int is_dmi_valid(const char *field)
@@ -1802,7 +1818,6 @@ int snd_soc_set_dmi_name(struct snd_soc_card *card, const char *flavour)
1802 return 0; 1818 return 0;
1803 } 1819 }
1804 1820
1805
1806 snprintf(card->dmi_longname, sizeof(card->snd_card->longname), 1821 snprintf(card->dmi_longname, sizeof(card->snd_card->longname),
1807 "%s", vendor); 1822 "%s", vendor);
1808 cleanup_dmi_name(card->dmi_longname); 1823 cleanup_dmi_name(card->dmi_longname);
@@ -1818,7 +1833,8 @@ int snd_soc_set_dmi_name(struct snd_soc_card *card, const char *flavour)
1818 if (len < longname_buf_size) 1833 if (len < longname_buf_size)
1819 cleanup_dmi_name(card->dmi_longname + len); 1834 cleanup_dmi_name(card->dmi_longname + len);
1820 1835
1821 /* some vendors like Lenovo may only put a self-explanatory 1836 /*
1837 * some vendors like Lenovo may only put a self-explanatory
1822 * name in the product version field 1838 * name in the product version field
1823 */ 1839 */
1824 product_version = dmi_get_system_info(DMI_PRODUCT_VERSION); 1840 product_version = dmi_get_system_info(DMI_PRODUCT_VERSION);
@@ -1914,7 +1930,8 @@ static void soc_check_tplg_fes(struct snd_soc_card *card)
1914 dai_link->be_hw_params_fixup = 1930 dai_link->be_hw_params_fixup =
1915 component->driver->be_hw_params_fixup; 1931 component->driver->be_hw_params_fixup;
1916 1932
1917 /* most BE links don't set stream name, so set it to 1933 /*
1934 * most BE links don't set stream name, so set it to
1918 * dai link name if it's NULL to help bind widgets. 1935 * dai link name if it's NULL to help bind widgets.
1919 */ 1936 */
1920 if (!dai_link->stream_name) 1937 if (!dai_link->stream_name)
@@ -1924,7 +1941,7 @@ static void soc_check_tplg_fes(struct snd_soc_card *card)
1924 /* Inform userspace we are using alternate topology */ 1941 /* Inform userspace we are using alternate topology */
1925 if (component->driver->topology_name_prefix) { 1942 if (component->driver->topology_name_prefix) {
1926 1943
1927 /* topology shortname created ? */ 1944 /* topology shortname created? */
1928 if (!card->topology_shortname_created) { 1945 if (!card->topology_shortname_created) {
1929 comp_drv = component->driver; 1946 comp_drv = component->driver;
1930 1947
@@ -2029,7 +2046,8 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
2029 if (ret < 0) 2046 if (ret < 0)
2030 goto probe_dai_err; 2047 goto probe_dai_err;
2031 2048
2032 /* Find new DAI links added during probing components and bind them. 2049 /*
2050 * Find new DAI links added during probing components and bind them.
2033 * Components with topology may bring new DAIs and DAI links. 2051 * Components with topology may bring new DAIs and DAI links.
2034 */ 2052 */
2035 for_each_card_links(card, dai_link) { 2053 for_each_card_links(card, dai_link) {
@@ -2061,7 +2079,8 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
2061 snd_soc_dapm_connect_dai_link_widgets(card); 2079 snd_soc_dapm_connect_dai_link_widgets(card);
2062 2080
2063 if (card->controls) 2081 if (card->controls)
2064 snd_soc_add_card_controls(card, card->controls, card->num_controls); 2082 snd_soc_add_card_controls(card, card->controls,
2083 card->num_controls);
2065 2084
2066 if (card->dapm_routes) 2085 if (card->dapm_routes)
2067 snd_soc_dapm_add_routes(&card->dapm, card->dapm_routes, 2086 snd_soc_dapm_add_routes(&card->dapm, card->dapm_routes,
@@ -2207,8 +2226,10 @@ int snd_soc_poweroff(struct device *dev)
2207 if (!card->instantiated) 2226 if (!card->instantiated)
2208 return 0; 2227 return 0;
2209 2228
2210 /* Flush out pmdown_time work - we actually do want to run it 2229 /*
2211 * now, we're shutting down so no imminent restart. */ 2230 * Flush out pmdown_time work - we actually do want to run it
2231 * now, we're shutting down so no imminent restart.
2232 */
2212 for_each_card_rtds(card, rtd) 2233 for_each_card_rtds(card, rtd)
2213 flush_delayed_work(&rtd->delayed_work); 2234 flush_delayed_work(&rtd->delayed_work);
2214 2235
@@ -2301,6 +2322,7 @@ static int snd_soc_add_controls(struct snd_card *card, struct device *dev,
2301 2322
2302 for (i = 0; i < num_controls; i++) { 2323 for (i = 0; i < num_controls; i++) {
2303 const struct snd_kcontrol_new *control = &controls[i]; 2324 const struct snd_kcontrol_new *control = &controls[i];
2325
2304 err = snd_ctl_add(card, snd_soc_cnew(control, data, 2326 err = snd_ctl_add(card, snd_soc_cnew(control, data,
2305 control->name, prefix)); 2327 control->name, prefix));
2306 if (err < 0) { 2328 if (err < 0) {
@@ -2418,8 +2440,9 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_set_sysclk);
2418 * 2440 *
2419 * Configures the CODEC master (MCLK) or system (SYSCLK) clocking. 2441 * Configures the CODEC master (MCLK) or system (SYSCLK) clocking.
2420 */ 2442 */
2421int snd_soc_component_set_sysclk(struct snd_soc_component *component, int clk_id, 2443int snd_soc_component_set_sysclk(struct snd_soc_component *component,
2422 int source, unsigned int freq, int dir) 2444 int clk_id, int source, unsigned int freq,
2445 int dir)
2423{ 2446{
2424 if (component->driver->set_sysclk) 2447 if (component->driver->set_sysclk)
2425 return component->driver->set_sysclk(component, clk_id, source, 2448 return component->driver->set_sysclk(component, clk_id, source,
@@ -2487,7 +2510,7 @@ int snd_soc_component_set_pll(struct snd_soc_component *component, int pll_id,
2487{ 2510{
2488 if (component->driver->set_pll) 2511 if (component->driver->set_pll)
2489 return component->driver->set_pll(component, pll_id, source, 2512 return component->driver->set_pll(component, pll_id, source,
2490 freq_in, freq_out); 2513 freq_in, freq_out);
2491 2514
2492 return -EINVAL; 2515 return -EINVAL;
2493} 2516}
@@ -2533,8 +2556,8 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_set_fmt);
2533 * Generates the TDM tx and rx slot default masks for DAI. 2556 * Generates the TDM tx and rx slot default masks for DAI.
2534 */ 2557 */
2535static int snd_soc_xlate_tdm_slot_mask(unsigned int slots, 2558static int snd_soc_xlate_tdm_slot_mask(unsigned int slots,
2536 unsigned int *tx_mask, 2559 unsigned int *tx_mask,
2537 unsigned int *rx_mask) 2560 unsigned int *rx_mask)
2538{ 2561{
2539 if (*tx_mask || *rx_mask) 2562 if (*tx_mask || *rx_mask)
2540 return 0; 2563 return 0;
@@ -2684,7 +2707,7 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
2684 return ret; 2707 return ret;
2685 2708
2686 /* deactivate pins to sleep state */ 2709 /* deactivate pins to sleep state */
2687 for_each_card_rtds(card, rtd) { 2710 for_each_card_rtds(card, rtd) {
2688 struct snd_soc_dai *cpu_dai = rtd->cpu_dai; 2711 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
2689 struct snd_soc_dai *codec_dai; 2712 struct snd_soc_dai *codec_dai;
2690 int j; 2713 int j;
@@ -2799,7 +2822,7 @@ static char *fmt_single_name(struct device *dev, int *id)
2799 } 2822 }
2800 2823
2801 } else { 2824 } else {
2802 /* I2C component devices are named "bus-addr" */ 2825 /* I2C component devices are named "bus-addr" */
2803 if (sscanf(name, "%x-%x", &id1, &id2) == 2) { 2826 if (sscanf(name, "%x-%x", &id1, &id2) == 2) {
2804 char tmp[NAME_SIZE]; 2827 char tmp[NAME_SIZE];
2805 2828
@@ -2807,7 +2830,8 @@ static char *fmt_single_name(struct device *dev, int *id)
2807 *id = ((id1 & 0xffff) << 16) + id2; 2830 *id = ((id1 & 0xffff) << 16) + id2;
2808 2831
2809 /* sanitize component name for DAI link creation */ 2832 /* sanitize component name for DAI link creation */
2810 snprintf(tmp, NAME_SIZE, "%s.%s", dev->driver->name, name); 2833 snprintf(tmp, NAME_SIZE, "%s.%s", dev->driver->name,
2834 name);
2811 strlcpy(name, tmp, NAME_SIZE); 2835 strlcpy(name, tmp, NAME_SIZE);
2812 } else 2836 } else
2813 *id = 0; 2837 *id = 0;
@@ -2874,7 +2898,7 @@ static struct snd_soc_dai *soc_add_dai(struct snd_soc_component *component,
2874 * component-less anymore. 2898 * component-less anymore.
2875 */ 2899 */
2876 if (legacy_dai_naming && 2900 if (legacy_dai_naming &&
2877 (dai_drv->id == 0 || dai_drv->name == NULL)) { 2901 (dai_drv->id == 0 || dai_drv->name == NULL)) {
2878 dai->name = fmt_single_name(dev, &dai->id); 2902 dai->name = fmt_single_name(dev, &dai->id);
2879 } else { 2903 } else {
2880 dai->name = fmt_multiple_name(dev, dai_drv); 2904 dai->name = fmt_multiple_name(dev, dai_drv);
@@ -2910,7 +2934,8 @@ static struct snd_soc_dai *soc_add_dai(struct snd_soc_component *component,
2910 * @count: Number of DAIs 2934 * @count: Number of DAIs
2911 */ 2935 */
2912static int snd_soc_register_dais(struct snd_soc_component *component, 2936static int snd_soc_register_dais(struct snd_soc_component *component,
2913 struct snd_soc_dai_driver *dai_drv, size_t count) 2937 struct snd_soc_dai_driver *dai_drv,
2938 size_t count)
2914{ 2939{
2915 struct device *dev = component->dev; 2940 struct device *dev = component->dev;
2916 struct snd_soc_dai *dai; 2941 struct snd_soc_dai *dai;
@@ -2921,8 +2946,8 @@ static int snd_soc_register_dais(struct snd_soc_component *component,
2921 2946
2922 for (i = 0; i < count; i++) { 2947 for (i = 0; i < count; i++) {
2923 2948
2924 dai = soc_add_dai(component, dai_drv + i, 2949 dai = soc_add_dai(component, dai_drv + i, count == 1 &&
2925 count == 1 && !component->driver->non_legacy_dai_naming); 2950 !component->driver->non_legacy_dai_naming);
2926 if (dai == NULL) { 2951 if (dai == NULL) {
2927 ret = -ENOMEM; 2952 ret = -ENOMEM;
2928 goto err; 2953 goto err;
@@ -2966,7 +2991,8 @@ int snd_soc_register_dai(struct snd_soc_component *component,
2966 if (!dai) 2991 if (!dai)
2967 return -ENOMEM; 2992 return -ENOMEM;
2968 2993
2969 /* Create the DAI widgets here. After adding DAIs, topology may 2994 /*
2995 * Create the DAI widgets here. After adding DAIs, topology may
2970 * also add routes that need these widgets as source or sink. 2996 * also add routes that need these widgets as source or sink.
2971 */ 2997 */
2972 ret = snd_soc_dapm_new_dai_widgets(dapm, dai); 2998 ret = snd_soc_dapm_new_dai_widgets(dapm, dai);
@@ -3048,7 +3074,8 @@ static void snd_soc_component_setup_regmap(struct snd_soc_component *component)
3048#ifdef CONFIG_REGMAP 3074#ifdef CONFIG_REGMAP
3049 3075
3050/** 3076/**
3051 * snd_soc_component_init_regmap() - Initialize regmap instance for the component 3077 * snd_soc_component_init_regmap() - Initialize regmap instance for the
3078 * component
3052 * @component: The component for which to initialize the regmap instance 3079 * @component: The component for which to initialize the regmap instance
3053 * @regmap: The regmap instance that should be used by the component 3080 * @regmap: The regmap instance that should be used by the component
3054 * 3081 *
@@ -3066,7 +3093,8 @@ void snd_soc_component_init_regmap(struct snd_soc_component *component,
3066EXPORT_SYMBOL_GPL(snd_soc_component_init_regmap); 3093EXPORT_SYMBOL_GPL(snd_soc_component_init_regmap);
3067 3094
3068/** 3095/**
3069 * snd_soc_component_exit_regmap() - De-initialize regmap instance for the component 3096 * snd_soc_component_exit_regmap() - De-initialize regmap instance for the
3097 * component
3070 * @component: The component for which to de-initialize the regmap instance 3098 * @component: The component for which to de-initialize the regmap instance
3071 * 3099 *
3072 * Calls regmap_exit() on the regmap instance associated to the component and 3100 * Calls regmap_exit() on the regmap instance associated to the component and
@@ -3090,7 +3118,8 @@ static void snd_soc_component_add(struct snd_soc_component *component)
3090 3118
3091 if (!component->driver->write && !component->driver->read) { 3119 if (!component->driver->write && !component->driver->read) {
3092 if (!component->regmap) 3120 if (!component->regmap)
3093 component->regmap = dev_get_regmap(component->dev, NULL); 3121 component->regmap = dev_get_regmap(component->dev,
3122 NULL);
3094 if (component->regmap) 3123 if (component->regmap)
3095 snd_soc_component_setup_regmap(component); 3124 snd_soc_component_setup_regmap(component);
3096 } 3125 }
@@ -3235,23 +3264,24 @@ static int __snd_soc_unregister_component(struct device *dev)
3235 if (dev != component->dev) 3264 if (dev != component->dev)
3236 continue; 3265 continue;
3237 3266
3238 snd_soc_tplg_component_remove(component, SND_SOC_TPLG_INDEX_ALL); 3267 snd_soc_tplg_component_remove(component,
3268 SND_SOC_TPLG_INDEX_ALL);
3239 snd_soc_component_del_unlocked(component); 3269 snd_soc_component_del_unlocked(component);
3240 found = 1; 3270 found = 1;
3241 break; 3271 break;
3242 } 3272 }
3243 mutex_unlock(&client_mutex); 3273 mutex_unlock(&client_mutex);
3244 3274
3245 if (found) { 3275 if (found)
3246 snd_soc_component_cleanup(component); 3276 snd_soc_component_cleanup(component);
3247 }
3248 3277
3249 return found; 3278 return found;
3250} 3279}
3251 3280
3252void snd_soc_unregister_component(struct device *dev) 3281void snd_soc_unregister_component(struct device *dev)
3253{ 3282{
3254 while (__snd_soc_unregister_component(dev)); 3283 while (__snd_soc_unregister_component(dev))
3284 ;
3255} 3285}
3256EXPORT_SYMBOL_GPL(snd_soc_unregister_component); 3286EXPORT_SYMBOL_GPL(snd_soc_unregister_component);
3257 3287
@@ -3832,7 +3862,7 @@ int snd_soc_of_get_dai_link_codecs(struct device *dev,
3832 for_each_link_codecs(dai_link, index, component) { 3862 for_each_link_codecs(dai_link, index, component) {
3833 ret = of_parse_phandle_with_args(of_node, name, 3863 ret = of_parse_phandle_with_args(of_node, name,
3834 "#sound-dai-cells", 3864 "#sound-dai-cells",
3835 index, &args); 3865 index, &args);
3836 if (ret) 3866 if (ret)
3837 goto err; 3867 goto err;
3838 component->of_node = args.np; 3868 component->of_node = args.np;