[PATCH] mtd: nandsim: use id_bytes exactly as passed
Nikolay Martynov
mar.kolya at gmail.com
Sat Nov 28 01:57:04 EST 2015
Currently when 5 bytes are passed as id_bytes the actual id
would be set to 6 bytes long. This means that it is not possible
to properly emulate chips with 5 bytes ids.
This patch addresses this problem
Signed-off-by: Nikolay Martynov <mar.kolya at gmail.com>
---
drivers/mtd/nand/nandsim.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c
index 52c0c1a..4659540 100644
--- a/drivers/mtd/nand/nandsim.c
+++ b/drivers/mtd/nand/nandsim.c
@@ -107,6 +107,7 @@ static unsigned int overridesize = 0;
static char *cache_file = NULL;
static unsigned int bbt;
static unsigned int bch;
+static unsigned int id_bytes_length;
static u_char id_bytes[8] = {
[0] = CONFIG_NANDSIM_FIRST_ID_BYTE,
[1] = CONFIG_NANDSIM_SECOND_ID_BYTE,
@@ -115,7 +116,7 @@ static u_char id_bytes[8] = {
[4 ... 7] = 0xFF,
};
-module_param_array(id_bytes, byte, NULL, 0400);
+module_param_array(id_bytes, byte, &id_bytes_length, 0400);
module_param_named(first_id_byte, id_bytes[0], byte, 0400);
module_param_named(second_id_byte, id_bytes[1], byte, 0400);
module_param_named(third_id_byte, id_bytes[2], byte, 0400);
@@ -2288,14 +2289,14 @@ static int __init ns_init_module(void)
* Perform minimum nandsim structure initialization to handle
* the initial ID read command correctly
*/
- if (id_bytes[6] != 0xFF || id_bytes[7] != 0xFF)
- nand->geom.idbytes = 8;
- else if (id_bytes[4] != 0xFF || id_bytes[5] != 0xFF)
- nand->geom.idbytes = 6;
- else if (id_bytes[2] != 0xFF || id_bytes[3] != 0xFF)
- nand->geom.idbytes = 4;
- else
- nand->geom.idbytes = 2;
+ if (id_bytes_length > 0) {
+ nand->geom.idbytes = id_bytes_length;
+ } else {
+ if (id_bytes[2] != 0xFF || id_bytes[3] != 0xFF)
+ nand->geom.idbytes = 4;
+ else
+ nand->geom.idbytes = 2;
+ }
nand->regs.status = NS_STATUS_OK(nand);
nand->nxstate = STATE_UNKNOWN;
nand->options |= OPT_PAGE512; /* temporary value */
--
2.6.3
More information about the linux-mtd
mailing list