diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2014-11-09 11:00:57 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2014-11-10 14:07:42 -0500 |
commit | 52ef6284a840bdef50b6ed505bdda014dd769cab (patch) | |
tree | 5716d6946d75fe0d4fac228ed6a754dc98a6d146 | |
parent | f114040e3ea6e07372334ade75d1ee0775c355e1 (diff) |
ASoC: ab8500-codec: Move control lock to the driver level
The ab8500 driver uses a driver specific lock to protect concurrent access
to some of the control put/get handlers and uses the snd_soc_codec mutex for
some others. This patch updates the driver to consistently use the driver
specific lock for all controls. This will allow us to eventually remove the
snd_soc_codec mutex.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | sound/soc/codecs/ab8500-codec.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/sound/soc/codecs/ab8500-codec.c b/sound/soc/codecs/ab8500-codec.c index fd43827bb856..7dfbc9921e91 100644 --- a/sound/soc/codecs/ab8500-codec.c +++ b/sound/soc/codecs/ab8500-codec.c | |||
@@ -126,13 +126,13 @@ struct ab8500_codec_drvdata_dbg { | |||
126 | /* Private data for AB8500 device-driver */ | 126 | /* Private data for AB8500 device-driver */ |
127 | struct ab8500_codec_drvdata { | 127 | struct ab8500_codec_drvdata { |
128 | struct regmap *regmap; | 128 | struct regmap *regmap; |
129 | struct mutex ctrl_lock; | ||
129 | 130 | ||
130 | /* Sidetone */ | 131 | /* Sidetone */ |
131 | long *sid_fir_values; | 132 | long *sid_fir_values; |
132 | enum sid_state sid_status; | 133 | enum sid_state sid_status; |
133 | 134 | ||
134 | /* ANC */ | 135 | /* ANC */ |
135 | struct mutex anc_lock; | ||
136 | long *anc_fir_values; | 136 | long *anc_fir_values; |
137 | long *anc_iir_values; | 137 | long *anc_iir_values; |
138 | enum anc_state anc_status; | 138 | enum anc_state anc_status; |
@@ -1129,9 +1129,9 @@ static int sid_status_control_get(struct snd_kcontrol *kcontrol, | |||
1129 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | 1129 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
1130 | struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev); | 1130 | struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev); |
1131 | 1131 | ||
1132 | mutex_lock(&codec->mutex); | 1132 | mutex_lock(&drvdata->ctrl_lock); |
1133 | ucontrol->value.integer.value[0] = drvdata->sid_status; | 1133 | ucontrol->value.integer.value[0] = drvdata->sid_status; |
1134 | mutex_unlock(&codec->mutex); | 1134 | mutex_unlock(&drvdata->ctrl_lock); |
1135 | 1135 | ||
1136 | return 0; | 1136 | return 0; |
1137 | } | 1137 | } |
@@ -1154,7 +1154,7 @@ static int sid_status_control_put(struct snd_kcontrol *kcontrol, | |||
1154 | return -EIO; | 1154 | return -EIO; |
1155 | } | 1155 | } |
1156 | 1156 | ||
1157 | mutex_lock(&codec->mutex); | 1157 | mutex_lock(&drvdata->ctrl_lock); |
1158 | 1158 | ||
1159 | sidconf = snd_soc_read(codec, AB8500_SIDFIRCONF); | 1159 | sidconf = snd_soc_read(codec, AB8500_SIDFIRCONF); |
1160 | if (((sidconf & BIT(AB8500_SIDFIRCONF_FIRSIDBUSY)) != 0)) { | 1160 | if (((sidconf & BIT(AB8500_SIDFIRCONF_FIRSIDBUSY)) != 0)) { |
@@ -1185,7 +1185,7 @@ static int sid_status_control_put(struct snd_kcontrol *kcontrol, | |||
1185 | drvdata->sid_status = SID_FIR_CONFIGURED; | 1185 | drvdata->sid_status = SID_FIR_CONFIGURED; |
1186 | 1186 | ||
1187 | out: | 1187 | out: |
1188 | mutex_unlock(&codec->mutex); | 1188 | mutex_unlock(&drvdata->ctrl_lock); |
1189 | 1189 | ||
1190 | dev_dbg(codec->dev, "%s: Exit\n", __func__); | 1190 | dev_dbg(codec->dev, "%s: Exit\n", __func__); |
1191 | 1191 | ||
@@ -1198,9 +1198,9 @@ static int anc_status_control_get(struct snd_kcontrol *kcontrol, | |||
1198 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | 1198 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
1199 | struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev); | 1199 | struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev); |
1200 | 1200 | ||
1201 | mutex_lock(&codec->mutex); | 1201 | mutex_lock(&drvdata->ctrl_lock); |
1202 | ucontrol->value.integer.value[0] = drvdata->anc_status; | 1202 | ucontrol->value.integer.value[0] = drvdata->anc_status; |
1203 | mutex_unlock(&codec->mutex); | 1203 | mutex_unlock(&drvdata->ctrl_lock); |
1204 | 1204 | ||
1205 | return 0; | 1205 | return 0; |
1206 | } | 1206 | } |
@@ -1217,7 +1217,7 @@ static int anc_status_control_put(struct snd_kcontrol *kcontrol, | |||
1217 | 1217 | ||
1218 | dev_dbg(dev, "%s: Enter.\n", __func__); | 1218 | dev_dbg(dev, "%s: Enter.\n", __func__); |
1219 | 1219 | ||
1220 | mutex_lock(&drvdata->anc_lock); | 1220 | mutex_lock(&drvdata->ctrl_lock); |
1221 | 1221 | ||
1222 | req = ucontrol->value.integer.value[0]; | 1222 | req = ucontrol->value.integer.value[0]; |
1223 | if (req >= ARRAY_SIZE(enum_anc_state)) { | 1223 | if (req >= ARRAY_SIZE(enum_anc_state)) { |
@@ -1244,9 +1244,7 @@ static int anc_status_control_put(struct snd_kcontrol *kcontrol, | |||
1244 | } | 1244 | } |
1245 | snd_soc_dapm_sync(&codec->dapm); | 1245 | snd_soc_dapm_sync(&codec->dapm); |
1246 | 1246 | ||
1247 | mutex_lock(&codec->mutex); | ||
1248 | anc_configure(codec, apply_fir, apply_iir); | 1247 | anc_configure(codec, apply_fir, apply_iir); |
1249 | mutex_unlock(&codec->mutex); | ||
1250 | 1248 | ||
1251 | if (apply_fir) { | 1249 | if (apply_fir) { |
1252 | if (drvdata->anc_status == ANC_IIR_CONFIGURED) | 1250 | if (drvdata->anc_status == ANC_IIR_CONFIGURED) |
@@ -1265,7 +1263,7 @@ static int anc_status_control_put(struct snd_kcontrol *kcontrol, | |||
1265 | snd_soc_dapm_sync(&codec->dapm); | 1263 | snd_soc_dapm_sync(&codec->dapm); |
1266 | 1264 | ||
1267 | cleanup: | 1265 | cleanup: |
1268 | mutex_unlock(&drvdata->anc_lock); | 1266 | mutex_unlock(&drvdata->ctrl_lock); |
1269 | 1267 | ||
1270 | if (status < 0) | 1268 | if (status < 0) |
1271 | dev_err(dev, "%s: Unable to configure ANC! (status = %d)\n", | 1269 | dev_err(dev, "%s: Unable to configure ANC! (status = %d)\n", |
@@ -1294,14 +1292,15 @@ static int filter_control_get(struct snd_kcontrol *kcontrol, | |||
1294 | struct snd_ctl_elem_value *ucontrol) | 1292 | struct snd_ctl_elem_value *ucontrol) |
1295 | { | 1293 | { |
1296 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | 1294 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
1295 | struct ab8500_codec_drvdata *drvdata = snd_soc_codec_get_drvdata(codec); | ||
1297 | struct filter_control *fc = | 1296 | struct filter_control *fc = |
1298 | (struct filter_control *)kcontrol->private_value; | 1297 | (struct filter_control *)kcontrol->private_value; |
1299 | unsigned int i; | 1298 | unsigned int i; |
1300 | 1299 | ||
1301 | mutex_lock(&codec->mutex); | 1300 | mutex_lock(&drvdata->ctrl_lock); |
1302 | for (i = 0; i < fc->count; i++) | 1301 | for (i = 0; i < fc->count; i++) |
1303 | ucontrol->value.integer.value[i] = fc->value[i]; | 1302 | ucontrol->value.integer.value[i] = fc->value[i]; |
1304 | mutex_unlock(&codec->mutex); | 1303 | mutex_unlock(&drvdata->ctrl_lock); |
1305 | 1304 | ||
1306 | return 0; | 1305 | return 0; |
1307 | } | 1306 | } |
@@ -1310,14 +1309,15 @@ static int filter_control_put(struct snd_kcontrol *kcontrol, | |||
1310 | struct snd_ctl_elem_value *ucontrol) | 1309 | struct snd_ctl_elem_value *ucontrol) |
1311 | { | 1310 | { |
1312 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | 1311 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
1312 | struct ab8500_codec_drvdata *drvdata = snd_soc_codec_get_drvdata(codec); | ||
1313 | struct filter_control *fc = | 1313 | struct filter_control *fc = |
1314 | (struct filter_control *)kcontrol->private_value; | 1314 | (struct filter_control *)kcontrol->private_value; |
1315 | unsigned int i; | 1315 | unsigned int i; |
1316 | 1316 | ||
1317 | mutex_lock(&codec->mutex); | 1317 | mutex_lock(&drvdata->ctrl_lock); |
1318 | for (i = 0; i < fc->count; i++) | 1318 | for (i = 0; i < fc->count; i++) |
1319 | fc->value[i] = ucontrol->value.integer.value[i]; | 1319 | fc->value[i] = ucontrol->value.integer.value[i]; |
1320 | mutex_unlock(&codec->mutex); | 1320 | mutex_unlock(&drvdata->ctrl_lock); |
1321 | 1321 | ||
1322 | return 0; | 1322 | return 0; |
1323 | } | 1323 | } |
@@ -2545,7 +2545,7 @@ static int ab8500_codec_probe(struct snd_soc_codec *codec) | |||
2545 | 2545 | ||
2546 | (void)snd_soc_dapm_disable_pin(&codec->dapm, "ANC Configure Input"); | 2546 | (void)snd_soc_dapm_disable_pin(&codec->dapm, "ANC Configure Input"); |
2547 | 2547 | ||
2548 | mutex_init(&drvdata->anc_lock); | 2548 | mutex_init(&drvdata->ctrl_lock); |
2549 | 2549 | ||
2550 | return status; | 2550 | return status; |
2551 | } | 2551 | } |