Skip to content

Commit e1ae4b0

Browse files
committed
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
2 parents 077e81d + b135b33 commit e1ae4b0

File tree

5 files changed

+27
-16
lines changed

5 files changed

+27
-16
lines changed

drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1615,7 +1615,7 @@ static int gpmi_ecc_read_page_raw(struct nand_chip *chip, uint8_t *buf,
16151615
/* Extract interleaved payload data and ECC bits */
16161616
for (step = 0; step < nfc_geo->ecc_chunk_count; step++) {
16171617
if (buf)
1618-
nand_extract_bits(buf, step * eccsize, tmp_buf,
1618+
nand_extract_bits(buf, step * eccsize * 8, tmp_buf,
16191619
src_bit_off, eccsize * 8);
16201620
src_bit_off += eccsize * 8;
16211621

drivers/mtd/nand/raw/intel-nand-controller.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ static int ebu_nand_probe(struct platform_device *pdev)
579579
struct device *dev = &pdev->dev;
580580
struct ebu_nand_controller *ebu_host;
581581
struct nand_chip *nand;
582-
struct mtd_info *mtd = NULL;
582+
struct mtd_info *mtd;
583583
struct resource *res;
584584
char *resname;
585585
int ret;
@@ -647,12 +647,13 @@ static int ebu_nand_probe(struct platform_device *pdev)
647647
ebu_host->ebu + EBU_ADDR_SEL(cs));
648648

649649
nand_set_flash_node(&ebu_host->chip, dev->of_node);
650+
651+
mtd = nand_to_mtd(&ebu_host->chip);
650652
if (!mtd->name) {
651653
dev_err(ebu_host->dev, "NAND label property is mandatory\n");
652654
return -EINVAL;
653655
}
654656

655-
mtd = nand_to_mtd(&ebu_host->chip);
656657
mtd->dev.parent = dev;
657658
ebu_host->dev = dev;
658659

drivers/mtd/nand/raw/nandsim.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2210,6 +2210,9 @@ static int ns_attach_chip(struct nand_chip *chip)
22102210
{
22112211
unsigned int eccsteps, eccbytes;
22122212

2213+
chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
2214+
chip->ecc.algo = bch ? NAND_ECC_ALGO_BCH : NAND_ECC_ALGO_HAMMING;
2215+
22132216
if (!bch)
22142217
return 0;
22152218

@@ -2233,8 +2236,6 @@ static int ns_attach_chip(struct nand_chip *chip)
22332236
return -EINVAL;
22342237
}
22352238

2236-
chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
2237-
chip->ecc.algo = NAND_ECC_ALGO_BCH;
22382239
chip->ecc.size = 512;
22392240
chip->ecc.strength = bch;
22402241
chip->ecc.bytes = eccbytes;
@@ -2273,8 +2274,6 @@ static int __init ns_init_module(void)
22732274
nsmtd = nand_to_mtd(chip);
22742275
nand_set_controller_data(chip, (void *)ns);
22752276

2276-
chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
2277-
chip->ecc.algo = NAND_ECC_ALGO_HAMMING;
22782277
/* The NAND_SKIP_BBTSCAN option is necessary for 'overridesize' */
22792278
/* and 'badblocks' parameters to work */
22802279
chip->options |= NAND_SKIP_BBTSCAN;

drivers/mtd/nand/raw/omap2.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/jiffies.h>
1616
#include <linux/sched.h>
1717
#include <linux/mtd/mtd.h>
18+
#include <linux/mtd/nand-ecc-sw-bch.h>
1819
#include <linux/mtd/rawnand.h>
1920
#include <linux/mtd/partitions.h>
2021
#include <linux/omap-dma.h>
@@ -1866,26 +1867,28 @@ static const struct mtd_ooblayout_ops omap_ooblayout_ops = {
18661867
static int omap_sw_ooblayout_ecc(struct mtd_info *mtd, int section,
18671868
struct mtd_oob_region *oobregion)
18681869
{
1869-
struct nand_chip *chip = mtd_to_nand(mtd);
1870+
struct nand_device *nand = mtd_to_nanddev(mtd);
1871+
const struct nand_ecc_sw_bch_conf *engine_conf = nand->ecc.ctx.priv;
18701872
int off = BADBLOCK_MARKER_LENGTH;
18711873

1872-
if (section >= chip->ecc.steps)
1874+
if (section >= engine_conf->nsteps)
18731875
return -ERANGE;
18741876

18751877
/*
18761878
* When SW correction is employed, one OMAP specific marker byte is
18771879
* reserved after each ECC step.
18781880
*/
1879-
oobregion->offset = off + (section * (chip->ecc.bytes + 1));
1880-
oobregion->length = chip->ecc.bytes;
1881+
oobregion->offset = off + (section * (engine_conf->code_size + 1));
1882+
oobregion->length = engine_conf->code_size;
18811883

18821884
return 0;
18831885
}
18841886

18851887
static int omap_sw_ooblayout_free(struct mtd_info *mtd, int section,
18861888
struct mtd_oob_region *oobregion)
18871889
{
1888-
struct nand_chip *chip = mtd_to_nand(mtd);
1890+
struct nand_device *nand = mtd_to_nanddev(mtd);
1891+
const struct nand_ecc_sw_bch_conf *engine_conf = nand->ecc.ctx.priv;
18891892
int off = BADBLOCK_MARKER_LENGTH;
18901893

18911894
if (section)
@@ -1895,7 +1898,7 @@ static int omap_sw_ooblayout_free(struct mtd_info *mtd, int section,
18951898
* When SW correction is employed, one OMAP specific marker byte is
18961899
* reserved after each ECC step.
18971900
*/
1898-
off += ((chip->ecc.bytes + 1) * chip->ecc.steps);
1901+
off += ((engine_conf->code_size + 1) * engine_conf->nsteps);
18991902
if (off >= mtd->oobsize)
19001903
return -ERANGE;
19011904

drivers/mtd/nand/spi/core.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ static int spinand_read_from_cache_op(struct spinand_device *spinand,
343343
const struct nand_page_io_req *req)
344344
{
345345
struct nand_device *nand = spinand_to_nand(spinand);
346+
struct mtd_info *mtd = spinand_to_mtd(spinand);
346347
struct spi_mem_dirmap_desc *rdesc;
347348
unsigned int nbytes = 0;
348349
void *buf = NULL;
@@ -382,9 +383,16 @@ static int spinand_read_from_cache_op(struct spinand_device *spinand,
382383
memcpy(req->databuf.in, spinand->databuf + req->dataoffs,
383384
req->datalen);
384385

385-
if (req->ooblen)
386-
memcpy(req->oobbuf.in, spinand->oobbuf + req->ooboffs,
387-
req->ooblen);
386+
if (req->ooblen) {
387+
if (req->mode == MTD_OPS_AUTO_OOB)
388+
mtd_ooblayout_get_databytes(mtd, req->oobbuf.in,
389+
spinand->oobbuf,
390+
req->ooboffs,
391+
req->ooblen);
392+
else
393+
memcpy(req->oobbuf.in, spinand->oobbuf + req->ooboffs,
394+
req->ooblen);
395+
}
388396

389397
return 0;
390398
}

0 commit comments

Comments
 (0)