From: John Crispin Date: Tue, 24 May 2016 15:01:41 +0000 (+0200) Subject: mediatek: update mtd backport X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=1eac53ba92894ca6ad84d6c14159d17c5f5b9ea5;p=openwrt%2Fstaging%2Fkaloz.git mediatek: update mtd backport Signed-off-by: John Crispin --- diff --git a/target/linux/mediatek/patches-4.4/0072-mtd-backport-v4.7-0day-patches-from-Boris.patch b/target/linux/mediatek/patches-4.4/0072-mtd-backport-v4.7-0day-patches-from-Boris.patch index e89c3729fb..e4c8bc36e5 100644 --- a/target/linux/mediatek/patches-4.4/0072-mtd-backport-v4.7-0day-patches-from-Boris.patch +++ b/target/linux/mediatek/patches-4.4/0072-mtd-backport-v4.7-0day-patches-from-Boris.patch @@ -53,11 +53,9 @@ Signed-off-by: John Crispin 45 files changed, 2077 insertions(+), 748 deletions(-) create mode 100644 drivers/mtd/spi-nor/mtk-quadspi.c -diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig -index a03ad29..e83a279 100644 --- a/drivers/mtd/Kconfig +++ b/drivers/mtd/Kconfig -@@ -112,7 +112,7 @@ config MTD_CMDLINE_PARTS +@@ -131,7 +131,7 @@ config MTD_AFS_PARTS tristate "ARM Firmware Suite partition parsing" @@ -66,7 +64,7 @@ index a03ad29..e83a279 100644 ---help--- The ARM Firmware Suite allows the user to divide flash devices into multiple 'images'. Each such image has a header containing its name -@@ -142,7 +142,7 @@ config MTD_AR7_PARTS +@@ -161,7 +161,7 @@ config MTD_BCM63XX_PARTS tristate "BCM63XX CFE partitioning support" @@ -75,11 +73,9 @@ index a03ad29..e83a279 100644 select CRC32 help This provides partions parsing for BCM63xx devices with CFE -diff --git a/drivers/mtd/cmdlinepart.c b/drivers/mtd/cmdlinepart.c -index 08f6298..fbd5aff 100644 --- a/drivers/mtd/cmdlinepart.c +++ b/drivers/mtd/cmdlinepart.c -@@ -304,7 +304,7 @@ static int mtdpart_setup_real(char *s) +@@ -304,7 +304,7 @@ * the first one in the chain if a NULL mtd_id is passed in. */ static int parse_cmdline_partitions(struct mtd_info *master, @@ -88,7 +84,7 @@ index 08f6298..fbd5aff 100644 struct mtd_part_parser_data *data) { unsigned long long offset; -@@ -382,7 +382,6 @@ static int __init mtdpart_setup(char *s) +@@ -382,7 +382,6 @@ __setup("mtdparts=", mtdpart_setup); static struct mtd_part_parser cmdline_parser = { @@ -96,11 +92,9 @@ index 08f6298..fbd5aff 100644 .parse_fn = parse_cmdline_partitions, .name = "cmdlinepart", }; -diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c -index fe9ceb7..c9c3b7f 100644 --- a/drivers/mtd/devices/m25p80.c +++ b/drivers/mtd/devices/m25p80.c -@@ -152,22 +152,6 @@ static int m25p80_read(struct spi_nor *nor, loff_t from, size_t len, +@@ -174,22 +174,6 @@ return 0; } @@ -123,7 +117,7 @@ index fe9ceb7..c9c3b7f 100644 /* * board specific setup should have ensured the SPI clock used here * matches what the READ command supports, at least until this driver -@@ -175,12 +159,11 @@ static int m25p80_erase(struct spi_nor *nor, loff_t offset) +@@ -197,12 +181,11 @@ */ static int m25p_probe(struct spi_device *spi) { @@ -137,7 +131,7 @@ index fe9ceb7..c9c3b7f 100644 int ret; data = dev_get_platdata(&spi->dev); -@@ -194,12 +177,11 @@ static int m25p_probe(struct spi_device *spi) +@@ -216,12 +199,11 @@ /* install the hooks */ nor->read = m25p80_read; nor->write = m25p80_write; @@ -151,7 +145,7 @@ index fe9ceb7..c9c3b7f 100644 nor->priv = flash; spi_set_drvdata(spi, flash); -@@ -220,6 +202,8 @@ static int m25p_probe(struct spi_device *spi) +@@ -242,6 +224,8 @@ */ if (data && data->type) flash_name = data->type; @@ -160,7 +154,7 @@ index fe9ceb7..c9c3b7f 100644 else flash_name = spi->modalias; -@@ -227,11 +211,8 @@ static int m25p_probe(struct spi_device *spi) +@@ -249,11 +233,8 @@ if (ret) return ret; @@ -174,7 +168,7 @@ index fe9ceb7..c9c3b7f 100644 } -@@ -257,14 +238,21 @@ static int m25p_remove(struct spi_device *spi) +@@ -279,14 +260,21 @@ */ static const struct spi_device_id m25p_ids[] = { /* @@ -199,11 +193,9 @@ index fe9ceb7..c9c3b7f 100644 */ {"at25df321a"}, {"at25df641"}, {"at26df081a"}, {"mr25h256"}, -diff --git a/drivers/mtd/maps/physmap_of.c b/drivers/mtd/maps/physmap_of.c -index e46b4e9..70c4531 100644 --- a/drivers/mtd/maps/physmap_of.c +++ b/drivers/mtd/maps/physmap_of.c -@@ -166,7 +166,6 @@ static int of_flash_probe(struct platform_device *dev) +@@ -128,7 +128,6 @@ int reg_tuple_size; struct mtd_info **mtd_list = NULL; resource_size_t res_size; @@ -211,28 +203,21 @@ index e46b4e9..70c4531 100644 bool map_indirect; const char *mtd_name = NULL; -@@ -310,13 +309,14 @@ static int of_flash_probe(struct platform_device *dev) +@@ -272,8 +271,9 @@ if (err) goto err_out; - ppdata.of_node = dp; +- mtd_device_parse_register(info->cmtd, part_probe_types_def, &ppdata, + info->cmtd->dev.parent = &dev->dev; + mtd_set_of_node(info->cmtd, dp); - part_probe_types = of_get_probes(dp); - if (!part_probe_types) { - err = -ENOMEM; - goto err_out; - } -- mtd_device_parse_register(info->cmtd, part_probe_types, &ppdata, -+ mtd_device_parse_register(info->cmtd, part_probe_types, NULL, ++ mtd_device_parse_register(info->cmtd, part_probe_types_def, NULL, NULL, 0); - of_free_probes(part_probe_types); -diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c -index 6d19835..2a47a3f 100644 + kfree(mtd_list); --- a/drivers/mtd/mtdchar.c +++ b/drivers/mtd/mtdchar.c -@@ -465,35 +465,108 @@ static int mtdchar_readoob(struct file *file, struct mtd_info *mtd, +@@ -465,38 +465,111 @@ } /* @@ -295,17 +280,19 @@ index 6d19835..2a47a3f 100644 + if (ret != -ERANGE) + return ret; + -+ break; + break; +- to->oobavail += from->oobfree[i].length; +- to->oobfree[i] = from->oobfree[i]; + } + + to->oobfree[i].offset = oobregion.offset; + to->oobfree[i].length = oobregion.length; + to->oobavail += to->oobfree[i].length; -+ } -+ -+ return 0; -+} -+ + } + + return 0; + } + +static int get_oobinfo(struct mtd_info *mtd, struct nand_oobinfo *to) +{ + struct mtd_oob_region oobregion; @@ -325,9 +312,7 @@ index 6d19835..2a47a3f 100644 + if (ret != -ERANGE) + return ret; + - break; -- to->oobavail += from->oobfree[i].length; -- to->oobfree[i] = from->oobfree[i]; ++ break; + } + + if (oobregion.length + i > ARRAY_SIZE(to->eccpos)) @@ -338,8 +323,8 @@ index 6d19835..2a47a3f 100644 + to->eccpos[i] = eccpos++; + to->eccbytes++; + } - } - ++ } ++ + for (i = 0; i < 8; i++) { + ret = mtd_ooblayout_free(mtd, i, &oobregion); + if (ret < 0) { @@ -355,10 +340,13 @@ index 6d19835..2a47a3f 100644 + + to->useecc = MTD_NANDECC_AUTOPLACE; + - return 0; - } - -@@ -815,16 +888,12 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg) ++ return 0; ++} ++ + static int mtdchar_blkpg_ioctl(struct mtd_info *mtd, + struct blkpg_ioctl_arg *arg) + { +@@ -815,16 +888,12 @@ { struct nand_oobinfo oi; @@ -379,7 +367,7 @@ index 6d19835..2a47a3f 100644 if (copy_to_user(argp, &oi, sizeof(struct nand_oobinfo))) return -EFAULT; -@@ -913,14 +982,14 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg) +@@ -913,14 +982,14 @@ { struct nand_ecclayout_user *usrlay; @@ -396,11 +384,9 @@ index 6d19835..2a47a3f 100644 if (copy_to_user(argp, usrlay, sizeof(*usrlay))) ret = -EFAULT; -diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c -index 239a8c8..d573606 100644 --- a/drivers/mtd/mtdconcat.c +++ b/drivers/mtd/mtdconcat.c -@@ -777,7 +777,7 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c +@@ -777,7 +777,7 @@ } @@ -409,8 +395,6 @@ index 239a8c8..d573606 100644 concat->num_subdev = num_devs; concat->mtd.name = name; -diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c -index 95c13b2..cbfa5ad 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -32,6 +32,7 @@ @@ -421,23 +405,7 @@ index 95c13b2..cbfa5ad 100644 #include #include #include -@@ -426,15 +427,6 @@ int add_mtd_device(struct mtd_info *mtd) - mtd->erasesize_mask = (1 << mtd->erasesize_shift) - 1; - mtd->writesize_mask = (1 << mtd->writesize_shift) - 1; - -- if (mtd->dev.parent) { -- if (!mtd->owner && mtd->dev.parent->driver) -- mtd->owner = mtd->dev.parent->driver->owner; -- if (!mtd->name) -- mtd->name = dev_name(mtd->dev.parent); -- } else { -- pr_debug("mtd device won't show a device symlink in sysfs\n"); -- } -- - /* Some chips always power up locked. Unlock them now */ - if ((mtd->flags & MTD_WRITEABLE) && (mtd->flags & MTD_POWERUP_LOCK)) { - error = mtd_unlock(mtd, 0, mtd->size); -@@ -454,6 +446,7 @@ int add_mtd_device(struct mtd_info *mtd) +@@ -446,6 +447,7 @@ mtd->dev.devt = MTD_DEVT(i); dev_set_name(&mtd->dev, "mtd%d", i); dev_set_drvdata(&mtd->dev, mtd); @@ -445,7 +413,7 @@ index 95c13b2..cbfa5ad 100644 error = device_register(&mtd->dev); if (error) goto fail_added; -@@ -476,6 +469,7 @@ int add_mtd_device(struct mtd_info *mtd) +@@ -477,6 +479,7 @@ return 0; fail_added: @@ -453,7 +421,7 @@ index 95c13b2..cbfa5ad 100644 idr_remove(&mtd_idr, i); fail_locked: mutex_unlock(&mtd_table_mutex); -@@ -517,6 +511,7 @@ int del_mtd_device(struct mtd_info *mtd) +@@ -518,6 +521,7 @@ device_unregister(&mtd->dev); idr_remove(&mtd_idr, mtd->index); @@ -461,7 +429,7 @@ index 95c13b2..cbfa5ad 100644 module_put(THIS_MODULE); ret = 0; -@@ -528,9 +523,10 @@ out_error: +@@ -529,9 +533,10 @@ } static int mtd_add_device_partitions(struct mtd_info *mtd, @@ -474,36 +442,16 @@ index 95c13b2..cbfa5ad 100644 int ret; if (nbparts == 0 || IS_ENABLED(CONFIG_MTD_PARTITIONED_MASTER)) { -@@ -549,6 +545,21 @@ static int mtd_add_device_partitions(struct mtd_info *mtd, - return 0; - } - -+/* -+ * Set a few defaults based on the parent devices, if not provided by the -+ * driver -+ */ -+static void mtd_set_dev_defaults(struct mtd_info *mtd) -+{ -+ if (mtd->dev.parent) { -+ if (!mtd->owner && mtd->dev.parent->driver) -+ mtd->owner = mtd->dev.parent->driver->owner; -+ if (!mtd->name) -+ mtd->name = dev_name(mtd->dev.parent); -+ } else { -+ pr_debug("mtd device won't show a device symlink in sysfs\n"); -+ } -+} - - /** - * mtd_device_parse_register - parse partitions and register an MTD device. -@@ -584,27 +595,29 @@ int mtd_device_parse_register(struct mtd_info *mtd, const char * const *types, +@@ -600,29 +605,29 @@ const struct mtd_partition *parts, int nr_parts) { + struct mtd_partitions parsed; int ret; - struct mtd_partition *real_parts = NULL; -- + + mtd_set_dev_defaults(mtd); + - ret = parse_mtd_partitions(mtd, types, &real_parts, parser_data); - if (ret <= 0 && nr_parts && parts) { - real_parts = kmemdup(parts, sizeof(*parts) * nr_parts, @@ -515,9 +463,7 @@ index 95c13b2..cbfa5ad 100644 - } - /* Didn't come up with either parsed OR fallback partitions */ - if (ret < 0) { -+ -+ mtd_set_dev_defaults(mtd); -+ +- pr_info("mtd: failed to find partitions; one or more parsers reports errors (%d)\n", + memset(&parsed, 0, sizeof(parsed)); + + ret = parse_mtd_partitions(mtd, types, &parsed, parser_data); @@ -529,7 +475,7 @@ index 95c13b2..cbfa5ad 100644 + }; + } else if (ret < 0) { + /* Didn't come up with parsed OR fallback partitions */ - pr_info("mtd: failed to find partitions; one or more parsers reports errors (%d)\n", ++ pr_info("mtd: failed to find partitions; one or more parsers reports errors (%d)\n", ret); /* Don't abort on errors; we can still use unpartitioned MTD */ - ret = 0; @@ -537,11 +483,11 @@ index 95c13b2..cbfa5ad 100644 } - ret = mtd_add_device_partitions(mtd, real_parts, ret); -+ ret = mtd_add_device_partitions(mtd, &parsed); ++ ret = mtd_add_device_partitions(mtd, ret); if (ret) goto out; -@@ -624,7 +637,8 @@ int mtd_device_parse_register(struct mtd_info *mtd, const char * const *types, +@@ -642,7 +647,8 @@ } out: @@ -551,7 +497,15 @@ index 95c13b2..cbfa5ad 100644 return ret; } EXPORT_SYMBOL_GPL(mtd_device_parse_register); -@@ -983,6 +997,366 @@ int mtd_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops) +@@ -767,7 +773,6 @@ + } + EXPORT_SYMBOL_GPL(get_mtd_device); + +- + int __get_mtd_device(struct mtd_info *mtd) + { + int err; +@@ -1001,6 +1006,366 @@ } EXPORT_SYMBOL_GPL(mtd_read_oob); @@ -918,11 +872,9 @@ index 95c13b2..cbfa5ad 100644 /* * Method to access the protection register area, present in some flash * devices. The user data is one time programmable but the factory data is read -diff --git a/drivers/mtd/mtdcore.h b/drivers/mtd/mtdcore.h -index 7b03533..55fdb8e 100644 --- a/drivers/mtd/mtdcore.h +++ b/drivers/mtd/mtdcore.h -@@ -10,10 +10,15 @@ int add_mtd_device(struct mtd_info *mtd); +@@ -10,10 +10,15 @@ int del_mtd_device(struct mtd_info *mtd); int add_mtd_partitions(struct mtd_info *, const struct mtd_partition *, int); int del_mtd_partitions(struct mtd_info *); @@ -939,11 +891,9 @@ index 7b03533..55fdb8e 100644 int __init init_mtdchar(void); void __exit cleanup_mtdchar(void); -diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c -index f8ba153..1f13e32 100644 --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c -@@ -48,9 +48,12 @@ struct mtd_part { +@@ -55,9 +55,12 @@ /* * Given a pointer to the MTD object in the mtd_part structure, we can retrieve @@ -958,7 +908,7 @@ index f8ba153..1f13e32 100644 /* -@@ -61,7 +64,7 @@ struct mtd_part { +@@ -68,7 +71,7 @@ static int part_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf) { @@ -967,7 +917,7 @@ index f8ba153..1f13e32 100644 struct mtd_ecc_stats stats; int res; -@@ -80,7 +83,7 @@ static int part_read(struct mtd_info *mtd, loff_t from, size_t len, +@@ -87,7 +90,7 @@ static int part_point(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, void **virt, resource_size_t *phys) { @@ -976,7 +926,7 @@ index f8ba153..1f13e32 100644 return part->master->_point(part->master, from + part->offset, len, retlen, virt, phys); -@@ -88,7 +91,7 @@ static int part_point(struct mtd_info *mtd, loff_t from, size_t len, +@@ -95,7 +98,7 @@ static int part_unpoint(struct mtd_info *mtd, loff_t from, size_t len) { @@ -985,7 +935,7 @@ index f8ba153..1f13e32 100644 return part->master->_unpoint(part->master, from + part->offset, len); } -@@ -98,7 +101,7 @@ static unsigned long part_get_unmapped_area(struct mtd_info *mtd, +@@ -105,7 +108,7 @@ unsigned long offset, unsigned long flags) { @@ -994,7 +944,7 @@ index f8ba153..1f13e32 100644 offset += part->offset; return part->master->_get_unmapped_area(part->master, len, offset, -@@ -108,7 +111,7 @@ static unsigned long part_get_unmapped_area(struct mtd_info *mtd, +@@ -115,7 +118,7 @@ static int part_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops) { @@ -1003,7 +953,7 @@ index f8ba153..1f13e32 100644 int res; if (from >= mtd->size) -@@ -123,10 +126,7 @@ static int part_read_oob(struct mtd_info *mtd, loff_t from, +@@ -130,10 +133,7 @@ if (ops->oobbuf) { size_t len, pages; @@ -1015,7 +965,7 @@ index f8ba153..1f13e32 100644 pages = mtd_div_by_ws(mtd->size, mtd); pages -= mtd_div_by_ws(from, mtd); if (ops->ooboffs + ops->ooblen > pages * len) -@@ -146,7 +146,7 @@ static int part_read_oob(struct mtd_info *mtd, loff_t from, +@@ -153,7 +153,7 @@ static int part_read_user_prot_reg(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf) { @@ -1024,7 +974,7 @@ index f8ba153..1f13e32 100644 return part->master->_read_user_prot_reg(part->master, from, len, retlen, buf); } -@@ -154,7 +154,7 @@ static int part_read_user_prot_reg(struct mtd_info *mtd, loff_t from, +@@ -161,7 +161,7 @@ static int part_get_user_prot_info(struct mtd_info *mtd, size_t len, size_t *retlen, struct otp_info *buf) { @@ -1033,7 +983,7 @@ index f8ba153..1f13e32 100644 return part->master->_get_user_prot_info(part->master, len, retlen, buf); } -@@ -162,7 +162,7 @@ static int part_get_user_prot_info(struct mtd_info *mtd, size_t len, +@@ -169,7 +169,7 @@ static int part_read_fact_prot_reg(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf) { @@ -1042,7 +992,7 @@ index f8ba153..1f13e32 100644 return part->master->_read_fact_prot_reg(part->master, from, len, retlen, buf); } -@@ -170,7 +170,7 @@ static int part_read_fact_prot_reg(struct mtd_info *mtd, loff_t from, +@@ -177,7 +177,7 @@ static int part_get_fact_prot_info(struct mtd_info *mtd, size_t len, size_t *retlen, struct otp_info *buf) { @@ -1051,7 +1001,7 @@ index f8ba153..1f13e32 100644 return part->master->_get_fact_prot_info(part->master, len, retlen, buf); } -@@ -178,7 +178,7 @@ static int part_get_fact_prot_info(struct mtd_info *mtd, size_t len, +@@ -185,7 +185,7 @@ static int part_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf) { @@ -1060,7 +1010,7 @@ index f8ba153..1f13e32 100644 return part->master->_write(part->master, to + part->offset, len, retlen, buf); } -@@ -186,7 +186,7 @@ static int part_write(struct mtd_info *mtd, loff_t to, size_t len, +@@ -193,7 +193,7 @@ static int part_panic_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf) { @@ -1069,7 +1019,7 @@ index f8ba153..1f13e32 100644 return part->master->_panic_write(part->master, to + part->offset, len, retlen, buf); } -@@ -194,7 +194,7 @@ static int part_panic_write(struct mtd_info *mtd, loff_t to, size_t len, +@@ -201,7 +201,7 @@ static int part_write_oob(struct mtd_info *mtd, loff_t to, struct mtd_oob_ops *ops) { @@ -1078,7 +1028,7 @@ index f8ba153..1f13e32 100644 if (to >= mtd->size) return -EINVAL; -@@ -206,7 +206,7 @@ static int part_write_oob(struct mtd_info *mtd, loff_t to, +@@ -213,7 +213,7 @@ static int part_write_user_prot_reg(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf) { @@ -1087,7 +1037,7 @@ index f8ba153..1f13e32 100644 return part->master->_write_user_prot_reg(part->master, from, len, retlen, buf); } -@@ -214,21 +214,21 @@ static int part_write_user_prot_reg(struct mtd_info *mtd, loff_t from, +@@ -221,21 +221,21 @@ static int part_lock_user_prot_reg(struct mtd_info *mtd, loff_t from, size_t len) { @@ -1111,17 +1061,17 @@ index f8ba153..1f13e32 100644 + struct mtd_part *part = mtd_to_part(mtd); int ret; - instr->addr += part->offset; -@@ -244,7 +244,7 @@ static int part_erase(struct mtd_info *mtd, struct erase_info *instr) + +@@ -299,7 +299,7 @@ void mtd_erase_callback(struct erase_info *instr) { if (instr->mtd->_erase == part_erase) { - struct mtd_part *part = PART(instr->mtd); + struct mtd_part *part = mtd_to_part(instr->mtd); + size_t wrlen = 0; - if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN) - instr->fail_addr -= part->offset; -@@ -257,57 +257,57 @@ EXPORT_SYMBOL_GPL(mtd_erase_callback); + if (instr->mtd->flags & MTD_ERASE_PARTIAL) { +@@ -330,13 +330,13 @@ static int part_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) { @@ -1134,8 +1084,10 @@ index f8ba153..1f13e32 100644 { - struct mtd_part *part = PART(mtd); + struct mtd_part *part = mtd_to_part(mtd); - return part->master->_unlock(part->master, ofs + part->offset, len); - } + + ofs += part->offset; + if (mtd->flags & MTD_ERASE_PARTIAL) { +@@ -349,45 +349,45 @@ static int part_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len) { @@ -1188,7 +1140,7 @@ index f8ba153..1f13e32 100644 int res; ofs += part->offset; -@@ -317,6 +317,27 @@ static int part_block_markbad(struct mtd_info *mtd, loff_t ofs) +@@ -397,6 +397,27 @@ return res; } @@ -1216,8 +1168,8 @@ index f8ba153..1f13e32 100644 static inline void free_partition(struct mtd_part *p) { kfree(p->mtd.name); -@@ -533,7 +554,7 @@ static struct mtd_part *allocate_partition(struct mtd_info *master, - part->name); +@@ -614,7 +635,7 @@ + slave->mtd.erasesize = slave->mtd.size; } - slave->mtd.ecclayout = master->ecclayout; @@ -1225,7 +1177,7 @@ index f8ba153..1f13e32 100644 slave->mtd.ecc_step_size = master->ecc_step_size; slave->mtd.ecc_strength = master->ecc_strength; slave->mtd.bitflip_threshold = master->bitflip_threshold; -@@ -558,7 +579,7 @@ static ssize_t mtd_partition_offset_show(struct device *dev, +@@ -639,7 +660,7 @@ struct device_attribute *attr, char *buf) { struct mtd_info *mtd = dev_get_drvdata(dev); @@ -1234,7 +1186,7 @@ index f8ba153..1f13e32 100644 return snprintf(buf, PAGE_SIZE, "%lld\n", part->offset); } -@@ -596,11 +617,10 @@ int mtd_add_partition(struct mtd_info *master, const char *name, +@@ -677,11 +698,10 @@ if (length <= 0) return -EINVAL; @@ -1247,7 +1199,7 @@ index f8ba153..1f13e32 100644 new = allocate_partition(master, &part, -1, offset); if (IS_ERR(new)) -@@ -685,7 +705,7 @@ int add_mtd_partitions(struct mtd_info *master, +@@ -845,7 +865,7 @@ static DEFINE_SPINLOCK(part_parser_lock); static LIST_HEAD(part_parsers); @@ -1256,7 +1208,7 @@ index f8ba153..1f13e32 100644 { struct mtd_part_parser *p, *ret = NULL; -@@ -702,15 +722,35 @@ static struct mtd_part_parser *get_partition_parser(const char *name) +@@ -862,7 +882,20 @@ return ret; } @@ -1276,9 +1228,25 @@ index f8ba153..1f13e32 100644 + kfree(pparts); +} + static struct mtd_part_parser * + get_partition_parser_by_type(enum mtd_parser_type type, +@@ -874,7 +907,7 @@ + + p = list_prepare_entry(start, &part_parsers, list); + if (start) +- put_partition_parser(start); ++ mtd_part_parser_put(start); + + list_for_each_entry_continue(p, &part_parsers, list) { + if (p->type == type && try_module_get(p->owner)) { +@@ -888,13 +921,19 @@ + return ret; + } + -void register_mtd_parser(struct mtd_part_parser *p) +-{ +int __register_mtd_parser(struct mtd_part_parser *p, struct module *owner) - { ++ { + p->owner = owner; + + if (!p->cleanup) @@ -1287,7 +1255,6 @@ index f8ba153..1f13e32 100644 spin_lock(&part_parser_lock); list_add(&p->list, &part_parsers); spin_unlock(&part_parser_lock); -+ + return 0; } -EXPORT_SYMBOL_GPL(register_mtd_parser); @@ -1295,7 +1262,7 @@ index f8ba153..1f13e32 100644 void deregister_mtd_parser(struct mtd_part_parser *p) { -@@ -734,7 +774,7 @@ static const char * const default_mtd_part_types[] = { +@@ -954,7 +993,7 @@ * parse_mtd_partitions - parse MTD partitions * @master: the master partition (describes whole MTD device) * @types: names of partition parsers to try or %NULL @@ -1304,7 +1271,7 @@ index f8ba153..1f13e32 100644 * @data: MTD partition parser-specific data * * This function tries to find partition on MTD device @master. It uses MTD -@@ -746,12 +786,13 @@ static const char * const default_mtd_part_types[] = { +@@ -966,45 +1005,42 @@ * * This function may return: * o a negative error code in case of failure @@ -1322,7 +1289,17 @@ index f8ba153..1f13e32 100644 struct mtd_part_parser_data *data) { struct mtd_part_parser *parser; -@@ -762,22 +803,24 @@ int parse_mtd_partitions(struct mtd_info *master, const char *const *types, + int ret, err = 0; + const char *const *types_of = NULL; + +- if (data && data->of_node) { +- types_of = of_get_probes(data->of_node); +- if (types_of != NULL) +- types = types_of; +- } +- + if (!types) + types = default_mtd_part_types; for ( ; *types; types++) { pr_debug("%s: parsing partitions %s\n", master->name, *types); @@ -1352,9 +1329,18 @@ index f8ba153..1f13e32 100644 /* * Stash the first error we see; only report it if no parser * succeeds -@@ -788,6 +831,22 @@ int parse_mtd_partitions(struct mtd_info *master, const char *const *types, - return err; +@@ -1034,7 +1070,7 @@ + ret = (*parser->parse_fn)(master, pparts, data); + + if (ret > 0) { +- put_partition_parser(parser); ++ mtd_part_parser_put(parser); + printk(KERN_NOTICE + "%d %s partitions found on MTD device %s\n", + ret, parser->name, master->name); +@@ -1048,6 +1084,22 @@ } + EXPORT_SYMBOL_GPL(parse_mtd_partitions_by_type); +void mtd_part_parser_cleanup(struct mtd_partitions *parts) +{ @@ -1375,7 +1361,25 @@ index f8ba153..1f13e32 100644 int mtd_is_partition(const struct mtd_info *mtd) { struct mtd_part *part; -@@ -811,6 +870,6 @@ uint64_t mtd_get_device_size(const struct mtd_info *mtd) +@@ -1070,7 +1122,7 @@ + if (!mtd_is_partition(mtd)) + return (struct mtd_info *)mtd; + +- return PART(mtd)->master; ++ return mtd_to_part(mtd)->master; + } + EXPORT_SYMBOL_GPL(mtdpart_get_master); + +@@ -1079,7 +1131,7 @@ + if (!mtd_is_partition(mtd)) + return 0; + +- return PART(mtd)->offset; ++ return mtd_to_part(mtd)->offset; + } + EXPORT_SYMBOL_GPL(mtdpart_get_offset); + +@@ -1089,6 +1141,6 @@ if (!mtd_is_partition(mtd)) return mtd->size; @@ -1383,11 +1387,9 @@ index f8ba153..1f13e32 100644 + return mtd_to_part(mtd)->master->size; } EXPORT_SYMBOL_GPL(mtd_get_device_size); -diff --git a/drivers/mtd/mtdswap.c b/drivers/mtd/mtdswap.c -index fc8b3d1..cb06bdd 100644 --- a/drivers/mtd/mtdswap.c +++ b/drivers/mtd/mtdswap.c -@@ -346,7 +346,7 @@ static int mtdswap_read_markers(struct mtdswap_dev *d, struct swap_eb *eb) +@@ -346,7 +346,7 @@ if (mtd_can_have_bb(d->mtd) && mtd_block_isbad(d->mtd, offset)) return MTDSWAP_SCANNED_BAD; @@ -1396,7 +1398,7 @@ index fc8b3d1..cb06bdd 100644 ops.oobbuf = d->oob_buf; ops.ooboffs = 0; ops.datbuf = NULL; -@@ -359,7 +359,7 @@ static int mtdswap_read_markers(struct mtdswap_dev *d, struct swap_eb *eb) +@@ -359,7 +359,7 @@ data = (struct mtdswap_oobdata *)d->oob_buf; data2 = (struct mtdswap_oobdata *) @@ -1405,7 +1407,7 @@ index fc8b3d1..cb06bdd 100644 if (le16_to_cpu(data->magic) == MTDSWAP_MAGIC_CLEAN) { eb->erase_count = le32_to_cpu(data->count); -@@ -933,7 +933,7 @@ static unsigned int mtdswap_eblk_passes(struct mtdswap_dev *d, +@@ -933,7 +933,7 @@ ops.mode = MTD_OPS_AUTO_OOB; ops.len = mtd->writesize; @@ -1414,7 +1416,7 @@ index fc8b3d1..cb06bdd 100644 ops.ooboffs = 0; ops.datbuf = d->page_buf; ops.oobbuf = d->oob_buf; -@@ -945,7 +945,7 @@ static unsigned int mtdswap_eblk_passes(struct mtdswap_dev *d, +@@ -945,7 +945,7 @@ for (i = 0; i < mtd_pages; i++) { patt = mtdswap_test_patt(test + i); memset(d->page_buf, patt, mtd->writesize); @@ -1423,7 +1425,7 @@ index fc8b3d1..cb06bdd 100644 ret = mtd_write_oob(mtd, pos, &ops); if (ret) goto error; -@@ -964,7 +964,7 @@ static unsigned int mtdswap_eblk_passes(struct mtdswap_dev *d, +@@ -964,7 +964,7 @@ if (p1[j] != patt) goto error; @@ -1432,7 +1434,7 @@ index fc8b3d1..cb06bdd 100644 if (p2[j] != (unsigned char)patt) goto error; -@@ -1387,7 +1387,7 @@ static int mtdswap_init(struct mtdswap_dev *d, unsigned int eblocks, +@@ -1387,7 +1387,7 @@ if (!d->page_buf) goto page_buf_fail; @@ -1441,7 +1443,7 @@ index fc8b3d1..cb06bdd 100644 if (!d->oob_buf) goto oob_buf_fail; -@@ -1417,7 +1417,6 @@ static void mtdswap_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) +@@ -1417,7 +1417,6 @@ unsigned long part; unsigned int eblocks, eavailable, bad_blocks, spare_cnt; uint64_t swap_size, use_size, size_limit; @@ -1449,7 +1451,7 @@ index fc8b3d1..cb06bdd 100644 int ret; parts = &partitions[0]; -@@ -1447,17 +1446,10 @@ static void mtdswap_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) +@@ -1447,17 +1446,10 @@ return; } @@ -1469,11 +1471,9 @@ index fc8b3d1..cb06bdd 100644 return; } -diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig -index 2896640..f05e0e9 100644 --- a/drivers/mtd/nand/Kconfig +++ b/drivers/mtd/nand/Kconfig -@@ -55,7 +55,7 @@ config MTD_NAND_DENALI_PCI +@@ -55,7 +55,7 @@ config MTD_NAND_DENALI_DT tristate "Support Denali NAND controller as a DT device" select MTD_NAND_DENALI @@ -1482,7 +1482,7 @@ index 2896640..f05e0e9 100644 help Enable the driver for NAND flash on platforms using a Denali NAND controller as a DT device. -@@ -74,6 +74,7 @@ config MTD_NAND_DENALI_SCRATCH_REG_ADDR +@@ -74,6 +74,7 @@ config MTD_NAND_GPIO tristate "GPIO assisted NAND Flash driver" depends on GPIOLIB || COMPILE_TEST @@ -1490,7 +1490,7 @@ index 2896640..f05e0e9 100644 help This enables a NAND flash driver where control signals are connected to GPIO pins, and commands and data are communicated -@@ -310,6 +311,7 @@ config MTD_NAND_CAFE +@@ -310,6 +311,7 @@ config MTD_NAND_CS553X tristate "NAND support for CS5535/CS5536 (AMD Geode companion chip)" depends on X86_32 @@ -1498,7 +1498,7 @@ index 2896640..f05e0e9 100644 help The CS553x companion chips for the AMD Geode processor include NAND flash controllers with built-in hardware ECC -@@ -463,6 +465,7 @@ config MTD_NAND_MPC5121_NFC +@@ -463,6 +465,7 @@ config MTD_NAND_VF610_NFC tristate "Support for Freescale NFC for VF610/MPC5125" depends on (SOC_VF610 || COMPILE_TEST) @@ -1506,7 +1506,7 @@ index 2896640..f05e0e9 100644 help Enables support for NAND Flash Controller on some Freescale processors like the VF610, MPC5125, MCF54418 or Kinetis K70. -@@ -480,7 +483,7 @@ config MTD_NAND_MXC +@@ -480,7 +483,7 @@ config MTD_NAND_SH_FLCTL tristate "Support for NAND on Renesas SuperH FLCTL" @@ -1515,7 +1515,7 @@ index 2896640..f05e0e9 100644 depends on HAS_IOMEM depends on HAS_DMA help -@@ -519,6 +522,13 @@ config MTD_NAND_JZ4740 +@@ -519,6 +522,13 @@ help Enables support for NAND Flash on JZ4740 SoC based boards. @@ -1529,7 +1529,7 @@ index 2896640..f05e0e9 100644 config MTD_NAND_FSMC tristate "Support for NAND on ST Micros FSMC" depends on PLAT_SPEAR || ARCH_NOMADIK || ARCH_U8500 || MACH_U300 -@@ -546,4 +556,11 @@ config MTD_NAND_HISI504 +@@ -546,4 +556,11 @@ help Enables support for NAND controller on Hisilicon SoC Hip04. @@ -1541,11 +1541,9 @@ index 2896640..f05e0e9 100644 + controller. This controller is found on IPQ806x SoC. + endif # MTD_NAND -diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile -index 2c7f014..f553353 100644 --- a/drivers/mtd/nand/Makefile +++ b/drivers/mtd/nand/Makefile -@@ -49,11 +49,13 @@ obj-$(CONFIG_MTD_NAND_MPC5121_NFC) += mpc5121_nfc.o +@@ -49,11 +49,13 @@ obj-$(CONFIG_MTD_NAND_VF610_NFC) += vf610_nfc.o obj-$(CONFIG_MTD_NAND_RICOH) += r852.o obj-$(CONFIG_MTD_NAND_JZ4740) += jz4740_nand.o @@ -1559,8 +1557,6 @@ index 2c7f014..f553353 100644 +obj-$(CONFIG_MTD_NAND_QCOM) += qcom_nandc.o nand-objs := nand_base.o nand_bbt.o nand_timings.o -diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c -index ece544e..cf0c3180 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -48,50 +48,6 @@ @@ -1614,7 +1610,7 @@ index ece544e..cf0c3180 100644 static int nand_get_device(struct mtd_info *mtd, int new_state); static int nand_do_write_oob(struct mtd_info *mtd, loff_t to, -@@ -103,10 +59,96 @@ static int nand_do_write_oob(struct mtd_info *mtd, loff_t to, +@@ -103,10 +59,96 @@ */ DEFINE_LED_TRIGGER(nand_led_trigger); @@ -1712,7 +1708,7 @@ index ece544e..cf0c3180 100644 int ret = 0; /* Start address must align on block boundary */ -@@ -132,7 +174,7 @@ static int check_offs_len(struct mtd_info *mtd, +@@ -132,7 +174,7 @@ */ static void nand_release_device(struct mtd_info *mtd) { @@ -1721,7 +1717,7 @@ index ece544e..cf0c3180 100644 /* Release the controller and the chip */ spin_lock(&chip->controller->lock); -@@ -150,7 +192,7 @@ static void nand_release_device(struct mtd_info *mtd) +@@ -150,7 +192,7 @@ */ static uint8_t nand_read_byte(struct mtd_info *mtd) { @@ -1730,7 +1726,7 @@ index ece544e..cf0c3180 100644 return readb(chip->IO_ADDR_R); } -@@ -163,7 +205,7 @@ static uint8_t nand_read_byte(struct mtd_info *mtd) +@@ -163,7 +205,7 @@ */ static uint8_t nand_read_byte16(struct mtd_info *mtd) { @@ -1739,7 +1735,7 @@ index ece544e..cf0c3180 100644 return (uint8_t) cpu_to_le16(readw(chip->IO_ADDR_R)); } -@@ -175,7 +217,7 @@ static uint8_t nand_read_byte16(struct mtd_info *mtd) +@@ -175,7 +217,7 @@ */ static u16 nand_read_word(struct mtd_info *mtd) { @@ -1748,7 +1744,7 @@ index ece544e..cf0c3180 100644 return readw(chip->IO_ADDR_R); } -@@ -188,7 +230,7 @@ static u16 nand_read_word(struct mtd_info *mtd) +@@ -188,7 +230,7 @@ */ static void nand_select_chip(struct mtd_info *mtd, int chipnr) { @@ -1757,7 +1753,7 @@ index ece544e..cf0c3180 100644 switch (chipnr) { case -1: -@@ -211,7 +253,7 @@ static void nand_select_chip(struct mtd_info *mtd, int chipnr) +@@ -211,7 +253,7 @@ */ static void nand_write_byte(struct mtd_info *mtd, uint8_t byte) { @@ -1766,7 +1762,7 @@ index ece544e..cf0c3180 100644 chip->write_buf(mtd, &byte, 1); } -@@ -225,7 +267,7 @@ static void nand_write_byte(struct mtd_info *mtd, uint8_t byte) +@@ -225,7 +267,7 @@ */ static void nand_write_byte16(struct mtd_info *mtd, uint8_t byte) { @@ -1775,7 +1771,7 @@ index ece544e..cf0c3180 100644 uint16_t word = byte; /* -@@ -257,7 +299,7 @@ static void nand_write_byte16(struct mtd_info *mtd, uint8_t byte) +@@ -257,7 +299,7 @@ */ static void nand_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) { @@ -1784,7 +1780,7 @@ index ece544e..cf0c3180 100644 iowrite8_rep(chip->IO_ADDR_W, buf, len); } -@@ -272,7 +314,7 @@ static void nand_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) +@@ -272,7 +314,7 @@ */ static void nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) { @@ -1793,7 +1789,7 @@ index ece544e..cf0c3180 100644 ioread8_rep(chip->IO_ADDR_R, buf, len); } -@@ -287,7 +329,7 @@ static void nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) +@@ -287,7 +329,7 @@ */ static void nand_write_buf16(struct mtd_info *mtd, const uint8_t *buf, int len) { @@ -1802,7 +1798,7 @@ index ece544e..cf0c3180 100644 u16 *p = (u16 *) buf; iowrite16_rep(chip->IO_ADDR_W, p, len >> 1); -@@ -303,7 +345,7 @@ static void nand_write_buf16(struct mtd_info *mtd, const uint8_t *buf, int len) +@@ -303,7 +345,7 @@ */ static void nand_read_buf16(struct mtd_info *mtd, uint8_t *buf, int len) { @@ -1811,7 +1807,7 @@ index ece544e..cf0c3180 100644 u16 *p = (u16 *) buf; ioread16_rep(chip->IO_ADDR_R, p, len >> 1); -@@ -313,14 +355,13 @@ static void nand_read_buf16(struct mtd_info *mtd, uint8_t *buf, int len) +@@ -313,14 +355,13 @@ * nand_block_bad - [DEFAULT] Read bad block marker from the chip * @mtd: MTD device structure * @ofs: offset from device start @@ -1829,7 +1825,7 @@ index ece544e..cf0c3180 100644 u16 bad; if (chip->bbt_options & NAND_BBT_SCANLASTPAGE) -@@ -328,15 +369,6 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip) +@@ -328,15 +369,6 @@ page = (int)(ofs >> chip->page_shift) & chip->pagemask; @@ -1845,7 +1841,7 @@ index ece544e..cf0c3180 100644 do { if (chip->options & NAND_BUSWIDTH_16) { chip->cmdfunc(mtd, NAND_CMD_READOOB, -@@ -361,11 +393,6 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip) +@@ -361,11 +393,6 @@ i++; } while (!res && i < 2 && (chip->bbt_options & NAND_BBT_SCAN2NDPAGE)); @@ -1857,7 +1853,7 @@ index ece544e..cf0c3180 100644 return res; } -@@ -380,7 +407,7 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip) +@@ -380,7 +407,7 @@ */ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs) { @@ -1866,7 +1862,7 @@ index ece544e..cf0c3180 100644 struct mtd_oob_ops ops; uint8_t buf[2] = { 0, 0 }; int ret = 0, res, i = 0; -@@ -430,7 +457,7 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs) +@@ -430,7 +457,7 @@ */ static int nand_block_markbad_lowlevel(struct mtd_info *mtd, loff_t ofs) { @@ -1875,7 +1871,7 @@ index ece544e..cf0c3180 100644 int res, ret = 0; if (!(chip->bbt_options & NAND_BBT_NO_OOB_BBM)) { -@@ -471,7 +498,7 @@ static int nand_block_markbad_lowlevel(struct mtd_info *mtd, loff_t ofs) +@@ -471,7 +498,7 @@ */ static int nand_check_wp(struct mtd_info *mtd) { @@ -1884,7 +1880,7 @@ index ece544e..cf0c3180 100644 /* Broken xD cards report WP despite being writable */ if (chip->options & NAND_BROKEN_XD) -@@ -491,7 +518,7 @@ static int nand_check_wp(struct mtd_info *mtd) +@@ -491,7 +518,7 @@ */ static int nand_block_isreserved(struct mtd_info *mtd, loff_t ofs) { @@ -1893,7 +1889,7 @@ index ece544e..cf0c3180 100644 if (!chip->bbt) return 0; -@@ -503,19 +530,17 @@ static int nand_block_isreserved(struct mtd_info *mtd, loff_t ofs) +@@ -503,19 +530,17 @@ * nand_block_checkbad - [GENERIC] Check if a block is marked bad * @mtd: MTD device structure * @ofs: offset from device start @@ -1916,7 +1912,7 @@ index ece544e..cf0c3180 100644 /* Return info from the table */ return nand_isbad_bbt(mtd, ofs, allowbbt); -@@ -531,7 +556,7 @@ static int nand_block_checkbad(struct mtd_info *mtd, loff_t ofs, int getchip, +@@ -531,7 +556,7 @@ */ static void panic_nand_wait_ready(struct mtd_info *mtd, unsigned long timeo) { @@ -1925,7 +1921,7 @@ index ece544e..cf0c3180 100644 int i; /* Wait for the device to get ready */ -@@ -551,7 +576,7 @@ static void panic_nand_wait_ready(struct mtd_info *mtd, unsigned long timeo) +@@ -551,7 +576,7 @@ */ void nand_wait_ready(struct mtd_info *mtd) { @@ -1934,7 +1930,7 @@ index ece544e..cf0c3180 100644 unsigned long timeo = 400; if (in_interrupt() || oops_in_progress) -@@ -566,8 +591,8 @@ void nand_wait_ready(struct mtd_info *mtd) +@@ -566,8 +591,8 @@ cond_resched(); } while (time_before(jiffies, timeo)); @@ -1945,7 +1941,7 @@ index ece544e..cf0c3180 100644 out: led_trigger_event(nand_led_trigger, LED_OFF); } -@@ -582,7 +607,7 @@ EXPORT_SYMBOL_GPL(nand_wait_ready); +@@ -582,7 +607,7 @@ */ static void nand_wait_status_ready(struct mtd_info *mtd, unsigned long timeo) { @@ -1954,7 +1950,7 @@ index ece544e..cf0c3180 100644 timeo = jiffies + msecs_to_jiffies(timeo); do { -@@ -605,7 +630,7 @@ static void nand_wait_status_ready(struct mtd_info *mtd, unsigned long timeo) +@@ -605,7 +630,7 @@ static void nand_command(struct mtd_info *mtd, unsigned int command, int column, int page_addr) { @@ -1963,7 +1959,7 @@ index ece544e..cf0c3180 100644 int ctrl = NAND_CTRL_CLE | NAND_CTRL_CHANGE; /* Write out the command to the device */ -@@ -708,7 +733,7 @@ static void nand_command(struct mtd_info *mtd, unsigned int command, +@@ -708,7 +733,7 @@ static void nand_command_lp(struct mtd_info *mtd, unsigned int command, int column, int page_addr) { @@ -1972,7 +1968,7 @@ index ece544e..cf0c3180 100644 /* Emulate NAND_CMD_READOOB */ if (command == NAND_CMD_READOOB) { -@@ -832,7 +857,7 @@ static void panic_nand_get_device(struct nand_chip *chip, +@@ -832,7 +857,7 @@ static int nand_get_device(struct mtd_info *mtd, int new_state) { @@ -1981,7 +1977,7 @@ index ece544e..cf0c3180 100644 spinlock_t *lock = &chip->controller->lock; wait_queue_head_t *wq = &chip->controller->wq; DECLARE_WAITQUEUE(wait, current); -@@ -952,7 +977,7 @@ static int __nand_unlock(struct mtd_info *mtd, loff_t ofs, +@@ -952,7 +977,7 @@ { int ret = 0; int status, page; @@ -1990,7 +1986,7 @@ index ece544e..cf0c3180 100644 /* Submit address of first page to unlock */ page = ofs >> chip->page_shift; -@@ -987,7 +1012,7 @@ int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) +@@ -987,7 +1012,7 @@ { int ret = 0; int chipnr; @@ -1999,7 +1995,7 @@ index ece544e..cf0c3180 100644 pr_debug("%s: start = 0x%012llx, len = %llu\n", __func__, (unsigned long long)ofs, len); -@@ -1050,7 +1075,7 @@ int nand_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) +@@ -1050,7 +1075,7 @@ { int ret = 0; int chipnr, status, page; @@ -2008,7 +2004,7 @@ index ece544e..cf0c3180 100644 pr_debug("%s: start = 0x%012llx, len = %llu\n", __func__, (unsigned long long)ofs, len); -@@ -1309,13 +1334,12 @@ static int nand_read_page_raw_syndrome(struct mtd_info *mtd, +@@ -1309,13 +1334,12 @@ static int nand_read_page_swecc(struct mtd_info *mtd, struct nand_chip *chip, uint8_t *buf, int oob_required, int page) { @@ -2023,7 +2019,7 @@ index ece544e..cf0c3180 100644 unsigned int max_bitflips = 0; chip->ecc.read_page_raw(mtd, chip, buf, 1, page); -@@ -1323,8 +1347,10 @@ static int nand_read_page_swecc(struct mtd_info *mtd, struct nand_chip *chip, +@@ -1323,8 +1347,10 @@ for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize) chip->ecc.calculate(mtd, p, &ecc_calc[i]); @@ -2036,7 +2032,7 @@ index ece544e..cf0c3180 100644 eccsteps = chip->ecc.steps; p = buf; -@@ -1356,14 +1382,14 @@ static int nand_read_subpage(struct mtd_info *mtd, struct nand_chip *chip, +@@ -1356,14 +1382,14 @@ uint32_t data_offs, uint32_t readlen, uint8_t *bufpoi, int page) { @@ -2054,7 +2050,7 @@ index ece544e..cf0c3180 100644 /* Column address within the page aligned to ECC size (256bytes) */ start_step = data_offs / chip->ecc.size; -@@ -1391,12 +1417,13 @@ static int nand_read_subpage(struct mtd_info *mtd, struct nand_chip *chip, +@@ -1391,12 +1417,13 @@ * The performance is faster if we position offsets according to * ecc.pos. Let's make sure that there are no gaps in ECC positions. */ @@ -2074,7 +2070,7 @@ index ece544e..cf0c3180 100644 if (gaps) { chip->cmdfunc(mtd, NAND_CMD_RNDOUT, mtd->writesize, -1); chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); -@@ -1405,20 +1432,23 @@ static int nand_read_subpage(struct mtd_info *mtd, struct nand_chip *chip, +@@ -1405,20 +1432,23 @@ * Send the command to read the particular ECC bytes take care * about buswidth alignment in read_buf. */ @@ -2104,7 +2100,7 @@ index ece544e..cf0c3180 100644 p = bufpoi + data_col_addr; for (i = 0; i < eccfrag_len ; i += chip->ecc.bytes, p += chip->ecc.size) { -@@ -1426,6 +1456,16 @@ static int nand_read_subpage(struct mtd_info *mtd, struct nand_chip *chip, +@@ -1426,6 +1456,16 @@ stat = chip->ecc.correct(mtd, p, &chip->buffers->ecccode[i], &chip->buffers->ecccalc[i]); @@ -2121,7 +2117,7 @@ index ece544e..cf0c3180 100644 if (stat < 0) { mtd->ecc_stats.failed++; } else { -@@ -1449,13 +1489,12 @@ static int nand_read_subpage(struct mtd_info *mtd, struct nand_chip *chip, +@@ -1449,13 +1489,12 @@ static int nand_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip, uint8_t *buf, int oob_required, int page) { @@ -2136,7 +2132,7 @@ index ece544e..cf0c3180 100644 unsigned int max_bitflips = 0; for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize) { -@@ -1465,8 +1504,10 @@ static int nand_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip, +@@ -1465,8 +1504,10 @@ } chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); @@ -2149,7 +2145,7 @@ index ece544e..cf0c3180 100644 eccsteps = chip->ecc.steps; p = buf; -@@ -1475,6 +1516,15 @@ static int nand_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip, +@@ -1475,6 +1516,15 @@ int stat; stat = chip->ecc.correct(mtd, p, &ecc_code[i], &ecc_calc[i]); @@ -2165,7 +2161,7 @@ index ece544e..cf0c3180 100644 if (stat < 0) { mtd->ecc_stats.failed++; } else { -@@ -1502,12 +1552,11 @@ static int nand_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip, +@@ -1502,12 +1552,11 @@ static int nand_read_page_hwecc_oob_first(struct mtd_info *mtd, struct nand_chip *chip, uint8_t *buf, int oob_required, int page) { @@ -2179,7 +2175,7 @@ index ece544e..cf0c3180 100644 uint8_t *ecc_calc = chip->buffers->ecccalc; unsigned int max_bitflips = 0; -@@ -1516,8 +1565,10 @@ static int nand_read_page_hwecc_oob_first(struct mtd_info *mtd, +@@ -1516,8 +1565,10 @@ chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); chip->cmdfunc(mtd, NAND_CMD_READ0, 0, page); @@ -2192,7 +2188,7 @@ index ece544e..cf0c3180 100644 for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize) { int stat; -@@ -1527,6 +1578,15 @@ static int nand_read_page_hwecc_oob_first(struct mtd_info *mtd, +@@ -1527,6 +1578,15 @@ chip->ecc.calculate(mtd, p, &ecc_calc[i]); stat = chip->ecc.correct(mtd, p, &ecc_code[i], NULL); @@ -2208,7 +2204,7 @@ index ece544e..cf0c3180 100644 if (stat < 0) { mtd->ecc_stats.failed++; } else { -@@ -1554,6 +1614,7 @@ static int nand_read_page_syndrome(struct mtd_info *mtd, struct nand_chip *chip, +@@ -1554,6 +1614,7 @@ int i, eccsize = chip->ecc.size; int eccbytes = chip->ecc.bytes; int eccsteps = chip->ecc.steps; @@ -2216,7 +2212,7 @@ index ece544e..cf0c3180 100644 uint8_t *p = buf; uint8_t *oob = chip->oob_poi; unsigned int max_bitflips = 0; -@@ -1573,19 +1634,29 @@ static int nand_read_page_syndrome(struct mtd_info *mtd, struct nand_chip *chip, +@@ -1573,19 +1634,29 @@ chip->read_buf(mtd, oob, eccbytes); stat = chip->ecc.correct(mtd, p, oob, NULL); @@ -2253,7 +2249,7 @@ index ece544e..cf0c3180 100644 } /* Calculate remaining oob bytes */ -@@ -1598,14 +1669,17 @@ static int nand_read_page_syndrome(struct mtd_info *mtd, struct nand_chip *chip, +@@ -1598,14 +1669,17 @@ /** * nand_transfer_oob - [INTERN] Transfer oob to client buffer @@ -2273,7 +2269,7 @@ index ece544e..cf0c3180 100644 switch (ops->mode) { case MTD_OPS_PLACE_OOB: -@@ -1613,31 +1687,12 @@ static uint8_t *nand_transfer_oob(struct nand_chip *chip, uint8_t *oob, +@@ -1613,31 +1687,12 @@ memcpy(oob, chip->oob_poi + ops->ooboffs, len); return oob + len; @@ -2311,7 +2307,7 @@ index ece544e..cf0c3180 100644 default: BUG(); } -@@ -1655,7 +1710,7 @@ static uint8_t *nand_transfer_oob(struct nand_chip *chip, uint8_t *oob, +@@ -1655,7 +1710,7 @@ */ static int nand_setup_read_retry(struct mtd_info *mtd, int retry_mode) { @@ -2320,7 +2316,7 @@ index ece544e..cf0c3180 100644 pr_debug("setting READ RETRY mode %d\n", retry_mode); -@@ -1680,12 +1735,11 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from, +@@ -1680,12 +1735,11 @@ struct mtd_oob_ops *ops) { int chipnr, page, realpage, col, bytes, aligned, oob_required; @@ -2335,7 +2331,7 @@ index ece544e..cf0c3180 100644 uint8_t *bufpoi, *oob, *buf; int use_bufpoi; -@@ -1772,7 +1826,7 @@ read_retry: +@@ -1772,7 +1826,7 @@ int toread = min(oobreadlen, max_oobsize); if (toread) { @@ -2344,7 +2340,7 @@ index ece544e..cf0c3180 100644 oob, ops, toread); oobreadlen -= toread; } -@@ -2024,7 +2078,7 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from, +@@ -2024,7 +2078,7 @@ struct mtd_oob_ops *ops) { int page, realpage, chipnr; @@ -2353,7 +2349,7 @@ index ece544e..cf0c3180 100644 struct mtd_ecc_stats stats; int readlen = ops->ooblen; int len; -@@ -2036,10 +2090,7 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from, +@@ -2036,10 +2090,7 @@ stats = mtd->ecc_stats; @@ -2365,7 +2361,7 @@ index ece544e..cf0c3180 100644 if (unlikely(ops->ooboffs >= len)) { pr_debug("%s: attempt to start read outside oob\n", -@@ -2073,7 +2124,7 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from, +@@ -2073,7 +2124,7 @@ break; len = min(len, readlen); @@ -2374,7 +2370,7 @@ index ece544e..cf0c3180 100644 if (chip->options & NAND_NEED_READRDY) { /* Apply delay or wait for ready/busy pin */ -@@ -2232,19 +2283,20 @@ static int nand_write_page_swecc(struct mtd_info *mtd, struct nand_chip *chip, +@@ -2232,19 +2283,20 @@ const uint8_t *buf, int oob_required, int page) { @@ -2399,7 +2395,7 @@ index ece544e..cf0c3180 100644 return chip->ecc.write_page_raw(mtd, chip, buf, 1, page); } -@@ -2261,12 +2313,11 @@ static int nand_write_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip, +@@ -2261,12 +2313,11 @@ const uint8_t *buf, int oob_required, int page) { @@ -2413,7 +2409,7 @@ index ece544e..cf0c3180 100644 for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize) { chip->ecc.hwctl(mtd, NAND_ECC_WRITE); -@@ -2274,8 +2325,10 @@ static int nand_write_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip, +@@ -2274,8 +2325,10 @@ chip->ecc.calculate(mtd, p, &ecc_calc[i]); } @@ -2426,7 +2422,7 @@ index ece544e..cf0c3180 100644 chip->write_buf(mtd, chip->oob_poi, mtd->oobsize); -@@ -2303,11 +2356,10 @@ static int nand_write_subpage_hwecc(struct mtd_info *mtd, +@@ -2303,11 +2356,10 @@ int ecc_size = chip->ecc.size; int ecc_bytes = chip->ecc.bytes; int ecc_steps = chip->ecc.steps; @@ -2439,7 +2435,7 @@ index ece544e..cf0c3180 100644 for (step = 0; step < ecc_steps; step++) { /* configure controller for WRITE access */ -@@ -2335,8 +2387,10 @@ static int nand_write_subpage_hwecc(struct mtd_info *mtd, +@@ -2335,8 +2387,10 @@ /* copy calculated ECC for whole page to chip->buffer->oob */ /* this include masked-value(0xFF) for unwritten subpages */ ecc_calc = chip->buffers->ecccalc; @@ -2452,7 +2448,7 @@ index ece544e..cf0c3180 100644 /* write OOB buffer to NAND device */ chip->write_buf(mtd, chip->oob_poi, mtd->oobsize); -@@ -2472,7 +2526,8 @@ static int nand_write_page(struct mtd_info *mtd, struct nand_chip *chip, +@@ -2472,7 +2526,8 @@ static uint8_t *nand_fill_oob(struct mtd_info *mtd, uint8_t *oob, size_t len, struct mtd_oob_ops *ops) { @@ -2462,7 +2458,7 @@ index ece544e..cf0c3180 100644 /* * Initialise to all 0xFF, to avoid the possibility of left over OOB -@@ -2487,31 +2542,12 @@ static uint8_t *nand_fill_oob(struct mtd_info *mtd, uint8_t *oob, size_t len, +@@ -2487,31 +2542,12 @@ memcpy(chip->oob_poi + ops->ooboffs, oob, len); return oob + len; @@ -2500,7 +2496,7 @@ index ece544e..cf0c3180 100644 default: BUG(); } -@@ -2532,12 +2568,11 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to, +@@ -2532,12 +2568,11 @@ struct mtd_oob_ops *ops) { int chipnr, realpage, page, blockmask, column; @@ -2515,7 +2511,7 @@ index ece544e..cf0c3180 100644 uint8_t *oob = ops->oobbuf; uint8_t *buf = ops->datbuf; -@@ -2662,7 +2697,7 @@ err_out: +@@ -2662,7 +2697,7 @@ static int panic_nand_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const uint8_t *buf) { @@ -2524,7 +2520,7 @@ index ece544e..cf0c3180 100644 struct mtd_oob_ops ops; int ret; -@@ -2722,15 +2757,12 @@ static int nand_do_write_oob(struct mtd_info *mtd, loff_t to, +@@ -2722,15 +2757,12 @@ struct mtd_oob_ops *ops) { int chipnr, page, status, len; @@ -2542,7 +2538,7 @@ index ece544e..cf0c3180 100644 /* Do not allow write past end of page */ if ((ops->ooboffs + ops->ooblen) > len) { -@@ -2847,7 +2879,7 @@ out: +@@ -2847,7 +2879,7 @@ */ static int single_erase(struct mtd_info *mtd, int page) { @@ -2551,7 +2547,7 @@ index ece544e..cf0c3180 100644 /* Send commands to erase a block */ chip->cmdfunc(mtd, NAND_CMD_ERASE1, -1, page); chip->cmdfunc(mtd, NAND_CMD_ERASE2, -1, -1); -@@ -2879,7 +2911,7 @@ int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr, +@@ -2879,7 +2911,7 @@ int allowbbt) { int page, status, pages_per_block, ret, chipnr; @@ -2560,7 +2556,7 @@ index ece544e..cf0c3180 100644 loff_t len; pr_debug("%s: start = 0x%012llx, len = %llu\n", -@@ -2918,7 +2950,7 @@ int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr, +@@ -2918,7 +2950,7 @@ while (len) { /* Check if we have a bad block, we do not erase bad blocks! */ if (nand_block_checkbad(mtd, ((loff_t) page) << @@ -2569,7 +2565,7 @@ index ece544e..cf0c3180 100644 pr_warn("%s: attempt to erase a bad block at page 0x%08x\n", __func__, page); instr->state = MTD_ERASE_FAILED; -@@ -3005,7 +3037,20 @@ static void nand_sync(struct mtd_info *mtd) +@@ -3005,7 +3037,20 @@ */ static int nand_block_isbad(struct mtd_info *mtd, loff_t offs) { @@ -2591,7 +2587,7 @@ index ece544e..cf0c3180 100644 } /** -@@ -3094,7 +3139,7 @@ static int nand_suspend(struct mtd_info *mtd) +@@ -3094,7 +3139,7 @@ */ static void nand_resume(struct mtd_info *mtd) { @@ -2600,7 +2596,7 @@ index ece544e..cf0c3180 100644 if (chip->state == FL_PM_SUSPENDED) nand_release_device(mtd); -@@ -3266,7 +3311,7 @@ ext_out: +@@ -3266,7 +3311,7 @@ static int nand_setup_read_retry_micron(struct mtd_info *mtd, int retry_mode) { @@ -2609,7 +2605,7 @@ index ece544e..cf0c3180 100644 uint8_t feature[ONFI_SUBFEATURE_PARAM_LEN] = {retry_mode}; return chip->onfi_set_features(mtd, chip, ONFI_FEATURE_ADDR_READ_RETRY, -@@ -3937,10 +3982,13 @@ ident_done: +@@ -3937,10 +3982,13 @@ return type; } @@ -2626,7 +2622,7 @@ index ece544e..cf0c3180 100644 if (of_get_nand_bus_width(dn) == 16) chip->options |= NAND_BUSWIDTH_16; -@@ -3949,6 +3997,7 @@ static int nand_dt_init(struct mtd_info *mtd, struct nand_chip *chip, +@@ -3949,6 +3997,7 @@ chip->bbt_options |= NAND_BBT_USE_FLASH; ecc_mode = of_get_nand_ecc_mode(dn); @@ -2634,7 +2630,7 @@ index ece544e..cf0c3180 100644 ecc_strength = of_get_nand_ecc_strength(dn); ecc_step = of_get_nand_ecc_step_size(dn); -@@ -3961,6 +4010,9 @@ static int nand_dt_init(struct mtd_info *mtd, struct nand_chip *chip, +@@ -3961,6 +4010,9 @@ if (ecc_mode >= 0) chip->ecc.mode = ecc_mode; @@ -2644,7 +2640,7 @@ index ece544e..cf0c3180 100644 if (ecc_strength >= 0) chip->ecc.strength = ecc_strength; -@@ -3985,15 +4037,16 @@ int nand_scan_ident(struct mtd_info *mtd, int maxchips, +@@ -3984,15 +4036,16 @@ struct nand_flash_dev *table) { int i, nand_maf_id, nand_dev_id; @@ -2665,9 +2661,9 @@ index ece544e..cf0c3180 100644 + if (!mtd->name && mtd->dev.parent) + mtd->name = dev_name(mtd->dev.parent); - /* Set the default functions */ - nand_set_defaults(chip, chip->options & NAND_BUSWIDTH_16); -@@ -4053,7 +4106,7 @@ EXPORT_SYMBOL(nand_scan_ident); + if (!mtd->name && mtd->dev.parent) + mtd->name = dev_name(mtd->dev.parent); +@@ -4055,7 +4108,7 @@ */ static bool nand_ecc_strength_good(struct mtd_info *mtd) { @@ -2676,7 +2672,7 @@ index ece544e..cf0c3180 100644 struct nand_ecc_ctrl *ecc = &chip->ecc; int corr, ds_corr; -@@ -4081,10 +4134,10 @@ static bool nand_ecc_strength_good(struct mtd_info *mtd) +@@ -4083,10 +4136,10 @@ */ int nand_scan_tail(struct mtd_info *mtd) { @@ -2689,7 +2685,7 @@ index ece544e..cf0c3180 100644 /* New bad blocks should be marked in OOB, flash-based BBT, or both */ BUG_ON((chip->bbt_options & NAND_BBT_NO_OOB_BBM) && -@@ -4111,19 +4164,15 @@ int nand_scan_tail(struct mtd_info *mtd) +@@ -4113,19 +4166,15 @@ /* * If no default placement scheme is given, select an appropriate one. */ @@ -2712,7 +2708,7 @@ index ece544e..cf0c3180 100644 break; default: pr_warn("No oob scheme defined for oobsize %d\n", -@@ -4166,7 +4215,7 @@ int nand_scan_tail(struct mtd_info *mtd) +@@ -4168,7 +4217,7 @@ ecc->write_oob = nand_write_oob_std; if (!ecc->read_subpage) ecc->read_subpage = nand_read_subpage; @@ -2721,7 +2717,7 @@ index ece544e..cf0c3180 100644 ecc->write_subpage = nand_write_subpage_hwecc; case NAND_ECC_HW_SYNDROME: -@@ -4244,10 +4293,8 @@ int nand_scan_tail(struct mtd_info *mtd) +@@ -4246,10 +4295,8 @@ } /* See nand_bch_init() for details. */ @@ -2734,7 +2730,7 @@ index ece544e..cf0c3180 100644 if (!ecc->priv) { pr_warn("BCH ECC initialization failed!\n"); BUG(); -@@ -4278,20 +4325,9 @@ int nand_scan_tail(struct mtd_info *mtd) +@@ -4280,20 +4327,9 @@ if (!ecc->write_oob_raw) ecc->write_oob_raw = ecc->write_oob; @@ -2758,7 +2754,7 @@ index ece544e..cf0c3180 100644 /* * Set the number of read / write steps for one page depending on ECC -@@ -4304,6 +4340,21 @@ int nand_scan_tail(struct mtd_info *mtd) +@@ -4306,6 +4342,21 @@ } ecc->total = ecc->steps * ecc->bytes; @@ -2780,7 +2776,7 @@ index ece544e..cf0c3180 100644 /* Allow subpage writes up to ecc.steps. Not possible for MLC flash */ if (!(chip->options & NAND_NO_SUBPAGE_WRITE) && nand_is_slc(chip)) { switch (ecc->steps) { -@@ -4360,10 +4411,6 @@ int nand_scan_tail(struct mtd_info *mtd) +@@ -4362,10 +4413,6 @@ mtd->_block_markbad = nand_block_markbad; mtd->writebufsize = mtd->writesize; @@ -2791,7 +2787,7 @@ index ece544e..cf0c3180 100644 /* * Initialize bitflip_threshold to its default prior scan_bbt() call. * scan_bbt() might invoke mtd_read(), thus bitflip_threshold must be -@@ -4426,7 +4473,7 @@ EXPORT_SYMBOL(nand_scan); +@@ -4421,7 +4468,7 @@ */ void nand_release(struct mtd_info *mtd) { @@ -2800,11 +2796,9 @@ index ece544e..cf0c3180 100644 if (chip->ecc.mode == NAND_ECC_SOFT_BCH) nand_bch_free((struct nand_bch_control *)chip->ecc.priv); -diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c -index b1d4f81..2fbb523 100644 --- a/drivers/mtd/nand/nand_bbt.c +++ b/drivers/mtd/nand/nand_bbt.c -@@ -172,7 +172,7 @@ static int read_bbt(struct mtd_info *mtd, uint8_t *buf, int page, int num, +@@ -172,7 +172,7 @@ struct nand_bbt_descr *td, int offs) { int res, ret = 0, i, j, act = 0; @@ -2813,7 +2807,7 @@ index b1d4f81..2fbb523 100644 size_t retlen, len, totlen; loff_t from; int bits = td->options & NAND_BBT_NRBITS_MSK; -@@ -263,7 +263,7 @@ static int read_bbt(struct mtd_info *mtd, uint8_t *buf, int page, int num, +@@ -263,7 +263,7 @@ */ static int read_abs_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *td, int chip) { @@ -2822,7 +2816,7 @@ index b1d4f81..2fbb523 100644 int res = 0, i; if (td->options & NAND_BBT_PERCHIP) { -@@ -388,7 +388,7 @@ static u32 bbt_get_ver_offs(struct mtd_info *mtd, struct nand_bbt_descr *td) +@@ -388,7 +388,7 @@ static void read_abs_bbts(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *td, struct nand_bbt_descr *md) { @@ -2831,7 +2825,7 @@ index b1d4f81..2fbb523 100644 /* Read the primary version, if available */ if (td->options & NAND_BBT_VERSION) { -@@ -454,7 +454,7 @@ static int scan_block_fast(struct mtd_info *mtd, struct nand_bbt_descr *bd, +@@ -454,7 +454,7 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *bd, int chip) { @@ -2840,7 +2834,7 @@ index b1d4f81..2fbb523 100644 int i, numblocks, numpages; int startblock; loff_t from; -@@ -523,7 +523,7 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf, +@@ -523,7 +523,7 @@ */ static int search_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *td) { @@ -2849,7 +2843,7 @@ index b1d4f81..2fbb523 100644 int i, chips; int startblock, block, dir; int scanlen = mtd->writesize + mtd->oobsize; -@@ -618,7 +618,7 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf, +@@ -618,7 +618,7 @@ struct nand_bbt_descr *td, struct nand_bbt_descr *md, int chipsel) { @@ -2858,7 +2852,7 @@ index b1d4f81..2fbb523 100644 struct erase_info einfo; int i, res, chip = 0; int bits, startblock, dir, page, offs, numblocks, sft, sftmsk; -@@ -819,7 +819,7 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf, +@@ -819,7 +819,7 @@ */ static inline int nand_memory_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd) { @@ -2867,7 +2861,7 @@ index b1d4f81..2fbb523 100644 return create_bbt(mtd, this->buffers->databuf, bd, -1); } -@@ -838,7 +838,7 @@ static inline int nand_memory_bbt(struct mtd_info *mtd, struct nand_bbt_descr *b +@@ -838,7 +838,7 @@ static int check_create(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *bd) { int i, chips, writeops, create, chipsel, res, res2; @@ -2876,7 +2870,7 @@ index b1d4f81..2fbb523 100644 struct nand_bbt_descr *td = this->bbt_td; struct nand_bbt_descr *md = this->bbt_md; struct nand_bbt_descr *rd, *rd2; -@@ -962,7 +962,7 @@ static int check_create(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_desc +@@ -962,7 +962,7 @@ */ static void mark_bbt_region(struct mtd_info *mtd, struct nand_bbt_descr *td) { @@ -2885,7 +2879,7 @@ index b1d4f81..2fbb523 100644 int i, j, chips, block, nrblocks, update; uint8_t oldval; -@@ -1022,7 +1022,7 @@ static void mark_bbt_region(struct mtd_info *mtd, struct nand_bbt_descr *td) +@@ -1022,7 +1022,7 @@ */ static void verify_bbt_descr(struct mtd_info *mtd, struct nand_bbt_descr *bd) { @@ -2894,7 +2888,7 @@ index b1d4f81..2fbb523 100644 u32 pattern_len; u32 bits; u32 table_size; -@@ -1074,7 +1074,7 @@ static void verify_bbt_descr(struct mtd_info *mtd, struct nand_bbt_descr *bd) +@@ -1074,7 +1074,7 @@ */ static int nand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd) { @@ -2903,7 +2897,7 @@ index b1d4f81..2fbb523 100644 int len, res; uint8_t *buf; struct nand_bbt_descr *td = this->bbt_td; -@@ -1147,7 +1147,7 @@ err: +@@ -1147,7 +1147,7 @@ */ static int nand_update_bbt(struct mtd_info *mtd, loff_t offs) { @@ -2912,7 +2906,7 @@ index b1d4f81..2fbb523 100644 int len, res = 0; int chip, chipsel; uint8_t *buf; -@@ -1281,7 +1281,7 @@ static int nand_create_badblock_pattern(struct nand_chip *this) +@@ -1281,7 +1281,7 @@ */ int nand_default_bbt(struct mtd_info *mtd) { @@ -2921,7 +2915,7 @@ index b1d4f81..2fbb523 100644 int ret; /* Is a flash based bad block table requested? */ -@@ -1317,7 +1317,7 @@ int nand_default_bbt(struct mtd_info *mtd) +@@ -1317,7 +1317,7 @@ */ int nand_isreserved_bbt(struct mtd_info *mtd, loff_t offs) { @@ -2930,7 +2924,7 @@ index b1d4f81..2fbb523 100644 int block; block = (int)(offs >> this->bbt_erase_shift); -@@ -1332,7 +1332,7 @@ int nand_isreserved_bbt(struct mtd_info *mtd, loff_t offs) +@@ -1332,7 +1332,7 @@ */ int nand_isbad_bbt(struct mtd_info *mtd, loff_t offs, int allowbbt) { @@ -2939,7 +2933,7 @@ index b1d4f81..2fbb523 100644 int block, res; block = (int)(offs >> this->bbt_erase_shift); -@@ -1359,7 +1359,7 @@ int nand_isbad_bbt(struct mtd_info *mtd, loff_t offs, int allowbbt) +@@ -1359,7 +1359,7 @@ */ int nand_markbad_bbt(struct mtd_info *mtd, loff_t offs) { @@ -2948,14 +2942,12 @@ index b1d4f81..2fbb523 100644 int block, ret = 0; block = (int)(offs >> this->bbt_erase_shift); -@@ -1373,5 +1373,3 @@ int nand_markbad_bbt(struct mtd_info *mtd, loff_t offs) +@@ -1373,5 +1373,3 @@ return ret; } - -EXPORT_SYMBOL(nand_scan_bbt); -diff --git a/drivers/mtd/nand/nand_bch.c b/drivers/mtd/nand/nand_bch.c -index 3803e0b..ca9b2a4 100644 --- a/drivers/mtd/nand/nand_bch.c +++ b/drivers/mtd/nand/nand_bch.c @@ -32,13 +32,11 @@ @@ -2972,7 +2964,7 @@ index 3803e0b..ca9b2a4 100644 unsigned int *errloc; unsigned char *eccmask; }; -@@ -52,7 +50,7 @@ struct nand_bch_control { +@@ -52,7 +50,7 @@ int nand_bch_calculate_ecc(struct mtd_info *mtd, const unsigned char *buf, unsigned char *code) { @@ -2981,7 +2973,7 @@ index 3803e0b..ca9b2a4 100644 struct nand_bch_control *nbc = chip->ecc.priv; unsigned int i; -@@ -79,7 +77,7 @@ EXPORT_SYMBOL(nand_bch_calculate_ecc); +@@ -79,7 +77,7 @@ int nand_bch_correct_data(struct mtd_info *mtd, unsigned char *buf, unsigned char *read_ecc, unsigned char *calc_ecc) { @@ -2990,7 +2982,7 @@ index 3803e0b..ca9b2a4 100644 struct nand_bch_control *nbc = chip->ecc.priv; unsigned int *errloc = nbc->errloc; int i, count; -@@ -98,7 +96,7 @@ int nand_bch_correct_data(struct mtd_info *mtd, unsigned char *buf, +@@ -98,7 +96,7 @@ } } else if (count < 0) { printk(KERN_ERR "ecc unrecoverable error\n"); @@ -2999,7 +2991,7 @@ index 3803e0b..ca9b2a4 100644 } return count; } -@@ -107,9 +105,6 @@ EXPORT_SYMBOL(nand_bch_correct_data); +@@ -107,9 +105,6 @@ /** * nand_bch_init - [NAND Interface] Initialize NAND BCH error correction * @mtd: MTD block structure @@ -3009,7 +3001,7 @@ index 3803e0b..ca9b2a4 100644 * * Returns: * a pointer to a new NAND BCH control structure, or NULL upon failure -@@ -123,14 +118,20 @@ EXPORT_SYMBOL(nand_bch_correct_data); +@@ -123,14 +118,20 @@ * @eccsize = 512 (thus, m=13 is the smallest integer such that 2^m-1 > 512*8) * @eccbytes = 7 (7 bytes are required to store m*t = 13*4 = 52 bits) */ @@ -3034,7 +3026,7 @@ index 3803e0b..ca9b2a4 100644 if (!eccsize || !eccbytes) { printk(KERN_WARNING "ecc parameters not supplied\n"); -@@ -158,7 +159,7 @@ nand_bch_init(struct mtd_info *mtd, unsigned int eccsize, unsigned int eccbytes, +@@ -158,7 +159,7 @@ eccsteps = mtd->writesize/eccsize; /* if no ecc placement scheme was provided, build one */ @@ -3043,7 +3035,7 @@ index 3803e0b..ca9b2a4 100644 /* handle large page devices only */ if (mtd->oobsize < 64) { -@@ -167,24 +168,7 @@ nand_bch_init(struct mtd_info *mtd, unsigned int eccsize, unsigned int eccbytes, +@@ -167,24 +168,7 @@ goto fail; } @@ -3069,7 +3061,7 @@ index 3803e0b..ca9b2a4 100644 } /* sanity checks */ -@@ -192,7 +176,8 @@ nand_bch_init(struct mtd_info *mtd, unsigned int eccsize, unsigned int eccbytes, +@@ -192,7 +176,8 @@ printk(KERN_WARNING "eccsize %u is too large\n", eccsize); goto fail; } @@ -3079,7 +3071,7 @@ index 3803e0b..ca9b2a4 100644 printk(KERN_WARNING "invalid ecc layout\n"); goto fail; } -@@ -216,6 +201,9 @@ nand_bch_init(struct mtd_info *mtd, unsigned int eccsize, unsigned int eccbytes, +@@ -216,6 +201,9 @@ for (i = 0; i < eccbytes; i++) nbc->eccmask[i] ^= 0xff; @@ -3089,11 +3081,9 @@ index 3803e0b..ca9b2a4 100644 return nbc; fail: nand_bch_free(nbc); -diff --git a/drivers/mtd/nand/nand_ecc.c b/drivers/mtd/nand/nand_ecc.c -index 97c4c02..d1770b0 100644 --- a/drivers/mtd/nand/nand_ecc.c +++ b/drivers/mtd/nand/nand_ecc.c -@@ -424,7 +424,7 @@ int nand_calculate_ecc(struct mtd_info *mtd, const unsigned char *buf, +@@ -424,7 +424,7 @@ unsigned char *code) { __nand_calculate_ecc(buf, @@ -3102,16 +3092,7 @@ index 97c4c02..d1770b0 100644 return 0; } -@@ -507,7 +507,7 @@ int __nand_correct_data(unsigned char *buf, - return 1; /* error in ECC data; no action needed */ - - pr_err("%s: uncorrectable ECC error\n", __func__); -- return -1; -+ return -EBADMSG; - } - EXPORT_SYMBOL(__nand_correct_data); - -@@ -524,7 +524,7 @@ int nand_correct_data(struct mtd_info *mtd, unsigned char *buf, +@@ -524,7 +524,7 @@ unsigned char *read_ecc, unsigned char *calc_ecc) { return __nand_correct_data(buf, read_ecc, calc_ecc, @@ -3120,11 +3101,9 @@ index 97c4c02..d1770b0 100644 } EXPORT_SYMBOL(nand_correct_data); -diff --git a/drivers/mtd/nand/nand_ids.c b/drivers/mtd/nand/nand_ids.c -index a8804a3..ccc05f5 100644 --- a/drivers/mtd/nand/nand_ids.c +++ b/drivers/mtd/nand/nand_ids.c -@@ -50,8 +50,8 @@ struct nand_flash_dev nand_flash_ids[] = { +@@ -50,8 +50,8 @@ SZ_16K, SZ_8K, SZ_4M, 0, 6, 1280, NAND_ECC_INFO(40, SZ_1K) }, {"H27UCG8T2ATR-BC 64G 3.3V 8-bit", { .id = {0xad, 0xde, 0x94, 0xda, 0x74, 0xc4} }, @@ -3135,11 +3114,9 @@ index a8804a3..ccc05f5 100644 LEGACY_ID_NAND("NAND 4MiB 5V 8-bit", 0x6B, 4, SZ_8K, SP_OPTIONS), LEGACY_ID_NAND("NAND 4MiB 3,3V 8-bit", 0xE3, 4, SZ_8K, SP_OPTIONS), -diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c -index b16d70a..6ff1d8d 100644 --- a/drivers/mtd/nand/nandsim.c +++ b/drivers/mtd/nand/nandsim.c -@@ -666,8 +666,8 @@ static char *get_partition_name(int i) +@@ -666,8 +666,8 @@ */ static int init_nandsim(struct mtd_info *mtd) { @@ -3150,7 +3127,7 @@ index b16d70a..6ff1d8d 100644 int i, ret = 0; uint64_t remains; uint64_t next_offset; -@@ -1908,7 +1908,8 @@ static void switch_state(struct nandsim *ns) +@@ -1908,7 +1908,8 @@ static u_char ns_nand_read_byte(struct mtd_info *mtd) { @@ -3160,7 +3137,7 @@ index b16d70a..6ff1d8d 100644 u_char outb = 0x00; /* Sanity and correctness checks */ -@@ -1969,7 +1970,8 @@ static u_char ns_nand_read_byte(struct mtd_info *mtd) +@@ -1969,7 +1970,8 @@ static void ns_nand_write_byte(struct mtd_info *mtd, u_char byte) { @@ -3170,7 +3147,7 @@ index b16d70a..6ff1d8d 100644 /* Sanity and correctness checks */ if (!ns->lines.ce) { -@@ -2123,7 +2125,8 @@ static void ns_nand_write_byte(struct mtd_info *mtd, u_char byte) +@@ -2123,7 +2125,8 @@ static void ns_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int bitmask) { @@ -3180,7 +3157,7 @@ index b16d70a..6ff1d8d 100644 ns->lines.cle = bitmask & NAND_CLE ? 1 : 0; ns->lines.ale = bitmask & NAND_ALE ? 1 : 0; -@@ -2141,7 +2144,7 @@ static int ns_device_ready(struct mtd_info *mtd) +@@ -2141,7 +2144,7 @@ static uint16_t ns_nand_read_word(struct mtd_info *mtd) { @@ -3189,7 +3166,7 @@ index b16d70a..6ff1d8d 100644 NS_DBG("read_word\n"); -@@ -2150,7 +2153,8 @@ static uint16_t ns_nand_read_word(struct mtd_info *mtd) +@@ -2150,7 +2153,8 @@ static void ns_nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len) { @@ -3199,7 +3176,7 @@ index b16d70a..6ff1d8d 100644 /* Check that chip is expecting data input */ if (!(ns->state & STATE_DATAIN_MASK)) { -@@ -2177,7 +2181,8 @@ static void ns_nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len) +@@ -2177,7 +2181,8 @@ static void ns_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len) { @@ -3209,7 +3186,7 @@ index b16d70a..6ff1d8d 100644 /* Sanity and correctness checks */ if (!ns->lines.ce) { -@@ -2198,7 +2203,7 @@ static void ns_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len) +@@ -2198,7 +2203,7 @@ int i; for (i = 0; i < len; i++) @@ -3218,7 +3195,7 @@ index b16d70a..6ff1d8d 100644 return; } -@@ -2236,16 +2241,15 @@ static int __init ns_init_module(void) +@@ -2236,16 +2241,15 @@ } /* Allocate and initialize mtd_info, nand_chip and nandsim structures */ @@ -3240,7 +3217,7 @@ index b16d70a..6ff1d8d 100644 /* * Register simulator's callbacks. -@@ -2257,6 +2261,7 @@ static int __init ns_init_module(void) +@@ -2257,6 +2261,7 @@ chip->read_buf = ns_nand_read_buf; chip->read_word = ns_nand_read_word; chip->ecc.mode = NAND_ECC_SOFT; @@ -3248,7 +3225,7 @@ index b16d70a..6ff1d8d 100644 /* The NAND_SKIP_BBTSCAN option is necessary for 'overridesize' */ /* and 'badblocks' parameters to work */ chip->options |= NAND_SKIP_BBTSCAN; -@@ -2335,6 +2340,7 @@ static int __init ns_init_module(void) +@@ -2335,6 +2340,7 @@ goto error; } chip->ecc.mode = NAND_ECC_SOFT_BCH; @@ -3256,7 +3233,7 @@ index b16d70a..6ff1d8d 100644 chip->ecc.size = 512; chip->ecc.strength = bch; chip->ecc.bytes = eccbytes; -@@ -2392,7 +2398,7 @@ err_exit: +@@ -2392,7 +2398,7 @@ for (i = 0;i < ARRAY_SIZE(nand->partitions); ++i) kfree(nand->partitions[i].name); error: @@ -3265,7 +3242,7 @@ index b16d70a..6ff1d8d 100644 free_lists(); return retval; -@@ -2405,7 +2411,8 @@ module_init(ns_init_module); +@@ -2405,7 +2411,8 @@ */ static void __exit ns_cleanup_module(void) { @@ -3275,7 +3252,7 @@ index b16d70a..6ff1d8d 100644 int i; nandsim_debugfs_remove(ns); -@@ -2413,7 +2420,7 @@ static void __exit ns_cleanup_module(void) +@@ -2413,7 +2420,7 @@ nand_release(nsmtd); /* Unregister driver */ for (i = 0;i < ARRAY_SIZE(ns->partitions); ++i) kfree(ns->partitions[i].name); @@ -3284,11 +3261,9 @@ index b16d70a..6ff1d8d 100644 free_lists(); } -diff --git a/drivers/mtd/ofpart.c b/drivers/mtd/ofpart.c -index 9ed6038..ede407d 100644 --- a/drivers/mtd/ofpart.c +++ b/drivers/mtd/ofpart.c -@@ -26,9 +26,10 @@ static bool node_has_compatible(struct device_node *pp) +@@ -26,9 +26,10 @@ } static int parse_ofpart_partitions(struct mtd_info *master, @@ -3300,7 +3275,7 @@ index 9ed6038..ede407d 100644 struct device_node *mtd_node; struct device_node *ofpart_node; const char *partname; -@@ -37,10 +38,8 @@ static int parse_ofpart_partitions(struct mtd_info *master, +@@ -37,10 +38,8 @@ bool dedicated = true; @@ -3313,7 +3288,7 @@ index 9ed6038..ede407d 100644 if (!mtd_node) return 0; -@@ -72,8 +71,8 @@ static int parse_ofpart_partitions(struct mtd_info *master, +@@ -72,8 +71,8 @@ if (nr_parts == 0) return 0; @@ -3324,7 +3299,7 @@ index 9ed6038..ede407d 100644 return -ENOMEM; i = 0; -@@ -107,19 +106,19 @@ static int parse_ofpart_partitions(struct mtd_info *master, +@@ -107,19 +106,19 @@ goto ofpart_fail; } @@ -3349,7 +3324,7 @@ index 9ed6038..ede407d 100644 i++; } -@@ -127,6 +126,7 @@ static int parse_ofpart_partitions(struct mtd_info *master, +@@ -127,6 +126,7 @@ if (!nr_parts) goto ofpart_none; @@ -3357,7 +3332,7 @@ index 9ed6038..ede407d 100644 return nr_parts; ofpart_fail: -@@ -135,21 +135,20 @@ ofpart_fail: +@@ -135,21 +135,20 @@ ret = -EINVAL; ofpart_none: of_node_put(pp); @@ -3382,7 +3357,7 @@ index 9ed6038..ede407d 100644 struct device_node *dp; int i, plen, nr_parts; const struct { -@@ -157,10 +156,8 @@ static int parse_ofoldpart_partitions(struct mtd_info *master, +@@ -157,10 +156,8 @@ } *part; const char *names; @@ -3395,7 +3370,7 @@ index 9ed6038..ede407d 100644 if (!dp) return 0; -@@ -173,37 +170,37 @@ static int parse_ofoldpart_partitions(struct mtd_info *master, +@@ -173,37 +170,37 @@ nr_parts = plen / sizeof(part[0]); @@ -3441,11 +3416,9 @@ index 9ed6038..ede407d 100644 .parse_fn = parse_ofoldpart_partitions, .name = "ofoldpart", }; -diff --git a/drivers/mtd/spi-nor/Kconfig b/drivers/mtd/spi-nor/Kconfig -index 2fe2a7e..d42c98e 100644 --- a/drivers/mtd/spi-nor/Kconfig +++ b/drivers/mtd/spi-nor/Kconfig -@@ -7,6 +7,14 @@ menuconfig MTD_SPI_NOR +@@ -7,6 +7,14 @@ if MTD_SPI_NOR @@ -3460,7 +3433,7 @@ index 2fe2a7e..d42c98e 100644 config MTD_SPI_NOR_USE_4K_SECTORS bool "Use small 4096 B erase sectors" default y -@@ -23,7 +31,7 @@ config MTD_SPI_NOR_USE_4K_SECTORS +@@ -23,7 +31,7 @@ config SPI_FSL_QUADSPI tristate "Freescale Quad SPI controller" @@ -3469,8 +3442,6 @@ index 2fe2a7e..d42c98e 100644 depends on HAS_IOMEM help This enables support for the Quad SPI controller in master mode. -diff --git a/drivers/mtd/spi-nor/Makefile b/drivers/mtd/spi-nor/Makefile -index e53333e..0bf3a7f8 100644 --- a/drivers/mtd/spi-nor/Makefile +++ b/drivers/mtd/spi-nor/Makefile @@ -1,3 +1,4 @@ @@ -3478,9 +3449,6 @@ index e53333e..0bf3a7f8 100644 obj-$(CONFIG_SPI_FSL_QUADSPI) += fsl-quadspi.o +obj-$(CONFIG_MTD_MT81xx_NOR) += mtk-quadspi.o obj-$(CONFIG_SPI_NXP_SPIFI) += nxp-spifi.o -diff --git a/drivers/mtd/spi-nor/mtk-quadspi.c b/drivers/mtd/spi-nor/mtk-quadspi.c -new file mode 100644 -index 0000000..8bed1a4c --- /dev/null +++ b/drivers/mtd/spi-nor/mtk-quadspi.c @@ -0,0 +1,485 @@ @@ -3969,8 +3937,6 @@ index 0000000..8bed1a4c +module_platform_driver(mtk_nor_driver); +MODULE_LICENSE("GPL v2"); +MODULE_DESCRIPTION("MediaTek SPI NOR Flash Driver"); -diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c -index 4988390..157841d 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -38,6 +38,7 @@ @@ -3981,7 +3947,7 @@ index 4988390..157841d 100644 struct flash_info { char *name; -@@ -60,14 +61,20 @@ struct flash_info { +@@ -60,14 +61,20 @@ u16 addr_width; u16 flags; @@ -4010,7 +3976,7 @@ index 4988390..157841d 100644 }; #define JEDEC_MFR(info) ((info)->id[0]) -@@ -313,6 +320,29 @@ static void spi_nor_unlock_and_unprep(struct spi_nor *nor, enum spi_nor_ops ops) +@@ -313,6 +320,29 @@ } /* @@ -4040,7 +4006,7 @@ index 4988390..157841d 100644 * Erase an address range on the nor chip. The address range may extend * one or more erase sectors. Return an error is there is a problem erasing. */ -@@ -371,10 +401,9 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr) +@@ -371,10 +401,9 @@ while (len) { write_enable(nor); @@ -4053,7 +4019,7 @@ index 4988390..157841d 100644 addr += mtd->erasesize; len -= mtd->erasesize; -@@ -387,17 +416,13 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr) +@@ -387,17 +416,13 @@ write_disable(nor); @@ -4073,7 +4039,7 @@ index 4988390..157841d 100644 } static void stm_get_locked_range(struct spi_nor *nor, u8 sr, loff_t *ofs, -@@ -415,32 +440,58 @@ static void stm_get_locked_range(struct spi_nor *nor, u8 sr, loff_t *ofs, +@@ -415,32 +440,58 @@ } else { pow = ((sr & mask) ^ mask) >> shift; *len = mtd->size >> pow; @@ -4139,7 +4105,7 @@ index 4988390..157841d 100644 * Sample table portion for 8MB flash (Winbond w25q64fw): * * SEC | TB | BP2 | BP1 | BP0 | Prot Length | Protected Portion -@@ -453,26 +504,55 @@ static int stm_is_locked_sr(struct spi_nor *nor, loff_t ofs, uint64_t len, +@@ -453,26 +504,55 @@ * 0 | 0 | 1 | 0 | 1 | 2 MB | Upper 1/4 * 0 | 0 | 1 | 1 | 0 | 4 MB | Upper 1/2 * X | X | 1 | 1 | 1 | 8 MB | ALL @@ -4204,7 +4170,7 @@ index 4988390..157841d 100644 /* * Need smallest pow such that: -@@ -483,7 +563,7 @@ static int stm_lock(struct spi_nor *nor, loff_t ofs, uint64_t len) +@@ -483,7 +563,7 @@ * * pow = ceil(log2(size / len)) = log2(size) - floor(log2(len)) */ @@ -4213,7 +4179,7 @@ index 4988390..157841d 100644 val = mask - (pow << shift); if (val & ~mask) return -EINVAL; -@@ -491,14 +571,27 @@ static int stm_lock(struct spi_nor *nor, loff_t ofs, uint64_t len) +@@ -491,14 +571,27 @@ if (!(val & mask)) return -EINVAL; @@ -4244,7 +4210,7 @@ index 4988390..157841d 100644 } /* -@@ -509,17 +602,43 @@ static int stm_lock(struct spi_nor *nor, loff_t ofs, uint64_t len) +@@ -509,17 +602,43 @@ static int stm_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len) { struct mtd_info *mtd = &nor->mtd; @@ -4260,10 +4226,7 @@ index 4988390..157841d 100644 status_old = read_sr(nor); + if (status_old < 0) + return status_old; - -- /* Cannot unlock; would unlock larger region than requested */ -- if (stm_is_locked_sr(nor, status_old, ofs - mtd->erasesize, -- mtd->erasesize)) ++ + /* If nothing in our range is locked, we don't need to do anything */ + if (stm_is_unlocked_sr(nor, ofs, len, status_old)) + return 0; @@ -4276,7 +4239,10 @@ index 4988390..157841d 100644 + if (!stm_is_unlocked_sr(nor, ofs + len, mtd->size - (ofs + len), + status_old)) + can_be_bottom = false; -+ + +- /* Cannot unlock; would unlock larger region than requested */ +- if (stm_is_locked_sr(nor, ofs - mtd->erasesize, mtd->erasesize, +- status_old)) + if (!can_be_bottom && !can_be_top) return -EINVAL; @@ -4292,7 +4258,7 @@ index 4988390..157841d 100644 /* * Need largest pow such that: * -@@ -529,8 +648,8 @@ static int stm_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len) +@@ -529,8 +648,8 @@ * * pow = floor(log2(size / len)) = log2(size) - ceil(log2(len)) */ @@ -4303,7 +4269,7 @@ index 4988390..157841d 100644 val = 0; /* fully unlocked */ } else { val = mask - (pow << shift); -@@ -539,14 +658,28 @@ static int stm_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len) +@@ -539,14 +658,28 @@ return -EINVAL; } @@ -4335,7 +4301,7 @@ index 4988390..157841d 100644 } /* -@@ -715,9 +848,9 @@ static const struct flash_info spi_nor_ids[] = { +@@ -715,9 +848,9 @@ { "mx25l4005a", INFO(0xc22013, 0, 64 * 1024, 8, SECT_4K) }, { "mx25l8005", INFO(0xc22014, 0, 64 * 1024, 16, 0) }, { "mx25l1606e", INFO(0xc22015, 0, 64 * 1024, 32, SECT_4K) }, @@ -4347,7 +4313,7 @@ index 4988390..157841d 100644 { "mx25u6435f", INFO(0xc22537, 0, 64 * 1024, 128, SECT_4K) }, { "mx25l12805d", INFO(0xc22018, 0, 64 * 1024, 256, 0) }, { "mx25l12855e", INFO(0xc22618, 0, 64 * 1024, 256, 0) }, -@@ -731,8 +864,8 @@ static const struct flash_info spi_nor_ids[] = { +@@ -731,8 +864,8 @@ { "n25q032a", INFO(0x20bb16, 0, 64 * 1024, 64, SPI_NOR_QUAD_READ) }, { "n25q064", INFO(0x20ba17, 0, 64 * 1024, 128, SECT_4K | SPI_NOR_QUAD_READ) }, { "n25q064a", INFO(0x20bb17, 0, 64 * 1024, 128, SECT_4K | SPI_NOR_QUAD_READ) }, @@ -4358,7 +4324,7 @@ index 4988390..157841d 100644 { "n25q256a", INFO(0x20ba19, 0, 64 * 1024, 512, SECT_4K | SPI_NOR_QUAD_READ) }, { "n25q512a", INFO(0x20bb20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ) }, { "n25q512ax3", INFO(0x20ba20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ) }, -@@ -766,6 +899,7 @@ static const struct flash_info spi_nor_ids[] = { +@@ -766,6 +899,7 @@ { "s25fl008k", INFO(0xef4014, 0, 64 * 1024, 16, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, { "s25fl016k", INFO(0xef4015, 0, 64 * 1024, 32, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, { "s25fl064k", INFO(0xef4017, 0, 64 * 1024, 128, SECT_4K) }, @@ -4366,7 +4332,7 @@ index 4988390..157841d 100644 { "s25fl132k", INFO(0x014016, 0, 64 * 1024, 64, SECT_4K) }, { "s25fl164k", INFO(0x014017, 0, 64 * 1024, 128, SECT_4K) }, { "s25fl204k", INFO(0x014013, 0, 64 * 1024, 8, SECT_4K | SPI_NOR_DUAL_READ) }, -@@ -829,11 +963,23 @@ static const struct flash_info spi_nor_ids[] = { +@@ -829,11 +963,23 @@ { "w25x16", INFO(0xef3015, 0, 64 * 1024, 32, SECT_4K) }, { "w25x32", INFO(0xef3016, 0, 64 * 1024, 64, SECT_4K) }, { "w25q32", INFO(0xef4016, 0, 64 * 1024, 64, SECT_4K) }, @@ -4393,7 +4359,7 @@ index 4988390..157841d 100644 { "w25q80", INFO(0xef5014, 0, 64 * 1024, 16, SECT_4K) }, { "w25q80bl", INFO(0xef4014, 0, 64 * 1024, 16, SECT_4K) }, { "w25q128", INFO(0xef4018, 0, 64 * 1024, 256, SECT_4K) }, -@@ -856,7 +1002,7 @@ static const struct flash_info *spi_nor_read_id(struct spi_nor *nor) +@@ -856,7 +1002,7 @@ tmp = nor->read_reg(nor, SPINOR_OP_RDID, id, SPI_NOR_MAX_ID_LEN); if (tmp < 0) { @@ -4402,7 +4368,7 @@ index 4988390..157841d 100644 return ERR_PTR(tmp); } -@@ -867,7 +1013,7 @@ static const struct flash_info *spi_nor_read_id(struct spi_nor *nor) +@@ -867,7 +1013,7 @@ return &spi_nor_ids[tmp]; } } @@ -4411,7 +4377,7 @@ index 4988390..157841d 100644 id[0], id[1], id[2]); return ERR_PTR(-ENODEV); } -@@ -1013,6 +1159,8 @@ static int macronix_quad_enable(struct spi_nor *nor) +@@ -1013,6 +1159,8 @@ int ret, val; val = read_sr(nor); @@ -4420,67 +4386,7 @@ index 4988390..157841d 100644 write_enable(nor); write_sr(nor, val | SR_QUAD_EN_MX); -@@ -1067,45 +1215,6 @@ static int spansion_quad_enable(struct spi_nor *nor) - return 0; - } - --static int micron_quad_enable(struct spi_nor *nor) --{ -- int ret; -- u8 val; -- -- ret = nor->read_reg(nor, SPINOR_OP_RD_EVCR, &val, 1); -- if (ret < 0) { -- dev_err(nor->dev, "error %d reading EVCR\n", ret); -- return ret; -- } -- -- write_enable(nor); -- -- /* set EVCR, enable quad I/O */ -- nor->cmd_buf[0] = val & ~EVCR_QUAD_EN_MICRON; -- ret = nor->write_reg(nor, SPINOR_OP_WD_EVCR, nor->cmd_buf, 1); -- if (ret < 0) { -- dev_err(nor->dev, "error while writing EVCR register\n"); -- return ret; -- } -- -- ret = spi_nor_wait_till_ready(nor); -- if (ret) -- return ret; -- -- /* read EVCR and check it */ -- ret = nor->read_reg(nor, SPINOR_OP_RD_EVCR, &val, 1); -- if (ret < 0) { -- dev_err(nor->dev, "error %d reading EVCR\n", ret); -- return ret; -- } -- if (val & EVCR_QUAD_EN_MICRON) { -- dev_err(nor->dev, "Micron EVCR Quad bit not clear\n"); -- return -EINVAL; -- } -- -- return 0; --} -- - static int set_quad_mode(struct spi_nor *nor, const struct flash_info *info) - { - int status; -@@ -1119,12 +1228,7 @@ static int set_quad_mode(struct spi_nor *nor, const struct flash_info *info) - } - return status; - case SNOR_MFR_MICRON: -- status = micron_quad_enable(nor); -- if (status) { -- dev_err(nor->dev, "Micron quad-read not enabled\n"); -- return -EINVAL; -- } -- return status; -+ return 0; - default: - status = spansion_quad_enable(nor); - if (status) { -@@ -1138,7 +1242,7 @@ static int set_quad_mode(struct spi_nor *nor, const struct flash_info *info) +@@ -1094,7 +1242,7 @@ static int spi_nor_check(struct spi_nor *nor) { if (!nor->dev || !nor->read || !nor->write || @@ -4489,7 +4395,7 @@ index 4988390..157841d 100644 pr_err("spi-nor: please fill all the necessary fields!\n"); return -EINVAL; } -@@ -1151,7 +1255,7 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode) +@@ -1107,7 +1255,7 @@ const struct flash_info *info = NULL; struct device *dev = nor->dev; struct mtd_info *mtd = &nor->mtd; @@ -4498,11 +4404,12 @@ index 4988390..157841d 100644 int ret; int i; -@@ -1201,9 +1305,10 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode) +@@ -1157,9 +1305,11 @@ if (JEDEC_MFR(info) == SNOR_MFR_ATMEL || JEDEC_MFR(info) == SNOR_MFR_INTEL || - JEDEC_MFR(info) == SNOR_MFR_SST || -- JEDEC_MFR(info) == SNOR_MFR_WINBOND) { + JEDEC_MFR(info) == SNOR_MFR_MACRONIX || +- JEDEC_MFR(info) == SNOR_MFR_SST) { ++ JEDEC_MFR(info) == SNOR_MFR_SST || + info->flags & SPI_NOR_HAS_LOCK) { write_enable(nor); write_sr(nor, 0); @@ -4510,16 +4417,17 @@ index 4988390..157841d 100644 } if (!mtd->name) -@@ -1218,7 +1323,7 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode) +@@ -1173,7 +1323,8 @@ + mtd->_read = spi_nor_read; /* NOR protection support for STmicro/Micron chips and similar */ - if (JEDEC_MFR(info) == SNOR_MFR_MICRON || -- JEDEC_MFR(info) == SNOR_MFR_WINBOND) { +- if (JEDEC_MFR(info) == SNOR_MFR_MICRON) { ++ if (JEDEC_MFR(info) == SNOR_MFR_MICRON || + info->flags & SPI_NOR_HAS_LOCK) { nor->flash_lock = stm_lock; nor->flash_unlock = stm_unlock; nor->flash_is_locked = stm_is_locked; -@@ -1238,6 +1343,8 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode) +@@ -1193,6 +1344,8 @@ if (info->flags & USE_FSR) nor->flags |= SNOR_F_USE_FSR; @@ -4528,7 +4436,7 @@ index 4988390..157841d 100644 #ifdef CONFIG_MTD_SPI_NOR_USE_4K_SECTORS /* prefer "small sector" erase if possible */ -@@ -1340,6 +1447,12 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode) +@@ -1295,6 +1448,12 @@ nor->addr_width = 3; } @@ -4541,11 +4449,9 @@ index 4988390..157841d 100644 nor->read_dummy = spi_nor_read_dummy_cycles(nor); dev_info(dev, "%s (%lld Kbytes)\n", info->name, -diff --git a/drivers/mtd/tests/mtd_nandecctest.c b/drivers/mtd/tests/mtd_nandecctest.c -index 7931615..88b6c81 100644 --- a/drivers/mtd/tests/mtd_nandecctest.c +++ b/drivers/mtd/tests/mtd_nandecctest.c -@@ -187,7 +187,7 @@ static int double_bit_error_detect(void *error_data, void *error_ecc, +@@ -187,7 +187,7 @@ __nand_calculate_ecc(error_data, size, calc_ecc); ret = __nand_correct_data(error_data, error_ecc, calc_ecc, size); @@ -4554,11 +4460,9 @@ index 7931615..88b6c81 100644 } static const struct nand_ecc_test nand_ecc_test[] = { -diff --git a/drivers/mtd/tests/oobtest.c b/drivers/mtd/tests/oobtest.c -index 3176212..1cb3f77 100644 --- a/drivers/mtd/tests/oobtest.c +++ b/drivers/mtd/tests/oobtest.c -@@ -215,19 +215,19 @@ static int verify_eraseblock(int ebnum) +@@ -215,19 +215,19 @@ pr_info("ignoring error as within bitflip_limit\n"); } @@ -4581,7 +4485,7 @@ index 3176212..1cb3f77 100644 pr_err("error: readoob failed at %#llx\n", (long long)addr); errcnt += 1; -@@ -244,7 +244,7 @@ static int verify_eraseblock(int ebnum) +@@ -244,7 +244,7 @@ /* verify post-(use_offset + use_len) area for 0xff */ k = use_offset + use_len; bitflips += memffshow(addr, k, readbuf + k, @@ -4590,7 +4494,7 @@ index 3176212..1cb3f77 100644 if (bitflips > bitflip_limit) { pr_err("error: verify failed at %#llx\n", -@@ -269,8 +269,8 @@ static int verify_eraseblock_in_one_go(int ebnum) +@@ -269,8 +269,8 @@ struct mtd_oob_ops ops; int err = 0; loff_t addr = (loff_t)ebnum * mtd->erasesize; @@ -4601,7 +4505,7 @@ index 3176212..1cb3f77 100644 size_t bitflips; int i; -@@ -394,8 +394,8 @@ static int __init mtd_oobtest_init(void) +@@ -394,8 +394,8 @@ goto out; use_offset = 0; @@ -4612,7 +4516,7 @@ index 3176212..1cb3f77 100644 vary_offset = 0; /* First test: write all OOB, read it back and verify */ -@@ -460,8 +460,8 @@ static int __init mtd_oobtest_init(void) +@@ -460,8 +460,8 @@ /* Write all eraseblocks */ use_offset = 0; @@ -4623,7 +4527,7 @@ index 3176212..1cb3f77 100644 vary_offset = 1; prandom_seed_state(&rnd_state, 5); -@@ -471,8 +471,8 @@ static int __init mtd_oobtest_init(void) +@@ -471,8 +471,8 @@ /* Check all eraseblocks */ use_offset = 0; @@ -4634,7 +4538,7 @@ index 3176212..1cb3f77 100644 vary_offset = 1; prandom_seed_state(&rnd_state, 5); err = verify_all_eraseblocks(); -@@ -480,8 +480,8 @@ static int __init mtd_oobtest_init(void) +@@ -480,8 +480,8 @@ goto out; use_offset = 0; @@ -4645,7 +4549,7 @@ index 3176212..1cb3f77 100644 vary_offset = 0; /* Fourth test: try to write off end of device */ -@@ -501,7 +501,7 @@ static int __init mtd_oobtest_init(void) +@@ -501,7 +501,7 @@ ops.retlen = 0; ops.ooblen = 1; ops.oobretlen = 0; @@ -4654,7 +4558,7 @@ index 3176212..1cb3f77 100644 ops.datbuf = NULL; ops.oobbuf = writebuf; pr_info("attempting to start write past end of OOB\n"); -@@ -521,7 +521,7 @@ static int __init mtd_oobtest_init(void) +@@ -521,7 +521,7 @@ ops.retlen = 0; ops.ooblen = 1; ops.oobretlen = 0; @@ -4663,7 +4567,7 @@ index 3176212..1cb3f77 100644 ops.datbuf = NULL; ops.oobbuf = readbuf; pr_info("attempting to start read past end of OOB\n"); -@@ -543,7 +543,7 @@ static int __init mtd_oobtest_init(void) +@@ -543,7 +543,7 @@ ops.mode = MTD_OPS_AUTO_OOB; ops.len = 0; ops.retlen = 0; @@ -4672,7 +4576,7 @@ index 3176212..1cb3f77 100644 ops.oobretlen = 0; ops.ooboffs = 0; ops.datbuf = NULL; -@@ -563,7 +563,7 @@ static int __init mtd_oobtest_init(void) +@@ -563,7 +563,7 @@ ops.mode = MTD_OPS_AUTO_OOB; ops.len = 0; ops.retlen = 0; @@ -4681,7 +4585,7 @@ index 3176212..1cb3f77 100644 ops.oobretlen = 0; ops.ooboffs = 0; ops.datbuf = NULL; -@@ -587,7 +587,7 @@ static int __init mtd_oobtest_init(void) +@@ -587,7 +587,7 @@ ops.mode = MTD_OPS_AUTO_OOB; ops.len = 0; ops.retlen = 0; @@ -4690,7 +4594,7 @@ index 3176212..1cb3f77 100644 ops.oobretlen = 0; ops.ooboffs = 1; ops.datbuf = NULL; -@@ -607,7 +607,7 @@ static int __init mtd_oobtest_init(void) +@@ -607,7 +607,7 @@ ops.mode = MTD_OPS_AUTO_OOB; ops.len = 0; ops.retlen = 0; @@ -4699,7 +4603,7 @@ index 3176212..1cb3f77 100644 ops.oobretlen = 0; ops.ooboffs = 1; ops.datbuf = NULL; -@@ -638,7 +638,7 @@ static int __init mtd_oobtest_init(void) +@@ -638,7 +638,7 @@ for (i = 0; i < ebcnt - 1; ++i) { int cnt = 2; int pg; @@ -4708,7 +4612,7 @@ index 3176212..1cb3f77 100644 if (bbt[i] || bbt[i + 1]) continue; addr = (loff_t)(i + 1) * mtd->erasesize - mtd->writesize; -@@ -673,13 +673,12 @@ static int __init mtd_oobtest_init(void) +@@ -673,13 +673,12 @@ for (i = 0; i < ebcnt - 1; ++i) { if (bbt[i] || bbt[i + 1]) continue; @@ -4724,7 +4628,7 @@ index 3176212..1cb3f77 100644 ops.oobretlen = 0; ops.ooboffs = 0; ops.datbuf = NULL; -@@ -688,7 +687,7 @@ static int __init mtd_oobtest_init(void) +@@ -688,7 +687,7 @@ if (err) goto out; if (memcmpshow(addr, readbuf, writebuf, @@ -4733,11 +4637,9 @@ index 3176212..1cb3f77 100644 pr_err("error: verify failed at %#llx\n", (long long)addr); errcnt += 1; -diff --git a/drivers/mtd/tests/pagetest.c b/drivers/mtd/tests/pagetest.c -index ba1890d..ff1e056 100644 --- a/drivers/mtd/tests/pagetest.c +++ b/drivers/mtd/tests/pagetest.c -@@ -127,13 +127,12 @@ static int crosstest(void) +@@ -127,13 +127,12 @@ unsigned char *pp1, *pp2, *pp3, *pp4; pr_info("crosstest\n"); @@ -4752,11 +4654,9 @@ index ba1890d..ff1e056 100644 addr0 = 0; for (i = 0; i < ebcnt && bbt[i]; ++i) -diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c -index 54e056d..ee2b74d 100644 --- a/drivers/mtd/ubi/cdev.c +++ b/drivers/mtd/ubi/cdev.c -@@ -174,9 +174,9 @@ static int vol_cdev_fsync(struct file *file, loff_t start, loff_t end, +@@ -174,9 +174,9 @@ struct ubi_device *ubi = desc->vol->ubi; struct inode *inode = file_inode(file); int err; @@ -4768,11 +4668,9 @@ index 54e056d..ee2b74d 100644 return err; } -diff --git a/drivers/mtd/ubi/misc.c b/drivers/mtd/ubi/misc.c -index 2a45ac2..989036c 100644 --- a/drivers/mtd/ubi/misc.c +++ b/drivers/mtd/ubi/misc.c -@@ -153,3 +153,52 @@ int ubi_check_pattern(const void *buf, uint8_t patt, int size) +@@ -153,3 +153,52 @@ return 0; return 1; } @@ -4825,8 +4723,6 @@ index 2a45ac2..989036c 100644 + ubi->ubi_num, __builtin_return_address(0), &vaf); + va_end(args); +} -diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h -index 2974b67..dadc6a9 100644 --- a/drivers/mtd/ubi/ubi.h +++ b/drivers/mtd/ubi/ubi.h @@ -49,15 +49,19 @@ @@ -4855,24 +4751,9 @@ index 2974b67..dadc6a9 100644 /* Background thread name pattern */ #define UBI_BGT_NAME_PATTERN "ubi_bgt%dd" -diff --git a/drivers/mtd/ubi/upd.c b/drivers/mtd/ubi/upd.c -index 2a1b6e0..0134ba3 100644 ---- a/drivers/mtd/ubi/upd.c -+++ b/drivers/mtd/ubi/upd.c -@@ -193,7 +193,7 @@ int ubi_start_leb_change(struct ubi_device *ubi, struct ubi_volume *vol, - vol->changing_leb = 1; - vol->ch_lnum = req->lnum; - -- vol->upd_buf = vmalloc(req->bytes); -+ vol->upd_buf = vmalloc(ALIGN((int)req->bytes, ubi->min_io_size)); - if (!vol->upd_buf) - return -ENOMEM; - -diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c -index 5606563..17ec948 100644 --- a/drivers/mtd/ubi/wl.c +++ b/drivers/mtd/ubi/wl.c -@@ -628,6 +628,7 @@ static int do_sync_erase(struct ubi_device *ubi, struct ubi_wl_entry *e, +@@ -628,6 +628,7 @@ return __erase_worker(ubi, &wl_wrk); } @@ -4880,7 +4761,7 @@ index 5606563..17ec948 100644 /** * wear_leveling_worker - wear-leveling worker function. * @ubi: UBI device description object -@@ -649,6 +650,7 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk, +@@ -649,6 +650,7 @@ #endif struct ubi_wl_entry *e1, *e2; struct ubi_vid_hdr *vid_hdr; @@ -4888,7 +4769,7 @@ index 5606563..17ec948 100644 kfree(wrk); if (shutdown) -@@ -753,6 +755,7 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk, +@@ -753,6 +755,7 @@ err = ubi_io_read_vid_hdr(ubi, e1->pnum, vid_hdr, 0); if (err && err != UBI_IO_BITFLIPS) { @@ -4896,7 +4777,7 @@ index 5606563..17ec948 100644 if (err == UBI_IO_FF) { /* * We are trying to move PEB without a VID header. UBI -@@ -798,10 +801,12 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk, +@@ -798,10 +801,12 @@ * protection queue. */ protect = 1; @@ -4909,7 +4790,7 @@ index 5606563..17ec948 100644 goto out_not_moved; } if (err == MOVE_TARGET_BITFLIPS || err == MOVE_TARGET_WR_ERR || -@@ -827,6 +832,7 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk, +@@ -827,6 +832,7 @@ ubi->erroneous_peb_count); goto out_error; } @@ -4917,7 +4798,7 @@ index 5606563..17ec948 100644 erroneous = 1; goto out_not_moved; } -@@ -897,15 +903,24 @@ out_not_moved: +@@ -897,15 +903,24 @@ wl_tree_add(e1, &ubi->scrub); else wl_tree_add(e1, &ubi->used); @@ -4945,11 +4826,9 @@ index 5606563..17ec948 100644 mutex_unlock(&ubi->move_mutex); return 0; -diff --git a/include/linux/mtd/bbm.h b/include/linux/mtd/bbm.h -index 36bb6a5..3bf8f95 100644 --- a/include/linux/mtd/bbm.h +++ b/include/linux/mtd/bbm.h -@@ -166,7 +166,6 @@ struct bbm_info { +@@ -166,7 +166,6 @@ }; /* OneNAND BBT interface */ @@ -4957,8 +4836,6 @@ index 36bb6a5..3bf8f95 100644 extern int onenand_default_bbt(struct mtd_info *mtd); #endif /* __LINUX_MTD_BBM_H */ -diff --git a/include/linux/mtd/fsmc.h b/include/linux/mtd/fsmc.h -index c8be32e..ad3c348 100644 --- a/include/linux/mtd/fsmc.h +++ b/include/linux/mtd/fsmc.h @@ -103,24 +103,6 @@ @@ -4986,11 +4863,9 @@ index c8be32e..ad3c348 100644 struct fsmc_nand_timings { uint8_t tclr; uint8_t tar; -diff --git a/include/linux/mtd/inftl.h b/include/linux/mtd/inftl.h -index 02cd5f9..8255118 100644 --- a/include/linux/mtd/inftl.h +++ b/include/linux/mtd/inftl.h -@@ -44,7 +44,6 @@ struct INFTLrecord { +@@ -44,7 +44,6 @@ unsigned int nb_blocks; /* number of physical blocks */ unsigned int nb_boot_blocks; /* number of blocks used by the bios */ struct erase_info instr; @@ -4998,8 +4873,6 @@ index 02cd5f9..8255118 100644 }; int INFTL_mount(struct INFTLrecord *s); -diff --git a/include/linux/mtd/map.h b/include/linux/mtd/map.h -index 366cf77..5e0eb7c 100644 --- a/include/linux/mtd/map.h +++ b/include/linux/mtd/map.h @@ -142,7 +142,9 @@ @@ -5012,7 +4885,7 @@ index 366cf77..5e0eb7c 100644 static inline int map_bankwidth(void *map) { BUG(); -@@ -238,8 +240,11 @@ struct map_info { +@@ -238,8 +240,11 @@ If there is no cache to care about this can be set to NULL. */ void (*inval_cache)(struct map_info *, unsigned long, ssize_t); @@ -5026,11 +4899,9 @@ index 366cf77..5e0eb7c 100644 void (*set_vpp)(struct map_info *, int); unsigned long pfow_base; -diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h -index f17fa75..df8c116 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h -@@ -96,17 +96,35 @@ struct mtd_oob_ops { +@@ -100,17 +100,35 @@ #define MTD_MAX_OOBFREE_ENTRIES_LARGE 32 #define MTD_MAX_ECCPOS_ENTRIES_LARGE 640 @@ -5075,7 +4946,7 @@ index f17fa75..df8c116 100644 }; struct module; /* only needed for owner field in mtd_info */ -@@ -167,8 +185,8 @@ struct mtd_info { +@@ -171,8 +189,8 @@ const char *name; int index; @@ -5086,7 +4957,7 @@ index f17fa75..df8c116 100644 /* the ecc step size. */ unsigned int ecc_step_size; -@@ -254,6 +272,46 @@ struct mtd_info { +@@ -258,6 +276,46 @@ int usecount; }; @@ -5133,11 +5004,9 @@ index f17fa75..df8c116 100644 int mtd_erase(struct mtd_info *mtd, struct erase_info *instr); int mtd_point(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, void **virt, resource_size_t *phys); -diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h -index 5a9d1d4..d766c12 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h -@@ -119,6 +119,12 @@ typedef enum { +@@ -119,6 +119,12 @@ NAND_ECC_SOFT_BCH, } nand_ecc_modes_t; @@ -5150,7 +5019,7 @@ index 5a9d1d4..d766c12 100644 /* * Constants for Hardware ECC */ -@@ -129,6 +135,14 @@ typedef enum { +@@ -129,6 +135,14 @@ /* Enable Hardware ECC before syndrome is read back from flash */ #define NAND_ECC_READSYN 2 @@ -5165,7 +5034,7 @@ index 5a9d1d4..d766c12 100644 /* Bit mask for flags passed to do_nand_read_ecc */ #define NAND_GET_DEVICE 0x80 -@@ -160,6 +174,12 @@ typedef enum { +@@ -160,6 +174,12 @@ /* Device supports subpage reads */ #define NAND_SUBPAGE_READ 0x00001000 @@ -5178,7 +5047,7 @@ index 5a9d1d4..d766c12 100644 /* Options valid for Samsung large page devices */ #define NAND_SAMSUNG_LP_OPTIONS NAND_CACHEPRG -@@ -276,15 +296,15 @@ struct nand_onfi_params { +@@ -276,15 +296,15 @@ __le16 t_r; __le16 t_ccs; __le16 src_sync_timing_mode; @@ -5197,7 +5066,7 @@ index 5a9d1d4..d766c12 100644 /* vendor */ __le16 vendor_revision; -@@ -407,7 +427,7 @@ struct nand_jedec_params { +@@ -407,7 +427,7 @@ __le16 input_pin_capacitance_typ; __le16 clk_pin_capacitance_typ; u8 driver_strength_support; @@ -5206,7 +5075,7 @@ index 5a9d1d4..d766c12 100644 u8 reserved4[36]; /* ECC and endurance block */ -@@ -444,6 +464,7 @@ struct nand_hw_control { +@@ -444,6 +464,7 @@ /** * struct nand_ecc_ctrl - Control structure for ECC * @mode: ECC mode @@ -5214,7 +5083,7 @@ index 5a9d1d4..d766c12 100644 * @steps: number of ECC steps per page * @size: data bytes per ECC step * @bytes: ECC bytes per step -@@ -451,12 +472,18 @@ struct nand_hw_control { +@@ -451,12 +472,18 @@ * @total: total number of ECC bytes per page * @prepad: padding information for syndrome based ECC generators * @postpad: padding information for syndrome based ECC generators @@ -5235,7 +5104,7 @@ index 5a9d1d4..d766c12 100644 * @read_page_raw: function to read a raw page without ECC. This function * should hide the specific layout used by the ECC * controller and always return contiguous in-band and -@@ -487,6 +514,7 @@ struct nand_hw_control { +@@ -487,6 +514,7 @@ */ struct nand_ecc_ctrl { nand_ecc_modes_t mode; @@ -5243,7 +5112,7 @@ index 5a9d1d4..d766c12 100644 int steps; int size; int bytes; -@@ -494,7 +522,7 @@ struct nand_ecc_ctrl { +@@ -494,7 +522,7 @@ int strength; int prepad; int postpad; @@ -5252,7 +5121,7 @@ index 5a9d1d4..d766c12 100644 void *priv; void (*hwctl)(struct mtd_info *mtd, int mode); int (*calculate)(struct mtd_info *mtd, const uint8_t *dat, -@@ -540,11 +568,11 @@ struct nand_buffers { +@@ -540,11 +568,11 @@ /** * struct nand_chip - NAND Private Flash Chip Data @@ -5265,7 +5134,7 @@ index 5a9d1d4..d766c12 100644 * @read_byte: [REPLACEABLE] read one byte from the chip * @read_word: [REPLACEABLE] read one word from the chip * @write_byte: [REPLACEABLE] write a single byte to the chip on the -@@ -640,18 +668,17 @@ struct nand_buffers { +@@ -640,18 +668,17 @@ */ struct nand_chip { @@ -5286,7 +5155,7 @@ index 5a9d1d4..d766c12 100644 int (*block_markbad)(struct mtd_info *mtd, loff_t ofs); void (*cmd_ctrl)(struct mtd_info *mtd, int dat, unsigned int ctrl); int (*dev_ready)(struct mtd_info *mtd); -@@ -719,6 +746,40 @@ struct nand_chip { +@@ -719,6 +746,40 @@ void *priv; }; @@ -5327,7 +5196,7 @@ index 5a9d1d4..d766c12 100644 /* * NAND Flash Manufacturer ID Codes */ -@@ -850,7 +911,6 @@ extern int nand_do_read(struct mtd_info *mtd, loff_t from, size_t len, +@@ -850,7 +911,6 @@ * @chip_delay: R/B delay value in us * @options: Option flags, e.g. 16bit buswidth * @bbt_options: BBT option flags, e.g. NAND_BBT_USE_FLASH @@ -5335,7 +5204,7 @@ index 5a9d1d4..d766c12 100644 * @part_probe_types: NULL-terminated array of probe types */ struct platform_nand_chip { -@@ -858,7 +918,6 @@ struct platform_nand_chip { +@@ -858,7 +918,6 @@ int chip_offset; int nr_partitions; struct mtd_partition *partitions; @@ -5343,7 +5212,7 @@ index 5a9d1d4..d766c12 100644 int chip_delay; unsigned int options; unsigned int bbt_options; -@@ -907,15 +966,6 @@ struct platform_nand_data { +@@ -908,15 +967,6 @@ struct platform_nand_ctrl ctrl; }; @@ -5359,11 +5228,9 @@ index 5a9d1d4..d766c12 100644 /* return the supported features. */ static inline int onfi_feature(struct nand_chip *chip) { -diff --git a/include/linux/mtd/nand_bch.h b/include/linux/mtd/nand_bch.h -index 74acf53..98f20ef 100644 --- a/include/linux/mtd/nand_bch.h +++ b/include/linux/mtd/nand_bch.h -@@ -32,9 +32,7 @@ int nand_bch_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, +@@ -32,9 +32,7 @@ /* * Initialize BCH encoder/decoder */ @@ -5374,7 +5241,7 @@ index 74acf53..98f20ef 100644 /* * Release BCH encoder/decoder resources */ -@@ -55,12 +53,10 @@ static inline int +@@ -55,12 +53,10 @@ nand_bch_correct_data(struct mtd_info *mtd, unsigned char *buf, unsigned char *read_ecc, unsigned char *calc_ecc) { @@ -5389,11 +5256,9 @@ index 74acf53..98f20ef 100644 { return NULL; } -diff --git a/include/linux/mtd/nftl.h b/include/linux/mtd/nftl.h -index b059629..044daa0 100644 --- a/include/linux/mtd/nftl.h +++ b/include/linux/mtd/nftl.h -@@ -50,7 +50,6 @@ struct NFTLrecord { +@@ -50,7 +50,6 @@ unsigned int nb_blocks; /* number of physical blocks */ unsigned int nb_boot_blocks; /* number of blocks used by the bios */ struct erase_info instr; @@ -5401,11 +5266,9 @@ index b059629..044daa0 100644 }; int NFTL_mount(struct NFTLrecord *s); -diff --git a/include/linux/mtd/onenand.h b/include/linux/mtd/onenand.h -index 4596503..0aaa98b 100644 --- a/include/linux/mtd/onenand.h +++ b/include/linux/mtd/onenand.h -@@ -80,7 +80,6 @@ struct onenand_bufferram { +@@ -80,7 +80,6 @@ * @page_buf: [INTERN] page main data buffer * @oob_buf: [INTERN] page oob data buffer * @subpagesize: [INTERN] holds the subpagesize @@ -5413,7 +5276,7 @@ index 4596503..0aaa98b 100644 * @bbm: [REPLACEABLE] pointer to Bad Block Management * @priv: [OPTIONAL] pointer to private chip date */ -@@ -134,7 +133,6 @@ struct onenand_chip { +@@ -134,7 +133,6 @@ #endif int subpagesize; @@ -5421,11 +5284,9 @@ index 4596503..0aaa98b 100644 void *bbm; -diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h -index 6a35e6d..70736e1 100644 --- a/include/linux/mtd/partitions.h +++ b/include/linux/mtd/partitions.h -@@ -41,7 +41,6 @@ struct mtd_partition { +@@ -42,7 +42,6 @@ uint64_t size; /* partition size */ uint64_t offset; /* offset within the master MTD space */ uint32_t mask_flags; /* master MTD flags to mask out for this partition */ @@ -5433,7 +5294,7 @@ index 6a35e6d..70736e1 100644 }; #define MTDPART_OFS_RETAIN (-3) -@@ -56,11 +55,9 @@ struct device_node; +@@ -56,11 +55,9 @@ /** * struct mtd_part_parser_data - used to pass data to MTD partition parsers. * @origin: for RedBoot, start address of MTD device @@ -5445,7 +5306,7 @@ index 6a35e6d..70736e1 100644 }; -@@ -72,13 +69,33 @@ struct mtd_part_parser { +@@ -78,14 +75,34 @@ struct list_head list; struct module *owner; const char *name; @@ -5453,6 +5314,7 @@ index 6a35e6d..70736e1 100644 + int (*parse_fn)(struct mtd_info *, const struct mtd_partition **, struct mtd_part_parser_data *); + void (*cleanup)(const struct mtd_partition *pparts, int nr_parts); + enum mtd_parser_type type; }; -extern void register_mtd_parser(struct mtd_part_parser *parser); @@ -5481,11 +5343,9 @@ index 6a35e6d..70736e1 100644 int mtd_is_partition(const struct mtd_info *mtd); int mtd_add_partition(struct mtd_info *master, const char *name, long long offset, long long length); -diff --git a/include/linux/mtd/sh_flctl.h b/include/linux/mtd/sh_flctl.h -index 1c28f88..2251add 100644 --- a/include/linux/mtd/sh_flctl.h +++ b/include/linux/mtd/sh_flctl.h -@@ -143,11 +143,11 @@ enum flctl_ecc_res_t { +@@ -143,11 +143,11 @@ struct dma_chan; struct sh_flctl { @@ -5498,7 +5358,7 @@ index 1c28f88..2251add 100644 uint8_t done_buff[2048 + 64]; /* max size 2048 + 64 */ int read_bytes; -@@ -186,7 +186,7 @@ struct sh_flctl_platform_data { +@@ -186,7 +186,7 @@ static inline struct sh_flctl *mtd_to_flctl(struct mtd_info *mtdinfo) { @@ -5507,8 +5367,6 @@ index 1c28f88..2251add 100644 } #endif /* __SH_FLCTL_H__ */ -diff --git a/include/linux/mtd/sharpsl.h b/include/linux/mtd/sharpsl.h -index 25f4d2a..65e91d0 100644 --- a/include/linux/mtd/sharpsl.h +++ b/include/linux/mtd/sharpsl.h @@ -14,7 +14,7 @@ @@ -5520,94 +5378,9 @@ index 25f4d2a..65e91d0 100644 struct mtd_partition *partitions; unsigned int nr_partitions; }; -diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h -index c8723b6..3c36113 100644 ---- a/include/linux/mtd/spi-nor.h -+++ b/include/linux/mtd/spi-nor.h -@@ -12,6 +12,7 @@ - - #include - #include -+#include - - /* - * Manufacturer IDs -@@ -25,7 +26,7 @@ - #define SNOR_MFR_MACRONIX CFI_MFR_MACRONIX - #define SNOR_MFR_SPANSION CFI_MFR_AMD - #define SNOR_MFR_SST CFI_MFR_SST --#define SNOR_MFR_WINBOND 0xef -+#define SNOR_MFR_WINBOND 0xef /* Also used by some Spansion */ - - /* - * Note on opcode nomenclature: some opcodes have a format like -@@ -84,6 +85,7 @@ - #define SR_BP0 BIT(2) /* Block protect 0 */ - #define SR_BP1 BIT(3) /* Block protect 1 */ - #define SR_BP2 BIT(4) /* Block protect 2 */ -+#define SR_TB BIT(5) /* Top/Bottom protect */ - #define SR_SRWD BIT(7) /* SR write protect */ - - #define SR_QUAD_EN_MX BIT(6) /* Macronix Quad I/O */ -@@ -115,16 +117,14 @@ enum spi_nor_ops { - - enum spi_nor_option_flags { - SNOR_F_USE_FSR = BIT(0), -+ SNOR_F_HAS_SR_TB = BIT(1), - }; - --struct mtd_info; -- - /** - * struct spi_nor - Structure for defining a the SPI NOR layer - * @mtd: point to a mtd_info structure - * @lock: the lock for the read/write/erase/lock/unlock operations - * @dev: point to a spi device, or a spi nor controller device. -- * @flash_node: point to a device node describing this flash instance. - * @page_size: the page size of the SPI NOR - * @addr_width: number of address bytes - * @erase_opcode: the opcode for erasing a sector -@@ -144,7 +144,8 @@ struct mtd_info; - * @read: [DRIVER-SPECIFIC] read data from the SPI NOR - * @write: [DRIVER-SPECIFIC] write data to the SPI NOR - * @erase: [DRIVER-SPECIFIC] erase a sector of the SPI NOR -- * at the offset @offs -+ * at the offset @offs; if not provided by the driver, -+ * spi-nor will send the erase opcode via write_reg() - * @flash_lock: [FLASH-SPECIFIC] lock a region of the SPI NOR - * @flash_unlock: [FLASH-SPECIFIC] unlock a region of the SPI NOR - * @flash_is_locked: [FLASH-SPECIFIC] check if a region of the SPI NOR is -@@ -155,7 +156,6 @@ struct spi_nor { - struct mtd_info mtd; - struct mutex lock; - struct device *dev; -- struct device_node *flash_node; - u32 page_size; - u8 addr_width; - u8 erase_opcode; -@@ -185,6 +185,17 @@ struct spi_nor { - void *priv; - }; - -+static inline void spi_nor_set_flash_node(struct spi_nor *nor, -+ struct device_node *np) -+{ -+ mtd_set_of_node(&nor->mtd, np); -+} -+ -+static inline struct device_node *spi_nor_get_flash_node(struct spi_nor *nor) -+{ -+ return mtd_get_of_node(&nor->mtd); -+} -+ - /** - * spi_nor_scan() - scan the SPI NOR - * @nor: the spi_nor structure -diff --git a/include/uapi/mtd/mtd-abi.h b/include/uapi/mtd/mtd-abi.h -index 763bb69..0ec1da2 100644 --- a/include/uapi/mtd/mtd-abi.h +++ b/include/uapi/mtd/mtd-abi.h -@@ -228,7 +228,7 @@ struct nand_oobfree { +@@ -228,7 +228,7 @@ * complete set of ECC information. The ioctl truncates the larger internal * structure to retain binary compatibility with the static declaration of the * ioctl. Note that the "MTD_MAX_..._ENTRIES" macros represent the max size of @@ -5616,6 +5389,30 @@ index 763bb69..0ec1da2 100644 */ struct nand_ecclayout_user { __u32 eccbytes; --- -1.7.10.4 - +--- a/fs/jffs2/wbuf.c ++++ b/fs/jffs2/wbuf.c +@@ -1183,22 +1183,20 @@ + + int jffs2_nand_flash_setup(struct jffs2_sb_info *c) + { +- struct nand_ecclayout *oinfo = c->mtd->ecclayout; +- + if (!c->mtd->oobsize) + return 0; + + /* Cleanmarker is out-of-band, so inline size zero */ + c->cleanmarker_size = 0; + +- if (!oinfo || oinfo->oobavail == 0) { ++ if (c->oobavail == 0) { + pr_err("inconsistent device description\n"); + return -EINVAL; + } + + jffs2_dbg(1, "using OOB on NAND\n"); + +- c->oobavail = oinfo->oobavail; ++ c->oobavail = c->mtd->oobavail; + + /* Initialise write buffer */ + init_rwsem(&c->wbuf_sem);