From 7a3dc0da931ea7c8a1f2e585a0465131f3c9e556 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 29 Aug 2025 17:13:15 +0200 Subject: [PATCH] ALSA: i2c: Use guard() for mutex locks Replace the manual mutex lock/unlock pairs with guard() for code simplification. Only code refactoring, and no behavior change. Signed-off-by: Takashi Iwai Link: https://patch.msgid.link/20250829151335.7342-2-tiwai@suse.de --- sound/i2c/other/ak4113.c | 6 +++--- sound/i2c/other/ak4114.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sound/i2c/other/ak4113.c b/sound/i2c/other/ak4113.c index c1f7447a4d11d..fd54e44fe7d65 100644 --- a/sound/i2c/other/ak4113.c +++ b/sound/i2c/other/ak4113.c @@ -127,9 +127,9 @@ void snd_ak4113_reinit(struct ak4113 *chip) { if (atomic_inc_return(&chip->wq_processing) == 1) cancel_delayed_work_sync(&chip->work); - mutex_lock(&chip->reinit_mutex); - ak4113_init_regs(chip); - mutex_unlock(&chip->reinit_mutex); + scoped_guard(mutex, &chip->reinit_mutex) { + ak4113_init_regs(chip); + } /* bring up statistics / event queing */ if (atomic_dec_and_test(&chip->wq_processing)) schedule_delayed_work(&chip->work, HZ / 10); diff --git a/sound/i2c/other/ak4114.c b/sound/i2c/other/ak4114.c index 7c493681f3cb6..f4ded69bb0e42 100644 --- a/sound/i2c/other/ak4114.c +++ b/sound/i2c/other/ak4114.c @@ -132,9 +132,9 @@ void snd_ak4114_reinit(struct ak4114 *chip) { if (atomic_inc_return(&chip->wq_processing) == 1) cancel_delayed_work_sync(&chip->work); - mutex_lock(&chip->reinit_mutex); - ak4114_init_regs(chip); - mutex_unlock(&chip->reinit_mutex); + scoped_guard(mutex, &chip->reinit_mutex) { + ak4114_init_regs(chip); + } /* bring up statistics / event queing */ if (atomic_dec_and_test(&chip->wq_processing)) schedule_delayed_work(&chip->work, HZ / 10); -- 2.47.3