aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorCharles Keepax <ckeepax@opensource.wolfsonmicro.com>2014-02-18 10:22:14 -0500
committerMark Brown <broonie@linaro.org>2014-02-20 04:40:07 -0500
commit113911006442a36c2b4669faf1699d9042ef80ab (patch)
treed93a53b643d0293bff11ffaceb35174524474b05 /sound
parentc4204960e9d0ba99459dbf1db918f99a45e7a62a (diff)
ASoC: dapm: Add locking to snd_soc_dapm_xxxx_pin functions
The snd_soc_dapm_xxxx_pin all require the dapm_mutex to be held when they are called as they edit the dirty list, however very few of the callers do so. This patch adds unlocked versions of all the functions replacing the existing implementations with one that holds the lock internally. We also fix up the places where the lock was actually held on the caller side. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@linaro.org> Cc: stable@vger.kernel.org
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/soc-dapm.c133
1 files changed, 123 insertions, 10 deletions
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index fd39cd2827d7..b9dc6acbba8c 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -3210,15 +3210,11 @@ int snd_soc_dapm_put_pin_switch(struct snd_kcontrol *kcontrol,
3210 struct snd_soc_card *card = snd_kcontrol_chip(kcontrol); 3210 struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
3211 const char *pin = (const char *)kcontrol->private_value; 3211 const char *pin = (const char *)kcontrol->private_value;
3212 3212
3213 mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
3214
3215 if (ucontrol->value.integer.value[0]) 3213 if (ucontrol->value.integer.value[0])
3216 snd_soc_dapm_enable_pin(&card->dapm, pin); 3214 snd_soc_dapm_enable_pin(&card->dapm, pin);
3217 else 3215 else
3218 snd_soc_dapm_disable_pin(&card->dapm, pin); 3216 snd_soc_dapm_disable_pin(&card->dapm, pin);
3219 3217
3220 mutex_unlock(&card->dapm_mutex);
3221
3222 snd_soc_dapm_sync(&card->dapm); 3218 snd_soc_dapm_sync(&card->dapm);
3223 return 0; 3219 return 0;
3224} 3220}
@@ -3767,23 +3763,52 @@ void snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream,
3767} 3763}
3768 3764
3769/** 3765/**
3766 * snd_soc_dapm_enable_pin_unlocked - enable pin.
3767 * @dapm: DAPM context
3768 * @pin: pin name
3769 *
3770 * Enables input/output pin and its parents or children widgets iff there is
3771 * a valid audio route and active audio stream.
3772 *
3773 * Requires external locking.
3774 *
3775 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
3776 * do any widget power switching.
3777 */
3778int snd_soc_dapm_enable_pin_unlocked(struct snd_soc_dapm_context *dapm,
3779 const char *pin)
3780{
3781 return snd_soc_dapm_set_pin(dapm, pin, 1);
3782}
3783EXPORT_SYMBOL_GPL(snd_soc_dapm_enable_pin_unlocked);
3784
3785/**
3770 * snd_soc_dapm_enable_pin - enable pin. 3786 * snd_soc_dapm_enable_pin - enable pin.
3771 * @dapm: DAPM context 3787 * @dapm: DAPM context
3772 * @pin: pin name 3788 * @pin: pin name
3773 * 3789 *
3774 * Enables input/output pin and its parents or children widgets iff there is 3790 * Enables input/output pin and its parents or children widgets iff there is
3775 * a valid audio route and active audio stream. 3791 * a valid audio route and active audio stream.
3792 *
3776 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to 3793 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
3777 * do any widget power switching. 3794 * do any widget power switching.
3778 */ 3795 */
3779int snd_soc_dapm_enable_pin(struct snd_soc_dapm_context *dapm, const char *pin) 3796int snd_soc_dapm_enable_pin(struct snd_soc_dapm_context *dapm, const char *pin)
3780{ 3797{
3781 return snd_soc_dapm_set_pin(dapm, pin, 1); 3798 int ret;
3799
3800 mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
3801
3802 ret = snd_soc_dapm_set_pin(dapm, pin, 1);
3803
3804 mutex_unlock(&dapm->card->dapm_mutex);
3805
3806 return ret;
3782} 3807}
3783EXPORT_SYMBOL_GPL(snd_soc_dapm_enable_pin); 3808EXPORT_SYMBOL_GPL(snd_soc_dapm_enable_pin);
3784 3809
3785/** 3810/**
3786 * snd_soc_dapm_force_enable_pin - force a pin to be enabled 3811 * snd_soc_dapm_force_enable_pin_unlocked - force a pin to be enabled
3787 * @dapm: DAPM context 3812 * @dapm: DAPM context
3788 * @pin: pin name 3813 * @pin: pin name
3789 * 3814 *
@@ -3791,11 +3816,13 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_enable_pin);
3791 * intended for use with microphone bias supplies used in microphone 3816 * intended for use with microphone bias supplies used in microphone
3792 * jack detection. 3817 * jack detection.
3793 * 3818 *
3819 * Requires external locking.
3820 *
3794 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to 3821 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
3795 * do any widget power switching. 3822 * do any widget power switching.
3796 */ 3823 */
3797int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm, 3824int snd_soc_dapm_force_enable_pin_unlocked(struct snd_soc_dapm_context *dapm,
3798 const char *pin) 3825 const char *pin)
3799{ 3826{
3800 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true); 3827 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true);
3801 3828
@@ -3811,25 +3838,103 @@ int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm,
3811 3838
3812 return 0; 3839 return 0;
3813} 3840}
3841EXPORT_SYMBOL_GPL(snd_soc_dapm_force_enable_pin_unlocked);
3842
3843/**
3844 * snd_soc_dapm_force_enable_pin - force a pin to be enabled
3845 * @dapm: DAPM context
3846 * @pin: pin name
3847 *
3848 * Enables input/output pin regardless of any other state. This is
3849 * intended for use with microphone bias supplies used in microphone
3850 * jack detection.
3851 *
3852 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
3853 * do any widget power switching.
3854 */
3855int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm,
3856 const char *pin)
3857{
3858 int ret;
3859
3860 mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
3861
3862 ret = snd_soc_dapm_force_enable_pin_unlocked(dapm, pin);
3863
3864 mutex_unlock(&dapm->card->dapm_mutex);
3865
3866 return ret;
3867}
3814EXPORT_SYMBOL_GPL(snd_soc_dapm_force_enable_pin); 3868EXPORT_SYMBOL_GPL(snd_soc_dapm_force_enable_pin);
3815 3869
3816/** 3870/**
3871 * snd_soc_dapm_disable_pin_unlocked - disable pin.
3872 * @dapm: DAPM context
3873 * @pin: pin name
3874 *
3875 * Disables input/output pin and its parents or children widgets.
3876 *
3877 * Requires external locking.
3878 *
3879 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
3880 * do any widget power switching.
3881 */
3882int snd_soc_dapm_disable_pin_unlocked(struct snd_soc_dapm_context *dapm,
3883 const char *pin)
3884{
3885 return snd_soc_dapm_set_pin(dapm, pin, 0);
3886}
3887EXPORT_SYMBOL_GPL(snd_soc_dapm_disable_pin_unlocked);
3888
3889/**
3817 * snd_soc_dapm_disable_pin - disable pin. 3890 * snd_soc_dapm_disable_pin - disable pin.
3818 * @dapm: DAPM context 3891 * @dapm: DAPM context
3819 * @pin: pin name 3892 * @pin: pin name
3820 * 3893 *
3821 * Disables input/output pin and its parents or children widgets. 3894 * Disables input/output pin and its parents or children widgets.
3895 *
3822 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to 3896 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
3823 * do any widget power switching. 3897 * do any widget power switching.
3824 */ 3898 */
3825int snd_soc_dapm_disable_pin(struct snd_soc_dapm_context *dapm, 3899int snd_soc_dapm_disable_pin(struct snd_soc_dapm_context *dapm,
3826 const char *pin) 3900 const char *pin)
3827{ 3901{
3828 return snd_soc_dapm_set_pin(dapm, pin, 0); 3902 int ret;
3903
3904 mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
3905
3906 ret = snd_soc_dapm_set_pin(dapm, pin, 0);
3907
3908 mutex_unlock(&dapm->card->dapm_mutex);
3909
3910 return ret;
3829} 3911}
3830EXPORT_SYMBOL_GPL(snd_soc_dapm_disable_pin); 3912EXPORT_SYMBOL_GPL(snd_soc_dapm_disable_pin);
3831 3913
3832/** 3914/**
3915 * snd_soc_dapm_nc_pin_unlocked - permanently disable pin.
3916 * @dapm: DAPM context
3917 * @pin: pin name
3918 *
3919 * Marks the specified pin as being not connected, disabling it along
3920 * any parent or child widgets. At present this is identical to
3921 * snd_soc_dapm_disable_pin() but in future it will be extended to do
3922 * additional things such as disabling controls which only affect
3923 * paths through the pin.
3924 *
3925 * Requires external locking.
3926 *
3927 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
3928 * do any widget power switching.
3929 */
3930int snd_soc_dapm_nc_pin_unlocked(struct snd_soc_dapm_context *dapm,
3931 const char *pin)
3932{
3933 return snd_soc_dapm_set_pin(dapm, pin, 0);
3934}
3935EXPORT_SYMBOL_GPL(snd_soc_dapm_nc_pin_unlocked);
3936
3937/**
3833 * snd_soc_dapm_nc_pin - permanently disable pin. 3938 * snd_soc_dapm_nc_pin - permanently disable pin.
3834 * @dapm: DAPM context 3939 * @dapm: DAPM context
3835 * @pin: pin name 3940 * @pin: pin name
@@ -3845,7 +3950,15 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_disable_pin);
3845 */ 3950 */
3846int snd_soc_dapm_nc_pin(struct snd_soc_dapm_context *dapm, const char *pin) 3951int snd_soc_dapm_nc_pin(struct snd_soc_dapm_context *dapm, const char *pin)
3847{ 3952{
3848 return snd_soc_dapm_set_pin(dapm, pin, 0); 3953 int ret;
3954
3955 mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
3956
3957 ret = snd_soc_dapm_set_pin(dapm, pin, 0);
3958
3959 mutex_unlock(&dapm->card->dapm_mutex);
3960
3961 return ret;
3849} 3962}
3850EXPORT_SYMBOL_GPL(snd_soc_dapm_nc_pin); 3963EXPORT_SYMBOL_GPL(snd_soc_dapm_nc_pin);
3851 3964