summaryrefslogtreecommitdiffstats
path: root/drivers/of/barebox.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2014-04-09 16:14:55 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2014-04-28 11:49:01 +0200
commit3781d93b06fddd9a5522e7ea7412e17693ece45c (patch)
tree526cbe31c39b322c72d713d7416888262c1e9b5c /drivers/of/barebox.c
parent1a8800458bd12febff981fadc86b2cdf0abaf827 (diff)
downloadbarebox-3781d93b06fddd9a5522e7ea7412e17693ece45c.tar.gz
barebox-3781d93b06fddd9a5522e7ea7412e17693ece45c.tar.xz
OF: barebox-env: Use bb device on NAND
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/of/barebox.c')
-rw-r--r--drivers/of/barebox.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/of/barebox.c b/drivers/of/barebox.c
index 44ec820ec5..8c05924be3 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);