We have a number of places where we check if a node is compatible with "fixed-partitions". In preparation for supporting "barebox,fixed-partitions" as well, factor out the existing compatible check into a new of_node_is_fixed_partitions() function. Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> --- drivers/of/base.c | 6 ++---- drivers/of/of_path.c | 7 ++++++- drivers/of/partition.c | 4 ++-- include/of.h | 6 ++++++ 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/of/base.c b/drivers/of/base.c index 125f24056eec..dfe4861c9eb6 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -351,7 +351,7 @@ static const char *of_get_partition_device_alias(struct device_node *np) return alias; np = of_get_parent(np); - if (np && of_device_is_compatible(np, "fixed-partitions")) + if (np && of_node_is_fixed_partitions(np)) np = of_get_parent(np); return of_alias_get(np); @@ -3271,10 +3271,8 @@ char *of_get_reproducible_name(struct device_node *node) * "fixed-partitions" compatible. We skip this extra subnode from the * reproducible name to get the same name for both bindings. */ - if (node->parent && - of_device_is_compatible(node->parent, "fixed-partitions")) { + if (node->parent && of_node_is_fixed_partitions(node->parent)) node = node->parent; - } offset = of_read_number(reg, na); diff --git a/drivers/of/of_path.c b/drivers/of/of_path.c index 42efb1ad1dbf..b3feaa07e39d 100644 --- a/drivers/of/of_path.c +++ b/drivers/of/of_path.c @@ -12,6 +12,11 @@ #include <linux/mtd/mtd.h> +bool of_node_is_fixed_partitions(const struct device_node *np) +{ + return of_device_is_compatible(np, "fixed-partitions"); +} + struct device *of_find_device_by_node_path(const char *path) { struct device *dev; @@ -55,7 +60,7 @@ static struct cdev *__of_cdev_find(struct device_node *node, const char *part) const char *uuid; struct device_node *devnode = node->parent; - if (of_device_is_compatible(devnode, "fixed-partitions")) { + if (of_node_is_fixed_partitions(devnode)) { devnode = devnode->parent; /* when partuuid is specified short-circuit the search for the cdev */ diff --git a/drivers/of/partition.c b/drivers/of/partition.c index 56933cc958f7..4f966d900f1f 100644 --- a/drivers/of/partition.c +++ b/drivers/of/partition.c @@ -93,7 +93,7 @@ int of_parse_partitions(struct cdev *cdev, struct device_node *node) subnode = of_get_child_by_name(node, "partitions"); if (subnode) { - if (!of_device_is_compatible(subnode, "fixed-partitions")) + if (!of_node_is_fixed_partitions(subnode)) return -EINVAL; node = subnode; } @@ -125,7 +125,7 @@ int of_partition_ensure_probed(struct device_node *np) return -EINVAL; /* Check if modern partitions binding */ - if (of_device_is_compatible(parent, "fixed-partitions")) { + if (of_node_is_fixed_partitions(parent)) { parent = of_get_parent(parent); /* diff --git a/include/of.h b/include/of.h index a83663c602b1..985f0195b2aa 100644 --- a/include/of.h +++ b/include/of.h @@ -204,6 +204,7 @@ extern const char *of_get_machine_compatible(void); extern int of_machine_is_compatible(const char *compat); extern int of_device_is_compatible(const struct device_node *device, const char *compat); +extern bool of_node_is_fixed_partitions(const struct device_node *np); extern int of_device_is_available(const struct device_node *device); extern bool of_device_is_big_endian(const struct device_node *device); @@ -916,6 +917,11 @@ static inline int of_device_is_compatible(const struct device_node *device, return 0; } +static inline bool of_node_is_fixed_partitions(const struct device_node *device) +{ + return false; +} + static inline int of_device_is_available(const struct device_node *device) { return 0; -- 2.39.5