Commit 76dc2bfc authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'mtd/fixes-for-5.10-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux

Pull mtd fixes from Miquel Raynal:
 "Because of a recent change in the core, NAND controller drivers
  initializing the ECC engine too early in the probe path are broken.

  Drivers should wait for the NAND device to be discovered and its
  memory layout known before doing any ECC related initialization, so
  instead of reverting the faulty change which is actually moving in the
  right direction, let's fix the drivers directly: socrates, sharpsl,
  r852, plat_nand, pasemi, tmio, txx9ndfmc, orion, mpc5121, lpc32xx_slc,
  lpc32xx_mlc, fsmc, diskonchip, davinci, cs553x, au1550, ams-delta,
  xway and gpio"

* tag 'mtd/fixes-for-5.10-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux:
  mtd: rawnand: socrates: Move the ECC initialization to ->attach_chip()
  mtd: rawnand: sharpsl: Move the ECC initialization to ->attach_chip()
  mtd: rawnand: r852: Move the ECC initialization to ->attach_chip()
  mtd: rawnand: plat_nand: Move the ECC initialization to ->attach_chip()
  mtd: rawnand: pasemi: Move the ECC initialization to ->attach_chip()
  mtd: rawnand: tmio: Move the ECC initialization to ->attach_chip()
  mtd: rawnand: txx9ndfmc: Move the ECC initialization to ->attach_chip()
  mtd: rawnand: orion: Move the ECC initialization to ->attach_chip()
  mtd: rawnand: mpc5121: Move the ECC initialization to ->attach_chip()
  mtd: rawnand: lpc32xx_slc: Move the ECC initialization to ->attach_chip()
  mtd: rawnand: lpc32xx_mlc: Move the ECC initialization to ->attach_chip()
  mtd: rawnand: fsmc: Move the ECC initialization to ->attach_chip()
  mtd: rawnand: diskonchip: Move the ECC initialization to ->attach_chip()
  mtd: rawnand: davinci: Move the ECC initialization to ->attach_chip()
  mtd: rawnand: cs553x: Move the ECC initialization to ->attach_chip()
  mtd: rawnand: au1550: Move the ECC initialization to ->attach_chip()
  mtd: rawnand: ams-delta: Move the ECC initialization to ->attach_chip()
  mtd: rawnand: xway: Move the ECC initialization to ->attach_chip()
  mtd: rawnand: gpio: Move the ECC initialization to ->attach_chip()
parents 87c301ca b36bf0a0
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -215,8 +215,17 @@ static int gpio_nand_setup_interface(struct nand_chip *this, int csline,
	return 0;
}

static int gpio_nand_attach_chip(struct nand_chip *chip)
{
	chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
	chip->ecc.algo = NAND_ECC_ALGO_HAMMING;

	return 0;
}

static const struct nand_controller_ops gpio_nand_ops = {
	.exec_op = gpio_nand_exec_op,
	.attach_chip = gpio_nand_attach_chip,
	.setup_interface = gpio_nand_setup_interface,
};

@@ -260,9 +269,6 @@ static int gpio_nand_probe(struct platform_device *pdev)
		return err;
	}

	this->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
	this->ecc.algo = NAND_ECC_ALGO_HAMMING;

	platform_set_drvdata(pdev, priv);

	/* Set chip enabled but write protected */
+9 −2
Original line number Diff line number Diff line
@@ -236,8 +236,17 @@ static int au1550nd_exec_op(struct nand_chip *this,
	return ret;
}

static int au1550nd_attach_chip(struct nand_chip *chip)
{
	chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
	chip->ecc.algo = NAND_ECC_ALGO_HAMMING;

	return 0;
}

static const struct nand_controller_ops au1550nd_ops = {
	.exec_op = au1550nd_exec_op,
	.attach_chip = au1550nd_attach_chip,
};

static int au1550nd_probe(struct platform_device *pdev)
@@ -294,8 +303,6 @@ static int au1550nd_probe(struct platform_device *pdev)
	nand_controller_init(&ctx->controller);
	ctx->controller.ops = &au1550nd_ops;
	this->controller = &ctx->controller;
	this->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
	this->ecc.algo = NAND_ECC_ALGO_HAMMING;

	if (pd->devwidth)
		this->options |= NAND_BUSWIDTH_16;
+16 −8
Original line number Diff line number Diff line
@@ -243,8 +243,24 @@ static int cs_calculate_ecc(struct nand_chip *this, const u_char *dat,

static struct cs553x_nand_controller *controllers[4];

static int cs553x_attach_chip(struct nand_chip *chip)
{
	if (chip->ecc.engine_type != NAND_ECC_ENGINE_TYPE_ON_HOST)
		return 0;

	chip->ecc.size = 256;
	chip->ecc.bytes = 3;
	chip->ecc.hwctl  = cs_enable_hwecc;
	chip->ecc.calculate = cs_calculate_ecc;
	chip->ecc.correct  = nand_correct_data;
	chip->ecc.strength = 1;

	return 0;
}

static const struct nand_controller_ops cs553x_nand_controller_ops = {
	.exec_op = cs553x_exec_op,
	.attach_chip = cs553x_attach_chip,
};

static int __init cs553x_init_one(int cs, int mmio, unsigned long adr)
@@ -286,14 +302,6 @@ static int __init cs553x_init_one(int cs, int mmio, unsigned long adr)
		goto out_mtd;
	}

	this->ecc.engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST;
	this->ecc.size = 256;
	this->ecc.bytes = 3;
	this->ecc.hwctl  = cs_enable_hwecc;
	this->ecc.calculate = cs_calculate_ecc;
	this->ecc.correct  = nand_correct_data;
	this->ecc.strength = 1;

	/* Enable the following for a flash based bad block table */
	this->bbt_options = NAND_BBT_USE_FLASH;

+4 −4
Original line number Diff line number Diff line
@@ -585,6 +585,10 @@ static int davinci_nand_attach_chip(struct nand_chip *chip)
	if (IS_ERR(pdata))
		return PTR_ERR(pdata);

	/* Use board-specific ECC config */
	info->chip.ecc.engine_type = pdata->engine_type;
	info->chip.ecc.placement = pdata->ecc_placement;

	switch (info->chip.ecc.engine_type) {
	case NAND_ECC_ENGINE_TYPE_NONE:
		pdata->ecc_bits = 0;
@@ -850,10 +854,6 @@ static int nand_davinci_probe(struct platform_device *pdev)
	info->mask_ale		= pdata->mask_ale ? : MASK_ALE;
	info->mask_cle		= pdata->mask_cle ? : MASK_CLE;

	/* Use board-specific ECC config */
	info->chip.ecc.engine_type = pdata->engine_type;
	info->chip.ecc.placement = pdata->ecc_placement;

	spin_lock_irq(&davinci_nand_lock);

	/* put CSxNAND into NAND mode */
+19 −10
Original line number Diff line number Diff line
@@ -1269,12 +1269,31 @@ static inline int __init doc2001plus_init(struct mtd_info *mtd)
	return 1;
}

static int doc200x_attach_chip(struct nand_chip *chip)
{
	if (chip->ecc.engine_type != NAND_ECC_ENGINE_TYPE_ON_HOST)
		return 0;

	chip->ecc.placement = NAND_ECC_PLACEMENT_INTERLEAVED;
	chip->ecc.size = 512;
	chip->ecc.bytes = 6;
	chip->ecc.strength = 2;
	chip->ecc.options = NAND_ECC_GENERIC_ERASED_CHECK;
	chip->ecc.hwctl = doc200x_enable_hwecc;
	chip->ecc.calculate = doc200x_calculate_ecc;
	chip->ecc.correct = doc200x_correct_data;

	return 0;
}

static const struct nand_controller_ops doc200x_ops = {
	.exec_op = doc200x_exec_op,
	.attach_chip = doc200x_attach_chip,
};

static const struct nand_controller_ops doc2001plus_ops = {
	.exec_op = doc2001plus_exec_op,
	.attach_chip = doc200x_attach_chip,
};

static int __init doc_probe(unsigned long physadr)
@@ -1452,16 +1471,6 @@ static int __init doc_probe(unsigned long physadr)

	nand->controller	= &doc->base;
	nand_set_controller_data(nand, doc);
	nand->ecc.hwctl		= doc200x_enable_hwecc;
	nand->ecc.calculate	= doc200x_calculate_ecc;
	nand->ecc.correct	= doc200x_correct_data;

	nand->ecc.engine_type	= NAND_ECC_ENGINE_TYPE_ON_HOST;
	nand->ecc.placement	= NAND_ECC_PLACEMENT_INTERLEAVED;
	nand->ecc.size		= 512;
	nand->ecc.bytes		= 6;
	nand->ecc.strength	= 2;
	nand->ecc.options	= NAND_ECC_GENERIC_ERASED_CHECK;
	nand->bbt_options	= NAND_BBT_USE_FLASH;
	/* Skip the automatic BBT scan so we can run it manually */
	nand->options		|= NAND_SKIP_BBTSCAN | NAND_NO_BBM_QUIRK;
Loading