[PATCH 3/4] fix-nand-partitions.patch
Andy Green
andy at openmoko.com
Fri Feb 20 09:42:44 CET 2009
From: Harald Welte <laforge at openmoko.com>
This patch allows commandline partition processing
to work with the s3c2410 nand platform driver.
I adapted Harald's original patch slightly to use the
bitfield style in s3c2410_nand_set that is already
in use there.
cc: Ben Dooks <ben at fluff.org>
Signed-off-by: Andy Green <andy at openmoko.com>
---
arch/arm/plat-s3c/include/plat/nand.h | 1 +
drivers/mtd/nand/s3c2410.c | 29 +++++++++++++++++++++++------
2 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/arch/arm/plat-s3c/include/plat/nand.h b/arch/arm/plat-s3c/include/plat/nand.h
index f4dcd14..882b88d 100644
--- a/arch/arm/plat-s3c/include/plat/nand.h
+++ b/arch/arm/plat-s3c/include/plat/nand.h
@@ -23,6 +23,7 @@
struct s3c2410_nand_set {
unsigned int disable_ecc : 1;
+ unsigned int use_bbt : 1;
int nr_chips;
int nr_partitions;
diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c
index 8e375d5..26b86e9 100644
--- a/drivers/mtd/nand/s3c2410.c
+++ b/drivers/mtd/nand/s3c2410.c
@@ -22,7 +22,9 @@
*/
#ifdef CONFIG_MTD_NAND_S3C2410_DEBUG
-#define DEBUG
+#ifndef DEBUG
+#define DEBUG 1
+#endif
#endif
#include <linux/module.h>
@@ -231,8 +233,6 @@ static int s3c2410_nand_setrate(struct s3c2410_nand_info *info)
BUG();
}
- dev_dbg(info->device, "NF_CONF is 0x%lx\n", cfg);
-
local_irq_save(flags);
cfg = readl(info->regs + S3C2410_NFCONF);
@@ -438,7 +438,7 @@ static int s3c2410_nand_correct_data(struct mtd_info *mtd, u_char *dat,
if ((diff0 & ~(1<<fls(diff0))) == 0)
return 1;
- return -1;
+ return -EBADMSG;
}
/* ECC functions
@@ -645,17 +645,31 @@ static int s3c2410_nand_remove(struct platform_device *pdev)
}
#ifdef CONFIG_MTD_PARTITIONS
+const char *part_probes[] = { "cmdlinepart", NULL };
static int s3c2410_nand_add_partition(struct s3c2410_nand_info *info,
struct s3c2410_nand_mtd *mtd,
struct s3c2410_nand_set *set)
{
+ struct mtd_partition *part_info;
+ int nr_part = 0;
+
if (set == NULL)
return add_mtd_device(&mtd->mtd);
- if (set->nr_partitions > 0 && set->partitions != NULL) {
- return add_mtd_partitions(&mtd->mtd, set->partitions, set->nr_partitions);
+ if (set->nr_partitions == 0) {
+ mtd->mtd.name = set->name;
+ nr_part = parse_mtd_partitions(&mtd->mtd, part_probes,
+ &part_info, 0);
+ } else {
+ if (set->nr_partitions > 0 && set->partitions != NULL) {
+ nr_part = set->nr_partitions;
+ part_info = set->partitions;
+ }
}
+ if (nr_part > 0 && part_info)
+ return add_mtd_partitions(&mtd->mtd, part_info, nr_part);
+
return add_mtd_device(&mtd->mtd);
}
#else
@@ -687,6 +701,9 @@ static void s3c2410_nand_init_chip(struct s3c2410_nand_info *info,
chip->options = 0;
chip->controller = &info->controller;
+ if (set->use_bbt)
+ chip->options |= NAND_USE_FLASH_BBT;
+
switch (info->cpu_type) {
case TYPE_S3C2410:
chip->IO_ADDR_W = regs + S3C2410_NFDATA;
More information about the openmoko-kernel
mailing list