summaryrefslogtreecommitdiffstats
path: root/drivers/of/of_path.c
diff options
context:
space:
mode:
authorMarc Kleine-Budde <mkl@pengutronix.de>2015-04-22 10:20:12 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2015-04-23 08:12:28 +0200
commit885a1cf27e6ae7a39113dd6c707d400c1585b35c (patch)
tree0042057d9f4946784d00c3f48aa71a3ed5a6fac3 /drivers/of/of_path.c
parent0238fb4c0da005421ed11b3e178558a140029972 (diff)
downloadbarebox-885a1cf27e6ae7a39113dd6c707d400c1585b35c.tar.gz
barebox-885a1cf27e6ae7a39113dd6c707d400c1585b35c.tar.xz
of_path: of_find_path(): add possibility to return .bb device
This patch adds a flags argument to the of_find_path() function. The only flag defined for now is OF_FIND_PATH_FLAGS_BB. When used on NAND devices, the function returns the bad block aware device (the ".bb" device). Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/of/of_path.c')
-rw-r--r--drivers/of/of_path.c12
1 files changed, 10 insertions, 2 deletions
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;
}