Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Sebastian Andrzej Siewior and committed by
David Woodhouse
ce85b79f 453281a9

+17 -2
+17 -2
drivers/mtd/nand/nandsim.c
··· 107 107 static unsigned int rptwear = 0; 108 108 static unsigned int overridesize = 0; 109 109 static char *cache_file = NULL; 110 + static unsigned int bbt; 110 111 111 112 module_param(first_id_byte, uint, 0400); 112 113 module_param(second_id_byte, uint, 0400); ··· 131 130 module_param(rptwear, uint, 0400); 132 131 module_param(overridesize, uint, 0400); 133 132 module_param(cache_file, charp, 0400); 133 + module_param(bbt, uint, 0400); 134 134 135 135 MODULE_PARM_DESC(first_id_byte, "The first byte returned by NAND Flash 'read ID' command (manufacturer ID)"); 136 136 MODULE_PARM_DESC(second_id_byte, "The second byte returned by NAND Flash 'read ID' command (chip ID)"); ··· 164 162 "The size is specified in erase blocks and as the exponent of a power of two" 165 163 " e.g. 5 means a size of 32 erase blocks"); 166 164 MODULE_PARM_DESC(cache_file, "File to use to cache nand pages instead of memory"); 165 + MODULE_PARM_DESC(bbt, "0 OOB, 1 BBT with marker in OOB, 2 BBT with marker in data area"); 167 166 168 167 /* The largest possible page size */ 169 168 #define NS_LARGEST_PAGE_SIZE 4096 ··· 2267 2264 /* and 'badblocks' parameters to work */ 2268 2265 chip->options |= NAND_SKIP_BBTSCAN; 2269 2266 2267 + switch (bbt) { 2268 + case 2: 2269 + chip->options |= NAND_USE_FLASH_BBT_NO_OOB; 2270 + case 1: 2271 + chip->options |= NAND_USE_FLASH_BBT; 2272 + case 0: 2273 + break; 2274 + default: 2275 + NS_ERR("bbt has to be 0..2\n"); 2276 + retval = -EINVAL; 2277 + goto error; 2278 + } 2270 2279 /* 2271 2280 * Perform minimum nandsim structure initialization to handle 2272 2281 * the initial ID read command correctly ··· 2336 2321 if ((retval = init_nandsim(nsmtd)) != 0) 2337 2322 goto err_exit; 2338 2323 2339 - if ((retval = parse_badblocks(nand, nsmtd)) != 0) 2324 + if ((retval = nand_default_bbt(nsmtd)) != 0) 2340 2325 goto err_exit; 2341 2326 2342 - if ((retval = nand_default_bbt(nsmtd)) != 0) 2327 + if ((retval = parse_badblocks(nand, nsmtd)) != 0) 2343 2328 goto err_exit; 2344 2329 2345 2330 /* Register NAND partitions */