forked from Minki/linux
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
This commit is contained in:
commit
e1ae4b0be1
@ -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 */
|
||||
for (step = 0; step < nfc_geo->ecc_chunk_count; step++) {
|
||||
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;
|
||||
|
||||
|
@ -579,7 +579,7 @@ static int ebu_nand_probe(struct platform_device *pdev)
|
||||
struct device *dev = &pdev->dev;
|
||||
struct ebu_nand_controller *ebu_host;
|
||||
struct nand_chip *nand;
|
||||
struct mtd_info *mtd = NULL;
|
||||
struct mtd_info *mtd;
|
||||
struct resource *res;
|
||||
char *resname;
|
||||
int ret;
|
||||
@ -647,12 +647,13 @@ static int ebu_nand_probe(struct platform_device *pdev)
|
||||
ebu_host->ebu + EBU_ADDR_SEL(cs));
|
||||
|
||||
nand_set_flash_node(&ebu_host->chip, dev->of_node);
|
||||
|
||||
mtd = nand_to_mtd(&ebu_host->chip);
|
||||
if (!mtd->name) {
|
||||
dev_err(ebu_host->dev, "NAND label property is mandatory\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
mtd = nand_to_mtd(&ebu_host->chip);
|
||||
mtd->dev.parent = dev;
|
||||
ebu_host->dev = dev;
|
||||
|
||||
|
@ -2210,6 +2210,9 @@ static int ns_attach_chip(struct nand_chip *chip)
|
||||
{
|
||||
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)
|
||||
return 0;
|
||||
|
||||
@ -2233,8 +2236,6 @@ static int ns_attach_chip(struct nand_chip *chip)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
|
||||
chip->ecc.algo = NAND_ECC_ALGO_BCH;
|
||||
chip->ecc.size = 512;
|
||||
chip->ecc.strength = bch;
|
||||
chip->ecc.bytes = eccbytes;
|
||||
@ -2273,8 +2274,6 @@ static int __init ns_init_module(void)
|
||||
nsmtd = nand_to_mtd(chip);
|
||||
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' */
|
||||
/* and 'badblocks' parameters to work */
|
||||
chip->options |= NAND_SKIP_BBTSCAN;
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/mtd/mtd.h>
|
||||
#include <linux/mtd/nand-ecc-sw-bch.h>
|
||||
#include <linux/mtd/rawnand.h>
|
||||
#include <linux/mtd/partitions.h>
|
||||
#include <linux/omap-dma.h>
|
||||
@ -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,
|
||||
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;
|
||||
|
||||
if (section >= chip->ecc.steps)
|
||||
if (section >= engine_conf->nsteps)
|
||||
return -ERANGE;
|
||||
|
||||
/*
|
||||
* When SW correction is employed, one OMAP specific marker byte is
|
||||
* reserved after each ECC step.
|
||||
*/
|
||||
oobregion->offset = off + (section * (chip->ecc.bytes + 1));
|
||||
oobregion->length = chip->ecc.bytes;
|
||||
oobregion->offset = off + (section * (engine_conf->code_size + 1));
|
||||
oobregion->length = engine_conf->code_size;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -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,
|
||||
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;
|
||||
|
||||
if (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
|
||||
* 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)
|
||||
return -ERANGE;
|
||||
|
||||
|
@ -343,6 +343,7 @@ static int spinand_read_from_cache_op(struct spinand_device *spinand,
|
||||
const struct nand_page_io_req *req)
|
||||
{
|
||||
struct nand_device *nand = spinand_to_nand(spinand);
|
||||
struct mtd_info *mtd = spinand_to_mtd(spinand);
|
||||
struct spi_mem_dirmap_desc *rdesc;
|
||||
unsigned int nbytes = 0;
|
||||
void *buf = NULL;
|
||||
@ -382,9 +383,16 @@ static int spinand_read_from_cache_op(struct spinand_device *spinand,
|
||||
memcpy(req->databuf.in, spinand->databuf + req->dataoffs,
|
||||
req->datalen);
|
||||
|
||||
if (req->ooblen)
|
||||
memcpy(req->oobbuf.in, spinand->oobbuf + req->ooboffs,
|
||||
req->ooblen);
|
||||
if (req->ooblen) {
|
||||
if (req->mode == MTD_OPS_AUTO_OOB)
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user