aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/nand/cafe_nand.c2
-rw-r--r--drivers/mtd/nand/gpmi-nand/gpmi-nand.c10
-rw-r--r--drivers/mtd/nand/mxc_nand.c37
-rw-r--r--drivers/mtd/nand/nand_base.c7
-rw-r--r--drivers/mtd/nand/nandsim.c12
-rw-r--r--drivers/mtd/ubi/debug.c8
6 files changed, 49 insertions, 27 deletions
diff --git a/drivers/mtd/nand/cafe_nand.c b/drivers/mtd/nand/cafe_nand.c
index 41371ba1a811..f3f6cfedd69e 100644
--- a/drivers/mtd/nand/cafe_nand.c
+++ b/drivers/mtd/nand/cafe_nand.c
@@ -102,7 +102,7 @@ static const char *part_probes[] = { "cmdlinepart", "RedBoot", NULL };
102static int cafe_device_ready(struct mtd_info *mtd) 102static int cafe_device_ready(struct mtd_info *mtd)
103{ 103{
104 struct cafe_priv *cafe = mtd->priv; 104 struct cafe_priv *cafe = mtd->priv;
105 int result = !!(cafe_readl(cafe, NAND_STATUS) | 0x40000000); 105 int result = !!(cafe_readl(cafe, NAND_STATUS) & 0x40000000);
106 uint32_t irqs = cafe_readl(cafe, NAND_IRQ); 106 uint32_t irqs = cafe_readl(cafe, NAND_IRQ);
107 107
108 cafe_writel(cafe, irqs, NAND_IRQ); 108 cafe_writel(cafe, irqs, NAND_IRQ);
diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
index a05b7b444d4f..a6cad5caba78 100644
--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
+++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
@@ -920,12 +920,12 @@ static int gpmi_ecc_read_page(struct mtd_info *mtd, struct nand_chip *chip,
920 */ 920 */
921 memset(chip->oob_poi, ~0, mtd->oobsize); 921 memset(chip->oob_poi, ~0, mtd->oobsize);
922 chip->oob_poi[0] = ((uint8_t *) auxiliary_virt)[0]; 922 chip->oob_poi[0] = ((uint8_t *) auxiliary_virt)[0];
923
924 read_page_swap_end(this, buf, mtd->writesize,
925 this->payload_virt, this->payload_phys,
926 nfc_geo->payload_size,
927 payload_virt, payload_phys);
928 } 923 }
924
925 read_page_swap_end(this, buf, mtd->writesize,
926 this->payload_virt, this->payload_phys,
927 nfc_geo->payload_size,
928 payload_virt, payload_phys);
929exit_nfc: 929exit_nfc:
930 return ret; 930 return ret;
931} 931}
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index c58e6a93f445..6acc790c2fbb 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -273,6 +273,26 @@ static struct nand_ecclayout nandv2_hw_eccoob_4k = {
273 273
274static const char *part_probes[] = { "RedBoot", "cmdlinepart", "ofpart", NULL }; 274static const char *part_probes[] = { "RedBoot", "cmdlinepart", "ofpart", NULL };
275 275
276static void memcpy32_fromio(void *trg, const void __iomem *src, size_t size)
277{
278 int i;
279 u32 *t = trg;
280 const __iomem u32 *s = src;
281
282 for (i = 0; i < (size >> 2); i++)
283 *t++ = __raw_readl(s++);
284}
285
286static void memcpy32_toio(void __iomem *trg, const void *src, int size)
287{
288 int i;
289 u32 __iomem *t = trg;
290 const u32 *s = src;
291
292 for (i = 0; i < (size >> 2); i++)
293 __raw_writel(*s++, t++);
294}
295
276static int check_int_v3(struct mxc_nand_host *host) 296static int check_int_v3(struct mxc_nand_host *host)
277{ 297{
278 uint32_t tmp; 298 uint32_t tmp;
@@ -519,7 +539,7 @@ static void send_read_id_v3(struct mxc_nand_host *host)
519 539
520 wait_op_done(host, true); 540 wait_op_done(host, true);
521 541
522 memcpy_fromio(host->data_buf, host->main_area0, 16); 542 memcpy32_fromio(host->data_buf, host->main_area0, 16);
523} 543}
524 544
525/* Request the NANDFC to perform a read of the NAND device ID. */ 545/* Request the NANDFC to perform a read of the NAND device ID. */
@@ -535,7 +555,7 @@ static void send_read_id_v1_v2(struct mxc_nand_host *host)
535 /* Wait for operation to complete */ 555 /* Wait for operation to complete */
536 wait_op_done(host, true); 556 wait_op_done(host, true);
537 557
538 memcpy_fromio(host->data_buf, host->main_area0, 16); 558 memcpy32_fromio(host->data_buf, host->main_area0, 16);
539 559
540 if (this->options & NAND_BUSWIDTH_16) { 560 if (this->options & NAND_BUSWIDTH_16) {
541 /* compress the ID info */ 561 /* compress the ID info */
@@ -797,16 +817,16 @@ static void copy_spare(struct mtd_info *mtd, bool bfrom)
797 817
798 if (bfrom) { 818 if (bfrom) {
799 for (i = 0; i < n - 1; i++) 819 for (i = 0; i < n - 1; i++)
800 memcpy_fromio(d + i * j, s + i * t, j); 820 memcpy32_fromio(d + i * j, s + i * t, j);
801 821
802 /* the last section */ 822 /* the last section */
803 memcpy_fromio(d + i * j, s + i * t, mtd->oobsize - i * j); 823 memcpy32_fromio(d + i * j, s + i * t, mtd->oobsize - i * j);
804 } else { 824 } else {
805 for (i = 0; i < n - 1; i++) 825 for (i = 0; i < n - 1; i++)
806 memcpy_toio(&s[i * t], &d[i * j], j); 826 memcpy32_toio(&s[i * t], &d[i * j], j);
807 827
808 /* the last section */ 828 /* the last section */
809 memcpy_toio(&s[i * t], &d[i * j], mtd->oobsize - i * j); 829 memcpy32_toio(&s[i * t], &d[i * j], mtd->oobsize - i * j);
810 } 830 }
811} 831}
812 832
@@ -1070,7 +1090,8 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
1070 1090
1071 host->devtype_data->send_page(mtd, NFC_OUTPUT); 1091 host->devtype_data->send_page(mtd, NFC_OUTPUT);
1072 1092
1073 memcpy_fromio(host->data_buf, host->main_area0, mtd->writesize); 1093 memcpy32_fromio(host->data_buf, host->main_area0,
1094 mtd->writesize);
1074 copy_spare(mtd, true); 1095 copy_spare(mtd, true);
1075 break; 1096 break;
1076 1097
@@ -1086,7 +1107,7 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
1086 break; 1107 break;
1087 1108
1088 case NAND_CMD_PAGEPROG: 1109 case NAND_CMD_PAGEPROG:
1089 memcpy_toio(host->main_area0, host->data_buf, mtd->writesize); 1110 memcpy32_toio(host->main_area0, host->data_buf, mtd->writesize);
1090 copy_spare(mtd, false); 1111 copy_spare(mtd, false);
1091 host->devtype_data->send_page(mtd, NFC_INPUT); 1112 host->devtype_data->send_page(mtd, NFC_INPUT);
1092 host->devtype_data->send_cmd(host, command, true); 1113 host->devtype_data->send_cmd(host, command, true);
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index d47586cf64ce..a11253a0fcab 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -3501,6 +3501,13 @@ int nand_scan_tail(struct mtd_info *mtd)
3501 /* propagate ecc info to mtd_info */ 3501 /* propagate ecc info to mtd_info */
3502 mtd->ecclayout = chip->ecc.layout; 3502 mtd->ecclayout = chip->ecc.layout;
3503 mtd->ecc_strength = chip->ecc.strength; 3503 mtd->ecc_strength = chip->ecc.strength;
3504 /*
3505 * Initialize bitflip_threshold to its default prior scan_bbt() call.
3506 * scan_bbt() might invoke mtd_read(), thus bitflip_threshold must be
3507 * properly set.
3508 */
3509 if (!mtd->bitflip_threshold)
3510 mtd->bitflip_threshold = mtd->ecc_strength;
3504 3511
3505 /* Check, if we should skip the bad block table scan */ 3512 /* Check, if we should skip the bad block table scan */
3506 if (chip->options & NAND_SKIP_BBTSCAN) 3513 if (chip->options & NAND_SKIP_BBTSCAN)
diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c
index 6cc8fbfabb8e..cf0cd3146817 100644
--- a/drivers/mtd/nand/nandsim.c
+++ b/drivers/mtd/nand/nandsim.c
@@ -28,7 +28,7 @@
28#include <linux/module.h> 28#include <linux/module.h>
29#include <linux/moduleparam.h> 29#include <linux/moduleparam.h>
30#include <linux/vmalloc.h> 30#include <linux/vmalloc.h>
31#include <asm/div64.h> 31#include <linux/math64.h>
32#include <linux/slab.h> 32#include <linux/slab.h>
33#include <linux/errno.h> 33#include <linux/errno.h>
34#include <linux/string.h> 34#include <linux/string.h>
@@ -546,12 +546,6 @@ static char *get_partition_name(int i)
546 return kstrdup(buf, GFP_KERNEL); 546 return kstrdup(buf, GFP_KERNEL);
547} 547}
548 548
549static uint64_t divide(uint64_t n, uint32_t d)
550{
551 do_div(n, d);
552 return n;
553}
554
555/* 549/*
556 * Initialize the nandsim structure. 550 * Initialize the nandsim structure.
557 * 551 *
@@ -580,7 +574,7 @@ static int init_nandsim(struct mtd_info *mtd)
580 ns->geom.oobsz = mtd->oobsize; 574 ns->geom.oobsz = mtd->oobsize;
581 ns->geom.secsz = mtd->erasesize; 575 ns->geom.secsz = mtd->erasesize;
582 ns->geom.pgszoob = ns->geom.pgsz + ns->geom.oobsz; 576 ns->geom.pgszoob = ns->geom.pgsz + ns->geom.oobsz;
583 ns->geom.pgnum = divide(ns->geom.totsz, ns->geom.pgsz); 577 ns->geom.pgnum = div_u64(ns->geom.totsz, ns->geom.pgsz);
584 ns->geom.totszoob = ns->geom.totsz + (uint64_t)ns->geom.pgnum * ns->geom.oobsz; 578 ns->geom.totszoob = ns->geom.totsz + (uint64_t)ns->geom.pgnum * ns->geom.oobsz;
585 ns->geom.secshift = ffs(ns->geom.secsz) - 1; 579 ns->geom.secshift = ffs(ns->geom.secsz) - 1;
586 ns->geom.pgshift = chip->page_shift; 580 ns->geom.pgshift = chip->page_shift;
@@ -921,7 +915,7 @@ static int setup_wear_reporting(struct mtd_info *mtd)
921 915
922 if (!rptwear) 916 if (!rptwear)
923 return 0; 917 return 0;
924 wear_eb_count = divide(mtd->size, mtd->erasesize); 918 wear_eb_count = div_u64(mtd->size, mtd->erasesize);
925 mem = wear_eb_count * sizeof(unsigned long); 919 mem = wear_eb_count * sizeof(unsigned long);
926 if (mem / sizeof(unsigned long) != wear_eb_count) { 920 if (mem / sizeof(unsigned long) != wear_eb_count) {
927 NS_ERR("Too many erase blocks for wear reporting\n"); 921 NS_ERR("Too many erase blocks for wear reporting\n");
diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c
index 09d4f8d9d592..7c1380305219 100644
--- a/drivers/mtd/ubi/debug.c
+++ b/drivers/mtd/ubi/debug.c
@@ -264,7 +264,7 @@ static struct dentry *dfs_rootdir;
264 */ 264 */
265int ubi_debugfs_init(void) 265int ubi_debugfs_init(void)
266{ 266{
267 if (!IS_ENABLED(DEBUG_FS)) 267 if (!IS_ENABLED(CONFIG_DEBUG_FS))
268 return 0; 268 return 0;
269 269
270 dfs_rootdir = debugfs_create_dir("ubi", NULL); 270 dfs_rootdir = debugfs_create_dir("ubi", NULL);
@@ -284,7 +284,7 @@ int ubi_debugfs_init(void)
284 */ 284 */
285void ubi_debugfs_exit(void) 285void ubi_debugfs_exit(void)
286{ 286{
287 if (IS_ENABLED(DEBUG_FS)) 287 if (IS_ENABLED(CONFIG_DEBUG_FS))
288 debugfs_remove(dfs_rootdir); 288 debugfs_remove(dfs_rootdir);
289} 289}
290 290
@@ -407,7 +407,7 @@ int ubi_debugfs_init_dev(struct ubi_device *ubi)
407 struct dentry *dent; 407 struct dentry *dent;
408 struct ubi_debug_info *d = ubi->dbg; 408 struct ubi_debug_info *d = ubi->dbg;
409 409
410 if (!IS_ENABLED(DEBUG_FS)) 410 if (!IS_ENABLED(CONFIG_DEBUG_FS))
411 return 0; 411 return 0;
412 412
413 n = snprintf(d->dfs_dir_name, UBI_DFS_DIR_LEN + 1, UBI_DFS_DIR_NAME, 413 n = snprintf(d->dfs_dir_name, UBI_DFS_DIR_LEN + 1, UBI_DFS_DIR_NAME,
@@ -477,6 +477,6 @@ out:
477 */ 477 */
478void ubi_debugfs_exit_dev(struct ubi_device *ubi) 478void ubi_debugfs_exit_dev(struct ubi_device *ubi)
479{ 479{
480 if (IS_ENABLED(DEBUG_FS)) 480 if (IS_ENABLED(CONFIG_DEBUG_FS))
481 debugfs_remove_recursive(ubi->dbg->dfs_dir); 481 debugfs_remove_recursive(ubi->dbg->dfs_dir);
482} 482}