Date: Fri, 22 May 2015 02:00:45 +0000 (UTC) From: Oleksandr Tymoshenko <gonzo@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r283275 - head/sys/dev/fdt Message-ID: <201505220200.t4M20jfi082771@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: gonzo Date: Fri May 22 02:00:44 2015 New Revision: 283275 URL: https://svnweb.freebsd.org/changeset/base/283275 Log: Add helper method fdt_find_child to make access to child nodes easier. Some FDT nodes have complex properties organized as a child sub-nodes (e.g. timing for LCD panel) we need easy way to obtain handles for these sub-nodes Modified: head/sys/dev/fdt/fdt_common.c head/sys/dev/fdt/fdt_common.h Modified: head/sys/dev/fdt/fdt_common.c ============================================================================== --- head/sys/dev/fdt/fdt_common.c Fri May 22 01:44:07 2015 (r283274) +++ head/sys/dev/fdt/fdt_common.c Fri May 22 02:00:44 2015 (r283275) @@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$"); #define FDT_COMPAT_LEN 255 #define FDT_TYPE_LEN 64 +#define FDT_NAME_LEN 32 #define FDT_REG_CELLS 4 @@ -310,6 +311,22 @@ fdt_find_compatible(phandle_t start, con } 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; Modified: head/sys/dev/fdt/fdt_common.h ============================================================================== --- head/sys/dev/fdt/fdt_common.h Fri May 22 01:44:07 2015 (r283274) +++ head/sys/dev/fdt/fdt_common.h Fri May 22 02:00:44 2015 (r283275) @@ -81,6 +81,7 @@ 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 **);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201505220200.t4M20jfi082771>