diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2015-05-06 21:36:13 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2015-05-06 21:36:13 +0200 |
commit | 3975737a7d48b3c767f60be994d55884321d45f9 (patch) | |
tree | 8be2f56c4978420e6e4c4b3292e18c61b07a926e /drivers/of | |
parent | 10fb7853084356ef3c6b40ddf21dfb05dbd15691 (diff) | |
parent | 6d4afd96fc94a3f2d256ef4e8d7c9687a145a701 (diff) | |
download | barebox-3975737a7d48b3c767f60be994d55884321d45f9.tar.gz barebox-3975737a7d48b3c767f60be994d55884321d45f9.tar.xz |
Merge branch 'for-next/misc'
Diffstat (limited to 'drivers/of')
-rw-r--r-- | drivers/of/barebox.c | 29 | ||||
-rw-r--r-- | drivers/of/of_path.c | 12 |
2 files changed, 11 insertions, 30 deletions
diff --git a/drivers/of/barebox.c b/drivers/of/barebox.c index 224674240e..1b3078eb47 100644 --- a/drivers/of/barebox.c +++ b/drivers/of/barebox.c @@ -26,42 +26,15 @@ #include <envfs.h> #include <linux/mtd/mtd.h> -struct of_partition { - struct list_head list; - char *nodepath; - struct device_d *dev; - struct device_node *of_partitions; -}; - -static LIST_HEAD(of_partition_list); - static int environment_probe(struct device_d *dev) { char *path; int ret; - ret = of_find_path(dev->device_node, "device-path", &path); + ret = of_find_path(dev->device_node, "device-path", &path, OF_FIND_PATH_FLAGS_BB); 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); diff --git a/drivers/of/of_path.c b/drivers/of/of_path.c index df63c5782a..2dc784851d 100644 --- a/drivers/of/of_path.c +++ b/drivers/of/of_path.c @@ -21,6 +21,8 @@ #include <malloc.h> #include <of.h> +#include <linux/mtd/mtd.h> + struct of_path { struct cdev *cdev; struct device_d *dev; @@ -112,6 +114,7 @@ out: * @propname: the property name of the path description * @outpath: if this function returns 0 outpath will contain the path belonging * to the input path description. Must be freed with free(). + * @flags: use OF_FIND_PATH_FLAGS_BB to return the .bb device if available * * paths in the devicetree have the form of a multistring property. The first * string contains the full path to the physical device containing the path. @@ -127,11 +130,12 @@ out: * device-path = &mmc0, "partname:0"; * device-path = &norflash, "partname:barebox-environment"; */ -int of_find_path(struct device_node *node, const char *propname, char **outpath) +int of_find_path(struct device_node *node, const char *propname, char **outpath, unsigned flags) { struct of_path op = {}; struct device_node *rnode; const char *path, *str; + bool add_bb = false; int i, ret; path = of_get_property(node, propname, NULL); @@ -166,7 +170,11 @@ int of_find_path(struct device_node *node, const char *propname, char **outpath) if (!op.cdev) return -ENOENT; - *outpath = asprintf("/dev/%s", op.cdev->name); + if ((flags & OF_FIND_PATH_FLAGS_BB) && op.cdev->mtd && + mtd_can_have_bb(op.cdev->mtd)) + add_bb = true; + + *outpath = asprintf("/dev/%s%s", op.cdev->name, add_bb ? ".bb" : ""); return 0; } |