Commit b9761687 authored by Boris Brezillon's avatar Boris Brezillon Committed by Miquel Raynal
Browse files

mtd: rawnand: Pass a nand_chip object to ecc->read_xxx() hooks



Let's make the raw NAND API consistent by patching all helpers and
hooks to take a nand_chip object instead of an mtd_info one or
remove the mtd_info object when both are passed.

Let's tackle all ecc->read_xxx() hooks at once.

Signed-off-by: default avatarBoris Brezillon <boris.brezillon@bootlin.com>
Acked-by: default avatarStefan Agner <stefan@agner.ch>
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
parent 00da2ea9
Loading
Loading
Loading
Loading
+4 −8
Original line number Diff line number Diff line
@@ -895,15 +895,13 @@ static int atmel_nand_pmecc_read_pg(struct nand_chip *chip, u8 *buf,
	return ret;
}

static int atmel_nand_pmecc_read_page(struct mtd_info *mtd,
				      struct nand_chip *chip, u8 *buf,
static int atmel_nand_pmecc_read_page(struct nand_chip *chip, u8 *buf,
				      int oob_required, int page)
{
	return atmel_nand_pmecc_read_pg(chip, buf, oob_required, page, false);
}

static int atmel_nand_pmecc_read_page_raw(struct mtd_info *mtd,
					  struct nand_chip *chip, u8 *buf,
static int atmel_nand_pmecc_read_page_raw(struct nand_chip *chip, u8 *buf,
					  int oob_required, int page)
{
	return atmel_nand_pmecc_read_pg(chip, buf, oob_required, page, true);
@@ -1037,16 +1035,14 @@ static int atmel_hsmc_nand_pmecc_read_pg(struct nand_chip *chip, u8 *buf,
	return ret;
}

static int atmel_hsmc_nand_pmecc_read_page(struct mtd_info *mtd,
					   struct nand_chip *chip, u8 *buf,
static int atmel_hsmc_nand_pmecc_read_page(struct nand_chip *chip, u8 *buf,
					   int oob_required, int page)
{
	return atmel_hsmc_nand_pmecc_read_pg(chip, buf, oob_required, page,
					     false);
}

static int atmel_hsmc_nand_pmecc_read_page_raw(struct mtd_info *mtd,
					       struct nand_chip *chip,
static int atmel_hsmc_nand_pmecc_read_page_raw(struct nand_chip *chip,
					       u8 *buf, int oob_required,
					       int page)
{
+12 −9
Original line number Diff line number Diff line
@@ -1689,7 +1689,7 @@ static int brcmstb_nand_verify_erased_page(struct mtd_info *mtd,
	sas = mtd->oobsize / chip->ecc.steps;

	/* read without ecc for verification */
	ret = chip->ecc.read_page_raw(mtd, chip, buf, true, page);
	ret = chip->ecc.read_page_raw(chip, buf, true, page);
	if (ret)
		return ret;

@@ -1786,9 +1786,10 @@ try_dmaread:
	return 0;
}

static int brcmnand_read_page(struct mtd_info *mtd, struct nand_chip *chip,
			      uint8_t *buf, int oob_required, int page)
static int brcmnand_read_page(struct nand_chip *chip, uint8_t *buf,
			      int oob_required, int page)
{
	struct mtd_info *mtd = nand_to_mtd(chip);
	struct brcmnand_host *host = nand_get_controller_data(chip);
	u8 *oob = oob_required ? (u8 *)chip->oob_poi : NULL;

@@ -1798,10 +1799,11 @@ static int brcmnand_read_page(struct mtd_info *mtd, struct nand_chip *chip,
			mtd->writesize >> FC_SHIFT, (u32 *)buf, oob);
}

static int brcmnand_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
				  uint8_t *buf, int oob_required, int page)
static int brcmnand_read_page_raw(struct nand_chip *chip, uint8_t *buf,
				  int oob_required, int page)
{
	struct brcmnand_host *host = nand_get_controller_data(chip);
	struct mtd_info *mtd = nand_to_mtd(chip);
	u8 *oob = oob_required ? (u8 *)chip->oob_poi : NULL;
	int ret;

@@ -1814,17 +1816,18 @@ static int brcmnand_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
	return ret;
}

static int brcmnand_read_oob(struct mtd_info *mtd, struct nand_chip *chip,
			     int page)
static int brcmnand_read_oob(struct nand_chip *chip, int page)
{
	struct mtd_info *mtd = nand_to_mtd(chip);

	return brcmnand_read(mtd, chip, (u64)page << chip->page_shift,
			mtd->writesize >> FC_SHIFT,
			NULL, (u8 *)chip->oob_poi);
}

static int brcmnand_read_oob_raw(struct mtd_info *mtd, struct nand_chip *chip,
				 int page)
static int brcmnand_read_oob_raw(struct nand_chip *chip, int page)
{
	struct mtd_info *mtd = nand_to_mtd(chip);
	struct brcmnand_host *host = nand_get_controller_data(chip);

	brcmnand_set_ecc_enabled(host, 0);
+6 −4
Original line number Diff line number Diff line
@@ -354,9 +354,10 @@ static int cafe_nand_write_oob(struct mtd_info *mtd,
}

/* Don't use -- use nand_read_oob_std for now */
static int cafe_nand_read_oob(struct mtd_info *mtd, struct nand_chip *chip,
			      int page)
static int cafe_nand_read_oob(struct nand_chip *chip, int page)
{
	struct mtd_info *mtd = nand_to_mtd(chip);

	return nand_read_oob_op(chip, page, 0, chip->oob_poi, mtd->oobsize);
}
/**
@@ -369,9 +370,10 @@ static int cafe_nand_read_oob(struct mtd_info *mtd, struct nand_chip *chip,
 * The hw generator calculates the error syndrome automatically. Therefore
 * we need a special oob layout and handling.
 */
static int cafe_nand_read_page(struct mtd_info *mtd, struct nand_chip *chip,
			       uint8_t *buf, int oob_required, int page)
static int cafe_nand_read_page(struct nand_chip *chip, uint8_t *buf,
			       int oob_required, int page)
{
	struct mtd_info *mtd = nand_to_mtd(chip);
	struct cafe_priv *cafe = nand_get_controller_data(chip);
	unsigned int max_bitflips = 0;

+10 −7
Original line number Diff line number Diff line
@@ -676,9 +676,10 @@ static void denali_oob_xfer(struct mtd_info *mtd, struct nand_chip *chip,
					   false);
}

static int denali_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
				uint8_t *buf, int oob_required, int page)
static int denali_read_page_raw(struct nand_chip *chip, uint8_t *buf,
				int oob_required, int page)
{
	struct mtd_info *mtd = nand_to_mtd(chip);
	struct denali_nand_info *denali = mtd_to_denali(mtd);
	int writesize = mtd->writesize;
	int oobsize = mtd->oobsize;
@@ -751,9 +752,10 @@ static int denali_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
	return 0;
}

static int denali_read_oob(struct mtd_info *mtd, struct nand_chip *chip,
			   int page)
static int denali_read_oob(struct nand_chip *chip, int page)
{
	struct mtd_info *mtd = nand_to_mtd(chip);

	denali_oob_xfer(mtd, chip, page, 0);

	return 0;
@@ -771,9 +773,10 @@ static int denali_write_oob(struct mtd_info *mtd, struct nand_chip *chip,
	return nand_prog_page_end_op(chip);
}

static int denali_read_page(struct mtd_info *mtd, struct nand_chip *chip,
			    uint8_t *buf, int oob_required, int page)
static int denali_read_page(struct nand_chip *chip, uint8_t *buf,
			    int oob_required, int page)
{
	struct mtd_info *mtd = nand_to_mtd(chip);
	struct denali_nand_info *denali = mtd_to_denali(mtd);
	unsigned long uncor_ecc_flags = 0;
	int stat = 0;
@@ -792,7 +795,7 @@ static int denali_read_page(struct mtd_info *mtd, struct nand_chip *chip,
		return stat;

	if (uncor_ecc_flags) {
		ret = denali_read_oob(mtd, chip, page);
		ret = denali_read_oob(chip, page);
		if (ret)
			return ret;

+10 −10
Original line number Diff line number Diff line
@@ -845,21 +845,21 @@ static int read_page(struct mtd_info *mtd, struct nand_chip *nand,
}


static int docg4_read_page_raw(struct mtd_info *mtd, struct nand_chip *nand,
			       uint8_t *buf, int oob_required, int page)
static int docg4_read_page_raw(struct nand_chip *nand, uint8_t *buf,
			       int oob_required, int page)
{
	return read_page(mtd, nand, buf, page, false);
	return read_page(nand_to_mtd(nand), nand, buf, page, false);
}

static int docg4_read_page(struct mtd_info *mtd, struct nand_chip *nand,
			   uint8_t *buf, int oob_required, int page)
static int docg4_read_page(struct nand_chip *nand, uint8_t *buf,
			   int oob_required, int page)
{
	return read_page(mtd, nand, buf, page, true);
	return read_page(nand_to_mtd(nand), nand, buf, page, true);
}

static int docg4_read_oob(struct mtd_info *mtd, struct nand_chip *nand,
			  int page)
static int docg4_read_oob(struct nand_chip *nand, int page)
{
	struct mtd_info *mtd = nand_to_mtd(nand);
	struct docg4_priv *doc = nand_get_controller_data(nand);
	void __iomem *docptr = doc->virtadr;
	uint16_t status;
@@ -1059,7 +1059,7 @@ static int __init read_factory_bbt(struct mtd_info *mtd)
		return -ENOMEM;

	read_page_prologue(mtd, g4_addr);
	docg4_read_page(mtd, nand, buf, 0, DOCG4_FACTORY_BBT_PAGE);
	docg4_read_page(nand, buf, 0, DOCG4_FACTORY_BBT_PAGE);

	/*
	 * If no memory-based bbt was created, exit.  This will happen if module
@@ -1077,7 +1077,7 @@ static int __init read_factory_bbt(struct mtd_info *mtd)
		 * It is stored redundantly, so we get another chance.
		 */
		eccfailed_stats = mtd->ecc_stats.failed;
		docg4_read_page(mtd, nand, buf, 0, DOCG4_REDUNDANT_BBT_PAGE);
		docg4_read_page(nand, buf, 0, DOCG4_REDUNDANT_BBT_PAGE);
		if (mtd->ecc_stats.failed > eccfailed_stats) {
			dev_warn(doc->dev,
				 "The factory bbt could not be read!\n");
Loading