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

mtd: rawnand: Pass a nand_chip object to ecc->write_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->write_xxx() hooks at once.

Signed-off-by: default avatarBoris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
parent b9761687
Loading
Loading
Loading
Loading
+4 −8
Original line number Diff line number Diff line
@@ -858,15 +858,13 @@ static int atmel_nand_pmecc_write_pg(struct nand_chip *chip, const u8 *buf,
	return nand_prog_page_end_op(chip);
}

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

static int atmel_nand_pmecc_write_page_raw(struct mtd_info *mtd,
					   struct nand_chip *chip,
static int atmel_nand_pmecc_write_page_raw(struct nand_chip *chip,
					   const u8 *buf, int oob_required,
					   int page)
{
@@ -963,8 +961,7 @@ static int atmel_hsmc_nand_pmecc_write_pg(struct nand_chip *chip,
	return ret;
}

static int atmel_hsmc_nand_pmecc_write_page(struct mtd_info *mtd,
					    struct nand_chip *chip,
static int atmel_hsmc_nand_pmecc_write_page(struct nand_chip *chip,
					    const u8 *buf, int oob_required,
					    int page)
{
@@ -972,8 +969,7 @@ static int atmel_hsmc_nand_pmecc_write_page(struct mtd_info *mtd,
					      false);
}

static int atmel_hsmc_nand_pmecc_write_page_raw(struct mtd_info *mtd,
						struct nand_chip *chip,
static int atmel_hsmc_nand_pmecc_write_page_raw(struct nand_chip *chip,
						const u8 *buf,
						int oob_required, int page)
{
+11 −10
Original line number Diff line number Diff line
@@ -1909,9 +1909,10 @@ out:
	return ret;
}

static int brcmnand_write_page(struct mtd_info *mtd, struct nand_chip *chip,
			       const uint8_t *buf, int oob_required, int page)
static int brcmnand_write_page(struct nand_chip *chip, const 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);
	void *oob = oob_required ? chip->oob_poi : NULL;

@@ -1921,10 +1922,10 @@ static int brcmnand_write_page(struct mtd_info *mtd, struct nand_chip *chip,
	return nand_prog_page_end_op(chip);
}

static int brcmnand_write_page_raw(struct mtd_info *mtd,
				   struct nand_chip *chip, const uint8_t *buf,
static int brcmnand_write_page_raw(struct nand_chip *chip, const 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);
	void *oob = oob_required ? chip->oob_poi : NULL;

@@ -1936,16 +1937,16 @@ static int brcmnand_write_page_raw(struct mtd_info *mtd,
	return nand_prog_page_end_op(chip);
}

static int brcmnand_write_oob(struct mtd_info *mtd, struct nand_chip *chip,
				  int page)
static int brcmnand_write_oob(struct nand_chip *chip, int page)
{
	return brcmnand_write(mtd, chip, (u64)page << chip->page_shift,
				  NULL, chip->oob_poi);
	return brcmnand_write(nand_to_mtd(chip), chip,
			      (u64)page << chip->page_shift, NULL,
			      chip->oob_poi);
}

static int brcmnand_write_oob_raw(struct mtd_info *mtd, struct nand_chip *chip,
				  int page)
static int brcmnand_write_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);
	int ret;

+7 −6
Original line number Diff line number Diff line
@@ -346,9 +346,10 @@ static irqreturn_t cafe_nand_interrupt(int irq, void *id)
	return IRQ_HANDLED;
}

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

	return nand_prog_page_op(chip, page, mtd->writesize, chip->oob_poi,
				 mtd->oobsize);
}
@@ -533,11 +534,11 @@ static struct nand_bbt_descr cafe_bbt_mirror_descr_512 = {
};


static int cafe_nand_write_page_lowlevel(struct mtd_info *mtd,
					  struct nand_chip *chip,
static int cafe_nand_write_page_lowlevel(struct nand_chip *chip,
					 const 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);

	nand_prog_page_begin_op(chip, page, 0, buf, mtd->writesize);
+8 −6
Original line number Diff line number Diff line
@@ -761,9 +761,9 @@ static int denali_read_oob(struct nand_chip *chip, int page)
	return 0;
}

static int denali_write_oob(struct mtd_info *mtd, struct nand_chip *chip,
			    int page)
static int denali_write_oob(struct nand_chip *chip, int page)
{
	struct mtd_info *mtd = nand_to_mtd(chip);
	struct denali_nand_info *denali = mtd_to_denali(mtd);

	denali_reset_irq(denali);
@@ -806,9 +806,10 @@ static int denali_read_page(struct nand_chip *chip, uint8_t *buf,
	return stat;
}

static int denali_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
				 const uint8_t *buf, int oob_required, int page)
static int denali_write_page_raw(struct nand_chip *chip, const 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;
@@ -884,9 +885,10 @@ static int denali_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
	return denali_data_xfer(denali, tmp_buf, size, page, 1, 1);
}

static int denali_write_page(struct mtd_info *mtd, struct nand_chip *chip,
			     const uint8_t *buf, int oob_required, int page)
static int denali_write_page(struct nand_chip *chip, const 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);

	return denali_data_xfer(denali, (void *)buf, mtd->writesize,
+8 −9
Original line number Diff line number Diff line
@@ -1007,20 +1007,19 @@ static int write_page(struct mtd_info *mtd, struct nand_chip *nand,
	return nand_prog_page_end_op(nand);
}

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

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

static int docg4_write_oob(struct mtd_info *mtd, struct nand_chip *nand,
			   int page)
static int docg4_write_oob(struct nand_chip *nand, int page)
{
	/*
	 * Writing oob-only is not really supported, because MLC nand must write
@@ -1144,7 +1143,7 @@ static int docg4_block_markbad(struct mtd_info *mtd, loff_t ofs)

	/* write first page of block */
	write_page_prologue(mtd, g4_addr);
	docg4_write_page(mtd, nand, buf, 1, page);
	docg4_write_page(nand, buf, 1, page);
	ret = pageprog(mtd);

	kfree(buf);
Loading