9
0
Fork 0

OF: barebox-env: Use bb device on NAND

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Sascha Hauer 2014-04-09 16:14:55 +02:00
parent 1a8800458b
commit 3781d93b06
1 changed files with 19 additions and 0 deletions

View File

@ -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);