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

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



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.

Now is ecc->calculate()'s turn.

Signed-off-by: default avatarBoris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
parent ec47636c
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -164,10 +164,10 @@ static void cs_enable_hwecc(struct nand_chip *this, int mode)
	writeb(0x07, mmio_base + MM_NAND_ECC_CTL);
	writeb(0x07, mmio_base + MM_NAND_ECC_CTL);
}
}


static int cs_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code)
static int cs_calculate_ecc(struct nand_chip *this, const u_char *dat,
			    u_char *ecc_code)
{
{
	uint32_t ecc;
	uint32_t ecc;
	struct nand_chip *this = mtd_to_nand(mtd);
	void __iomem *mmio_base = this->IO_ADDR_R;
	void __iomem *mmio_base = this->IO_ADDR_R;


	ecc = readl(mmio_base + MM_NAND_STS);
	ecc = readl(mmio_base + MM_NAND_STS);
+6 −6
Original line number Original line Diff line number Diff line
@@ -170,10 +170,10 @@ static void nand_davinci_hwctl_1bit(struct nand_chip *chip, int mode)
/*
/*
 * Read hardware ECC value and pack into three bytes
 * Read hardware ECC value and pack into three bytes
 */
 */
static int nand_davinci_calculate_1bit(struct mtd_info *mtd,
static int nand_davinci_calculate_1bit(struct nand_chip *chip,
				       const u_char *dat, u_char *ecc_code)
				       const u_char *dat, u_char *ecc_code)
{
{
	unsigned int ecc_val = nand_davinci_readecc_1bit(mtd);
	unsigned int ecc_val = nand_davinci_readecc_1bit(nand_to_mtd(chip));
	unsigned int ecc24 = (ecc_val & 0x0fff) | ((ecc_val & 0x0fff0000) >> 4);
	unsigned int ecc24 = (ecc_val & 0x0fff) | ((ecc_val & 0x0fff0000) >> 4);


	/* invert so that erased block ecc is correct */
	/* invert so that erased block ecc is correct */
@@ -266,10 +266,10 @@ nand_davinci_readecc_4bit(struct davinci_nand_info *info, u32 code[4])
}
}


/* Terminate read ECC; or return ECC (as bytes) of data written to NAND. */
/* Terminate read ECC; or return ECC (as bytes) of data written to NAND. */
static int nand_davinci_calculate_4bit(struct mtd_info *mtd,
static int nand_davinci_calculate_4bit(struct nand_chip *chip,
				       const u_char *dat, u_char *ecc_code)
				       const u_char *dat, u_char *ecc_code)
{
{
	struct davinci_nand_info *info = to_davinci_nand(mtd);
	struct davinci_nand_info *info = to_davinci_nand(nand_to_mtd(chip));
	u32 raw_ecc[4], *p;
	u32 raw_ecc[4], *p;
	unsigned i;
	unsigned i;


+2 −2
Original line number Original line Diff line number Diff line
@@ -834,9 +834,9 @@ static void doc2001plus_enable_hwecc(struct nand_chip *this, int mode)
}
}


/* This code is only called on write */
/* This code is only called on write */
static int doc200x_calculate_ecc(struct mtd_info *mtd, const u_char *dat, unsigned char *ecc_code)
static int doc200x_calculate_ecc(struct nand_chip *this, const u_char *dat,
				 unsigned char *ecc_code)
{
{
	struct nand_chip *this = mtd_to_nand(mtd);
	struct doc_priv *doc = nand_get_controller_data(this);
	struct doc_priv *doc = nand_get_controller_data(this);
	void __iomem *docptr = doc->virtadr;
	void __iomem *docptr = doc->virtadr;
	int i;
	int i;
+5 −5
Original line number Original line Diff line number Diff line
@@ -385,10 +385,10 @@ static void fsmc_enable_hwecc(struct nand_chip *chip, int mode)
 * FSMC. ECC is 13 bytes for 512 bytes of data (supports error correction up to
 * FSMC. ECC is 13 bytes for 512 bytes of data (supports error correction up to
 * max of 8-bits)
 * max of 8-bits)
 */
 */
static int fsmc_read_hwecc_ecc4(struct mtd_info *mtd, const uint8_t *data,
static int fsmc_read_hwecc_ecc4(struct nand_chip *chip, const uint8_t *data,
				uint8_t *ecc)
				uint8_t *ecc)
{
{
	struct fsmc_nand_data *host = mtd_to_fsmc(mtd);
	struct fsmc_nand_data *host = mtd_to_fsmc(nand_to_mtd(chip));
	uint32_t ecc_tmp;
	uint32_t ecc_tmp;
	unsigned long deadline = jiffies + FSMC_BUSY_WAIT_TIMEOUT;
	unsigned long deadline = jiffies + FSMC_BUSY_WAIT_TIMEOUT;


@@ -433,10 +433,10 @@ static int fsmc_read_hwecc_ecc4(struct mtd_info *mtd, const uint8_t *data,
 * FSMC. ECC is 3 bytes for 512 bytes of data (supports error correction up to
 * FSMC. ECC is 3 bytes for 512 bytes of data (supports error correction up to
 * max of 1-bit)
 * max of 1-bit)
 */
 */
static int fsmc_read_hwecc_ecc1(struct mtd_info *mtd, const uint8_t *data,
static int fsmc_read_hwecc_ecc1(struct nand_chip *chip, const uint8_t *data,
				uint8_t *ecc)
				uint8_t *ecc)
{
{
	struct fsmc_nand_data *host = mtd_to_fsmc(mtd);
	struct fsmc_nand_data *host = mtd_to_fsmc(nand_to_mtd(chip));
	uint32_t ecc_tmp;
	uint32_t ecc_tmp;


	ecc_tmp = readl_relaxed(host->regs_va + ECC1);
	ecc_tmp = readl_relaxed(host->regs_va + ECC1);
@@ -767,7 +767,7 @@ static int fsmc_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,
		}
		}


		memcpy(&ecc_code[i], oob, chip->ecc.bytes);
		memcpy(&ecc_code[i], oob, chip->ecc.bytes);
		chip->ecc.calculate(mtd, p, &ecc_calc[i]);
		chip->ecc.calculate(chip, p, &ecc_calc[i]);


		stat = chip->ecc.correct(mtd, p, &ecc_code[i], &ecc_calc[i]);
		stat = chip->ecc.correct(mtd, p, &ecc_code[i], &ecc_calc[i]);
		if (stat < 0) {
		if (stat < 0) {
+3 −3
Original line number Original line Diff line number Diff line
@@ -162,10 +162,10 @@ static void jz_nand_hwctl(struct nand_chip *chip, int mode)
	writel(reg, nand->base + JZ_REG_NAND_ECC_CTRL);
	writel(reg, nand->base + JZ_REG_NAND_ECC_CTRL);
}
}


static int jz_nand_calculate_ecc_rs(struct mtd_info *mtd, const uint8_t *dat,
static int jz_nand_calculate_ecc_rs(struct nand_chip *chip, const uint8_t *dat,
				    uint8_t *ecc_code)
				    uint8_t *ecc_code)
{
{
	struct jz_nand *nand = mtd_to_jz_nand(mtd);
	struct jz_nand *nand = mtd_to_jz_nand(nand_to_mtd(chip));
	uint32_t reg, status;
	uint32_t reg, status;
	int i;
	int i;
	unsigned int timeout = 1000;
	unsigned int timeout = 1000;
Loading