mirror of
https://github.com/torvalds/linux.git
synced 2026-10-11 21:07:03 +02:00
ASoC: codecs: es8326: Use guard() for mutex locks
Clean up the code using guard() for mutex locks. Merely code refactoring, and no behavior change. Signed-off-by: bui duc phuc <phucduc.bui@gmail.com> Link: https://patch.msgid.link/20260721102600.523199-5-phucduc.bui@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
357d20c73d
commit
61bc0010fa
|
|
@ -6,6 +6,7 @@
|
|||
// Authors: David Yang <yangxiaohua@everest-semi.com>
|
||||
//
|
||||
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/clk.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/interrupt.h>
|
||||
|
|
@ -790,7 +791,7 @@ static void es8326_jack_button_handler(struct work_struct *work)
|
|||
if (!(es8326->jack->status & SND_JACK_HEADSET)) /* Jack unplugged */
|
||||
return;
|
||||
|
||||
mutex_lock(&es8326->lock);
|
||||
guard(mutex)(&es8326->lock);
|
||||
iface = snd_soc_component_read(comp, ES8326_HPDET_STA);
|
||||
switch (iface) {
|
||||
case 0x93:
|
||||
|
|
@ -845,7 +846,6 @@ static void es8326_jack_button_handler(struct work_struct *work)
|
|||
}
|
||||
es8326_disable_micbias(es8326->component);
|
||||
}
|
||||
mutex_unlock(&es8326->lock);
|
||||
}
|
||||
|
||||
static void es8326_jack_detect_handler(struct work_struct *work)
|
||||
|
|
@ -855,7 +855,7 @@ static void es8326_jack_detect_handler(struct work_struct *work)
|
|||
struct snd_soc_component *comp = es8326->component;
|
||||
unsigned int iface;
|
||||
|
||||
mutex_lock(&es8326->lock);
|
||||
guard(mutex)(&es8326->lock);
|
||||
iface = snd_soc_component_read(comp, ES8326_HPDET_STA);
|
||||
dev_dbg(comp->dev, "gpio flag %#04x", iface);
|
||||
|
||||
|
|
@ -873,7 +873,7 @@ static void es8326_jack_detect_handler(struct work_struct *work)
|
|||
regmap_update_bits(es8326->regmap, ES8326_HPDET_TYPE,
|
||||
ES8326_HP_DET_JACK_POL, (es8326->jd_inverted ?
|
||||
~es8326->jack_pol : es8326->jack_pol));
|
||||
goto exit;
|
||||
return;
|
||||
}
|
||||
|
||||
if ((iface & ES8326_HPINSERT_FLAG) == 0) {
|
||||
|
|
@ -930,7 +930,7 @@ static void es8326_jack_detect_handler(struct work_struct *work)
|
|||
queue_delayed_work(system_dfl_wq, &es8326->jack_detect_work,
|
||||
msecs_to_jiffies(400));
|
||||
es8326->hp = 1;
|
||||
goto exit;
|
||||
return;
|
||||
}
|
||||
if (es8326->jack->status & SND_JACK_HEADSET) {
|
||||
/* detect button */
|
||||
|
|
@ -939,7 +939,7 @@ static void es8326_jack_detect_handler(struct work_struct *work)
|
|||
(ES8326_INT_SRC_PIN9 | ES8326_INT_SRC_BUTTON));
|
||||
es8326_enable_micbias(es8326->component);
|
||||
queue_delayed_work(system_dfl_wq, &es8326->button_press_work, 10);
|
||||
goto exit;
|
||||
return;
|
||||
}
|
||||
if ((iface & ES8326_HPBUTTON_FLAG) == 0x01) {
|
||||
dev_dbg(comp->dev, "Headphone detected\n");
|
||||
|
|
@ -958,8 +958,6 @@ static void es8326_jack_detect_handler(struct work_struct *work)
|
|||
usleep_range(10000, 15000);
|
||||
}
|
||||
}
|
||||
exit:
|
||||
mutex_unlock(&es8326->lock);
|
||||
}
|
||||
|
||||
static irqreturn_t es8326_irq(int irq, void *dev_id)
|
||||
|
|
@ -1200,13 +1198,12 @@ static void es8326_enable_jack_detect(struct snd_soc_component *component,
|
|||
{
|
||||
struct es8326_priv *es8326 = snd_soc_component_get_drvdata(component);
|
||||
|
||||
mutex_lock(&es8326->lock);
|
||||
if (es8326->jd_inverted)
|
||||
snd_soc_component_update_bits(component, ES8326_HPDET_TYPE,
|
||||
ES8326_HP_DET_JACK_POL, ~es8326->jack_pol);
|
||||
es8326->jack = jack;
|
||||
|
||||
mutex_unlock(&es8326->lock);
|
||||
scoped_guard(mutex, &es8326->lock) {
|
||||
if (es8326->jd_inverted)
|
||||
snd_soc_component_update_bits(component, ES8326_HPDET_TYPE,
|
||||
ES8326_HP_DET_JACK_POL, ~es8326->jack_pol);
|
||||
es8326->jack = jack;
|
||||
}
|
||||
es8326_irq(es8326->irq, es8326);
|
||||
}
|
||||
|
||||
|
|
@ -1219,13 +1216,12 @@ static void es8326_disable_jack_detect(struct snd_soc_component *component)
|
|||
return; /* Already disabled (or never enabled) */
|
||||
cancel_delayed_work_sync(&es8326->jack_detect_work);
|
||||
|
||||
mutex_lock(&es8326->lock);
|
||||
guard(mutex)(&es8326->lock);
|
||||
if (es8326->jack->status & SND_JACK_MICROPHONE) {
|
||||
es8326_disable_micbias(component);
|
||||
snd_soc_jack_report(es8326->jack, 0, SND_JACK_HEADSET);
|
||||
}
|
||||
es8326->jack = NULL;
|
||||
mutex_unlock(&es8326->lock);
|
||||
}
|
||||
|
||||
static int es8326_set_jack(struct snd_soc_component *component,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user