Skip to contentSkip to conversation

mtd: nand: Use guard for mutex in nand_suspend

PATCH New Richard Lyu 1 participant 1 message Mar 12

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: nand: Use guard for mutex in nand_suspend

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.

---
 drivers/mtd/nand/raw/nand_base.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/mtd/nand/raw/nand_base.c +1 -2
index 9e3561f34ea8..93ba5dec1669 100644
@@ -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;
 }
Signature · 1 line
2.51.0