Commit e1ae4b0b authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'mtd/fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux

Pull mtd fixes from Miquel Raynal.

* 'mtd/fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux:
  mtd: rawnand: omap: Use BCH private fields in the specific OOB layout
  mtd: spinand: Fix MTD_OPS_AUTO_OOB requests
  mtd: rawnand: intel: check the mtd name only after setting the variable
  mtd: rawnand: nandsim: Fix the logic when selecting Hamming soft ECC engine
  mtd: rawnand: gpmi: fix dst bit offset when extracting raw payload
parents 077e81d5 b135b335
...@@ -1615,7 +1615,7 @@ static int gpmi_ecc_read_page_raw(struct nand_chip *chip, uint8_t *buf, ...@@ -1615,7 +1615,7 @@ static int gpmi_ecc_read_page_raw(struct nand_chip *chip, uint8_t *buf,
/* Extract interleaved payload data and ECC bits */ /* Extract interleaved payload data and ECC bits */
for (step = 0; step < nfc_geo->ecc_chunk_count; step++) { for (step = 0; step < nfc_geo->ecc_chunk_count; step++) {
if (buf) if (buf)
nand_extract_bits(buf, step * eccsize, tmp_buf, nand_extract_bits(buf, step * eccsize * 8, tmp_buf,
src_bit_off, eccsize * 8); src_bit_off, eccsize * 8);
src_bit_off += eccsize * 8; src_bit_off += eccsize * 8;
......
...@@ -579,7 +579,7 @@ static int ebu_nand_probe(struct platform_device *pdev) ...@@ -579,7 +579,7 @@ static int ebu_nand_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct ebu_nand_controller *ebu_host; struct ebu_nand_controller *ebu_host;
struct nand_chip *nand; struct nand_chip *nand;
struct mtd_info *mtd = NULL; struct mtd_info *mtd;
struct resource *res; struct resource *res;
char *resname; char *resname;
int ret; int ret;
...@@ -647,12 +647,13 @@ static int ebu_nand_probe(struct platform_device *pdev) ...@@ -647,12 +647,13 @@ static int ebu_nand_probe(struct platform_device *pdev)
ebu_host->ebu + EBU_ADDR_SEL(cs)); ebu_host->ebu + EBU_ADDR_SEL(cs));
nand_set_flash_node(&ebu_host->chip, dev->of_node); nand_set_flash_node(&ebu_host->chip, dev->of_node);
mtd = nand_to_mtd(&ebu_host->chip);
if (!mtd->name) { if (!mtd->name) {
dev_err(ebu_host->dev, "NAND label property is mandatory\n"); dev_err(ebu_host->dev, "NAND label property is mandatory\n");
return -EINVAL; return -EINVAL;
} }
mtd = nand_to_mtd(&ebu_host->chip);
mtd->dev.parent = dev; mtd->dev.parent = dev;
ebu_host->dev = dev; ebu_host->dev = dev;
......
...@@ -2210,6 +2210,9 @@ static int ns_attach_chip(struct nand_chip *chip) ...@@ -2210,6 +2210,9 @@ static int ns_attach_chip(struct nand_chip *chip)
{ {
unsigned int eccsteps, eccbytes; unsigned int eccsteps, eccbytes;
chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
chip->ecc.algo = bch ? NAND_ECC_ALGO_BCH : NAND_ECC_ALGO_HAMMING;
if (!bch) if (!bch)
return 0; return 0;
...@@ -2233,8 +2236,6 @@ static int ns_attach_chip(struct nand_chip *chip) ...@@ -2233,8 +2236,6 @@ static int ns_attach_chip(struct nand_chip *chip)
return -EINVAL; return -EINVAL;
} }
chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
chip->ecc.algo = NAND_ECC_ALGO_BCH;
chip->ecc.size = 512; chip->ecc.size = 512;
chip->ecc.strength = bch; chip->ecc.strength = bch;
chip->ecc.bytes = eccbytes; chip->ecc.bytes = eccbytes;
...@@ -2273,8 +2274,6 @@ static int __init ns_init_module(void) ...@@ -2273,8 +2274,6 @@ static int __init ns_init_module(void)
nsmtd = nand_to_mtd(chip); nsmtd = nand_to_mtd(chip);
nand_set_controller_data(chip, (void *)ns); nand_set_controller_data(chip, (void *)ns);
chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
chip->ecc.algo = NAND_ECC_ALGO_HAMMING;
/* The NAND_SKIP_BBTSCAN option is necessary for 'overridesize' */ /* The NAND_SKIP_BBTSCAN option is necessary for 'overridesize' */
/* and 'badblocks' parameters to work */ /* and 'badblocks' parameters to work */
chip->options |= NAND_SKIP_BBTSCAN; chip->options |= NAND_SKIP_BBTSCAN;
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <linux/jiffies.h> #include <linux/jiffies.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/nand-ecc-sw-bch.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/rawnand.h>
#include <linux/mtd/partitions.h> #include <linux/mtd/partitions.h>
#include <linux/omap-dma.h> #include <linux/omap-dma.h>
...@@ -1866,18 +1867,19 @@ static const struct mtd_ooblayout_ops omap_ooblayout_ops = { ...@@ -1866,18 +1867,19 @@ static const struct mtd_ooblayout_ops omap_ooblayout_ops = {
static int omap_sw_ooblayout_ecc(struct mtd_info *mtd, int section, static int omap_sw_ooblayout_ecc(struct mtd_info *mtd, int section,
struct mtd_oob_region *oobregion) struct mtd_oob_region *oobregion)
{ {
struct nand_chip *chip = mtd_to_nand(mtd); struct nand_device *nand = mtd_to_nanddev(mtd);
const struct nand_ecc_sw_bch_conf *engine_conf = nand->ecc.ctx.priv;
int off = BADBLOCK_MARKER_LENGTH; int off = BADBLOCK_MARKER_LENGTH;
if (section >= chip->ecc.steps) if (section >= engine_conf->nsteps)
return -ERANGE; return -ERANGE;
/* /*
* When SW correction is employed, one OMAP specific marker byte is * When SW correction is employed, one OMAP specific marker byte is
* reserved after each ECC step. * reserved after each ECC step.
*/ */
oobregion->offset = off + (section * (chip->ecc.bytes + 1)); oobregion->offset = off + (section * (engine_conf->code_size + 1));
oobregion->length = chip->ecc.bytes; oobregion->length = engine_conf->code_size;
return 0; return 0;
} }
...@@ -1885,7 +1887,8 @@ static int omap_sw_ooblayout_ecc(struct mtd_info *mtd, int section, ...@@ -1885,7 +1887,8 @@ static int omap_sw_ooblayout_ecc(struct mtd_info *mtd, int section,
static int omap_sw_ooblayout_free(struct mtd_info *mtd, int section, static int omap_sw_ooblayout_free(struct mtd_info *mtd, int section,
struct mtd_oob_region *oobregion) struct mtd_oob_region *oobregion)
{ {
struct nand_chip *chip = mtd_to_nand(mtd); struct nand_device *nand = mtd_to_nanddev(mtd);
const struct nand_ecc_sw_bch_conf *engine_conf = nand->ecc.ctx.priv;
int off = BADBLOCK_MARKER_LENGTH; int off = BADBLOCK_MARKER_LENGTH;
if (section) if (section)
...@@ -1895,7 +1898,7 @@ static int omap_sw_ooblayout_free(struct mtd_info *mtd, int section, ...@@ -1895,7 +1898,7 @@ static int omap_sw_ooblayout_free(struct mtd_info *mtd, int section,
* When SW correction is employed, one OMAP specific marker byte is * When SW correction is employed, one OMAP specific marker byte is
* reserved after each ECC step. * reserved after each ECC step.
*/ */
off += ((chip->ecc.bytes + 1) * chip->ecc.steps); off += ((engine_conf->code_size + 1) * engine_conf->nsteps);
if (off >= mtd->oobsize) if (off >= mtd->oobsize)
return -ERANGE; return -ERANGE;
......
...@@ -343,6 +343,7 @@ static int spinand_read_from_cache_op(struct spinand_device *spinand, ...@@ -343,6 +343,7 @@ static int spinand_read_from_cache_op(struct spinand_device *spinand,
const struct nand_page_io_req *req) const struct nand_page_io_req *req)
{ {
struct nand_device *nand = spinand_to_nand(spinand); struct nand_device *nand = spinand_to_nand(spinand);
struct mtd_info *mtd = spinand_to_mtd(spinand);
struct spi_mem_dirmap_desc *rdesc; struct spi_mem_dirmap_desc *rdesc;
unsigned int nbytes = 0; unsigned int nbytes = 0;
void *buf = NULL; void *buf = NULL;
...@@ -382,9 +383,16 @@ static int spinand_read_from_cache_op(struct spinand_device *spinand, ...@@ -382,9 +383,16 @@ static int spinand_read_from_cache_op(struct spinand_device *spinand,
memcpy(req->databuf.in, spinand->databuf + req->dataoffs, memcpy(req->databuf.in, spinand->databuf + req->dataoffs,
req->datalen); req->datalen);
if (req->ooblen) if (req->ooblen) {
memcpy(req->oobbuf.in, spinand->oobbuf + req->ooboffs, if (req->mode == MTD_OPS_AUTO_OOB)
req->ooblen); mtd_ooblayout_get_databytes(mtd, req->oobbuf.in,
spinand->oobbuf,
req->ooboffs,
req->ooblen);
else
memcpy(req->oobbuf.in, spinand->oobbuf + req->ooboffs,
req->ooblen);
}
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment