[PATCH 5/7] ASoC: ti: ams-delta: Use guard() for spin locks
From: phucduc . bui
Date: Fri May 08 2026 - 06:43:01 EST
From: bui duc phuc <phucduc.bui@xxxxxxxxx>
Clean up the code using guard() for spin locks.
Merely code refactoring, and no behavior change.
Signed-off-by: bui duc phuc <phucduc.bui@xxxxxxxxx>
---
sound/soc/ti/ams-delta.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/sound/soc/ti/ams-delta.c b/sound/soc/ti/ams-delta.c
index ba173d9fcba9..6dd0d051a757 100644
--- a/sound/soc/ti/ams-delta.c
+++ b/sound/soc/ti/ams-delta.c
@@ -264,10 +264,10 @@ static void cx81801_timeout(struct timer_list *unused)
{
int muted;
- spin_lock(&ams_delta_lock);
- cx81801_cmd_pending = 0;
- muted = ams_delta_muted;
- spin_unlock(&ams_delta_lock);
+ scoped_guard(spinlock, &ams_delta_lock) {
+ cx81801_cmd_pending = 0;
+ muted = ams_delta_muted;
+ }
/* Reconnect the codec DAI back from the modem to the CPU DAI
* only if digital mute still off */
@@ -373,11 +373,11 @@ static void cx81801_receive(struct tty_struct *tty, const u8 *cp, const u8 *fp,
continue;
/* Complete modem response received, apply config to codec */
- spin_lock_bh(&ams_delta_lock);
- mod_timer(&cx81801_timer, jiffies + msecs_to_jiffies(150));
- apply = !ams_delta_muted && !cx81801_cmd_pending;
- cx81801_cmd_pending = 1;
- spin_unlock_bh(&ams_delta_lock);
+ scoped_guard(spinlock_bh, &ams_delta_lock) {
+ mod_timer(&cx81801_timer, jiffies + msecs_to_jiffies(150));
+ apply = !ams_delta_muted && !cx81801_cmd_pending;
+ cx81801_cmd_pending = 1;
+ }
/* Apply config pulse by connecting the codec to the modem
* if not already done */
@@ -426,10 +426,10 @@ static int ams_delta_mute(struct snd_soc_dai *dai, int mute, int direction)
if (ams_delta_muted == mute)
return 0;
- spin_lock_bh(&ams_delta_lock);
- ams_delta_muted = mute;
- apply = !cx81801_cmd_pending;
- spin_unlock_bh(&ams_delta_lock);
+ scoped_guard(spinlock_bh, &ams_delta_lock) {
+ ams_delta_muted = mute;
+ apply = !cx81801_cmd_pending;
+ }
if (apply)
gpiod_set_value(gpiod_modem_codec, !!mute);
--
2.43.0