From: Trent Piepho <tpiepho@kymetacorp.com>
To: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: "barebox@lists.infradead.org" <barebox@lists.infradead.org>
Subject: [PATCH] of_path: Fix bug with partitions, simply code
Date: Fri, 11 Dec 2015 00:07:34 +0000 [thread overview]
Message-ID: <1449792460.26955.91.camel@rtred1test09.kymeta.local> (raw)
In-Reply-To: <1449787121.26955.89.camel@rtred1test09.kymeta.local>
In commit f72b64815619b41e026dd3eb9d53bf9855f84628 using a path that
has a partition description broke.
Fix this and simplify the code some.
There is no need to loop over each string in the path property: it's
defined to have at most one partition description, no extant dts has
more than one, and how it would handle more than one didn't make sense
anyway.
Once not looping, __of_find_path() just needs the partition
description text, not both the original node and property name to look
it up from.
When using a partition description, don't lookup the cdev of the node
just to replace it with the partition's cdev.
Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com>
---
drivers/of/of_path.c | 47 +++++++++++++++++++++++++++++------------------
1 file changed, 29 insertions(+), 18 deletions(-)
diff --git a/drivers/of/of_path.c b/drivers/of/of_path.c
index 6903905..9016147 100644
--- a/drivers/of/of_path.c
+++ b/drivers/of/of_path.c
@@ -106,12 +106,22 @@ out:
return ret;
}
-static int __of_find_path(struct device_node *node, const char *propname, char **outpath, unsigned flags)
+/**
+ * __of_find_path
+ *
+ * @node: The node to find the cdev for, can be the device or a
+ * partition in the device
+ * @part: Optionally, a description of a parition of @node. See of_find_path
+ * @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
+ *
+ */
+static int __of_find_path(struct device_node *node, const char *part, char **outpath, unsigned flags)
{
- struct of_path op = {};
- const char *str;
+ struct of_path op;
bool add_bb = false;
- int i, ret;
+ int ret;
op.dev = of_find_device_by_node_path(node->full_name);
if (!op.dev) {
@@ -122,23 +132,18 @@ static int __of_find_path(struct device_node *node, const char *propname, char *
device_detect(op.dev);
- op.cdev = cdev_by_device_node(node);
-
- i = 1;
-
- while (propname) {
- ret = of_property_read_string_index(node, propname, i++, &str);
- if (ret)
- break;
-
- ret = of_path_parse_one(&op, str);
+ if (part) {
+ /* Find a partition inside op.dev */
+ ret = of_path_parse_one(&op, part);
if (ret)
return ret;
+ } else {
+ /* node points directly to device */
+ op.cdev = cdev_by_device_node(node);
+ if (!op.cdev)
+ return -ENOENT;
}
- if (!op.cdev)
- return -ENOENT;
-
if ((flags & OF_FIND_PATH_FLAGS_BB) && op.cdev->mtd &&
mtd_can_have_bb(op.cdev->mtd))
add_bb = true;
@@ -193,6 +198,8 @@ int of_find_path(struct device_node *node, const char *propname, char **outpath,
{
struct device_node *rnode;
const char *path;
+ const char *part;
+ int ret;
path = of_get_property(node, propname, NULL);
if (!path)
@@ -202,5 +209,9 @@ int of_find_path(struct device_node *node, const char *propname, char **outpath,
if (!rnode)
return -ENODEV;
- return __of_find_path(rnode, propname, outpath, flags);
+ ret = of_property_read_string_index(node, propname, 1, &part);
+ if (ret)
+ part = NULL;
+
+ return __of_find_path(rnode, part, outpath, flags);
}
--
1.8.3.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2015-12-11 0:08 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-20 8:39 [PATCH v2 1/8] state framework enhancements Marc Kleine-Budde
2015-10-20 8:39 ` [PATCH v2 1/8] of_path: of_find_path() factor out device detection logic into separate function Marc Kleine-Budde
2015-10-21 6:24 ` Sascha Hauer
2015-12-10 22:38 ` Trent Piepho
2015-12-11 0:07 ` Trent Piepho [this message]
2015-12-11 9:35 ` [PATCH] of_path: Fix bug with partitions, simply code Sascha Hauer
2015-12-11 18:51 ` Trent Piepho
2015-12-16 10:43 ` Sascha Hauer
2015-10-20 8:39 ` [PATCH v2 2/8] of_path: add of_find_path_by_phandle() Marc Kleine-Budde
2015-10-20 8:39 ` [PATCH v2 3/8] state: make use of of_find_path_by_phandle() and add return -EPROBE_DEFER if device is not available Marc Kleine-Budde
2015-10-20 8:39 ` [PATCH v2 4/8] state: use name of device node as name if alias " Marc Kleine-Budde
2015-10-20 8:39 ` [PATCH v2 5/8] state: disable load command Marc Kleine-Budde
2015-10-20 8:39 ` [PATCH v2 6/8] crypto: add simple keystore Marc Kleine-Budde
2015-10-20 8:39 ` [PATCH v2 7/8] state: prepare raw backend for hmac support Marc Kleine-Budde
2015-10-20 8:39 ` [PATCH v2 8/8] state: backend_raw: add hamc support Marc Kleine-Budde
2015-10-20 9:49 ` Jan Lübbe
2015-10-21 7:13 ` Sascha Hauer
2015-10-21 8:56 ` Marc Kleine-Budde
2015-10-21 9:12 ` Sascha Hauer
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=1449792460.26955.91.camel@rtred1test09.kymeta.local \
--to=tpiepho@kymetacorp.com \
--cc=barebox@lists.infradead.org \
--cc=mkl@pengutronix.de \
/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