Skip to content

Commit ce85b79

Browse files
Sebastian Andrzej SiewiorDavid Woodhouse
authored andcommitted
mtd: nandsim: add module param for BBT handling
I used this to check the BBT on flash together with a hack in mtdchar in order to read bad blocks. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
1 parent 453281a commit ce85b79

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

‎drivers/mtd/nand/nandsim.c‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ static char *gravepages = NULL;
107107
static unsigned int rptwear = 0;
108108
static unsigned int overridesize = 0;
109109
static char *cache_file = NULL;
110+
static unsigned int bbt;
110111

111112
module_param(first_id_byte, uint, 0400);
112113
module_param(second_id_byte, uint, 0400);
@@ -130,6 +131,7 @@ module_param(gravepages, charp, 0400);
130131
module_param(rptwear, uint, 0400);
131132
module_param(overridesize, uint, 0400);
132133
module_param(cache_file, charp, 0400);
134+
module_param(bbt, uint, 0400);
133135

134136
MODULE_PARM_DESC(first_id_byte, "The first byte returned by NAND Flash 'read ID' command (manufacturer ID)");
135137
MODULE_PARM_DESC(second_id_byte, "The second byte returned by NAND Flash 'read ID' command (chip ID)");
@@ -162,6 +164,7 @@ MODULE_PARM_DESC(overridesize, "Specifies the NAND Flash size overriding the I
162164
"The size is specified in erase blocks and as the exponent of a power of two"
163165
" e.g. 5 means a size of 32 erase blocks");
164166
MODULE_PARM_DESC(cache_file, "File to use to cache nand pages instead of memory");
167+
MODULE_PARM_DESC(bbt, "0 OOB, 1 BBT with marker in OOB, 2 BBT with marker in data area");
165168

166169
/* The largest possible page size */
167170
#define NS_LARGEST_PAGE_SIZE 4096
@@ -2264,6 +2267,18 @@ static int __init ns_init_module(void)
22642267
/* and 'badblocks' parameters to work */
22652268
chip->options |= NAND_SKIP_BBTSCAN;
22662269

2270+
switch (bbt) {
2271+
case 2:
2272+
chip->options |= NAND_USE_FLASH_BBT_NO_OOB;
2273+
case 1:
2274+
chip->options |= NAND_USE_FLASH_BBT;
2275+
case 0:
2276+
break;
2277+
default:
2278+
NS_ERR("bbt has to be 0..2\n");
2279+
retval = -EINVAL;
2280+
goto error;
2281+
}
22672282
/*
22682283
* Perform minimum nandsim structure initialization to handle
22692284
* the initial ID read command correctly
@@ -2321,10 +2336,10 @@ static int __init ns_init_module(void)
23212336
if ((retval = init_nandsim(nsmtd)) != 0)
23222337
goto err_exit;
23232338

2324-
if ((retval = parse_badblocks(nand, nsmtd)) != 0)
2339+
if ((retval = nand_default_bbt(nsmtd)) != 0)
23252340
goto err_exit;
23262341

2327-
if ((retval = nand_default_bbt(nsmtd)) != 0)
2342+
if ((retval = parse_badblocks(nand, nsmtd)) != 0)
23282343
goto err_exit;
23292344

23302345
/* Register NAND partitions */

0 commit comments

Comments
 (0)