[U-Boot] [PATCH] NAND: Allow nand_scan to be replaced by user

Marek Vasut marek.vasut at gmail.com
Tue Dec 6 00:16:02 CET 2011


This patch allows user to supply nand_scan() call replacement via the usual
method. This will be beneficial for PXA3XX NAND driver, which does further init
of the chip at this stage.

Signed-off-by: Marek Vasut <marek.vasut at gmail.com>
Cc: Scott Wood <scottwood at freescale.com>
---
 drivers/mtd/nand/nand_base.c |   12 +++++++++---
 include/linux/mtd/nand.h     |    2 ++
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 27f6c77..baf7622 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -2974,10 +2974,16 @@ int nand_scan_tail(struct mtd_info *mtd)
 int nand_scan(struct mtd_info *mtd, int maxchips)
 {
 	int ret;
+	struct nand_chip *nand = mtd->priv;
+
+	if (nand->scan) {
+		ret = nand->scan(mtd);
+	} else {
+		ret = nand_scan_ident(mtd, maxchips, NULL);
+		if (!ret)
+			ret = nand_scan_tail(mtd);
+	}
 
-	ret = nand_scan_ident(mtd, maxchips, NULL);
-	if (!ret)
-		ret = nand_scan_tail(mtd);
 	return ret;
 }
 
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index 1cdc7ae..698208c 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -432,6 +432,7 @@ struct nand_buffers {
  * @errstat:		[OPTIONAL] hardware specific function to perform additional error status checks
  *			(determine if errors are correctable)
  * @write_page:		[REPLACEABLE] High-level page write function
+ * @scan:		[REPLACEABLE] Fill in the chip size and other parameters
  */
 
 struct nand_chip {
@@ -456,6 +457,7 @@ struct nand_chip {
 	int		(*errstat)(struct mtd_info *mtd, struct nand_chip *this, int state, int status, int page);
 	int		(*write_page)(struct mtd_info *mtd, struct nand_chip *chip,
 				      const uint8_t *buf, int page, int cached, int raw);
+	int		(*scan)(struct mtd_info *mtd);
 
 	int		chip_delay;
 	unsigned int	options;
-- 
1.7.7.1



More information about the U-Boot mailing list