[PATCH] mtd: nand: Use guard for mutex in nand_suspend
From: Richard Lyu
Date: Thu Mar 12 2026 - 10:44:47 EST
Refactor nand_suspend() to use the guard(mutex) macro instead of explicit
mutex_lock() and mutex_unlock() calls. This simplifies the code and
improves safety by ensuring the mutex is always released via the
RAII-based cleanup infrastructure when the function returns.
No functional changes intended.
Signed-off-by: Richard Lyu <richard.lyu@xxxxxxxx>
---
drivers/mtd/nand/raw/nand_base.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
index 9e3561f34ea8..93ba5dec1669 100644
--- a/drivers/mtd/nand/raw/nand_base.c
+++ b/drivers/mtd/nand/raw/nand_base.c
@@ -4687,12 +4687,11 @@ static int nand_suspend(struct mtd_info *mtd)
struct nand_chip *chip = mtd_to_nand(mtd);
int ret = 0;
- mutex_lock(&chip->lock);
+ guard(mutex)(&chip->lock);
if (chip->ops.suspend)
ret = chip->ops.suspend(chip);
if (!ret)
chip->suspended = 1;
- mutex_unlock(&chip->lock);
return ret;
}
--
2.51.0