of_platform_populate will eventually call of_platform_device_create,
which will print out errors, because of_translate_address chokes on the
partitions node.

The correct fix would be not to use a platform bus here, but until we
add something like the fauxbus, just opencode the platform device
creation without the address translation parts.

Signed-off-by: Ahmad Fatoum <a.fat...@pengutronix.de>
---
 drivers/of/partition.c | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/drivers/of/partition.c b/drivers/of/partition.c
index a0890bfcdef0..4be2a2c33716 100644
--- a/drivers/of/partition.c
+++ b/drivers/of/partition.c
@@ -112,11 +112,33 @@ int of_parse_partitions(struct cdev *cdev, struct 
device_node *node)
        }
 
        for_each_child_of_node(node, n) {
-               of_parse_partition(cdev, n);
+               struct cdev *partcdev;
+               struct device *dev;
+               int ret;
+
+               partcdev = of_parse_partition(cdev, n);
+               if (!partcdev || !subnode)
+                       continue;
+
+               if (!of_property_present(n, "compatible") ||
+                   !of_device_is_available(n))
+                       continue;
+
+               /* TODO: migrate to a faux bus? */
+               dev = xzalloc(sizeof(*dev));
+               dev->id = DEVICE_ID_SINGLE;
+               dev->of_node = n;
+               dev->parent = partcdev->dev;
+               n->dev = dev;
+               dev_set_name(dev, "%s", partcdev->name);
+
+               ret = platform_device_register(dev);
+               if (WARN_ON(ret)) {
+                       n->dev = NULL;
+                       free_device(dev);
+               }
        }
 
-       if (subnode)
-               of_platform_populate(subnode, NULL, cdev->dev);
        return 0;
 }
 
-- 
2.39.5


Reply via email to