[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1443193758-22071-3-git-send-email-boris.brezillon@free-electrons.com>
Date: Fri, 25 Sep 2015 17:09:15 +0200
From: Boris Brezillon <boris.brezillon@...e-electrons.com>
To: David Woodhouse <dwmw2@...radead.org>,
Brian Norris <computersforpeace@...il.com>,
linux-mtd@...ts.infradead.org,
Artem Bityutskiy <dedekind1@...il.com>,
Richard Weinberger <richard@....at>
Cc: Andrea Scian <rnd4@...e-tech.it>,
Bean Huo 霍斌斌 (beanhuo)
<beanhuo@...ron.com>,
Karl Zhang 张双锣 (karlzhang)
<karlzhang@...ron.com>,
Iwo Mergler <Iwo.Mergler@...commwireless.com>,
"Jeff Lauruhn (jlauruhn)" <jlauruhn@...ron.com>,
Stefan Roese <sr@...x.de>, linux-kernel@...r.kernel.org,
Boris Brezillon <boris.brezillon@...e-electrons.com>
Subject: [PATCH 2/5] mtd: nand: return -EROFS in case of power-cut emulation
Now that we are able to emulate power-cuts, we should differentiate the
power-cut emulation and input/output error cases to let the MTD user
decide what it should do.
EROFS was chosen to mimic what's done in UBI when a power-cut emulation
occurs.
Signed-off-by: Boris Brezillon <boris.brezillon@...e-electrons.com>
---
drivers/mtd/nand/nand_base.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index a621814..223aabdb 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -1951,6 +1951,9 @@ static int nand_write_oob_std(struct mtd_info *mtd, struct nand_chip *chip,
status = chip->waitfunc(mtd, chip);
+ if (unlikely(status & NAND_STATUS_POWER_CUT))
+ return -EROFS;
+
return status & NAND_STATUS_FAIL ? -EIO : 0;
}
@@ -2009,6 +2012,8 @@ static int nand_write_oob_syndrome(struct mtd_info *mtd,
chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1);
status = chip->waitfunc(mtd, chip);
+ if (unlikely(status & NAND_STATUS_POWER_CUT))
+ return -EROFS;
return status & NAND_STATUS_FAIL ? -EIO : 0;
}
@@ -2442,6 +2447,9 @@ static int nand_write_page(struct mtd_info *mtd, struct nand_chip *chip,
status = chip->errstat(mtd, chip, FL_WRITING, status,
page);
+ if (unlikely(status & NAND_STATUS_POWER_CUT))
+ return -EROFS;
+
if (status & NAND_STATUS_FAIL)
return -EIO;
} else {
@@ -2868,7 +2876,7 @@ static int nand_erase(struct mtd_info *mtd, struct erase_info *instr)
int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr,
int allowbbt)
{
- int page, status, pages_per_block, ret, chipnr;
+ int page, status = 0, pages_per_block, ret, chipnr;
struct nand_chip *chip = mtd->priv;
loff_t len;
@@ -2958,7 +2966,12 @@ int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr,
erase_exit:
- ret = instr->state == MTD_ERASE_DONE ? 0 : -EIO;
+ if (instr->state == MTD_ERASE_DONE)
+ ret = 0;
+ else if (unlikely(status & NAND_STATUS_POWER_CUT))
+ ret = -EROFS;
+ else
+ ret = -EIO;
/* Deselect and wake up anyone waiting on the device */
chip->select_chip(mtd, -1);
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists