mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 09/10] mtd: nand: Add bbt parameter
Date: Mon,  4 Mar 2013 11:13:53 +0100	[thread overview]
Message-ID: <1362392034-1908-10-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1362392034-1908-1-git-send-email-s.hauer@pengutronix.de>

The information which kind of bbt (if any) is used is hidden somewhere
in the NAND layer. Expose it to a device parameter to make it detectable
and visible during runtime.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mtd/nand/nand_base.c |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index ac223ca..7675695 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -1688,6 +1688,23 @@ static int mtd_set_erasebad(struct device_d *dev, struct param_d *param,
 	return 0;
 }
 
+static const char *mtd_get_bbt_type(struct device_d *dev, struct param_d *p)
+{
+	struct mtd_info *mtd = container_of(dev, struct mtd_info, class_dev);
+	struct nand_chip *chip = mtd->priv;
+	char *str;
+
+	if (!chip->bbt)
+		str = "none";
+	else if ((chip->bbt_td && chip->bbt_td->pages[0] != -1) ||
+				(chip->bbt_md && chip->bbt_md->pages[0] != -1))
+		str = "flashbased";
+	else
+		str = "memorybased";
+
+	return str;
+}
+
 int add_mtd_nand_device(struct mtd_info *mtd, char *devname)
 {
 	int ret;
@@ -1700,6 +1717,8 @@ int add_mtd_nand_device(struct mtd_info *mtd, char *devname)
 		dev_add_param(&mtd->class_dev, "erasebad", mtd_set_erasebad,
 				NULL, 0);
 
+	dev_add_param(&mtd->class_dev, "bbt", NULL, mtd_get_bbt_type, 0);
+
 	return ret;
 }
 
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2013-03-04 10:14 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-04 10:13 [PATCH] nand bad block erase and i.MX bbt tool Sascha Hauer
2013-03-04 10:13 ` [PATCH 01/10] mtd: nand: register nand flashes with nand specific function Sascha Hauer
2013-03-04 10:13 ` [PATCH 02/10] mtd: Add parameter to allow erasing bad blocks Sascha Hauer
2013-03-04 10:13 ` [PATCH 03/10] mtd nand: introduce bbm.h Sascha Hauer
2013-03-04 10:13 ` [PATCH 04/10] nand command: use loff_t for block offset Sascha Hauer
2013-03-04 10:13 ` [PATCH 05/10] nand command: use enumeration for command instead of bitmask Sascha Hauer
2013-03-04 21:25   ` Alexander Aring
2013-03-04 10:13 ` [PATCH 06/10] nand command: check for <dev> directly after option parsing Sascha Hauer
2013-03-04 10:13 ` [PATCH 07/10] mtd: nand: replace NAND_USE_FLASH_BBT with NAND_BBT_USE_FLASH Sascha Hauer
2013-03-04 10:13 ` [PATCH 08/10] mtd nand i.MX: remove unused code Sascha Hauer
2013-03-04 10:13 ` Sascha Hauer [this message]
2013-03-04 20:42   ` [PATCH 09/10] mtd: nand: Add bbt parameter Juergen Beisert
2013-03-05 10:48     ` Sascha Hauer
2013-03-04 10:13 ` [PATCH 10/10] mtd: nand: Add command to generate a flash BBT Sascha Hauer
2013-03-04 20:43   ` Juergen Beisert
2013-03-05 10:49     ` Sascha Hauer

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=1362392034-1908-10-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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