aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-core.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/soc-core.c')
-rw-r--r--sound/soc/soc-core.c41
1 files changed, 30 insertions, 11 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 30579ca5bacb..e5c990889dcc 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -347,6 +347,8 @@ static ssize_t codec_list_read_file(struct file *file, char __user *user_buf,
347 if (!buf) 347 if (!buf)
348 return -ENOMEM; 348 return -ENOMEM;
349 349
350 mutex_lock(&client_mutex);
351
350 list_for_each_entry(codec, &codec_list, list) { 352 list_for_each_entry(codec, &codec_list, list) {
351 len = snprintf(buf + ret, PAGE_SIZE - ret, "%s\n", 353 len = snprintf(buf + ret, PAGE_SIZE - ret, "%s\n",
352 codec->component.name); 354 codec->component.name);
@@ -358,6 +360,8 @@ static ssize_t codec_list_read_file(struct file *file, char __user *user_buf,
358 } 360 }
359 } 361 }
360 362
363 mutex_unlock(&client_mutex);
364
361 if (ret >= 0) 365 if (ret >= 0)
362 ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret); 366 ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
363 367
@@ -382,6 +386,8 @@ static ssize_t dai_list_read_file(struct file *file, char __user *user_buf,
382 if (!buf) 386 if (!buf)
383 return -ENOMEM; 387 return -ENOMEM;
384 388
389 mutex_lock(&client_mutex);
390
385 list_for_each_entry(component, &component_list, list) { 391 list_for_each_entry(component, &component_list, list) {
386 list_for_each_entry(dai, &component->dai_list, list) { 392 list_for_each_entry(dai, &component->dai_list, list) {
387 len = snprintf(buf + ret, PAGE_SIZE - ret, "%s\n", 393 len = snprintf(buf + ret, PAGE_SIZE - ret, "%s\n",
@@ -395,6 +401,8 @@ static ssize_t dai_list_read_file(struct file *file, char __user *user_buf,
395 } 401 }
396 } 402 }
397 403
404 mutex_unlock(&client_mutex);
405
398 ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret); 406 ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
399 407
400 kfree(buf); 408 kfree(buf);
@@ -418,6 +426,8 @@ static ssize_t platform_list_read_file(struct file *file,
418 if (!buf) 426 if (!buf)
419 return -ENOMEM; 427 return -ENOMEM;
420 428
429 mutex_lock(&client_mutex);
430
421 list_for_each_entry(platform, &platform_list, list) { 431 list_for_each_entry(platform, &platform_list, list) {
422 len = snprintf(buf + ret, PAGE_SIZE - ret, "%s\n", 432 len = snprintf(buf + ret, PAGE_SIZE - ret, "%s\n",
423 platform->component.name); 433 platform->component.name);
@@ -429,6 +439,8 @@ static ssize_t platform_list_read_file(struct file *file,
429 } 439 }
430 } 440 }
431 441
442 mutex_unlock(&client_mutex);
443
432 ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret); 444 ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
433 445
434 kfree(buf); 446 kfree(buf);
@@ -836,6 +848,8 @@ static struct snd_soc_component *soc_find_component(
836{ 848{
837 struct snd_soc_component *component; 849 struct snd_soc_component *component;
838 850
851 lockdep_assert_held(&client_mutex);
852
839 list_for_each_entry(component, &component_list, list) { 853 list_for_each_entry(component, &component_list, list) {
840 if (of_node) { 854 if (of_node) {
841 if (component->dev->of_node == of_node) 855 if (component->dev->of_node == of_node)
@@ -854,6 +868,8 @@ static struct snd_soc_dai *snd_soc_find_dai(
854 struct snd_soc_component *component; 868 struct snd_soc_component *component;
855 struct snd_soc_dai *dai; 869 struct snd_soc_dai *dai;
856 870
871 lockdep_assert_held(&client_mutex);
872
857 /* Find CPU DAI from registered DAIs*/ 873 /* Find CPU DAI from registered DAIs*/
858 list_for_each_entry(component, &component_list, list) { 874 list_for_each_entry(component, &component_list, list) {
859 if (dlc->of_node && component->dev->of_node != dlc->of_node) 875 if (dlc->of_node && component->dev->of_node != dlc->of_node)
@@ -1508,6 +1524,7 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
1508 struct snd_soc_codec *codec; 1524 struct snd_soc_codec *codec;
1509 int ret, i, order; 1525 int ret, i, order;
1510 1526
1527 mutex_lock(&client_mutex);
1511 mutex_lock_nested(&card->mutex, SND_SOC_CARD_CLASS_INIT); 1528 mutex_lock_nested(&card->mutex, SND_SOC_CARD_CLASS_INIT);
1512 1529
1513 /* bind DAIs */ 1530 /* bind DAIs */
@@ -1662,6 +1679,7 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
1662 card->instantiated = 1; 1679 card->instantiated = 1;
1663 snd_soc_dapm_sync(&card->dapm); 1680 snd_soc_dapm_sync(&card->dapm);
1664 mutex_unlock(&card->mutex); 1681 mutex_unlock(&card->mutex);
1682 mutex_unlock(&client_mutex);
1665 1683
1666 return 0; 1684 return 0;
1667 1685
@@ -1680,6 +1698,7 @@ card_probe_error:
1680 1698
1681base_error: 1699base_error:
1682 mutex_unlock(&card->mutex); 1700 mutex_unlock(&card->mutex);
1701 mutex_unlock(&client_mutex);
1683 1702
1684 return ret; 1703 return ret;
1685} 1704}
@@ -2713,13 +2732,6 @@ static void snd_soc_component_del_unlocked(struct snd_soc_component *component)
2713 list_del(&component->list); 2732 list_del(&component->list);
2714} 2733}
2715 2734
2716static void snd_soc_component_del(struct snd_soc_component *component)
2717{
2718 mutex_lock(&client_mutex);
2719 snd_soc_component_del_unlocked(component);
2720 mutex_unlock(&client_mutex);
2721}
2722
2723int snd_soc_register_component(struct device *dev, 2735int snd_soc_register_component(struct device *dev,
2724 const struct snd_soc_component_driver *cmpnt_drv, 2736 const struct snd_soc_component_driver *cmpnt_drv,
2725 struct snd_soc_dai_driver *dai_drv, 2737 struct snd_soc_dai_driver *dai_drv,
@@ -2767,14 +2779,17 @@ void snd_soc_unregister_component(struct device *dev)
2767{ 2779{
2768 struct snd_soc_component *cmpnt; 2780 struct snd_soc_component *cmpnt;
2769 2781
2782 mutex_lock(&client_mutex);
2770 list_for_each_entry(cmpnt, &component_list, list) { 2783 list_for_each_entry(cmpnt, &component_list, list) {
2771 if (dev == cmpnt->dev && cmpnt->registered_as_component) 2784 if (dev == cmpnt->dev && cmpnt->registered_as_component)
2772 goto found; 2785 goto found;
2773 } 2786 }
2787 mutex_unlock(&client_mutex);
2774 return; 2788 return;
2775 2789
2776found: 2790found:
2777 snd_soc_component_del(cmpnt); 2791 snd_soc_component_del_unlocked(cmpnt);
2792 mutex_unlock(&client_mutex);
2778 snd_soc_component_cleanup(cmpnt); 2793 snd_soc_component_cleanup(cmpnt);
2779 kfree(cmpnt); 2794 kfree(cmpnt);
2780} 2795}
@@ -2882,10 +2897,14 @@ struct snd_soc_platform *snd_soc_lookup_platform(struct device *dev)
2882{ 2897{
2883 struct snd_soc_platform *platform; 2898 struct snd_soc_platform *platform;
2884 2899
2900 mutex_lock(&client_mutex);
2885 list_for_each_entry(platform, &platform_list, list) { 2901 list_for_each_entry(platform, &platform_list, list) {
2886 if (dev == platform->dev) 2902 if (dev == platform->dev) {
2903 mutex_unlock(&client_mutex);
2887 return platform; 2904 return platform;
2905 }
2888 } 2906 }
2907 mutex_unlock(&client_mutex);
2889 2908
2890 return NULL; 2909 return NULL;
2891} 2910}
@@ -3090,15 +3109,15 @@ void snd_soc_unregister_codec(struct device *dev)
3090{ 3109{
3091 struct snd_soc_codec *codec; 3110 struct snd_soc_codec *codec;
3092 3111
3112 mutex_lock(&client_mutex);
3093 list_for_each_entry(codec, &codec_list, list) { 3113 list_for_each_entry(codec, &codec_list, list) {
3094 if (dev == codec->dev) 3114 if (dev == codec->dev)
3095 goto found; 3115 goto found;
3096 } 3116 }
3117 mutex_unlock(&client_mutex);
3097 return; 3118 return;
3098 3119
3099found: 3120found:
3100
3101 mutex_lock(&client_mutex);
3102 list_del(&codec->list); 3121 list_del(&codec->list);
3103 snd_soc_component_del_unlocked(&codec->component); 3122 snd_soc_component_del_unlocked(&codec->component);
3104 mutex_unlock(&client_mutex); 3123 mutex_unlock(&client_mutex);