summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/boards/ccxmx51/ccxmx51.c2
-rw-r--r--arch/arm/boards/gateworks-ventana/board.c4
-rw-r--r--arch/arm/boards/phytec-som-imx6/board.c2
-rw-r--r--arch/arm/boards/protonic-imx6/board.c2
-rw-r--r--arch/arm/boards/skov-imx6/board.c4
-rw-r--r--arch/arm/boards/zii-common/pn-fixup.c2
-rw-r--r--arch/arm/boards/zii-imx51-rdu1/board.c2
-rw-r--r--arch/arm/boards/zii-imx6q-rdu2/board.c12
-rw-r--r--arch/arm/boards/zii-imx8mq-dev/board.c2
-rw-r--r--arch/arm/mach-imx/imx6.c2
-rw-r--r--arch/arm/mach-stm32mp/init.c2
-rw-r--r--arch/riscv/cpu/core.c2
-rw-r--r--commands/of_display_timings.c4
-rw-r--r--common/oftree.c4
-rw-r--r--drivers/aiodev/qoriq_thermal.c2
-rw-r--r--drivers/net/cpsw.c2
-rw-r--r--drivers/net/phy/mv88e6xxx/port.c2
-rw-r--r--drivers/of/base.c40
-rw-r--r--drivers/of/fdt.c2
-rw-r--r--drivers/of/platform.c44
-rw-r--r--drivers/of/resolver.c4
-rw-r--r--include/of.h21
22 files changed, 128 insertions, 35 deletions
diff --git a/arch/arm/boards/ccxmx51/ccxmx51.c b/arch/arm/boards/ccxmx51/ccxmx51.c
index 09437b047f..dfc26cd835 100644
--- a/arch/arm/boards/ccxmx51/ccxmx51.c
+++ b/arch/arm/boards/ccxmx51/ccxmx51.c
@@ -174,7 +174,7 @@ static void ccxmx51_power_init(struct mc13xxx *mc13xxx)
static void ccxmx51_disable_device(struct device_node *root, const char *label)
{
- struct device_node *np = of_find_node_by_name(root, label);
+ struct device_node *np = of_find_node_by_name_address(root, label);
if (np)
of_device_disable(np);
}
diff --git a/arch/arm/boards/gateworks-ventana/board.c b/arch/arm/boards/gateworks-ventana/board.c
index 163f8338c6..c4c6960192 100644
--- a/arch/arm/boards/gateworks-ventana/board.c
+++ b/arch/arm/boards/gateworks-ventana/board.c
@@ -19,9 +19,9 @@ static int gw54xx_wdog_of_fixup(struct device_node *root, void *context)
struct device_node *np;
/* switch to the watchdog with internal reset capabilities */
- np = of_find_node_by_name(root, "wdog@020c0000");
+ np = of_find_node_by_name_address(root, "wdog@020c0000");
of_device_disable(np);
- np = of_find_node_by_name(root, "wdog@020bc000");
+ np = of_find_node_by_name_address(root, "wdog@020bc000");
of_device_enable(np);
return 0;
diff --git a/arch/arm/boards/phytec-som-imx6/board.c b/arch/arm/boards/phytec-som-imx6/board.c
index 1e515a093a..c540aaeb3f 100644
--- a/arch/arm/boards/phytec-som-imx6/board.c
+++ b/arch/arm/boards/phytec-som-imx6/board.c
@@ -107,7 +107,7 @@ static int phycore_da9062_setup_buck_mode(void)
unsigned char value;
int ret;
- pmic_np = of_find_node_by_name(NULL, "pmic@58");
+ pmic_np = of_find_node_by_name_address(NULL, "pmic@58");
if (!pmic_np)
return -ENODEV;
diff --git a/arch/arm/boards/protonic-imx6/board.c b/arch/arm/boards/protonic-imx6/board.c
index 9b2a00c6c3..adde1be8d9 100644
--- a/arch/arm/boards/protonic-imx6/board.c
+++ b/arch/arm/boards/protonic-imx6/board.c
@@ -736,7 +736,7 @@ static int prt_imx6_get_id(struct prt_imx6_priv *priv)
struct device_node *gpio_np = NULL;
int ret;
- gpio_np = of_find_node_by_name(NULL, "gpio@20a0000");
+ gpio_np = of_find_node_by_name_address(NULL, "gpio@20a0000");
if (!gpio_np)
return -ENODEV;
diff --git a/arch/arm/boards/skov-imx6/board.c b/arch/arm/boards/skov-imx6/board.c
index cd7b8e208d..2702bc1de9 100644
--- a/arch/arm/boards/skov-imx6/board.c
+++ b/arch/arm/boards/skov-imx6/board.c
@@ -496,7 +496,7 @@ static void skov_init_board(const struct board_description *variant)
char *environment_path, *envdev;
int ret;
- gpio_np = of_find_node_by_name(NULL, "gpio@20b4000");
+ gpio_np = of_find_node_by_name_address(NULL, "gpio@20b4000");
if (gpio_np) {
ret = of_device_ensure_probed(gpio_np);
if (ret)
@@ -568,7 +568,7 @@ static void skov_init_board(const struct board_description *variant)
pr_err("Cannot find \"fsl,imx6q-ldb\" node\n");
/* ... as well as its channel 0 */
- np = of_find_node_by_name(np, "lvds-channel@0");
+ np = of_find_node_by_name_address(np, "lvds-channel@0");
if (np)
of_device_enable(np);
else
diff --git a/arch/arm/boards/zii-common/pn-fixup.c b/arch/arm/boards/zii-common/pn-fixup.c
index 80785285b7..3c69f1a022 100644
--- a/arch/arm/boards/zii-common/pn-fixup.c
+++ b/arch/arm/boards/zii-common/pn-fixup.c
@@ -11,7 +11,7 @@ char *zii_read_part_number(const char *cell_name, size_t cell_size)
{
struct device_node *np;
- np = of_find_node_by_name(NULL, "device-info");
+ np = of_find_node_by_name_address(NULL, "device-info");
if (!np) {
pr_warn("No device information found\n");
return ERR_PTR(-ENOENT);
diff --git a/arch/arm/boards/zii-imx51-rdu1/board.c b/arch/arm/boards/zii-imx51-rdu1/board.c
index 8fdcb76260..42c99ecc1e 100644
--- a/arch/arm/boards/zii-imx51-rdu1/board.c
+++ b/arch/arm/boards/zii-imx51-rdu1/board.c
@@ -99,7 +99,7 @@ static int zii_rdu1_load_config(void)
file = "shadow copy in RAVE SP EEPROM";
root = of_get_root_node();
- np = of_find_node_by_name(root, "eeprom@a4");
+ np = of_find_node_by_name_address(root, "eeprom@a4");
if (!np)
return -ENODEV;
diff --git a/arch/arm/boards/zii-imx6q-rdu2/board.c b/arch/arm/boards/zii-imx6q-rdu2/board.c
index b915a05dd2..f57827cd13 100644
--- a/arch/arm/boards/zii-imx6q-rdu2/board.c
+++ b/arch/arm/boards/zii-imx6q-rdu2/board.c
@@ -199,19 +199,19 @@ static int rdu2_fixup_dsa(struct device_node *root, void *context)
if (!switch_np)
return -ENODEV;
- np = of_find_node_by_name(switch_np, "port@2");
+ np = of_find_node_by_name_address(switch_np, "port@2");
if (!np)
return -ENODEV;
of_delete_node(np);
- np = of_find_node_by_name(root, "i210@0");
+ np = of_find_node_by_name_address(root, "i210@0");
if (!np)
return -ENODEV;
i210_handle = of_node_create_phandle(np);
- np = of_find_node_by_name(switch_np, "port@0");
+ np = of_find_node_by_name_address(switch_np, "port@0");
if (!np)
return -ENODEV;
@@ -265,7 +265,7 @@ static int rdu2_fixup_lvds(struct device_node *root,
/*
* LVDS panels need the correct timings
*/
- np = of_find_node_by_name(root, "panel");
+ np = of_find_node_by_name_address(root, "panel");
if (!np)
return -ENODEV;
@@ -280,7 +280,7 @@ static int rdu2_fixup_lvds(struct device_node *root,
* Delete all mode entries, which aren't suited for the
* current display
*/
- np = of_find_node_by_name(np, "display-timings");
+ np = of_find_node_by_name_address(np, "display-timings");
if (!np)
return -ENODEV;
@@ -305,7 +305,7 @@ static int rdu2_fixup_lvds(struct device_node *root,
if (fixup->type == IT_DUAL_LVDS)
of_set_property(np, "fsl,dual-channel", NULL, 0, 1);
- np = of_find_node_by_name(np, "lvds-channel@0");
+ np = of_find_node_by_name_address(np, "lvds-channel@0");
if (!np)
return -ENODEV;
diff --git a/arch/arm/boards/zii-imx8mq-dev/board.c b/arch/arm/boards/zii-imx8mq-dev/board.c
index 4ad09663ac..02e257f35f 100644
--- a/arch/arm/boards/zii-imx8mq-dev/board.c
+++ b/arch/arm/boards/zii-imx8mq-dev/board.c
@@ -106,7 +106,7 @@ static int zii_imx8mq_dev_fixup_deb_internal(void)
unregister_device(dev);
- np = of_find_node_by_name(NULL, "i210@0");
+ np = of_find_node_by_name_address(NULL, "i210@0");
if (!np)
return -ENODEV;
diff --git a/arch/arm/mach-imx/imx6.c b/arch/arm/mach-imx/imx6.c
index bf8d1a0065..697a8a21fa 100644
--- a/arch/arm/mach-imx/imx6.c
+++ b/arch/arm/mach-imx/imx6.c
@@ -326,7 +326,7 @@ static int imx6_fixup_cpus(struct device_node *root, void *context)
unsigned long scu_phys_base;
unsigned int max_core_index;
- cpus_node = of_find_node_by_name(root, "cpus");
+ cpus_node = of_find_node_by_name_address(root, "cpus");
if (!cpus_node)
return 0;
diff --git a/arch/arm/mach-stm32mp/init.c b/arch/arm/mach-stm32mp/init.c
index 01961ae456..bcd04b210a 100644
--- a/arch/arm/mach-stm32mp/init.c
+++ b/arch/arm/mach-stm32mp/init.c
@@ -140,7 +140,7 @@ static int stm32mp15_fixup_cpus(struct device_node *root, void *_ctx)
unsigned long ctx = (unsigned long)_ctx;
struct device_node *cpus_node, *np, *tmp;
- cpus_node = of_find_node_by_name(root, "cpus");
+ cpus_node = of_find_node_by_name_address(root, "cpus");
if (!cpus_node)
return 0;
diff --git a/arch/riscv/cpu/core.c b/arch/riscv/cpu/core.c
index 1d5902a51f..c075301b1b 100644
--- a/arch/riscv/cpu/core.c
+++ b/arch/riscv/cpu/core.c
@@ -43,7 +43,7 @@ static int riscv_fixup_cpus(struct device_node *root, void *context)
{
struct device_node *cpus_node, *np, *tmp;
- cpus_node = of_find_node_by_name(root, "cpus");
+ cpus_node = of_find_node_by_name_address(root, "cpus");
if (!cpus_node)
return 0;
diff --git a/commands/of_display_timings.c b/commands/of_display_timings.c
index 4e5ec223b7..aab57b17d6 100644
--- a/commands/of_display_timings.c
+++ b/commands/of_display_timings.c
@@ -98,7 +98,7 @@ static int do_of_display_timings(int argc, char *argv[])
int found = 0;
const char *node = "display-timings";
- for_each_node_by_name_from(display, root, node) {
+ for_each_node_by_name_address_from(display, root, node) {
for_each_child_of_node(display, timings) {
printf("%s\n", timings->full_name);
found = 1;
@@ -113,7 +113,7 @@ static int do_of_display_timings(int argc, char *argv[])
int found = 0;
const char *node = "display-timings";
- for_each_node_by_name_from(display, root, node) {
+ for_each_node_by_name_address_from(display, root, node) {
timings = of_parse_phandle_from(display, root,
"native-mode", 0);
if (!timings)
diff --git a/common/oftree.c b/common/oftree.c
index 0738ab6e9e..bce0ff09d6 100644
--- a/common/oftree.c
+++ b/common/oftree.c
@@ -405,7 +405,7 @@ int of_autoenable_device_by_path(char *path)
struct device_node *node;
int ret;
- node = of_find_node_by_name(NULL, path);
+ node = of_find_node_by_name_address(NULL, path);
if (!node)
node = of_find_node_by_path(path);
@@ -442,7 +442,7 @@ int of_autoenable_i2c_by_component(char *path)
if (!IS_ENABLED(CONFIG_I2C))
return -ENODEV;
- node = of_find_node_by_name(NULL, path);
+ node = of_find_node_by_name_address(NULL, path);
if (!node)
node = of_find_node_by_path(path);
if (!node)
diff --git a/drivers/aiodev/qoriq_thermal.c b/drivers/aiodev/qoriq_thermal.c
index d62048ef13..1acb06a9de 100644
--- a/drivers/aiodev/qoriq_thermal.c
+++ b/drivers/aiodev/qoriq_thermal.c
@@ -118,7 +118,7 @@ static int qoriq_tmu_get_sensor_id(void)
struct of_phandle_args sensor_specs;
struct device_node *np, *sensor_np;
- np = of_find_node_by_name(NULL, "thermal-zones");
+ np = of_find_node_by_name_address(NULL, "thermal-zones");
if (!np)
return -ENODEV;
diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c
index 6725c7b9bd..748aa861f1 100644
--- a/drivers/net/cpsw.c
+++ b/drivers/net/cpsw.c
@@ -1224,7 +1224,7 @@ static void cpsw_add_slave(struct cpsw_slave *slave, struct device_node *child,
uint32_t phy_id[2] = {-1, -1};
int ret;
- if (!of_find_node_by_name(child, "fixed-link")) {
+ if (!of_find_node_by_name_address(child, "fixed-link")) {
ret = of_property_read_u32_array(child, "phy_id", phy_id, 2);
if (!ret)
dev_warn(slave->cpsw->dev, "phy_id is deprecated, use phy-handle\n");
diff --git a/drivers/net/phy/mv88e6xxx/port.c b/drivers/net/phy/mv88e6xxx/port.c
index ba2b03e18d..79694e5237 100644
--- a/drivers/net/phy/mv88e6xxx/port.c
+++ b/drivers/net/phy/mv88e6xxx/port.c
@@ -558,7 +558,7 @@ int mv88e6xxx_port_probe(struct mv88e6xxx_chip *chip)
struct device_node *port_nodes[DSA_MAX_PORTS] = { NULL };
int err, i;
- switch_node = of_find_node_by_name(np, "ports");
+ switch_node = of_find_node_by_name_address(np, "ports");
if (!switch_node)
return -EINVAL;
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 723bf2132d..83291c4785 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -23,6 +23,21 @@
static struct device_node *root_node;
+bool of_node_name_eq(const struct device_node *np, const char *name)
+{
+ const char *node_name;
+ size_t len;
+
+ if (!np)
+ return false;
+
+ node_name = kbasename(np->full_name);
+ len = strchrnul(node_name, '@') - node_name;
+
+ return (strlen(name) == len) && (strncmp(node_name, name, len) == 0);
+}
+EXPORT_SYMBOL(of_node_name_eq);
+
/*
* Iterate over all nodes of a tree. As a devicetree does not
* have a dedicated list head, the start node (usually the root
@@ -538,6 +553,29 @@ int of_device_is_compatible(const struct device_node *device,
EXPORT_SYMBOL(of_device_is_compatible);
/**
+ * of_find_node_by_name_address - Find a node by its full name
+ * @from: The node to start searching from or NULL, the node
+ * you pass will not be searched, only the next one
+ * will; typically, you pass what the previous call
+ * returned.
+ * @name: The name string to match against
+ *
+ * Returns a pointer to the node found or NULL.
+ */
+struct device_node *of_find_node_by_name_address(struct device_node *from,
+ const char *name)
+{
+ struct device_node *np;
+
+ of_tree_for_each_node_from(np, from)
+ if (np->name && !of_node_cmp(np->name, name))
+ return np;
+
+ return NULL;
+}
+EXPORT_SYMBOL(of_find_node_by_name_address);
+
+/**
* of_find_node_by_name - Find a node by its "name" property
* @from: The node to start searching from or NULL, the node
* you pass will not be searched, only the next one
@@ -553,7 +591,7 @@ struct device_node *of_find_node_by_name(struct device_node *from,
struct device_node *np;
of_tree_for_each_node_from(np, from)
- if (np->name && !of_node_cmp(np->name, name))
+ if (np->name && of_node_name_eq(np, name))
return np;
return NULL;
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 770126c78e..5ccbd1bb69 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -486,7 +486,7 @@ void *of_flatten_dtb(struct device_node *node)
if (ret)
goto out_free;
- memreserve = of_find_node_by_name(node, "memreserve");
+ memreserve = of_find_node_by_name_address(node, "memreserve");
if (memreserve) {
const void *entries = of_get_property(memreserve, "reg", &len);
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 9b487cbb0c..7f377b8b37 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -202,7 +202,7 @@ struct device_d *of_device_enable_and_register_by_name(const char *name)
{
struct device_node *node;
- node = of_find_node_by_name(NULL, name);
+ node = of_find_node_by_name_address(NULL, name);
if (!node)
node = of_find_node_by_path(name);
@@ -457,6 +457,9 @@ int of_device_ensure_probed_by_alias(const char *alias)
{
struct device_node *dev_node;
+ if (!deep_probe_is_supported())
+ return 0;
+
dev_node = of_find_node_by_alias(NULL, alias);
if (!dev_node)
return -EINVAL;
@@ -482,6 +485,9 @@ int of_devices_ensure_probed_by_dev_id(const struct of_device_id *ids)
struct device_node *np;
int err, ret = 0;
+ if (!deep_probe_is_supported())
+ return 0;
+
for_each_matching_node(np, ids) {
if (!of_device_is_available(np))
continue;
@@ -510,19 +516,39 @@ EXPORT_SYMBOL_GPL(of_devices_ensure_probed_by_dev_id);
int of_devices_ensure_probed_by_property(const char *property_name)
{
struct device_node *node;
+ int err, ret = 0;
- for_each_node_with_property(node, property_name) {
- int ret;
+ if (!deep_probe_is_supported())
+ return 0;
+ for_each_node_with_property(node, property_name) {
ret = of_device_ensure_probed(node);
- if (ret)
- return ret;
+ if (err)
+ ret = err;
}
return 0;
}
EXPORT_SYMBOL_GPL(of_devices_ensure_probed_by_property);
+int of_devices_ensure_probed_by_name(const char *name)
+{
+ struct device_node *node;
+ int err, ret = 0;
+
+ if (!deep_probe_is_supported())
+ return 0;
+
+ for_each_node_by_name(node, name) {
+ ret = of_device_ensure_probed(node);
+ if (err)
+ ret = err;
+ }
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(of_devices_ensure_probed_by_name);
+
static int of_stdoutpath_init(void)
{
struct device_node *np;
@@ -539,3 +565,11 @@ static int of_stdoutpath_init(void)
return of_device_ensure_probed(np);
}
postconsole_initcall(of_stdoutpath_init);
+
+static int of_timer_init(void)
+{
+ of_devices_ensure_probed_by_name("timer");
+
+ return 0;
+}
+postcore_initcall(of_timer_init);
diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c
index 242775099e..2457ae96a4 100644
--- a/drivers/of/resolver.c
+++ b/drivers/of/resolver.c
@@ -214,7 +214,7 @@ struct device_node *of_resolve_phandles(struct device_node *root,
* to a phandle defined in the overlay. We must update the references,
* because we just adjusted the definitions.
*/
- local_fixups = of_find_node_by_name(result, "__local_fixups__");
+ local_fixups = of_find_node_by_name_address(result, "__local_fixups__");
err = adjust_local_phandle_references(local_fixups, result, delta);
if (err) {
pr_err("failed to fix phandles in overlay\n");
@@ -227,7 +227,7 @@ struct device_node *of_resolve_phandles(struct device_node *root,
* the base device tree. We must update the references, because they
* are otherwise undefined.
*/
- overlay_fixups = of_find_node_by_name(result, "__fixups__");
+ overlay_fixups = of_find_node_by_name_address(result, "__fixups__");
if (!overlay_fixups) {
pr_debug("overlay does not contain phandles to base devicetree\n");
goto out;
diff --git a/include/of.h b/include/of.h
index b449d10ec7..cf9950e9b3 100644
--- a/include/of.h
+++ b/include/of.h
@@ -120,6 +120,7 @@ extern int of_bus_n_addr_cells(struct device_node *np);
extern int of_n_addr_cells(struct device_node *np);
extern int of_bus_n_size_cells(struct device_node *np);
extern int of_n_size_cells(struct device_node *np);
+extern bool of_node_name_eq(const struct device_node *np, const char *name);
extern struct property *of_find_property(const struct device_node *np,
const char *name, int *lenp);
@@ -138,6 +139,8 @@ extern void of_delete_property(struct property *pp);
extern struct device_node *of_find_node_by_name(struct device_node *from,
const char *name);
+extern struct device_node *of_find_node_by_name_address(struct device_node *from,
+ const char *name);
extern struct device_node *of_find_node_by_path_from(struct device_node *from,
const char *path);
extern struct device_node *of_find_node_by_path(const char *path);
@@ -284,6 +287,7 @@ extern struct device_d *of_device_enable_and_register_by_alias(
extern int of_device_ensure_probed(struct device_node *np);
extern int of_device_ensure_probed_by_alias(const char *alias);
extern int of_devices_ensure_probed_by_property(const char *property_name);
+extern int of_devices_ensure_probed_by_name(const char *name);
extern int of_devices_ensure_probed_by_dev_id(const struct of_device_id *ids);
extern int of_partition_ensure_probed(struct device_node *np);
@@ -313,6 +317,11 @@ struct device_node *of_find_node_by_path_or_alias(struct device_node *root,
int of_autoenable_device_by_path(char *path);
int of_autoenable_i2c_by_component(char *path);
#else
+static inline bool of_node_name_eq(const struct device_node *np, const char *name)
+{
+ return false;
+}
+
static inline int of_parse_partitions(struct cdev *cdev,
struct device_node *node)
{
@@ -659,6 +668,12 @@ static inline struct device_node *of_find_node_by_name(struct device_node *from,
return NULL;
}
+static inline struct device_node *of_find_node_by_name_address(struct device_node *from,
+ const char *name)
+{
+ return NULL;
+}
+
static inline struct device_node *of_find_node_by_phandle(phandle phandle)
{
return NULL;
@@ -827,12 +842,18 @@ static inline int of_autoenable_i2c_by_component(char *path)
#define for_each_node_by_name(dn, name) \
for (dn = of_find_node_by_name(NULL, name); dn; \
dn = of_find_node_by_name(dn, name))
+#define for_each_node_by_name_address(dn, name) \
+ for (dn = of_find_node_by_name_address(NULL, name); dn; \
+ dn = of_find_node_by_name_address(dn, name))
#define for_each_node_by_type(dn, type) \
for (dn = of_find_node_by_type(NULL, type); dn; \
dn = of_find_node_by_type(dn, type))
#define for_each_node_by_name_from(dn, root, name) \
for (dn = of_find_node_by_name(root, name); dn; \
dn = of_find_node_by_name(dn, name))
+#define for_each_node_by_name_address_from(dn, root, name) \
+ for (dn = of_find_node_by_name_address(root, name); dn; \
+ dn = of_find_node_by_name_address(dn, name))
/* Iterate over compatible nodes starting from given root */
#define for_each_compatible_node_from(dn, root, type, compatible) \
for (dn = of_find_compatible_node(root, type, compatible); dn; \