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 6/6] OF: barebox-env: Use bb device on NAND
Date: Mon, 28 Apr 2014 11:49:39 +0200	[thread overview]
Message-ID: <1398678579-17491-6-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1398678579-17491-1-git-send-email-s.hauer@pengutronix.de>

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

diff --git a/drivers/of/barebox.c b/drivers/of/barebox.c
index 44ec820..8c05924 100644
--- a/drivers/of/barebox.c
+++ b/drivers/of/barebox.c
@@ -24,6 +24,7 @@
 #include <malloc.h>
 #include <partition.h>
 #include <envfs.h>
+#include <linux/mtd/mtd.h>
 
 struct of_partition {
 	struct list_head list;
@@ -57,6 +58,24 @@ static int environment_probe(struct device_d *dev)
 	if (ret)
 		return ret;
 
+	/*
+	 * The environment support is not bad block aware, hence we
+	 * have to use the .bb device. Test if we have a nand device
+	 * and if yes, append .bb to the filename.
+	 */
+	if (!strncmp(path, "/dev/", 5)) {
+		struct cdev *cdev;
+		char *cdevname;
+
+		cdevname = path + 5;
+		cdev = cdev_by_name(cdevname);
+		if (cdev && cdev->mtd && mtd_can_have_bb(cdev->mtd)) {
+			char *bbpath = asprintf("%s.bb", path);
+			free(path);
+			path = bbpath;
+		}
+	}
+
 	dev_info(dev, "setting default environment path to %s\n", path);
 
 	default_environment_path_set(path);
-- 
1.9.1


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

      parent reply	other threads:[~2014-04-28  9:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-28  9:49 [PATCH 1/6] environment: drop envfs_register_partition Sascha Hauer
2014-04-28  9:49 ` [PATCH 2/6] env: erase/protect in envfs_save Sascha Hauer
2014-04-28  9:49 ` [PATCH 3/6] mtd: nand: bb: use mtd api directly Sascha Hauer
2014-04-28 13:05   ` Alexander Aring
2014-04-28 18:48     ` Sascha Hauer
2014-04-28  9:49 ` [PATCH 4/6] mtd: refactor bb device creation Sascha Hauer
2014-04-28  9:49 ` [PATCH 5/6] mtd: nand: create bb devices automatically Sascha Hauer
2014-04-28  9:49 ` Sascha Hauer [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=1398678579-17491-6-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