summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBastian Stender <bst@pengutronix.de>2017-03-29 14:47:10 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2017-03-31 13:58:00 +0200
commitea1d08e26b73a4855165ed56043fa439ff9948cb (patch)
treed776b7b915d0e5b4a9384dbcbcf08244730a5727
parent791a2404116d8049a3f1e6317876fd76a9e2f228 (diff)
downloaddt-utils-ea1d08e26b73a4855165ed56043fa439ff9948cb.tar.gz
dt-utils-ea1d08e26b73a4855165ed56043fa439ff9948cb.tar.xz
libdt: support "partitions" subnode on mtd devices
In case there is an additional "partitions" subnode between the device itself and its partitions like /soc/spi@?/mram@?/partitions/partition@? also try the parent of the parent before giving up finding the device node. See kernel docs for reference: Documentation/devicetree/bindings/mtd/partition.txt Signed-off-by: Bastian Stender <bst@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--src/libdt.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/libdt.c b/src/libdt.c
index 2c730cd..4db5160 100644
--- a/src/libdt.c
+++ b/src/libdt.c
@@ -2391,9 +2391,15 @@ int of_get_devicepath(struct device_node *partition_node, char **devpath, off_t
/*
* Ok, the partition node has no udev_device. Try parent node.
*/
-
node = partition_node->parent;
+ /*
+ * Respect flash "partitions" subnode. Use parent of parent in this
+ * case.
+ */
+ if (!strcmp(node->name, "partitions"))
+ node = node->parent;
+
dev = of_find_device_by_node_path(node->full_name);
if (!dev) {
fprintf(stderr, "%s: cannot find device from node %s\n", __func__,