mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-06-13 15:03:58 +03:00
mtd: spinand: Align logic for enabling ECC to match Linux kernel
This aligns the logic to match the Linux kernel implementation. Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu> Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de> Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
This commit is contained in:
committed by
Michael Trimarchi
parent
5faba88f98
commit
4254ed38ec
@@ -542,12 +542,12 @@ static int spinand_mtd_read(struct mtd_info *mtd, loff_t from,
|
||||
struct nand_device *nand = mtd_to_nanddev(mtd);
|
||||
unsigned int max_bitflips = 0;
|
||||
struct nand_io_iter iter;
|
||||
bool enable_ecc = false;
|
||||
bool disable_ecc = false;
|
||||
bool ecc_failed = false;
|
||||
int ret = 0;
|
||||
|
||||
if (ops->mode != MTD_OPS_RAW && spinand->eccinfo.ooblayout)
|
||||
enable_ecc = true;
|
||||
if (ops->mode == MTD_OPS_RAW || !spinand->eccinfo.ooblayout)
|
||||
disable_ecc = true;
|
||||
|
||||
#ifndef __UBOOT__
|
||||
mutex_lock(&spinand->lock);
|
||||
@@ -555,15 +555,18 @@ static int spinand_mtd_read(struct mtd_info *mtd, loff_t from,
|
||||
|
||||
nanddev_io_for_each_page(nand, NAND_PAGE_READ, from, ops, &iter) {
|
||||
schedule();
|
||||
if (disable_ecc)
|
||||
iter.req.mode = MTD_OPS_RAW;
|
||||
|
||||
ret = spinand_select_target(spinand, iter.req.pos.target);
|
||||
if (ret)
|
||||
break;
|
||||
|
||||
ret = spinand_ecc_enable(spinand, enable_ecc);
|
||||
ret = spinand_ecc_enable(spinand, !disable_ecc);
|
||||
if (ret)
|
||||
break;
|
||||
|
||||
ret = spinand_read_page(spinand, &iter.req, enable_ecc);
|
||||
ret = spinand_read_page(spinand, &iter.req, !disable_ecc);
|
||||
if (ret < 0 && ret != -EBADMSG)
|
||||
break;
|
||||
|
||||
@@ -595,11 +598,11 @@ static int spinand_mtd_write(struct mtd_info *mtd, loff_t to,
|
||||
struct spinand_device *spinand = mtd_to_spinand(mtd);
|
||||
struct nand_device *nand = mtd_to_nanddev(mtd);
|
||||
struct nand_io_iter iter;
|
||||
bool enable_ecc = false;
|
||||
bool disable_ecc = false;
|
||||
int ret = 0;
|
||||
|
||||
if (ops->mode != MTD_OPS_RAW && mtd->ooblayout)
|
||||
enable_ecc = true;
|
||||
if (ops->mode == MTD_OPS_RAW || !mtd->ooblayout)
|
||||
disable_ecc = true;
|
||||
|
||||
#ifndef __UBOOT__
|
||||
mutex_lock(&spinand->lock);
|
||||
@@ -607,11 +610,14 @@ static int spinand_mtd_write(struct mtd_info *mtd, loff_t to,
|
||||
|
||||
nanddev_io_for_each_page(nand, NAND_PAGE_WRITE, to, ops, &iter) {
|
||||
schedule();
|
||||
if (disable_ecc)
|
||||
iter.req.mode = MTD_OPS_RAW;
|
||||
|
||||
ret = spinand_select_target(spinand, iter.req.pos.target);
|
||||
if (ret)
|
||||
break;
|
||||
|
||||
ret = spinand_ecc_enable(spinand, enable_ecc);
|
||||
ret = spinand_ecc_enable(spinand, !disable_ecc);
|
||||
if (ret)
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user