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

[MTD] nandsim: enhance nandsim to allow arbitrary NAND size

A new module parameter has been added called 'overridesize',
which overrides the size that would be determined by the
ID bytes. 'overridesize' is specified in erase blocks and
as the exponent of a power of two e.g. 5 means a size of
32 erase blocks.

Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>

authored by

Adrian Hunter and committed by
David Woodhouse
a5ac8aeb 57aa6b54

+20 -1
+20 -1
drivers/mtd/nand/nandsim.c
··· 100 100 static unsigned int bitflips = 0; 101 101 static char *gravepages = NULL; 102 102 static unsigned int rptwear = 0; 103 + static unsigned int overridesize = 0; 103 104 104 105 module_param(first_id_byte, uint, 0400); 105 106 module_param(second_id_byte, uint, 0400); ··· 122 121 module_param(bitflips, uint, 0400); 123 122 module_param(gravepages, charp, 0400); 124 123 module_param(rptwear, uint, 0400); 124 + module_param(overridesize, uint, 0400); 125 125 126 - MODULE_PARM_DESC(first_id_byte, "The fist byte returned by NAND Flash 'read ID' command (manufaturer ID)"); 126 + MODULE_PARM_DESC(first_id_byte, "The first byte returned by NAND Flash 'read ID' command (manufacturer ID)"); 127 127 MODULE_PARM_DESC(second_id_byte, "The second byte returned by NAND Flash 'read ID' command (chip ID)"); 128 128 MODULE_PARM_DESC(third_id_byte, "The third byte returned by NAND Flash 'read ID' command"); 129 129 MODULE_PARM_DESC(fourth_id_byte, "The fourth byte returned by NAND Flash 'read ID' command"); ··· 151 149 " separated by commas e.g. 1401:2 means page 1401" 152 150 " can be read only twice before failing"); 153 151 MODULE_PARM_DESC(rptwear, "Number of erases inbetween reporting wear, if not zero"); 152 + MODULE_PARM_DESC(overridesize, "Specifies the NAND Flash size overriding the ID bytes. " 153 + "The size is specified in erase blocks and as the exponent of a power of two" 154 + " e.g. 5 means a size of 32 erase blocks"); 154 155 155 156 /* The largest possible page size */ 156 157 #define NS_LARGEST_PAGE_SIZE 2048 ··· 1964 1959 chip->verify_buf = ns_nand_verify_buf; 1965 1960 chip->read_word = ns_nand_read_word; 1966 1961 chip->ecc.mode = NAND_ECC_SOFT; 1962 + /* The NAND_SKIP_BBTSCAN option is necessary for 'overridesize' */ 1963 + /* and 'badblocks' parameters to work */ 1967 1964 chip->options |= NAND_SKIP_BBTSCAN; 1968 1965 1969 1966 /* ··· 2004 1997 if (retval > 0) 2005 1998 retval = -ENXIO; 2006 1999 goto error; 2000 + } 2001 + 2002 + if (overridesize) { 2003 + u_int32_t new_size = nsmtd->erasesize << overridesize; 2004 + if (new_size >> overridesize != nsmtd->erasesize) { 2005 + NS_ERR("overridesize is too big\n"); 2006 + goto err_exit; 2007 + } 2008 + /* N.B. This relies on nand_scan not doing anything with the size before we change it */ 2009 + nsmtd->size = new_size; 2010 + chip->chipsize = new_size; 2011 + chip->chip_shift = ffs(new_size) - 1; 2007 2012 } 2008 2013 2009 2014 if ((retval = setup_wear_reporting(nsmtd)) != 0)