[PATCH] mtd: rawnand: Add status chack in r852_ready()

Wentao Liang posted 1 patch 10 months, 1 week ago
drivers/mtd/nand/raw/r852.c | 3 +++
1 file changed, 3 insertions(+)
[PATCH] mtd: rawnand: Add status chack in r852_ready()
Posted by Wentao Liang 10 months, 1 week ago
In r852_ready(), the dev get from r852_get_dev() need to be checked.
An unstable device should not be ready. A proper implementation can
be found in r852_read_byte(). Add a status check and return 0 when it is
unstable.

Fixes: 50a487e7719c ("mtd: rawnand: Pass a nand_chip object to chip->dev_ready()")
Cc: stable@vger.kernel.org # v4.20+
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/mtd/nand/raw/r852.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/mtd/nand/raw/r852.c b/drivers/mtd/nand/raw/r852.c
index b07c2f8b4035..918974d088cf 100644
--- a/drivers/mtd/nand/raw/r852.c
+++ b/drivers/mtd/nand/raw/r852.c
@@ -387,6 +387,9 @@ static int r852_wait(struct nand_chip *chip)
 static int r852_ready(struct nand_chip *chip)
 {
 	struct r852_device *dev = r852_get_dev(nand_to_mtd(chip));
+	if (dev->card_unstable)
+		return 0;
+
 	return !(r852_read_reg(dev, R852_CARD_STA) & R852_CARD_STA_BUSY);
 }
 
-- 
2.42.0.windows.2
Re: [PATCH] mtd: rawnand: Add status chack in r852_ready()
Posted by Miquel Raynal 10 months ago
On Wed, 02 Apr 2025 15:56:23 +0800, Wentao Liang wrote:
> In r852_ready(), the dev get from r852_get_dev() need to be checked.
> An unstable device should not be ready. A proper implementation can
> be found in r852_read_byte(). Add a status check and return 0 when it is
> unstable.
> 
> 

Applied to mtd/fixes, thanks!

[1/1] mtd: rawnand: Add status chack in r852_ready()
      commit: b79fe1829975556854665258cf4d2476784a89db

Patche(s) should be available on mtd/linux.git and will be
part of the next PR (provided that no robot complains by then).

Kind regards,
Miquèl