[PATCH 16/27] ASoC: codecs: peb2466: Use guard() for mutex locks
phucduc.bui at gmail.com
phucduc.bui at gmail.com
Mon Jun 29 23:34:38 PDT 2026
From: bui duc phuc <phucduc.bui at 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 at gmail.com>
---
sound/soc/codecs/peb2466.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/sound/soc/codecs/peb2466.c b/sound/soc/codecs/peb2466.c
index 2d71d204d8fa..5a1ed02abb84 100644
--- a/sound/soc/codecs/peb2466.c
+++ b/sound/soc/codecs/peb2466.c
@@ -6,6 +6,7 @@
//
// Author: Herve Codina <herve.codina at bootlin.com>
+#include <linux/cleanup.h>
#include <linux/unaligned.h>
#include <linux/clk.h>
#include <linux/firmware.h>
@@ -1704,13 +1705,11 @@ static int peb2466_chip_gpio_update_bits(struct peb2466 *peb2466, unsigned int x
* So, a specific cache value is used.
*/
- mutex_lock(&peb2466->gpio.lock);
+ guard(mutex)(&peb2466->gpio.lock);
cache = peb2466_chip_gpio_get_cache(peb2466, xr_reg);
- if (!cache) {
- ret = -EINVAL;
- goto end;
- }
+ if (!cache)
+ return -EINVAL;
tmp = *cache;
tmp &= ~mask;
@@ -1718,14 +1717,11 @@ static int peb2466_chip_gpio_update_bits(struct peb2466 *peb2466, unsigned int x
ret = regmap_write(peb2466->regmap, xr_reg, tmp);
if (ret)
- goto end;
+ return ret;
*cache = tmp;
- ret = 0;
-end:
- mutex_unlock(&peb2466->gpio.lock);
- return ret;
+ return 0;
}
static int peb2466_chip_gpio_set(struct gpio_chip *c, unsigned int offset,
--
2.43.0
More information about the Linux-mediatek
mailing list