summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2017-03-30 22:20:25 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2017-03-31 18:43:24 +0200
commit1accb5ecdd59e255f01b98b837138c553582ab4c (patch)
treea3f099edc394552d95721ba0cf32cbad06bc7797 /drivers
parent4031a17fa01902363929c818dcab4aed3881e7ad (diff)
downloadbarebox-1accb5ecdd59e255f01b98b837138c553582ab4c.tar.gz
barebox-1accb5ecdd59e255f01b98b837138c553582ab4c.tar.xz
of: partition: only create partition node when partitions exist
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@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/of/partition.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/of/partition.c b/drivers/of/partition.c
index 2a0d5bb563..e66b6ccc16 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