mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Huang Shijie <b32955@freescale.com>
To: <dwmw2@infradead.org>
Cc: <artem.bityutskiy@linux.intel.com>, <computersforpeace@gmail.com>,
	<shmulik.ladkani@gmail.com>, <linux-mtd@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>,
	Huang Shijie <b32955@freescale.com>
Subject: [PATCH v2 3/3] mtd: add the new detection method for the unparsable nand chips
Date: Thu, 24 Jan 2013 14:11:41 +0800	[thread overview]
Message-ID: <1359007901-26464-4-git-send-email-b32955@freescale.com> (raw)
In-Reply-To: <1359007901-26464-1-git-send-email-b32955@freescale.com>

Add the new detection method find_nand_type_by_fullid() for the
unparsable nand chips. The new detection method is called firstly
before all the other detection methods.

Signed-off-by: Huang Shijie <b32955@freescale.com>
---
 drivers/mtd/nand/nand_base.c |   33 ++++++++++++++++++++++++++++++++-
 1 files changed, 32 insertions(+), 1 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 0e80ec4..7f0431d 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -3152,6 +3152,29 @@ static void nand_decode_bbm_options(struct mtd_info *mtd,
 		chip->bbt_options |= NAND_BBT_SCAN2NDPAGE;
 }
 
+static struct nand_flash_dev *find_nand_type_by_fullid(struct mtd_info *mtd,
+				struct nand_chip *chip, u8 *id_data, int *busw)
+{
+	struct nand_flash_dev *type = nand_flash_full_ids;
+
+	for (; type->name != NULL; type++) {
+		if (!strncmp(type->id, id_data, type->id_len)) {
+			mtd->writesize = type->pagesize;
+			mtd->erasesize = type->erasesize;
+			mtd->oobsize = type->oobsize;
+
+			chip->cellinfo = id_data[2];
+			chip->chipsize = (uint64_t)type->chipsize << 20;
+			chip->options |= type->options;
+
+			*busw = type->options & NAND_BUSWIDTH_16;
+
+			break;
+		}
+	}
+	return type;
+}
+
 /*
  * Get the flash and manufacturer id and lookup if the type is supported.
  */
@@ -3200,8 +3223,16 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
 		return ERR_PTR(-ENODEV);
 	}
 
-	if (!type)
+	if (!type) {
+		/*
+		 * Some nand chips's information can not be paresed out
+		 * from the id data. So, try your luck in the full-id table.
+		 */
+		type = find_nand_type_by_fullid(mtd, chip, id_data, &busw);
+		if (type->name != NULL)
+			goto ident_done;
 		type = nand_flash_ids;
+	}
 
 	for (; type->name != NULL; type++)
 		if (*dev_id == type->id[1])
-- 
1.7.0.4



      parent reply	other threads:[~2013-01-24  7:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-24  6:11 [PATCH v2 0/3] mtd: use the full-id as the keyword Huang Shijie
2013-01-24  6:11 ` [PATCH v2 1/3] mtd: add new fields to nand_flash_dev{} Huang Shijie
2013-01-28  2:06   ` Huang Shijie
2013-02-04  8:42     ` Artem Bityutskiy
2013-02-04  8:46       ` Huang Shijie
2013-01-24  6:11 ` [PATCH v2 2/3] mtd: add a new table for the unparsable nand chips Huang Shijie
2013-01-28  2:04   ` Huang Shijie
2013-01-24  6:11 ` Huang Shijie [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1359007901-26464-4-git-send-email-b32955@freescale.com \
    --to=b32955@freescale.com \
    --cc=artem.bityutskiy@linux.intel.com \
    --cc=computersforpeace@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=shmulik.ladkani@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®