summaryrefslogtreecommitdiffstats
path: root/drivers/of
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2024-01-10 01:14:50 +0000
committerGeert Uytterhoeven <geert+renesas@glider.be>2024-01-23 09:38:30 +0100
commit28c5d4e40752fc39507a647b20649c5ca1cf33b7 (patch)
tree89baf1d060e94cff251b801e7c8a3c9c85a1f49e /drivers/of
parent8918283af1bd68f46f75164289492988dbc67a41 (diff)
downloadlinux-28c5d4e40752fc39507a647b20649c5ca1cf33b7.tar.gz
linux-28c5d4e40752fc39507a647b20649c5ca1cf33b7.tar.bz2
linux-28c5d4e40752fc39507a647b20649c5ca1cf33b7.zip
of: Add for_each_reserved_child_of_node()
We would like to use for_each loop for status = "reserved" nodes. Add for_each_reserved_child_of_node() for it. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Tested-by: Yusuke Goda <yusuke.goda.sx@renesas.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Rob Herring <robh@kernel.org> Link: https://lore.kernel.org/r/87a5pegfau.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Diffstat (limited to 'drivers/of')
-rw-r--r--drivers/of/base.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c
index ae26a15390f7..49a9ad8134db 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -466,6 +466,20 @@ static bool __of_device_is_available(const struct device_node *device)
}
/**
+ * __of_device_is_reserved - check if a device is reserved
+ *
+ * @device: Node to check for availability, with locks already held
+ *
+ * Return: True if the status property is set to "reserved", false otherwise
+ */
+static bool __of_device_is_reserved(const struct device_node *device)
+{
+ static const char * const reserved[] = {"reserved", NULL};
+
+ return __of_device_is_status(device, reserved);
+}
+
+/**
* of_device_is_available - check if a device is available for use
*
* @device: Node to check for availability
@@ -651,6 +665,21 @@ struct device_node *of_get_next_available_child(const struct device_node *node,
EXPORT_SYMBOL(of_get_next_available_child);
/**
+ * of_get_next_reserved_child - Find the next reserved child node
+ * @node: parent node
+ * @prev: previous child of the parent node, or NULL to get first
+ *
+ * This function is like of_get_next_child(), except that it
+ * automatically skips any disabled nodes (i.e. status = "disabled").
+ */
+struct device_node *of_get_next_reserved_child(const struct device_node *node,
+ struct device_node *prev)
+{
+ return of_get_next_status_child(node, prev, __of_device_is_reserved);
+}
+EXPORT_SYMBOL(of_get_next_reserved_child);
+
+/**
* of_get_next_cpu_node - Iterate on cpu nodes
* @prev: previous child of the /cpus node, or NULL to get first
*