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

mtd: rawnand: Get rid of chip->ecc_{strength,step}_ds



nand_device embeds a nand_ecc_req object which contains the minimum
strength and step-size required by the NAND device.

Drop the chip->ecc_{strength,step}_ds fields and use
chip->base.eccreq.{strength,step_size} instead.

Signed-off-by: default avatarBoris Brezillon <bbrezillon@kernel.org>
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: default avatarFrieder Schrempf <frieder.schrempf@kontron.de>
parent 32813e28
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -1072,15 +1072,15 @@ static int atmel_nand_pmecc_init(struct nand_chip *chip)
		req.ecc.strength = ATMEL_PMECC_MAXIMIZE_ECC_STRENGTH;
	else if (chip->ecc.strength)
		req.ecc.strength = chip->ecc.strength;
	else if (chip->ecc_strength_ds)
		req.ecc.strength = chip->ecc_strength_ds;
	else if (chip->base.eccreq.strength)
		req.ecc.strength = chip->base.eccreq.strength;
	else
		req.ecc.strength = ATMEL_PMECC_MAXIMIZE_ECC_STRENGTH;

	if (chip->ecc.size)
		req.ecc.sectorsize = chip->ecc.size;
	else if (chip->ecc_step_ds)
		req.ecc.sectorsize = chip->ecc_step_ds;
	else if (chip->base.eccreq.step_size)
		req.ecc.sectorsize = chip->base.eccreq.step_size;
	else
		req.ecc.sectorsize = ATMEL_PMECC_SECTOR_SIZE_AUTO;

+7 −4
Original line number Diff line number Diff line
@@ -204,7 +204,8 @@ static int set_geometry_by_ecc_info(struct gpmi_nand_data *this,
	default:
		dev_err(this->dev,
			"unsupported nand chip. ecc bits : %d, ecc size : %d\n",
			chip->ecc_strength_ds, chip->ecc_step_ds);
			chip->base.eccreq.strength,
			chip->base.eccreq.step_size);
		return -EINVAL;
	}
	geo->ecc_chunk_size = ecc_step;
@@ -417,11 +418,13 @@ int common_nfc_set_geometry(struct gpmi_nand_data *this)

	if ((of_property_read_bool(this->dev->of_node, "fsl,use-minimum-ecc"))
				|| legacy_set_geometry(this)) {
		if (!(chip->ecc_strength_ds > 0 && chip->ecc_step_ds > 0))
		if (!(chip->base.eccreq.strength > 0 &&
		      chip->base.eccreq.step_size > 0))
			return -EINVAL;

		return set_geometry_by_ecc_info(this, chip->ecc_strength_ds,
						chip->ecc_step_ds);
		return set_geometry_by_ecc_info(this,
						chip->base.eccreq.strength,
						chip->base.eccreq.step_size);
	}

	return 0;
+3 −3
Original line number Diff line number Diff line
@@ -2248,9 +2248,9 @@ static int marvell_nand_ecc_init(struct mtd_info *mtd,
	int ret;

	if (ecc->mode != NAND_ECC_NONE && (!ecc->size || !ecc->strength)) {
		if (chip->ecc_step_ds && chip->ecc_strength_ds) {
			ecc->size = chip->ecc_step_ds;
			ecc->strength = chip->ecc_strength_ds;
		if (chip->base.eccreq.step_size && chip->base.eccreq.strength) {
			ecc->size = chip->base.eccreq.step_size;
			ecc->strength = chip->base.eccreq.strength;
		} else {
			dev_info(nfc->dev,
				 "No minimum ECC strength, using 1b/512B\n");
+2 −2
Original line number Diff line number Diff line
@@ -1197,8 +1197,8 @@ static int mtk_nfc_ecc_init(struct device *dev, struct mtd_info *mtd)
	/* if optional dt settings not present */
	if (!nand->ecc.size || !nand->ecc.strength) {
		/* use datasheet requirements */
		nand->ecc.strength = nand->ecc_strength_ds;
		nand->ecc.size = nand->ecc_step_ds;
		nand->ecc.strength = nand->base.eccreq.strength;
		nand->ecc.size = nand->base.eccreq.step_size;

		/*
		 * align eccstrength and eccsize
+8 −7
Original line number Diff line number Diff line
@@ -4547,8 +4547,8 @@ static bool find_full_id_nand(struct nand_chip *chip,
					   memorg->pagesize *
					   memorg->pages_per_eraseblock);
		chip->options |= type->options;
		chip->ecc_strength_ds = NAND_ECC_STRENGTH(type);
		chip->ecc_step_ds = NAND_ECC_STEP(type);
		chip->base.eccreq.strength = NAND_ECC_STRENGTH(type);
		chip->base.eccreq.step_size = NAND_ECC_STEP(type);
		chip->onfi_timing_mode_default =
					type->onfi_timing_mode_default;

@@ -5227,8 +5227,8 @@ nand_match_ecc_req(struct nand_chip *chip,
{
	struct mtd_info *mtd = nand_to_mtd(chip);
	const struct nand_ecc_step_info *stepinfo;
	int req_step = chip->ecc_step_ds;
	int req_strength = chip->ecc_strength_ds;
	int req_step = chip->base.eccreq.step_size;
	int req_strength = chip->base.eccreq.strength;
	int req_corr, step_size, strength, nsteps, ecc_bytes, ecc_bytes_total;
	int best_step, best_strength, best_ecc_bytes;
	int best_ecc_bytes_total = INT_MAX;
@@ -5421,7 +5421,7 @@ static bool nand_ecc_strength_good(struct nand_chip *chip)
	struct nand_ecc_ctrl *ecc = &chip->ecc;
	int corr, ds_corr;

	if (ecc->size == 0 || chip->ecc_step_ds == 0)
	if (ecc->size == 0 || chip->base.eccreq.step_size == 0)
		/* Not enough information */
		return true;

@@ -5430,9 +5430,10 @@ static bool nand_ecc_strength_good(struct nand_chip *chip)
	 * the correction density.
	 */
	corr = (mtd->writesize * ecc->strength) / ecc->size;
	ds_corr = (mtd->writesize * chip->ecc_strength_ds) / chip->ecc_step_ds;
	ds_corr = (mtd->writesize * chip->base.eccreq.strength) /
		  chip->base.eccreq.step_size;

	return corr >= ds_corr && ecc->strength >= chip->ecc_strength_ds;
	return corr >= ds_corr && ecc->strength >= chip->base.eccreq.strength;
}

static int rawnand_erase(struct nand_device *nand, const struct nand_pos *pos)
Loading