[PATCH 11/14] of: partition: only create partition node when partitions exist
Sascha Hauer
s.hauer at pengutronix.de
Thu Mar 30 22:33:20 PDT 2017
With the legacy partition binding we did not modify the device
node when no partition exist, but with the new binding we would
create the "partitions" node with compatible = "fixed-partitions".
Prevent that by catching the absence of partitions early.
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
drivers/of/partition.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/of/partition.c b/drivers/of/partition.c
index 9b96a39edb..2e2ba35e87 100644
--- a/drivers/of/partition.c
+++ b/drivers/of/partition.c
@@ -131,7 +131,7 @@ static int of_partition_fixup(struct device_node *root, void *ctx)
struct cdev *cdev = ctx, *partcdev;
struct device_node *np, *part, *partnode;
int ret;
- int n_cells;
+ int n_cells, n_parts = 0;
if (of_partition_binding == MTD_OF_BINDING_DONTTOUCH)
return 0;
@@ -139,6 +139,13 @@ static int of_partition_fixup(struct device_node *root, void *ctx)
if (!cdev->device_node)
return -EINVAL;
+ list_for_each_entry(partcdev, &cdev->partitions, partition_entry) {
+ n_parts++;
+ }
+
+ if (!n_parts)
+ return 0;
+
if (cdev->size >= 0x100000000)
n_cells = 2;
else
--
2.11.0
More information about the barebox
mailing list