From: bui duc phuc <[email protected]>
Clean up the code using guard() for mutex locks.
Merely code refactoring, and no behavior change.
Signed-off-by: bui duc phuc <[email protected]>
---
sound/soc/codecs/wm8994.c | 51 +++++++++++++++------------------------
1 file changed, 20 insertions(+), 31 deletions(-)
diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c
index 1d64c7c42ed1..58f18bb0057e 100644
--- a/sound/soc/codecs/wm8994.c
+++ b/sound/soc/codecs/wm8994.c
@@ -766,7 +766,7 @@ static void active_reference(struct snd_soc_component *component)
{
struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
- mutex_lock(&wm8994->accdet_lock);
+ guard(mutex)(&wm8994->accdet_lock);
wm8994->active_refcount++;
@@ -775,8 +775,6 @@ static void active_reference(struct snd_soc_component *component)
/* If we're using jack detection go into audio mode */
wm1811_jackdet_set_mode(component, WM1811_JACKDET_MODE_AUDIO);
-
- mutex_unlock(&wm8994->accdet_lock);
}
static void active_dereference(struct snd_soc_component *component)
@@ -784,7 +782,7 @@ static void active_dereference(struct snd_soc_component *component)
struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
u16 mode;
- mutex_lock(&wm8994->accdet_lock);
+ guard(mutex)(&wm8994->accdet_lock);
wm8994->active_refcount--;
@@ -800,8 +798,6 @@ static void active_dereference(struct snd_soc_component *component)
wm1811_jackdet_set_mode(component, mode);
}
-
- mutex_unlock(&wm8994->accdet_lock);
}
static int clk_sys_event(struct snd_soc_dapm_widget *w,
@@ -3704,7 +3700,7 @@ static void wm8958_open_circuit_work(struct work_struct *work)
open_circuit_work.work);
struct device *dev = wm8994->wm8994->dev;
- mutex_lock(&wm8994->accdet_lock);
+ guard(mutex)(&wm8994->accdet_lock);
wm1811_micd_stop(wm8994->hubs.component);
@@ -3718,8 +3714,6 @@ static void wm8958_open_circuit_work(struct work_struct *work)
snd_soc_jack_report(wm8994->micdet[0].jack, 0,
wm8994->btn_mask |
SND_JACK_HEADSET);
-
- mutex_unlock(&wm8994->accdet_lock);
}
static void wm8958_mic_id(void *data, u16 status)
@@ -3785,27 +3779,25 @@ static void wm1811_mic_work(struct work_struct *work)
snd_soc_dapm_sync(dapm);
}
- mutex_lock(&wm8994->accdet_lock);
-
- dev_dbg(component->dev, "Starting mic detection\n");
+ scoped_guard(mutex, &wm8994->accdet_lock) {
+ dev_dbg(component->dev, "Starting mic detection\n");
- /* Use a user-supplied callback if we have one */
- if (wm8994->micd_cb) {
- wm8994->micd_cb(wm8994->micd_cb_data);
- } else {
- /*
- * Start off measument of microphone impedence to find out
- * what's actually there.
- */
- wm8994->mic_detecting = true;
- wm1811_jackdet_set_mode(component, WM1811_JACKDET_MODE_MIC);
+ /* Use a user-supplied callback if we have one */
+ if (wm8994->micd_cb) {
+ wm8994->micd_cb(wm8994->micd_cb_data);
+ } else {
+ /*
+ * Start off measument of microphone impedence to find out
+ * what's actually there.
+ */
+ wm8994->mic_detecting = true;
+ wm1811_jackdet_set_mode(component, WM1811_JACKDET_MODE_MIC);
- snd_soc_component_update_bits(component, WM8958_MIC_DETECT_1,
- WM8958_MICD_ENA, WM8958_MICD_ENA);
+ snd_soc_component_update_bits(component, WM8958_MIC_DETECT_1,
+ WM8958_MICD_ENA, WM8958_MICD_ENA);
+ }
}
- mutex_unlock(&wm8994->accdet_lock);
-
pm_runtime_put(component->dev);
}
@@ -4028,11 +4020,8 @@ static void wm8958_mic_work(struct work_struct *work)
pm_runtime_get_sync(component->dev);
- mutex_lock(&wm8994->accdet_lock);
-
- wm8994->mic_id_cb(wm8994->mic_id_cb_data, wm8994->mic_status);
-
- mutex_unlock(&wm8994->accdet_lock);
+ scoped_guard(mutex, &wm8994->accdet_lock)
+ wm8994->mic_id_cb(wm8994->mic_id_cb_data, wm8994->mic_status);
pm_runtime_put(component->dev);
}
--
2.43.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.