diff options
Diffstat (limited to 'sound/soc/soc-core.c')
-rw-r--r-- | sound/soc/soc-core.c | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 5c0658d49609..07aa54385ae0 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 */ |
@@ -1670,6 +1687,7 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) | |||
1670 | card->instantiated = 1; | 1687 | card->instantiated = 1; |
1671 | snd_soc_dapm_sync(&card->dapm); | 1688 | snd_soc_dapm_sync(&card->dapm); |
1672 | mutex_unlock(&card->mutex); | 1689 | mutex_unlock(&card->mutex); |
1690 | mutex_unlock(&client_mutex); | ||
1673 | 1691 | ||
1674 | return 0; | 1692 | return 0; |
1675 | 1693 | ||
@@ -1688,6 +1706,7 @@ card_probe_error: | |||
1688 | 1706 | ||
1689 | base_error: | 1707 | base_error: |
1690 | mutex_unlock(&card->mutex); | 1708 | mutex_unlock(&card->mutex); |
1709 | mutex_unlock(&client_mutex); | ||
1691 | 1710 | ||
1692 | return ret; | 1711 | return ret; |
1693 | } | 1712 | } |
@@ -2721,13 +2740,6 @@ static void snd_soc_component_del_unlocked(struct snd_soc_component *component) | |||
2721 | list_del(&component->list); | 2740 | list_del(&component->list); |
2722 | } | 2741 | } |
2723 | 2742 | ||
2724 | static void snd_soc_component_del(struct snd_soc_component *component) | ||
2725 | { | ||
2726 | mutex_lock(&client_mutex); | ||
2727 | snd_soc_component_del_unlocked(component); | ||
2728 | mutex_unlock(&client_mutex); | ||
2729 | } | ||
2730 | |||
2731 | int snd_soc_register_component(struct device *dev, | 2743 | int snd_soc_register_component(struct device *dev, |
2732 | const struct snd_soc_component_driver *cmpnt_drv, | 2744 | const struct snd_soc_component_driver *cmpnt_drv, |
2733 | struct snd_soc_dai_driver *dai_drv, | 2745 | struct snd_soc_dai_driver *dai_drv, |
@@ -2775,14 +2787,17 @@ void snd_soc_unregister_component(struct device *dev) | |||
2775 | { | 2787 | { |
2776 | struct snd_soc_component *cmpnt; | 2788 | struct snd_soc_component *cmpnt; |
2777 | 2789 | ||
2790 | mutex_lock(&client_mutex); | ||
2778 | list_for_each_entry(cmpnt, &component_list, list) { | 2791 | list_for_each_entry(cmpnt, &component_list, list) { |
2779 | if (dev == cmpnt->dev && cmpnt->registered_as_component) | 2792 | if (dev == cmpnt->dev && cmpnt->registered_as_component) |
2780 | goto found; | 2793 | goto found; |
2781 | } | 2794 | } |
2795 | mutex_unlock(&client_mutex); | ||
2782 | return; | 2796 | return; |
2783 | 2797 | ||
2784 | found: | 2798 | found: |
2785 | snd_soc_component_del(cmpnt); | 2799 | snd_soc_component_del_unlocked(cmpnt); |
2800 | mutex_unlock(&client_mutex); | ||
2786 | snd_soc_component_cleanup(cmpnt); | 2801 | snd_soc_component_cleanup(cmpnt); |
2787 | kfree(cmpnt); | 2802 | kfree(cmpnt); |
2788 | } | 2803 | } |
@@ -2890,10 +2905,14 @@ struct snd_soc_platform *snd_soc_lookup_platform(struct device *dev) | |||
2890 | { | 2905 | { |
2891 | struct snd_soc_platform *platform; | 2906 | struct snd_soc_platform *platform; |
2892 | 2907 | ||
2908 | mutex_lock(&client_mutex); | ||
2893 | list_for_each_entry(platform, &platform_list, list) { | 2909 | list_for_each_entry(platform, &platform_list, list) { |
2894 | if (dev == platform->dev) | 2910 | if (dev == platform->dev) { |
2911 | mutex_unlock(&client_mutex); | ||
2895 | return platform; | 2912 | return platform; |
2913 | } | ||
2896 | } | 2914 | } |
2915 | mutex_unlock(&client_mutex); | ||
2897 | 2916 | ||
2898 | return NULL; | 2917 | return NULL; |
2899 | } | 2918 | } |
@@ -3098,15 +3117,15 @@ void snd_soc_unregister_codec(struct device *dev) | |||
3098 | { | 3117 | { |
3099 | struct snd_soc_codec *codec; | 3118 | struct snd_soc_codec *codec; |
3100 | 3119 | ||
3120 | mutex_lock(&client_mutex); | ||
3101 | list_for_each_entry(codec, &codec_list, list) { | 3121 | list_for_each_entry(codec, &codec_list, list) { |
3102 | if (dev == codec->dev) | 3122 | if (dev == codec->dev) |
3103 | goto found; | 3123 | goto found; |
3104 | } | 3124 | } |
3125 | mutex_unlock(&client_mutex); | ||
3105 | return; | 3126 | return; |
3106 | 3127 | ||
3107 | found: | 3128 | found: |
3108 | |||
3109 | mutex_lock(&client_mutex); | ||
3110 | list_del(&codec->list); | 3129 | list_del(&codec->list); |
3111 | snd_soc_component_del_unlocked(&codec->component); | 3130 | snd_soc_component_del_unlocked(&codec->component); |
3112 | mutex_unlock(&client_mutex); | 3131 | mutex_unlock(&client_mutex); |