summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbui duc phuc <phucduc.bui@gmail.com>2026-07-21 17:25:44 +0700
committerMark Brown <broonie@kernel.org>2026-07-23 17:27:24 +0100
commit3ec678539a9fd98bc6100013d7900d22abd330f8 (patch)
treea7269b9c8d80291bda56848584c2e7b330f15cc7
parent750c61b2920f993eae36da32f6ea3071e7470e26 (diff)
downloadlinux-3ec678539a9fd98bc6100013d7900d22abd330f8.tar.gz
linux-3ec678539a9fd98bc6100013d7900d22abd330f8.zip
ASoC: codecs: mt6359-accdet: 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-14-phucduc.bui@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/codecs/mt6359-accdet.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/sound/soc/codecs/mt6359-accdet.c b/sound/soc/codecs/mt6359-accdet.c
index ed34cc15b80e..e1190c644021 100644
--- a/sound/soc/codecs/mt6359-accdet.c
+++ b/sound/soc/codecs/mt6359-accdet.c
@@ -6,6 +6,7 @@
// Author: Argus Lin <argus.lin@mediatek.com>
//
+#include <linux/cleanup.h>
#include <linux/of.h>
#include <linux/input.h>
#include <linux/kthread.h>
@@ -398,14 +399,13 @@ static void mt6359_accdet_work(struct work_struct *work)
struct mt6359_accdet *priv =
container_of(work, struct mt6359_accdet, accdet_work);
- mutex_lock(&priv->res_lock);
+ guard(mutex)(&priv->res_lock);
priv->pre_accdet_status = priv->accdet_status;
check_jack_btn_type(priv);
if (priv->jack_plugged &&
priv->pre_accdet_status != priv->accdet_status)
mt6359_accdet_jack_report(priv);
- mutex_unlock(&priv->res_lock);
}
static void mt6359_accdet_jd_work(struct work_struct *work)
@@ -416,7 +416,7 @@ static void mt6359_accdet_jd_work(struct work_struct *work)
struct mt6359_accdet *priv =
container_of(work, struct mt6359_accdet, jd_work);
- mutex_lock(&priv->res_lock);
+ guard(mutex)(&priv->res_lock);
if (priv->jd_sts == M_PLUG_IN) {
priv->jack_plugged = true;
@@ -450,7 +450,6 @@ static void mt6359_accdet_jd_work(struct work_struct *work)
if (priv->caps & ACCDET_PMIC_EINT_IRQ)
recover_eint_setting(priv);
- mutex_unlock(&priv->res_lock);
}
static irqreturn_t mt6359_accdet_irq(int irq, void *data)
@@ -459,7 +458,7 @@ static irqreturn_t mt6359_accdet_irq(int irq, void *data)
unsigned int irq_val = 0, val = 0, value = 0;
int ret;
- mutex_lock(&priv->res_lock);
+ guard(mutex)(&priv->res_lock);
regmap_read(priv->regmap, ACCDET_IRQ_ADDR, &irq_val);
if (irq_val & ACCDET_IRQ_MASK_SFT) {
@@ -474,7 +473,6 @@ static irqreturn_t mt6359_accdet_irq(int irq, void *data)
1000);
if (ret) {
dev_err(priv->dev, "%s(), ret %d\n", __func__, ret);
- mutex_unlock(&priv->res_lock);
return IRQ_NONE;
}
regmap_update_bits(priv->regmap, ACCDET_IRQ_ADDR,
@@ -498,7 +496,6 @@ static irqreturn_t mt6359_accdet_irq(int irq, void *data)
if (ret) {
dev_err(priv->dev, "%s(), ret %d\n", __func__,
ret);
- mutex_unlock(&priv->res_lock);
return IRQ_NONE;
}
regmap_update_bits(priv->regmap, ACCDET_IRQ_ADDR,
@@ -521,7 +518,6 @@ static irqreturn_t mt6359_accdet_irq(int irq, void *data)
if (ret) {
dev_err(priv->dev, "%s(), ret %d\n", __func__,
ret);
- mutex_unlock(&priv->res_lock);
return IRQ_NONE;
}
regmap_update_bits(priv->regmap, ACCDET_IRQ_ADDR,
@@ -540,7 +536,6 @@ static irqreturn_t mt6359_accdet_irq(int irq, void *data)
queue_work(priv->jd_workqueue, &priv->jd_work);
}
- mutex_unlock(&priv->res_lock);
return IRQ_HANDLED;
}