linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: nandsim: use id_bytes exactly as passed
@ 2015-11-28  6:57 Nikolay Martynov
  0 siblings, 0 replies; only message in thread
From: Nikolay Martynov @ 2015-11-28  6:57 UTC (permalink / raw)
  To: linux-mtd; +Cc: Nikolay Martynov, dwmw2, computersforpeace

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@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

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-11-28  6:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-28  6:57 [PATCH] mtd: nandsim: use id_bytes exactly as passed Nikolay Martynov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).