From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wolfgang Denk Date: Wed, 26 May 2010 22:17:36 +0200 Subject: [U-Boot] [PATCH] libfdt: introduce function fdt_get_max_phandle In-Reply-To: <1274308618-2974-1-git-send-email-timur@freescale.com> References: <1274308618-2974-1-git-send-email-timur@freescale.com> Message-ID: <20100526201736.07107EAC238@gemini.denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Timur Tabi, In message <1274308618-2974-1-git-send-email-timur@freescale.com> you wrote: > Introduce function fdt_get_max_phandle(), which returns the largest value > of all phandles in a device tree. This is useful for allocating a new phandle > property, since all phandles must be unique. > > Signed-off-by: Timur Tabi > --- > include/libfdt.h | 20 ++++++++++++++++++++ > lib/libfdt/fdt_ro.c | 17 +++++++++++++++++ > 2 files changed, 37 insertions(+), 0 deletions(-) Please submit as part of a patch / patch series that acrtually uses this feature. As is, it's just dead code that has no users. > +int fdt_get_max_phandle(const void *fdt) > +{ > + int offset; > + uint32_t temp, phandle = 0; > + > + FDT_CHECK_HEADER(fdt); > + > + for (offset = fdt_next_node(fdt, -1, NULL); offset >= 0; > + offset = fdt_next_node(fdt, offset, NULL)) { > + temp = fdt_get_phandle(fdt, offset); > + if (temp > phandle) > + phandle = temp; > + } > + > + return phandle; > +} As fdt_get_phandle() returns a uint32_t, fdt_get_max_phandle() should return the same type, not int. Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Star Trek Lives!