From: Richard Lyu <richard.lyu@suse.com>
To: Richard Weinberger <richard@nod.at>
Cc: Vignesh Raghavendra <vigneshr@ti.com>,
Richard Lyu <richard.lyu@suse.com>,
Aryan Srivastava <aryan.srivastava@alliedtelesis.co.nz>,
Thomas Gleixner <tglx@kernel.org>,
Markus Stockhausen <markus.stockhausen@gmx.de>,
Kees Cook <kees@kernel.org>,
linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: [PATCH] mtd: nand: Use guard for mutex in nand_suspend
Date: Thu, 12 Mar 2026 22:44:25 +0800 [thread overview]
Message-ID: <20260312144408.489659-1-richard.lyu@suse.com> (raw)
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@suse.com>
---
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
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
reply other threads:[~2026-03-12 14:44 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260312144408.489659-1-richard.lyu@suse.com \
--to=richard.lyu@suse.com \
--cc=aryan.srivastava@alliedtelesis.co.nz \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=markus.stockhausen@gmx.de \
--cc=richard@nod.at \
--cc=tglx@kernel.org \
--cc=vigneshr@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox