aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/arm/ti/am335x/am335x_lcd.c4
-rw-r--r--sys/dev/fdt/fdt_common.c17
-rw-r--r--sys/dev/fdt/fdt_common.h1
-rw-r--r--sys/dev/ofw/ofw_bus_subr.c22
-rw-r--r--sys/dev/ofw/ofw_bus_subr.h3
5 files changed, 27 insertions, 20 deletions
diff --git a/sys/arm/ti/am335x/am335x_lcd.c b/sys/arm/ti/am335x/am335x_lcd.c
index df5c537544a5..501042a9fcd2 100644
--- a/sys/arm/ti/am335x/am335x_lcd.c
+++ b/sys/arm/ti/am335x/am335x_lcd.c
@@ -273,7 +273,7 @@ am335x_read_timing(device_t dev, phandle_t node, struct panel_info *panel)
int error;
phandle_t timings_node, timing_node, native;
- timings_node = fdt_find_child(node, "display-timings");
+ timings_node = ofw_bus_find_child(node, "display-timings");
if (timings_node == 0) {
device_printf(dev, "no \"display-timings\" node\n");
return (-1);
@@ -346,7 +346,7 @@ am335x_read_panel_info(device_t dev, phandle_t node, struct panel_info *panel)
int error;
phandle_t panel_info_node;
- panel_info_node = fdt_find_child(node, "panel-info");
+ panel_info_node = ofw_bus_find_child(node, "panel-info");
if (panel_info_node == 0)
return (-1);
diff --git a/sys/dev/fdt/fdt_common.c b/sys/dev/fdt/fdt_common.c
index 0198d550ca2c..f00519e5646f 100644
--- a/sys/dev/fdt/fdt_common.c
+++ b/sys/dev/fdt/fdt_common.c
@@ -57,7 +57,6 @@ __FBSDID("$FreeBSD$");
#define FDT_COMPAT_LEN 255
#define FDT_TYPE_LEN 64
-#define FDT_NAME_LEN 32
#define FDT_REG_CELLS 4
@@ -311,22 +310,6 @@ fdt_find_compatible(phandle_t start, const char *compat, int strict)
}
phandle_t
-fdt_find_child(phandle_t start, const char *child_name)
-{
- char name[FDT_NAME_LEN];
- phandle_t child;
-
- for (child = OF_child(start); child != 0; child = OF_peer(child)) {
- if (OF_getprop(child, "name", name, sizeof(name)) <= 0)
- continue;
- if (strcmp(name, child_name) == 0)
- return (child);
- }
-
- return (0);
-}
-
-phandle_t
fdt_depth_search_compatible(phandle_t start, const char *compat, int strict)
{
phandle_t child, node;
diff --git a/sys/dev/fdt/fdt_common.h b/sys/dev/fdt/fdt_common.h
index 68012978ac26..3d05341dad1d 100644
--- a/sys/dev/fdt/fdt_common.h
+++ b/sys/dev/fdt/fdt_common.h
@@ -81,7 +81,6 @@ u_long fdt_data_get(void *, int);
int fdt_data_to_res(pcell_t *, int, int, u_long *, u_long *);
phandle_t fdt_find_compatible(phandle_t, const char *, int);
phandle_t fdt_depth_search_compatible(phandle_t, const char *, int);
-phandle_t fdt_find_child(phandle_t, const char *);
int fdt_get_mem_regions(struct mem_region *, int *, uint32_t *);
int fdt_get_reserved_regions(struct mem_region *, int *);
int fdt_get_phyaddr(phandle_t, device_t, int *, void **);
diff --git a/sys/dev/ofw/ofw_bus_subr.c b/sys/dev/ofw/ofw_bus_subr.c
index 5063930d5a9e..a9261cee1346 100644
--- a/sys/dev/ofw/ofw_bus_subr.c
+++ b/sys/dev/ofw/ofw_bus_subr.c
@@ -503,6 +503,28 @@ ofw_bus_intr_to_rl(device_t dev, phandle_t node,
}
phandle_t
+ofw_bus_find_child(phandle_t start, const char *child_name)
+{
+ char *name;
+ int ret;
+ phandle_t child;
+
+ for (child = OF_child(start); child != 0; child = OF_peer(child)) {
+ ret = OF_getencprop_alloc(child, "name", sizeof(*name), (void **)&name);
+ if (ret == -1)
+ continue;
+ if (strcmp(name, child_name) == 0) {
+ free(name, M_OFWPROP);
+ return (child);
+ }
+
+ free(name, M_OFWPROP);
+ }
+
+ return (0);
+}
+
+phandle_t
ofw_bus_find_compatible(phandle_t node, const char *onecompat)
{
phandle_t child, ret;
diff --git a/sys/dev/ofw/ofw_bus_subr.h b/sys/dev/ofw/ofw_bus_subr.h
index be35711b0281..bbeda7f5533c 100644
--- a/sys/dev/ofw/ofw_bus_subr.h
+++ b/sys/dev/ofw/ofw_bus_subr.h
@@ -104,4 +104,7 @@ int ofw_bus_has_prop(device_t, const char *);
/* Helper to search for a child with a given compat prop */
phandle_t ofw_bus_find_compatible(phandle_t, const char *);
+/* Helper to search for a child with a given name */
+phandle_t ofw_bus_find_child(phandle_t, const char *);
+
#endif /* !_DEV_OFW_OFW_BUS_SUBR_H_ */