From ea1d08e26b73a4855165ed56043fa439ff9948cb Mon Sep 17 00:00:00 2001 From: Bastian Stender Date: Wed, 29 Mar 2017 14:47:10 +0200 Subject: 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 Signed-off-by: Sascha Hauer --- src/libdt.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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__, -- cgit v1.2.3