* [PATCH 00/10] ASoC: mediatek: Use guard() for mutex & spin locks
@ 2026-06-10 10:20 phucduc.bui
2026-06-10 10:20 ` [PATCH 01/10] ASoC: mediatek: common: mtk-afe-fe-dai: Use guard() for mutex locks phucduc.bui
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: phucduc.bui @ 2026-06-10 10:20 UTC (permalink / raw)
To: Mark Brown, Matthias Brugger
Cc: Liam Girdwood, AngeloGioacchino Del Regno, Linus Walleij,
Bartosz Golaszewski, Jaroslav Kysela, Takashi Iwai, linux-sound,
linux-arm-kernel, linux-mediatek, linux-kernel, linux-gpio,
bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
Hi all,
This series converts mutex and spinlock handling in Mediatek ASoC drivers
to use guard() helpers.
Most patches are straightforward conversions to guard() helpers with no
functional change intended.
One exception is mt8192-afe-gpio, where the mutex release point moves from
immediately before dev_warn() to scope exit. However, the affected path
only emits a warning and immediately returns -EINVAL, without any further
processing.
Compile-tested only.
Best regards,
Phuc
bui duc phuc (10):
ASoC: mediatek: common: mtk-afe-fe-dai: Use guard() for mutex locks
ASoC: mediatek: common: mtk-btcvsd: Use guard() for spin locks
ASoC: mediatek: mt8186: mt8186-afe-gpio: Use guard() for mutex locks
ASoC: mediatek: mt8188: mt8188-afe-clk: Use guard() for spin locks
ASoC: mediatek: mt8192: mt8192-afe-gpio: Use guard() for mutex locks
ASoC: mediatek: mt8195: mt8195-afe-clk: Use guard() for spin locks
ASoC: mediatek: mt8195: mt8195-dai-etdm: Use guard() for spin locks
ASoC: mediatek: mt8195: mt8365-afe-clk: Use guard() for mutex & spin
locks
ASoC: mediatek: mt8195: mt8365-dai-adda: Use guard() for spin locks
ASoC: mediatek: mt8195: mt8365-dai-i2s: Use guard() for spin locks
sound/soc/mediatek/common/mtk-afe-fe-dai.c | 8 +-
sound/soc/mediatek/common/mtk-btcvsd.c | 81 +++++++++------------
sound/soc/mediatek/mt8186/mt8186-afe-gpio.c | 13 +---
sound/soc/mediatek/mt8188/mt8188-afe-clk.c | 29 +++-----
sound/soc/mediatek/mt8192/mt8192-afe-gpio.c | 4 +-
sound/soc/mediatek/mt8195/mt8195-afe-clk.c | 42 +++++------
sound/soc/mediatek/mt8195/mt8195-dai-etdm.c | 16 ++--
sound/soc/mediatek/mt8365/mt8365-afe-clk.c | 30 ++------
sound/soc/mediatek/mt8365/mt8365-dai-adda.c | 10 +--
sound/soc/mediatek/mt8365/mt8365-dai-i2s.c | 5 +-
10 files changed, 87 insertions(+), 151 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 01/10] ASoC: mediatek: common: mtk-afe-fe-dai: Use guard() for mutex locks
2026-06-10 10:20 [PATCH 00/10] ASoC: mediatek: Use guard() for mutex & spin locks phucduc.bui
@ 2026-06-10 10:20 ` phucduc.bui
2026-06-10 10:20 ` [PATCH 02/10] ASoC: mediatek: common: mtk-btcvsd: Use guard() for spin locks phucduc.bui
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: phucduc.bui @ 2026-06-10 10:20 UTC (permalink / raw)
To: Mark Brown, Matthias Brugger
Cc: Liam Girdwood, AngeloGioacchino Del Regno, Linus Walleij,
Bartosz Golaszewski, Jaroslav Kysela, Takashi Iwai, linux-sound,
linux-arm-kernel, linux-mediatek, linux-kernel, linux-gpio,
bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
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>
---
sound/soc/mediatek/common/mtk-afe-fe-dai.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/sound/soc/mediatek/common/mtk-afe-fe-dai.c b/sound/soc/mediatek/common/mtk-afe-fe-dai.c
index 3809068f5620..2a20fa5dba49 100644
--- a/sound/soc/mediatek/common/mtk-afe-fe-dai.c
+++ b/sound/soc/mediatek/common/mtk-afe-fe-dai.c
@@ -292,28 +292,24 @@ int mtk_dynamic_irq_acquire(struct mtk_base_afe *afe)
{
int i;
- mutex_lock(&afe->irq_alloc_lock);
+ guard(mutex)(&afe->irq_alloc_lock);
for (i = 0; i < afe->irqs_size; ++i) {
if (afe->irqs[i].irq_occupyed == 0) {
afe->irqs[i].irq_occupyed = 1;
- mutex_unlock(&afe->irq_alloc_lock);
return i;
}
}
- mutex_unlock(&afe->irq_alloc_lock);
return afe->irqs_size;
}
EXPORT_SYMBOL_GPL(mtk_dynamic_irq_acquire);
int mtk_dynamic_irq_release(struct mtk_base_afe *afe, int irq_id)
{
- mutex_lock(&afe->irq_alloc_lock);
+ guard(mutex)(&afe->irq_alloc_lock);
if (irq_id >= 0 && irq_id < afe->irqs_size) {
afe->irqs[irq_id].irq_occupyed = 0;
- mutex_unlock(&afe->irq_alloc_lock);
return 0;
}
- mutex_unlock(&afe->irq_alloc_lock);
return -EINVAL;
}
EXPORT_SYMBOL_GPL(mtk_dynamic_irq_release);
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 02/10] ASoC: mediatek: common: mtk-btcvsd: Use guard() for spin locks
2026-06-10 10:20 [PATCH 00/10] ASoC: mediatek: Use guard() for mutex & spin locks phucduc.bui
2026-06-10 10:20 ` [PATCH 01/10] ASoC: mediatek: common: mtk-afe-fe-dai: Use guard() for mutex locks phucduc.bui
@ 2026-06-10 10:20 ` phucduc.bui
2026-06-10 10:20 ` [PATCH 03/10] ASoC: mediatek: mt8186: mt8186-afe-gpio: Use guard() for mutex locks phucduc.bui
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: phucduc.bui @ 2026-06-10 10:20 UTC (permalink / raw)
To: Mark Brown, Matthias Brugger
Cc: Liam Girdwood, AngeloGioacchino Del Regno, Linus Walleij,
Bartosz Golaszewski, Jaroslav Kysela, Takashi Iwai, linux-sound,
linux-arm-kernel, linux-mediatek, linux-kernel, linux-gpio,
bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
Clean up the code using guard() for spin locks.
Merely code refactoring, and no behavior change.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/mediatek/common/mtk-btcvsd.c | 81 +++++++++++---------------
1 file changed, 35 insertions(+), 46 deletions(-)
diff --git a/sound/soc/mediatek/common/mtk-btcvsd.c b/sound/soc/mediatek/common/mtk-btcvsd.c
index 5e7e85b4c98a..85cfc602dfd3 100644
--- a/sound/soc/mediatek/common/mtk-btcvsd.c
+++ b/sound/soc/mediatek/common/mtk-btcvsd.c
@@ -319,7 +319,6 @@ static int btcvsd_tx_clean_buffer(struct mtk_btcvsd_snd *bt)
{
unsigned int i;
unsigned int num_valid_addr;
- unsigned long flags;
enum BT_SCO_BAND band = bt->band;
/* prepare encoded mute data */
@@ -330,7 +329,7 @@ static int btcvsd_tx_clean_buffer(struct mtk_btcvsd_snd *bt)
table_msbc_silence, SCO_PACKET_180);
/* write mute data to bt tx sram buffer */
- spin_lock_irqsave(&bt->tx_lock, flags);
+ guard(spinlock_irqsave)(&bt->tx_lock);
num_valid_addr = bt->tx->buffer_info.num_valid_addr;
dev_info(bt->dev, "%s(), band %d, num_valid_addr %u\n",
@@ -349,7 +348,6 @@ static int btcvsd_tx_clean_buffer(struct mtk_btcvsd_snd *bt)
bt->tx->buffer_info.packet_length,
bt->tx->buffer_info.packet_num);
}
- spin_unlock_irqrestore(&bt->tx_lock, flags);
return 0;
}
@@ -365,7 +363,6 @@ static int mtk_btcvsd_read_from_bt(struct mtk_btcvsd_snd *bt,
int pv;
u8 *src;
unsigned int packet_buf_ofs;
- unsigned long flags;
unsigned long connsys_addr_rx, ap_addr_rx;
connsys_addr_rx = *bt->bt_reg_pkt_r;
@@ -385,7 +382,7 @@ static int mtk_btcvsd_read_from_bt(struct mtk_btcvsd_snd *bt,
bt->rx->temp_packet_buf, packet_length,
packet_num);
- spin_lock_irqsave(&bt->rx_lock, flags);
+ guard(spinlock_irqsave)(&bt->rx_lock);
for (i = 0; i < blk_size; i++) {
packet_buf_ofs = (bt->rx->packet_w & SCO_RX_PACKET_MASK) *
bt->rx->packet_size;
@@ -403,7 +400,7 @@ static int mtk_btcvsd_read_from_bt(struct mtk_btcvsd_snd *bt,
SCO_CVSD_PACKET_VALID_SIZE);
bt->rx->packet_w++;
}
- spin_unlock_irqrestore(&bt->rx_lock, flags);
+
return 0;
}
@@ -414,7 +411,6 @@ static int mtk_btcvsd_write_to_bt(struct mtk_btcvsd_snd *bt,
unsigned int blk_size)
{
unsigned int i;
- unsigned long flags;
u8 *dst;
unsigned long connsys_addr_tx, ap_addr_tx;
bool new_ap_addr_tx = true;
@@ -430,17 +426,17 @@ static int mtk_btcvsd_write_to_bt(struct mtk_btcvsd_snd *bt,
return -EIO;
}
- spin_lock_irqsave(&bt->tx_lock, flags);
- for (i = 0; i < blk_size; i++) {
- memcpy(bt->tx->temp_packet_buf + (bt->tx->packet_size * i),
- (bt->tx_packet_buf +
- (bt->tx->packet_r % SCO_TX_PACKER_BUF_NUM) *
- bt->tx->packet_size),
- bt->tx->packet_size);
+ scoped_guard(spinlock_irqsave, &bt->tx_lock) {
+ for (i = 0; i < blk_size; i++) {
+ memcpy(bt->tx->temp_packet_buf + (bt->tx->packet_size * i),
+ (bt->tx_packet_buf +
+ (bt->tx->packet_r % SCO_TX_PACKER_BUF_NUM) *
+ bt->tx->packet_size),
+ bt->tx->packet_size);
- bt->tx->packet_r++;
+ bt->tx->packet_r++;
+ }
}
- spin_unlock_irqrestore(&bt->tx_lock, flags);
dst = (u8 *)ap_addr_tx;
@@ -462,11 +458,11 @@ static int mtk_btcvsd_write_to_bt(struct mtk_btcvsd_snd *bt,
if (new_ap_addr_tx) {
unsigned int next_idx;
- spin_lock_irqsave(&bt->tx_lock, flags);
- bt->tx->buffer_info.num_valid_addr++;
- next_idx = bt->tx->buffer_info.num_valid_addr - 1;
- bt->tx->buffer_info.bt_sram_addr[next_idx] = ap_addr_tx;
- spin_unlock_irqrestore(&bt->tx_lock, flags);
+ scoped_guard(spinlock_irqsave, &bt->tx_lock) {
+ bt->tx->buffer_info.num_valid_addr++;
+ next_idx = bt->tx->buffer_info.num_valid_addr - 1;
+ bt->tx->buffer_info.bt_sram_addr[next_idx] = ap_addr_tx;
+ }
dev_info(bt->dev, "%s(), new ap_addr_tx = 0x%lx, num_valid_addr %d\n",
__func__, ap_addr_tx,
bt->tx->buffer_info.num_valid_addr);
@@ -701,17 +697,16 @@ static ssize_t mtk_btcvsd_snd_read(struct mtk_btcvsd_snd *bt,
{
ssize_t read_size = 0, read_count = 0, cur_read_idx, cont;
unsigned long avail;
- unsigned long flags;
unsigned int packet_size = bt->rx->packet_size;
while (count) {
- spin_lock_irqsave(&bt->rx_lock, flags);
- /* available data in RX packet buffer */
- avail = (bt->rx->packet_w - bt->rx->packet_r) * packet_size;
+ scoped_guard(spinlock_irqsave, &bt->rx_lock) {
+ /* available data in RX packet buffer */
+ avail = (bt->rx->packet_w - bt->rx->packet_r) * packet_size;
- cur_read_idx = (bt->rx->packet_r & SCO_RX_PACKET_MASK) *
- packet_size;
- spin_unlock_irqrestore(&bt->rx_lock, flags);
+ cur_read_idx = (bt->rx->packet_r & SCO_RX_PACKET_MASK) *
+ packet_size;
+ }
if (!avail) {
int ret = wait_for_bt_irq(bt, bt->rx);
@@ -749,9 +744,8 @@ static ssize_t mtk_btcvsd_snd_read(struct mtk_btcvsd_snd *bt,
return -EFAULT;
}
- spin_lock_irqsave(&bt->rx_lock, flags);
- bt->rx->packet_r += read_size / packet_size;
- spin_unlock_irqrestore(&bt->rx_lock, flags);
+ scoped_guard(spinlock_irqsave, &bt->rx_lock)
+ bt->rx->packet_r += read_size / packet_size;
read_count += read_size;
count -= read_size;
@@ -778,7 +772,6 @@ static ssize_t mtk_btcvsd_snd_write(struct mtk_btcvsd_snd *bt,
size_t count)
{
int written_size = count, avail, cur_write_idx, write_size, cont;
- unsigned long flags;
unsigned int packet_size = bt->tx->packet_size;
/*
@@ -794,14 +787,14 @@ static ssize_t mtk_btcvsd_snd_write(struct mtk_btcvsd_snd *bt,
bt->tx->buf_data_equivalent_time *= 1000;
while (count) {
- spin_lock_irqsave(&bt->tx_lock, flags);
- /* free space of TX packet buffer */
- avail = bt->tx->buf_size -
- (bt->tx->packet_w - bt->tx->packet_r) * packet_size;
+ scoped_guard(spinlock_irqsave, &bt->tx_lock) {
+ /* free space of TX packet buffer */
+ avail = bt->tx->buf_size -
+ (bt->tx->packet_w - bt->tx->packet_r) * packet_size;
- cur_write_idx = (bt->tx->packet_w % SCO_TX_PACKER_BUF_NUM) *
- packet_size;
- spin_unlock_irqrestore(&bt->tx_lock, flags);
+ cur_write_idx = (bt->tx->packet_w % SCO_TX_PACKER_BUF_NUM) *
+ packet_size;
+ }
if (!avail) {
int ret = wait_for_bt_irq(bt, bt->tx);
@@ -838,9 +831,8 @@ static ssize_t mtk_btcvsd_snd_write(struct mtk_btcvsd_snd *bt,
return -EFAULT;
}
- spin_lock_irqsave(&bt->tx_lock, flags);
- bt->tx->packet_w += write_size / packet_size;
- spin_unlock_irqrestore(&bt->tx_lock, flags);
+ scoped_guard(spinlock_irqsave, &bt->tx_lock)
+ bt->tx->packet_w += write_size / packet_size;
count -= write_size;
}
@@ -985,7 +977,6 @@ static snd_pcm_uframes_t mtk_pcm_btcvsd_pointer(
int hw_packet_ptr;
int packet_diff;
spinlock_t *lock; /* spinlock for bt stream control */
- unsigned long flags;
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
lock = &bt->tx_lock;
@@ -995,7 +986,7 @@ static snd_pcm_uframes_t mtk_pcm_btcvsd_pointer(
bt_stream = bt->rx;
}
- spin_lock_irqsave(lock, flags);
+ guard(spinlock_irqsave)(lock);
hw_packet_ptr = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
bt->tx->packet_r : bt->rx->packet_w;
@@ -1018,8 +1009,6 @@ static snd_pcm_uframes_t mtk_pcm_btcvsd_pointer(
bt_stream->prev_frame = frame;
- spin_unlock_irqrestore(lock, flags);
-
return frame;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 03/10] ASoC: mediatek: mt8186: mt8186-afe-gpio: Use guard() for mutex locks
2026-06-10 10:20 [PATCH 00/10] ASoC: mediatek: Use guard() for mutex & spin locks phucduc.bui
2026-06-10 10:20 ` [PATCH 01/10] ASoC: mediatek: common: mtk-afe-fe-dai: Use guard() for mutex locks phucduc.bui
2026-06-10 10:20 ` [PATCH 02/10] ASoC: mediatek: common: mtk-btcvsd: Use guard() for spin locks phucduc.bui
@ 2026-06-10 10:20 ` phucduc.bui
2026-06-10 10:20 ` [PATCH 04/10] ASoC: mediatek: mt8188: mt8188-afe-clk: Use guard() for spin locks phucduc.bui
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: phucduc.bui @ 2026-06-10 10:20 UTC (permalink / raw)
To: Mark Brown, Matthias Brugger
Cc: Liam Girdwood, AngeloGioacchino Del Regno, Linus Walleij,
Bartosz Golaszewski, Jaroslav Kysela, Takashi Iwai, linux-sound,
linux-arm-kernel, linux-mediatek, linux-kernel, linux-gpio,
bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
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>
---
sound/soc/mediatek/mt8186/mt8186-afe-gpio.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/sound/soc/mediatek/mt8186/mt8186-afe-gpio.c b/sound/soc/mediatek/mt8186/mt8186-afe-gpio.c
index 9e86e7079718..aced8e7e920c 100644
--- a/sound/soc/mediatek/mt8186/mt8186-afe-gpio.c
+++ b/sound/soc/mediatek/mt8186/mt8186-afe-gpio.c
@@ -201,7 +201,7 @@ int mt8186_afe_gpio_request(struct device *dev, bool enable,
enum mt8186_afe_gpio sel;
int ret = -EINVAL;
- mutex_lock(&gpio_request_mutex);
+ guard(mutex)(&gpio_request_mutex);
switch (dai) {
case MT8186_DAI_ADDA:
@@ -209,7 +209,7 @@ int mt8186_afe_gpio_request(struct device *dev, bool enable,
ret = mt8186_afe_gpio_adda_ul(dev, enable);
else
ret = mt8186_afe_gpio_adda_dl(dev, enable);
- goto unlock;
+ return ret;
case MT8186_DAI_I2S_0:
sel = enable ? MT8186_AFE_GPIO_I2S0_ON : MT8186_AFE_GPIO_I2S0_OFF;
break;
@@ -230,13 +230,8 @@ int mt8186_afe_gpio_request(struct device *dev, bool enable,
break;
default:
dev_dbg(dev, "%s(), invalid dai %d\n", __func__, dai);
- goto unlock;
+ return ret;
}
- ret = mt8186_afe_gpio_select(dev, sel);
-
-unlock:
- mutex_unlock(&gpio_request_mutex);
-
- return ret;
+ return mt8186_afe_gpio_select(dev, sel);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 04/10] ASoC: mediatek: mt8188: mt8188-afe-clk: Use guard() for spin locks
2026-06-10 10:20 [PATCH 00/10] ASoC: mediatek: Use guard() for mutex & spin locks phucduc.bui
` (2 preceding siblings ...)
2026-06-10 10:20 ` [PATCH 03/10] ASoC: mediatek: mt8186: mt8186-afe-gpio: Use guard() for mutex locks phucduc.bui
@ 2026-06-10 10:20 ` phucduc.bui
2026-06-10 10:20 ` [PATCH 05/10] ASoC: mediatek: mt8192: mt8192-afe-gpio: Use guard() for mutex locks phucduc.bui
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: phucduc.bui @ 2026-06-10 10:20 UTC (permalink / raw)
To: Mark Brown, Matthias Brugger
Cc: Liam Girdwood, AngeloGioacchino Del Regno, Linus Walleij,
Bartosz Golaszewski, Jaroslav Kysela, Takashi Iwai, linux-sound,
linux-arm-kernel, linux-mediatek, linux-kernel, linux-gpio,
bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
Clean up the code using guard() for spin locks.
Merely code refactoring, and no behavior change.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/mediatek/mt8188/mt8188-afe-clk.c | 29 ++++++++--------------
1 file changed, 11 insertions(+), 18 deletions(-)
diff --git a/sound/soc/mediatek/mt8188/mt8188-afe-clk.c b/sound/soc/mediatek/mt8188/mt8188-afe-clk.c
index 7f411b857782..fc6cb3f0469e 100644
--- a/sound/soc/mediatek/mt8188/mt8188-afe-clk.c
+++ b/sound/soc/mediatek/mt8188/mt8188-afe-clk.c
@@ -301,7 +301,6 @@ static int mt8188_afe_disable_tuner_clk(struct mtk_base_afe *afe,
static int mt8188_afe_enable_apll_tuner(struct mtk_base_afe *afe, unsigned int id)
{
struct mt8188_afe_tuner_cfg *cfg = mt8188_afe_found_apll_tuner(id);
- unsigned long flags;
int ret;
if (!cfg)
@@ -315,8 +314,7 @@ static int mt8188_afe_enable_apll_tuner(struct mtk_base_afe *afe, unsigned int i
if (ret)
return ret;
- spin_lock_irqsave(&cfg->ctrl_lock, flags);
-
+ guard(spinlock_irqsave)(&cfg->ctrl_lock);
cfg->ref_cnt++;
if (cfg->ref_cnt == 1)
regmap_update_bits(afe->regmap,
@@ -324,32 +322,27 @@ static int mt8188_afe_enable_apll_tuner(struct mtk_base_afe *afe, unsigned int i
cfg->tuner_en_maskbit << cfg->tuner_en_shift,
BIT(cfg->tuner_en_shift));
- spin_unlock_irqrestore(&cfg->ctrl_lock, flags);
-
return 0;
}
static int mt8188_afe_disable_apll_tuner(struct mtk_base_afe *afe, unsigned int id)
{
struct mt8188_afe_tuner_cfg *cfg = mt8188_afe_found_apll_tuner(id);
- unsigned long flags;
int ret;
if (!cfg)
return -EINVAL;
- spin_lock_irqsave(&cfg->ctrl_lock, flags);
-
- cfg->ref_cnt--;
- if (cfg->ref_cnt == 0)
- regmap_update_bits(afe->regmap,
- cfg->tuner_en_reg,
- cfg->tuner_en_maskbit << cfg->tuner_en_shift,
- 0 << cfg->tuner_en_shift);
- else if (cfg->ref_cnt < 0)
- cfg->ref_cnt = 0;
-
- spin_unlock_irqrestore(&cfg->ctrl_lock, flags);
+ scoped_guard(spinlock_irqsave, &cfg->ctrl_lock) {
+ cfg->ref_cnt--;
+ if (cfg->ref_cnt == 0)
+ regmap_update_bits(afe->regmap,
+ cfg->tuner_en_reg,
+ cfg->tuner_en_maskbit << cfg->tuner_en_shift,
+ 0 << cfg->tuner_en_shift);
+ else if (cfg->ref_cnt < 0)
+ cfg->ref_cnt = 0;
+ }
ret = mt8188_afe_disable_tuner_clk(afe, id);
if (ret)
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 05/10] ASoC: mediatek: mt8192: mt8192-afe-gpio: Use guard() for mutex locks
2026-06-10 10:20 [PATCH 00/10] ASoC: mediatek: Use guard() for mutex & spin locks phucduc.bui
` (3 preceding siblings ...)
2026-06-10 10:20 ` [PATCH 04/10] ASoC: mediatek: mt8188: mt8188-afe-clk: Use guard() for spin locks phucduc.bui
@ 2026-06-10 10:20 ` phucduc.bui
2026-06-10 10:20 ` [PATCH 06/10] ASoC: mediatek: mt8195: mt8195-afe-clk: Use guard() for spin locks phucduc.bui
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: phucduc.bui @ 2026-06-10 10:20 UTC (permalink / raw)
To: Mark Brown, Matthias Brugger
Cc: Liam Girdwood, AngeloGioacchino Del Regno, Linus Walleij,
Bartosz Golaszewski, Jaroslav Kysela, Takashi Iwai, linux-sound,
linux-arm-kernel, linux-mediatek, linux-kernel, linux-gpio,
bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
Convert the explicit mutex_lock()/mutex_unlock() pair to guard(mutex)
to simplify the locking logic and automatically release the mutex on
all exit paths.
This changes the mutex release point from immediately before dev_warn()
to automatic cleanup at scope exit. However, the affected path only emits
a warning and immediately returns -EINVAL, without any further processing.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/mediatek/mt8192/mt8192-afe-gpio.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/sound/soc/mediatek/mt8192/mt8192-afe-gpio.c b/sound/soc/mediatek/mt8192/mt8192-afe-gpio.c
index de5e1deaa167..b993ca2dbd7c 100644
--- a/sound/soc/mediatek/mt8192/mt8192-afe-gpio.c
+++ b/sound/soc/mediatek/mt8192/mt8192-afe-gpio.c
@@ -208,7 +208,7 @@ static int mt8192_afe_gpio_adda_ch34_ul(struct device *dev, bool enable)
int mt8192_afe_gpio_request(struct device *dev, bool enable,
int dai, int uplink)
{
- mutex_lock(&gpio_request_mutex);
+ guard(mutex)(&gpio_request_mutex);
switch (dai) {
case MT8192_DAI_ADDA:
if (uplink)
@@ -296,11 +296,9 @@ int mt8192_afe_gpio_request(struct device *dev, bool enable,
}
break;
default:
- mutex_unlock(&gpio_request_mutex);
dev_warn(dev, "%s(), invalid dai %d\n", __func__, dai);
return -EINVAL;
}
- mutex_unlock(&gpio_request_mutex);
return 0;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 06/10] ASoC: mediatek: mt8195: mt8195-afe-clk: Use guard() for spin locks
2026-06-10 10:20 [PATCH 00/10] ASoC: mediatek: Use guard() for mutex & spin locks phucduc.bui
` (4 preceding siblings ...)
2026-06-10 10:20 ` [PATCH 05/10] ASoC: mediatek: mt8192: mt8192-afe-gpio: Use guard() for mutex locks phucduc.bui
@ 2026-06-10 10:20 ` phucduc.bui
2026-06-10 10:20 ` [PATCH 07/10] ASoC: mediatek: mt8195: mt8195-dai-etdm: " phucduc.bui
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: phucduc.bui @ 2026-06-10 10:20 UTC (permalink / raw)
To: Mark Brown, Matthias Brugger
Cc: Liam Girdwood, AngeloGioacchino Del Regno, Linus Walleij,
Bartosz Golaszewski, Jaroslav Kysela, Takashi Iwai, linux-sound,
linux-arm-kernel, linux-mediatek, linux-kernel, linux-gpio,
bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
Clean up the code using guard() for spin locks.
Merely code refactoring, and no behavior change.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/mediatek/mt8195/mt8195-afe-clk.c | 42 ++++++++++------------
1 file changed, 18 insertions(+), 24 deletions(-)
diff --git a/sound/soc/mediatek/mt8195/mt8195-afe-clk.c b/sound/soc/mediatek/mt8195/mt8195-afe-clk.c
index f35318ae0739..618d8400913a 100644
--- a/sound/soc/mediatek/mt8195/mt8195-afe-clk.c
+++ b/sound/soc/mediatek/mt8195/mt8195-afe-clk.c
@@ -283,7 +283,6 @@ static int mt8195_afe_enable_apll_tuner(struct mtk_base_afe *afe,
unsigned int id)
{
struct mt8195_afe_tuner_cfg *cfg = mt8195_afe_found_apll_tuner(id);
- unsigned long flags;
int ret;
if (!cfg)
@@ -297,16 +296,14 @@ static int mt8195_afe_enable_apll_tuner(struct mtk_base_afe *afe,
if (ret)
return ret;
- spin_lock_irqsave(&cfg->ctrl_lock, flags);
-
- cfg->ref_cnt++;
- if (cfg->ref_cnt == 1)
- regmap_update_bits(afe->regmap,
- cfg->tuner_en_reg,
- cfg->tuner_en_maskbit << cfg->tuner_en_shift,
- 1 << cfg->tuner_en_shift);
-
- spin_unlock_irqrestore(&cfg->ctrl_lock, flags);
+ scoped_guard(spinlock_irqsave, &cfg->ctrl_lock) {
+ cfg->ref_cnt++;
+ if (cfg->ref_cnt == 1)
+ regmap_update_bits(afe->regmap,
+ cfg->tuner_en_reg,
+ cfg->tuner_en_maskbit << cfg->tuner_en_shift,
+ 1 << cfg->tuner_en_shift);
+ }
return 0;
}
@@ -315,24 +312,21 @@ static int mt8195_afe_disable_apll_tuner(struct mtk_base_afe *afe,
unsigned int id)
{
struct mt8195_afe_tuner_cfg *cfg = mt8195_afe_found_apll_tuner(id);
- unsigned long flags;
int ret;
if (!cfg)
return -EINVAL;
- spin_lock_irqsave(&cfg->ctrl_lock, flags);
-
- cfg->ref_cnt--;
- if (cfg->ref_cnt == 0)
- regmap_update_bits(afe->regmap,
- cfg->tuner_en_reg,
- cfg->tuner_en_maskbit << cfg->tuner_en_shift,
- 0 << cfg->tuner_en_shift);
- else if (cfg->ref_cnt < 0)
- cfg->ref_cnt = 0;
-
- spin_unlock_irqrestore(&cfg->ctrl_lock, flags);
+ scoped_guard(spinlock_irqsave, &cfg->ctrl_lock) {
+ cfg->ref_cnt--;
+ if (cfg->ref_cnt == 0)
+ regmap_update_bits(afe->regmap,
+ cfg->tuner_en_reg,
+ cfg->tuner_en_maskbit << cfg->tuner_en_shift,
+ 0 << cfg->tuner_en_shift);
+ else if (cfg->ref_cnt < 0)
+ cfg->ref_cnt = 0;
+ }
ret = mt8195_afe_disable_tuner_clk(afe, id);
if (ret)
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 07/10] ASoC: mediatek: mt8195: mt8195-dai-etdm: Use guard() for spin locks
2026-06-10 10:20 [PATCH 00/10] ASoC: mediatek: Use guard() for mutex & spin locks phucduc.bui
` (5 preceding siblings ...)
2026-06-10 10:20 ` [PATCH 06/10] ASoC: mediatek: mt8195: mt8195-afe-clk: Use guard() for spin locks phucduc.bui
@ 2026-06-10 10:20 ` phucduc.bui
2026-06-10 10:20 ` [PATCH 08/10] ASoC: mediatek: mt8195: mt8365-afe-clk: Use guard() for mutex & " phucduc.bui
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: phucduc.bui @ 2026-06-10 10:20 UTC (permalink / raw)
To: Mark Brown, Matthias Brugger
Cc: Liam Girdwood, AngeloGioacchino Del Regno, Linus Walleij,
Bartosz Golaszewski, Jaroslav Kysela, Takashi Iwai, linux-sound,
linux-arm-kernel, linux-mediatek, linux-kernel, linux-gpio,
bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
Clean up the code using guard() for spin locks.
Merely code refactoring, and no behavior change.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/mediatek/mt8195/mt8195-dai-etdm.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/sound/soc/mediatek/mt8195/mt8195-dai-etdm.c b/sound/soc/mediatek/mt8195/mt8195-dai-etdm.c
index 5dcc8ed26e00..1a20adb2cbf5 100644
--- a/sound/soc/mediatek/mt8195/mt8195-dai-etdm.c
+++ b/sound/soc/mediatek/mt8195/mt8195-dai-etdm.c
@@ -1318,24 +1318,22 @@ static int mt8195_afe_enable_etdm(struct mtk_base_afe *afe, int dai_id)
struct etdm_con_reg etdm_reg;
struct mt8195_afe_private *afe_priv = afe->platform_priv;
struct mtk_dai_etdm_priv *etdm_data;
- unsigned long flags;
if (!mt8195_afe_etdm_is_valid(dai_id))
return -EINVAL;
etdm_data = afe_priv->dai_priv[dai_id];
- spin_lock_irqsave(&afe_priv->afe_ctrl_lock, flags);
+ guard(spinlock_irqsave)(&afe_priv->afe_ctrl_lock);
etdm_data->en_ref_cnt++;
if (etdm_data->en_ref_cnt == 1) {
ret = get_etdm_reg(dai_id, &etdm_reg);
if (ret < 0)
- goto out;
+ return ret;
regmap_update_bits(afe->regmap, etdm_reg.con0,
ETDM_CON0_EN, ETDM_CON0_EN);
}
-out:
- spin_unlock_irqrestore(&afe_priv->afe_ctrl_lock, flags);
+
return ret;
}
@@ -1345,26 +1343,24 @@ static int mt8195_afe_disable_etdm(struct mtk_base_afe *afe, int dai_id)
struct etdm_con_reg etdm_reg;
struct mt8195_afe_private *afe_priv = afe->platform_priv;
struct mtk_dai_etdm_priv *etdm_data;
- unsigned long flags;
if (!mt8195_afe_etdm_is_valid(dai_id))
return -EINVAL;
etdm_data = afe_priv->dai_priv[dai_id];
- spin_lock_irqsave(&afe_priv->afe_ctrl_lock, flags);
+ guard(spinlock_irqsave)(&afe_priv->afe_ctrl_lock);
if (etdm_data->en_ref_cnt > 0) {
etdm_data->en_ref_cnt--;
if (etdm_data->en_ref_cnt == 0) {
ret = get_etdm_reg(dai_id, &etdm_reg);
if (ret < 0)
- goto out;
+ return ret;
regmap_update_bits(afe->regmap, etdm_reg.con0,
ETDM_CON0_EN, 0);
}
}
-out:
- spin_unlock_irqrestore(&afe_priv->afe_ctrl_lock, flags);
+
return ret;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 08/10] ASoC: mediatek: mt8195: mt8365-afe-clk: Use guard() for mutex & spin locks
2026-06-10 10:20 [PATCH 00/10] ASoC: mediatek: Use guard() for mutex & spin locks phucduc.bui
` (6 preceding siblings ...)
2026-06-10 10:20 ` [PATCH 07/10] ASoC: mediatek: mt8195: mt8195-dai-etdm: " phucduc.bui
@ 2026-06-10 10:20 ` phucduc.bui
2026-06-10 10:20 ` [PATCH 09/10] ASoC: mediatek: mt8195: mt8365-dai-adda: Use guard() for " phucduc.bui
2026-06-10 10:20 ` [PATCH 10/10] ASoC: mediatek: mt8195: mt8365-dai-i2s: " phucduc.bui
9 siblings, 0 replies; 11+ messages in thread
From: phucduc.bui @ 2026-06-10 10:20 UTC (permalink / raw)
To: Mark Brown, Matthias Brugger
Cc: Liam Girdwood, AngeloGioacchino Del Regno, Linus Walleij,
Bartosz Golaszewski, Jaroslav Kysela, Takashi Iwai, linux-sound,
linux-arm-kernel, linux-mediatek, linux-kernel, linux-gpio,
bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
Clean up the code using guard() for mutex & spin locks.
Merely code refactoring, and no behavior change.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/mediatek/mt8365/mt8365-afe-clk.c | 30 +++++-----------------
1 file changed, 7 insertions(+), 23 deletions(-)
diff --git a/sound/soc/mediatek/mt8365/mt8365-afe-clk.c b/sound/soc/mediatek/mt8365/mt8365-afe-clk.c
index 7078c01ba19b..af96aa446fe2 100644
--- a/sound/soc/mediatek/mt8365/mt8365-afe-clk.c
+++ b/sound/soc/mediatek/mt8365/mt8365-afe-clk.c
@@ -194,16 +194,13 @@ int mt8365_afe_enable_top_cg(struct mtk_base_afe *afe, unsigned int cg_type)
unsigned int reg = get_top_cg_reg(cg_type);
unsigned int mask = get_top_cg_mask(cg_type);
unsigned int val = get_top_cg_on_val(cg_type);
- unsigned long flags;
- spin_lock_irqsave(&afe_priv->afe_ctrl_lock, flags);
+ guard(spinlock_irqsave)(&afe_priv->afe_ctrl_lock);
afe_priv->top_cg_ref_cnt[cg_type]++;
if (afe_priv->top_cg_ref_cnt[cg_type] == 1)
regmap_update_bits(afe->regmap, reg, mask, val);
- spin_unlock_irqrestore(&afe_priv->afe_ctrl_lock, flags);
-
return 0;
}
@@ -213,9 +210,8 @@ int mt8365_afe_disable_top_cg(struct mtk_base_afe *afe, unsigned int cg_type)
unsigned int reg = get_top_cg_reg(cg_type);
unsigned int mask = get_top_cg_mask(cg_type);
unsigned int val = get_top_cg_off_val(cg_type);
- unsigned long flags;
- spin_lock_irqsave(&afe_priv->afe_ctrl_lock, flags);
+ guard(spinlock_irqsave)(&afe_priv->afe_ctrl_lock);
afe_priv->top_cg_ref_cnt[cg_type]--;
if (afe_priv->top_cg_ref_cnt[cg_type] == 0)
@@ -223,8 +219,6 @@ int mt8365_afe_disable_top_cg(struct mtk_base_afe *afe, unsigned int cg_type)
else if (afe_priv->top_cg_ref_cnt[cg_type] < 0)
afe_priv->top_cg_ref_cnt[cg_type] = 0;
- spin_unlock_irqrestore(&afe_priv->afe_ctrl_lock, flags);
-
return 0;
}
@@ -263,25 +257,21 @@ int mt8365_afe_emi_clk_off(struct mtk_base_afe *afe)
int mt8365_afe_enable_afe_on(struct mtk_base_afe *afe)
{
struct mt8365_afe_private *afe_priv = afe->platform_priv;
- unsigned long flags;
- spin_lock_irqsave(&afe_priv->afe_ctrl_lock, flags);
+ guard(spinlock_irqsave)(&afe_priv->afe_ctrl_lock);
afe_priv->afe_on_ref_cnt++;
if (afe_priv->afe_on_ref_cnt == 1)
regmap_update_bits(afe->regmap, AFE_DAC_CON0, 0x1, 0x1);
- spin_unlock_irqrestore(&afe_priv->afe_ctrl_lock, flags);
-
return 0;
}
int mt8365_afe_disable_afe_on(struct mtk_base_afe *afe)
{
struct mt8365_afe_private *afe_priv = afe->platform_priv;
- unsigned long flags;
- spin_lock_irqsave(&afe_priv->afe_ctrl_lock, flags);
+ guard(spinlock_irqsave)(&afe_priv->afe_ctrl_lock);
afe_priv->afe_on_ref_cnt--;
if (afe_priv->afe_on_ref_cnt == 0)
@@ -289,8 +279,6 @@ int mt8365_afe_disable_afe_on(struct mtk_base_afe *afe)
else if (afe_priv->afe_on_ref_cnt < 0)
afe_priv->afe_on_ref_cnt = 0;
- spin_unlock_irqrestore(&afe_priv->afe_ctrl_lock, flags);
-
return 0;
}
@@ -322,13 +310,11 @@ int mt8365_afe_enable_apll_tuner_cfg(struct mtk_base_afe *afe, unsigned int apll
{
struct mt8365_afe_private *afe_priv = afe->platform_priv;
- mutex_lock(&afe_priv->afe_clk_mutex);
+ guard(mutex)(&afe_priv->afe_clk_mutex);
afe_priv->apll_tuner_ref_cnt[apll]++;
- if (afe_priv->apll_tuner_ref_cnt[apll] != 1) {
- mutex_unlock(&afe_priv->afe_clk_mutex);
+ if (afe_priv->apll_tuner_ref_cnt[apll] != 1)
return 0;
- }
if (apll == MT8365_AFE_APLL1) {
regmap_update_bits(afe->regmap, AFE_APLL_TUNER_CFG,
@@ -342,7 +328,6 @@ int mt8365_afe_enable_apll_tuner_cfg(struct mtk_base_afe *afe, unsigned int apll
AFE_APLL_TUNER_CFG1_EN_MASK, 0x1);
}
- mutex_unlock(&afe_priv->afe_clk_mutex);
return 0;
}
@@ -350,7 +335,7 @@ int mt8365_afe_disable_apll_tuner_cfg(struct mtk_base_afe *afe, unsigned int apl
{
struct mt8365_afe_private *afe_priv = afe->platform_priv;
- mutex_lock(&afe_priv->afe_clk_mutex);
+ guard(mutex)(&afe_priv->afe_clk_mutex);
afe_priv->apll_tuner_ref_cnt[apll]--;
if (afe_priv->apll_tuner_ref_cnt[apll] == 0) {
@@ -365,7 +350,6 @@ int mt8365_afe_disable_apll_tuner_cfg(struct mtk_base_afe *afe, unsigned int apl
afe_priv->apll_tuner_ref_cnt[apll] = 0;
}
- mutex_unlock(&afe_priv->afe_clk_mutex);
return 0;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 09/10] ASoC: mediatek: mt8195: mt8365-dai-adda: Use guard() for spin locks
2026-06-10 10:20 [PATCH 00/10] ASoC: mediatek: Use guard() for mutex & spin locks phucduc.bui
` (7 preceding siblings ...)
2026-06-10 10:20 ` [PATCH 08/10] ASoC: mediatek: mt8195: mt8365-afe-clk: Use guard() for mutex & " phucduc.bui
@ 2026-06-10 10:20 ` phucduc.bui
2026-06-10 10:20 ` [PATCH 10/10] ASoC: mediatek: mt8195: mt8365-dai-i2s: " phucduc.bui
9 siblings, 0 replies; 11+ messages in thread
From: phucduc.bui @ 2026-06-10 10:20 UTC (permalink / raw)
To: Mark Brown, Matthias Brugger
Cc: Liam Girdwood, AngeloGioacchino Del Regno, Linus Walleij,
Bartosz Golaszewski, Jaroslav Kysela, Takashi Iwai, linux-sound,
linux-arm-kernel, linux-mediatek, linux-kernel, linux-gpio,
bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
Clean up the code using guard() for spin locks.
Merely code refactoring, and no behavior change.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/mediatek/mt8365/mt8365-dai-adda.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/sound/soc/mediatek/mt8365/mt8365-dai-adda.c b/sound/soc/mediatek/mt8365/mt8365-dai-adda.c
index a04c24bbfcff..d8eda9e17eb8 100644
--- a/sound/soc/mediatek/mt8365/mt8365-dai-adda.c
+++ b/sound/soc/mediatek/mt8365/mt8365-dai-adda.c
@@ -63,10 +63,9 @@ static int mt8365_dai_set_adda_in(struct mtk_base_afe *afe, unsigned int rate)
int mt8365_dai_enable_adda_on(struct mtk_base_afe *afe)
{
- unsigned long flags;
struct mt8365_afe_private *afe_priv = afe->platform_priv;
- spin_lock_irqsave(&afe_priv->afe_ctrl_lock, flags);
+ guard(spinlock_irqsave)(&afe_priv->afe_ctrl_lock);
adda_afe_on_ref_cnt++;
if (adda_afe_on_ref_cnt == 1)
@@ -74,17 +73,14 @@ int mt8365_dai_enable_adda_on(struct mtk_base_afe *afe)
AFE_ADDA_UL_DL_ADDA_AFE_ON,
AFE_ADDA_UL_DL_ADDA_AFE_ON);
- spin_unlock_irqrestore(&afe_priv->afe_ctrl_lock, flags);
-
return 0;
}
int mt8365_dai_disable_adda_on(struct mtk_base_afe *afe)
{
- unsigned long flags;
struct mt8365_afe_private *afe_priv = afe->platform_priv;
- spin_lock_irqsave(&afe_priv->afe_ctrl_lock, flags);
+ guard(spinlock_irqsave)(&afe_priv->afe_ctrl_lock);
adda_afe_on_ref_cnt--;
if (adda_afe_on_ref_cnt == 0)
@@ -96,8 +92,6 @@ int mt8365_dai_disable_adda_on(struct mtk_base_afe *afe)
dev_warn(afe->dev, "Abnormal adda_on ref count. Force it to 0\n");
}
- spin_unlock_irqrestore(&afe_priv->afe_ctrl_lock, flags);
-
return 0;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 10/10] ASoC: mediatek: mt8195: mt8365-dai-i2s: Use guard() for spin locks
2026-06-10 10:20 [PATCH 00/10] ASoC: mediatek: Use guard() for mutex & spin locks phucduc.bui
` (8 preceding siblings ...)
2026-06-10 10:20 ` [PATCH 09/10] ASoC: mediatek: mt8195: mt8365-dai-adda: Use guard() for " phucduc.bui
@ 2026-06-10 10:20 ` phucduc.bui
9 siblings, 0 replies; 11+ messages in thread
From: phucduc.bui @ 2026-06-10 10:20 UTC (permalink / raw)
To: Mark Brown, Matthias Brugger
Cc: Liam Girdwood, AngeloGioacchino Del Regno, Linus Walleij,
Bartosz Golaszewski, Jaroslav Kysela, Takashi Iwai, linux-sound,
linux-arm-kernel, linux-mediatek, linux-kernel, linux-gpio,
bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
Clean up the code using guard() for spin locks.
Merely code refactoring, and no behavior change.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/mediatek/mt8365/mt8365-dai-i2s.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/sound/soc/mediatek/mt8365/mt8365-dai-i2s.c b/sound/soc/mediatek/mt8365/mt8365-dai-i2s.c
index cb9beb172ed5..a058973662b3 100644
--- a/sound/soc/mediatek/mt8365/mt8365-dai-i2s.c
+++ b/sound/soc/mediatek/mt8365/mt8365-dai-i2s.c
@@ -463,7 +463,6 @@ static int mt8365_afe_set_2nd_i2s_asrc_enable(struct mtk_base_afe *afe,
void mt8365_afe_set_i2s_out_enable(struct mtk_base_afe *afe, bool enable)
{
int i;
- unsigned long flags;
struct mt8365_afe_private *afe_priv = afe->platform_priv;
struct mtk_afe_i2s_priv *i2s_data = NULL;
@@ -475,7 +474,7 @@ void mt8365_afe_set_i2s_out_enable(struct mtk_base_afe *afe, bool enable)
if (!i2s_data)
return;
- spin_lock_irqsave(&afe_priv->afe_ctrl_lock, flags);
+ guard(spinlock_irqsave)(&afe_priv->afe_ctrl_lock);
if (enable) {
i2s_data->i2s_out_on_ref_cnt++;
@@ -490,8 +489,6 @@ void mt8365_afe_set_i2s_out_enable(struct mtk_base_afe *afe, bool enable)
else if (i2s_data->i2s_out_on_ref_cnt < 0)
i2s_data->i2s_out_on_ref_cnt = 0;
}
-
- spin_unlock_irqrestore(&afe_priv->afe_ctrl_lock, flags);
}
static void mt8365_dai_set_enable(struct mtk_base_afe *afe,
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
end of thread, other threads:[~2026-06-10 10:21 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-10 10:20 [PATCH 00/10] ASoC: mediatek: Use guard() for mutex & spin locks phucduc.bui
2026-06-10 10:20 ` [PATCH 01/10] ASoC: mediatek: common: mtk-afe-fe-dai: Use guard() for mutex locks phucduc.bui
2026-06-10 10:20 ` [PATCH 02/10] ASoC: mediatek: common: mtk-btcvsd: Use guard() for spin locks phucduc.bui
2026-06-10 10:20 ` [PATCH 03/10] ASoC: mediatek: mt8186: mt8186-afe-gpio: Use guard() for mutex locks phucduc.bui
2026-06-10 10:20 ` [PATCH 04/10] ASoC: mediatek: mt8188: mt8188-afe-clk: Use guard() for spin locks phucduc.bui
2026-06-10 10:20 ` [PATCH 05/10] ASoC: mediatek: mt8192: mt8192-afe-gpio: Use guard() for mutex locks phucduc.bui
2026-06-10 10:20 ` [PATCH 06/10] ASoC: mediatek: mt8195: mt8195-afe-clk: Use guard() for spin locks phucduc.bui
2026-06-10 10:20 ` [PATCH 07/10] ASoC: mediatek: mt8195: mt8195-dai-etdm: " phucduc.bui
2026-06-10 10:20 ` [PATCH 08/10] ASoC: mediatek: mt8195: mt8365-afe-clk: Use guard() for mutex & " phucduc.bui
2026-06-10 10:20 ` [PATCH 09/10] ASoC: mediatek: mt8195: mt8365-dai-adda: Use guard() for " phucduc.bui
2026-06-10 10:20 ` [PATCH 10/10] ASoC: mediatek: mt8195: mt8365-dai-i2s: " phucduc.bui
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox