diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2020-11-24 16:21:17 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2020-11-25 06:30:54 +0100 |
commit | fa9179444c36f9daf5010215cf8e4dcb3bd1ffb2 (patch) | |
tree | 6b90c82b78be1e9d89dd8f11c7775e36bc8b378b | |
parent | 9aa53beb03fd811054b7d14d729a7145f1eeb2cb (diff) | |
download | barebox-fa9179444c36f9daf5010215cf8e4dcb3bd1ffb2.tar.gz |
of: partitions: export of_fixup_partitions
of_partitions_register_fixup() tries to automatically determine the
node to fixup. Sometimes this doesn't work, so add of_fixup_partitions()
that can called at fixup time with a device node determined by subsystem
or driver code.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | drivers/of/partition.c | 37 | ||||
-rw-r--r-- | include/of.h | 6 |
2 files changed, 27 insertions, 16 deletions
diff --git a/drivers/of/partition.c b/drivers/of/partition.c index 7367073c67..65c24c5426 100644 --- a/drivers/of/partition.c +++ b/drivers/of/partition.c @@ -123,20 +123,16 @@ static void delete_subnodes(struct device_node *np) } } -static int of_partition_fixup(struct device_node *root, void *ctx) +int of_fixup_partitions(struct device_node *np, struct cdev *cdev) { - struct cdev *cdev = ctx, *partcdev; - struct device_node *np, *part, *partnode; - char *name; + struct cdev *partcdev; + struct device_node *part, *partnode; int ret; int n_cells, n_parts = 0; if (of_partition_binding == MTD_OF_BINDING_DONTTOUCH) return 0; - if (!cdev->device_node) - return -EINVAL; - list_for_each_entry(partcdev, &cdev->partitions, partition_entry) { if (partcdev->flags & DEVFS_PARTITION_FROM_TABLE) continue; @@ -151,15 +147,6 @@ static int of_partition_fixup(struct device_node *root, void *ctx) else n_cells = 1; - name = of_get_reproducible_name(cdev->device_node); - np = of_find_node_by_reproducible_name(root, name); - free(name); - if (!np) { - dev_err(cdev->dev, "Cannot find nodepath %s, cannot fixup\n", - cdev->device_node->full_name); - return -EINVAL; - } - partnode = of_get_child_by_name(np, "partitions"); if (partnode) { if (of_partition_binding == MTD_OF_BINDING_LEGACY) { @@ -242,6 +229,24 @@ static int of_partition_fixup(struct device_node *root, void *ctx) return 0; } +static int of_partition_fixup(struct device_node *root, void *ctx) +{ + struct cdev *cdev = ctx; + struct device_node *np; + char *name; + + name = of_get_reproducible_name(cdev->device_node); + np = of_find_node_by_reproducible_name(root, name); + free(name); + if (!np) { + dev_err(cdev->dev, "Cannot find nodepath %s, cannot fixup\n", + cdev->device_node->full_name); + return -EINVAL; + } + + return of_fixup_partitions(np, cdev); +} + int of_partitions_register_fixup(struct cdev *cdev) { return of_register_fixup(of_partition_fixup, cdev); diff --git a/include/of.h b/include/of.h index dd93e44aac..6dce76fd8c 100644 --- a/include/of.h +++ b/include/of.h @@ -275,6 +275,7 @@ extern struct device_d *of_device_enable_and_register_by_alias( struct cdev *of_parse_partition(struct cdev *cdev, struct device_node *node); int of_parse_partitions(struct cdev *cdev, struct device_node *node); +int of_fixup_partitions(struct device_node *np, struct cdev *cdev); int of_partitions_register_fixup(struct cdev *cdev); int of_device_is_stdout_path(struct device_d *dev); const char *of_get_model(void); @@ -303,6 +304,11 @@ static inline int of_parse_partitions(struct cdev *cdev, return -EINVAL; } +static inline int of_fixup_partitions(struct device_node *np, struct cdev *cdev) +{ + return -ENOSYS; +} + static inline int of_partitions_register_fixup(struct cdev *cdev) { return -ENOSYS; |