summaryrefslogtreecommitdiff
path: root/lib/libfdt/fdt_ro.c
AgeCommit message (Collapse)Author
2019-04-11libfdt: Add phandle generation helperThierry Reding
The new fdt_generate_phandle() function can be used to generate a new, unused phandle given a specific device tree blob. The implementation is somewhat naive in that it simply walks the entire device tree to find the highest phandle value and then returns a phandle value one higher than that. A more clever implementation might try to find holes in the current set of phandle values and fill them. But this implementation is relatively simple and works reliably. Also add a test that validates that phandles generated by this new API are indeed unique. Signed-off-by: Thierry Reding <treding@nvidia.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-05-31scripts/dtc: Update to upstream version v1.4.6-9-gaadd0b65c987Rob Herring
This adds the following commits from upstream: aadd0b65c987 checks: centralize printing of property names in failure messages 88960e398907 checks: centralize printing of node path in check_msg f1879e1a50eb Add limited read-only support for older (V2 and V3) device tree to libfdt. 37dea76e9700 srcpos: drop special handling of tab 65893da4aee0 libfdt: overlay: Add missing license 962a45ca034d Avoid installing pylibfdt when dependencies are missing cd6ea1b2bea6 Makefile: Split INSTALL out into INSTALL_{PROGRAM,LIB,DATA,SCRIPT} 51b3a16338df Makefile.tests: Add LIBDL make(1) variable for portability sake 333d533a8f4d Attempt to auto-detect stat(1) being used if not given proper invocation e54388015af1 dtc: Bump version to v1.4.6 a1fe86f380cb fdtoverlay: Switch from using alloca to malloc c8d5472de3ff tests: Improve compatibility with other platforms c81d389a10cc checks: add chosen node checks e671852042a7 checks: add aliases node checks d0c44ebe3f42 checks: check for #{size,address}-cells without child nodes 18a3d84bb802 checks: add string list check for *-names properties 8fe94fd6f19f checks: add string list check 6c5730819604 checks: add a string check for 'label' property a384191eba09 checks: fix sound-dai phandle with arg property check b260c4f610c0 Fix ambiguous grammar for devicetree rule fe667e382bac tests: Add some basic tests for the pci_bridge checks 7975f6422260 Fix widespread incorrect use of strneq(), replace with new strprefixeq() fca296445eab Add strstarts() helper function cc392f089007 tests: Check non-matching cases for fdt_node_check_compatible() bba26a5291c8 livetree: avoid assertion of orphan phandles with overlays c8f8194d76cc implement strnlen for systems that need it c8b38f65fdec libfdt: Remove leading underscores from identifiers 3b62fdaebfe5 Remove leading underscores from identifiers 2d45d1c5c65e Replace FDT_VERSION() with stringify() 2e6fe5a107b5 Fix some errors in comments b0ae9e4b0ceb tests: Correct warning in sw_tree1.c Commit c8b38f65fdec upstream ("libfdt: Remove leading underscores from identifiers") changed the multiple inclusion define protection, so the kernel's libfdt_env.h needs the corresponding update. Signed-off-by: Rob Herring <robh@kernel.org> [ Linux commit: 9130ba884640328bb78aaa4840e5ddf06ccafb1c ] [erosca: - Fixup conflicts in include/linux/libfdt_env.h caused by v2018.03-rc4 commit b08c8c487083 ("libfdt: move headers to <linux/libfdt.h> and <linux/libfdt_env.h>") - Fix build errors in lib/libfdt/fdt_ro.c, tools/libfdt/fdt_rw.c by: - s/_fdt_mem_rsv/fdt_mem_rsv_/ - s/_fdt_offset_ptr/fdt_offset_ptr_/ - s/_fdt_check_node_offset/fdt_check_node_offset_/ - s/_fdt_check_prop_offset/fdt_check_prop_offset_/ - s/_fdt_find_add_string/fdt_find_add_string_/] Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-05-07SPDX: Convert all of our multiple license tags to Linux Kernel styleTom Rini
When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have multiple licenses (in these cases, dual license) declared in the SPDX-License-Identifier tag. In this case we change from listing "LICENSE-A LICENSE-B" or "LICENSE-A or LICENSE-B" or "(LICENSE-A OR LICENSE-B)" to "LICENSE-A OR LICENSE-B" as per the Linux Kernel style document. Note that parenthesis are allowed so when they were used before we continue to use them. Reviewed-by: Fabio Estevam <fabio.estevam@nxp.com> Signed-off-by: Tom Rini <trini@konsulko.com>
2018-03-05libfdt: move headers to <linux/libfdt.h> and <linux/libfdt_env.h>Masahiro Yamada
Thomas reported U-Boot failed to build host tools if libfdt-devel package is installed because tools include libfdt headers from /usr/include/ instead of using internal ones. This commit moves the header code: include/libfdt.h -> include/linux/libfdt.h include/libfdt_env.h -> include/linux/libfdt_env.h and replaces include directives: #include <libfdt.h> -> #include <linux/libfdt.h> #include <libfdt_env.h> -> #include <linux/libfdt_env.h> Reported-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2016-10-24libfdt: fix fdt_stringlist_search()Masahiro Yamada
If fdt_getprop() fails, negative error code should be returned. [ DTC commit: daa75e8fa5942caa8e97931aed3a1ee0b7edd74b ] Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-10-24libfdt: fix fdt_stringlist_count()Masahiro Yamada
If fdt_getprop() fails, negative error code should be returned. [ DTC commit: e28eff5b787adb3f461d1653598818b2f1f25a73 ] Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-10-13libfdt: Drop inlining of fdt_path_offset()Simon Glass
The fdt_path_offset() function is not inlined in upstream libfdt. Adjust U-Boot's version to match. Signed-off-by: Simon Glass <sjg@chromium.org>
2016-10-13libfdt: Bring in upstream stringlist functionsSimon Glass
These have now landed upstream. The naming is different and in one case the function signature has changed. Update the code to match. This applies the following upstream commits by Thierry Reding <treding@nvidia.com> : 604e61e fdt: Add functions to retrieve strings 8702bd1 fdt: Add a function to get the index of a string 2218387 fdt: Add a function to count strings Signed-off-by: Simon Glass <sjg@chromium.org>
2016-10-13libfdt: Sync up with upstreamSimon Glass
This includes small changes to the following functions, from upstream commit 6d1832c: - fdt_get_max_phandle() (upstream commit 84e0e134) - fdt_node_check_compatible (upstream commit 53bf130b) - fdt_setprop_inplace_namelen_partial() to remove useless brackets and use idx instead of index - _fdt_resize_property() to use idx instead of index - _fdt_splice() (upstream commit d4c7c25c) It also includes various typo fixes in libfdt.h Signed-off-by: Simon Glass <sjg@chromium.org>
2016-08-20libfdt: Add fdt_path_offset_namelenMaxime Ripard
Add a namelen variant of fdt_path_offset to retrieve the node offset using only a fixed number of characters. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2016-08-20libfdt: Fix separator spellingMaxime Ripard
The function fdt_path_next_seperator had an obvious mispell. Fix it. Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2016-08-20libfdt: Add max phandle retrieval functionMaxime Ripard
Add a function to retrieve the highest phandle in a given device tree. Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com> Reviewed-by: Stefan Agner <stefan@agner.ch> Acked-by: Simon Glass <sjg@chromium.org>
2016-06-19lib/libfdt/: General aesthetic/style fixes.Robert P. J. Day
A number of style fixes across the files in this directory, including: * Correct invalid kernel-doc content. * Tidy up massive comment in fdt_region.c. * Use correct spelling of "U-Boot". * Replace tests of "! <var>" with "!<var>". * Replace "libfdt_env.h" with <libfdt_env.h>. Signed-off-by: Robert P. J. Day <rpjday@crashcourse.ca> Acked-by: Simon Glass <sjg@chromium.org>
2015-07-20libfdt: fix error code of fdt_count_strings()Masahiro Yamada
Currently, this function returns a positive value on error, so we never know whether this function has succeeded or failed. For example, if the given property is not found, fdt_getprop() returns -FDT_ERR_NOTFOUND, and then this function inverts it, i.e., returns FDT_ERR_NOTFOUND (=1). Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Fixes: bc4147ab2d69 ("fdt: Add a function to count strings") Acked-by: Simon Glass <sjg@chromium.org>
2015-07-20libfdt: fix error code of fdt_get_string_index()Masahiro Yamada
As mentioned in the comment block in include/libfdt.h, fdt_get_string_index() is supposed to return a negative value on error. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Fixes: 5094eb408a5d ("fdt: Add functions to retrieve strings") Acked-by: Simon Glass <sjg@chromium.org>
2015-04-23fdt: Fix handling of paths with options in themHans de Goede
After syncing the sunxi dts files with the upstream kernel dm/fdt sunxi builds would no longer boot. The problem is that stdout-path is now set like this in the upstream dts files: stdout-path = "serial0:115200n8". The use of options in of-paths, either after an alias name, or after a full path, e.g. stdout-path = "/soc@01c00000/serial@01c28000:115200", is standard of usage, but something which the u-boot dts code so far did not handle. This commit fixes this, adding support for both path formats. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Acked-by: Simon Glass <sjg@chromium.org>
2014-10-22fdt: Add functions to retrieve stringsThierry Reding
Given a device tree node, a property name and an index, the new function fdt_get_string_index() will return in an output argument a pointer to the index'th string in the property's value. The fdt_get_string() is a shortcut for the above with the index being 0. Signed-off-by: Thierry Reding <treding@nvidia.com> Acked-by: Simon Glass <sjg@chromium.org>
2014-10-22fdt: Add a function to get the index of a stringThierry Reding
Given a device tree node and a property name, the new fdt_find_string() function will look up a given string in the string list contained in the property's value and return its index. Signed-off-by: Thierry Reding <treding@nvidia.com> Acked-by: Simon Glass <sjg@chromium.org>
2014-10-22fdt: Add a function to count stringsThierry Reding
Given a device tree node and a property name, the fdt_count_strings() function counts the number of strings found in the property value. Signed-off-by: Thierry Reding <treding@nvidia.com> Acked-by: Simon Glass <sjg@chromium.org>
2014-06-19libfdt: Fix segfault when calling fit_check_format() on corrupt FIT imagesJon Nalley
It has been observed that fit_check_format() will fail when passed a corrupt FIT image. This was tracked down to _fdt_string_eq(): return (strlen(p) == len) && (memcmp(p, s, len) == 0); In the case of a corrupt FIT image one can't depend on 'p' being NULL terminated. I changed it to use strnlen() to fix the issue. Signed-off-by: Tom Rini <trini@ti.com>
2013-08-10libfdt: SPDX-License-Identifier: GPL-2.0+ BSD-2-ClauseRoger Meier
Signed-off-by: Roger Meier <roger@bufferoverflow.ch> Acked-by: Wolfgang Denk <wd@denx.de>
2013-05-10Export fdt_stringlist_contains()Simon Glass
This function is useful outside libfdt, so export it. Ref: DTC commit b7aa300e Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: David Gibson <david@gibson.dropbear.id.au>
2013-02-07libfdt: update from upstream dtc commit 142419eKim Phillips
commit 142419e "dtc/libfdt: sparse fixes", for u-boot's libfdt copy. Signed-off-by: Kim Phillips <kim.phillips@freescale.com> Cc: Jerry Van Baren <gvb.uboot@gmail.com>
2011-07-14libfdt: Implement property iteration functionsDavid Gibson
For ages, we've been talking about adding functions to libfdt to allow iteration through properties. So, finally, here are some. I got bogged down on this for a long time because I didn't want to expose offsets directly to properties to the callers. But without that, attempting to make reasonable iteration functions just became horrible. So eventually, I settled on an interface which does now expose property offsets. fdt_first_property_offset() and fdt_next_property_offset() are used to step through the offsets of the properties starting from a particularly node offset. The details of the property at each offset can then be retrieved with either fdt_get_property_by_offset() or fdt_getprop_by_offset() which have interfaces similar to fdt_get_property() and fdt_getprop() respectively. No explicit testcases are included, but we do use the new functions to reimplement the existing fdt_get_property() function. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> This was extracted from the DTC commit: 73dca9ae0b9abe6924ba640164ecce9f8df69c5a Mon Sep 17 00:00:00 2001 Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
2011-07-14Support ePAPR compliant phandle propertiesDavid Gibson
Currently, the Linux kernel, libfdt and dtc, when using flattened device trees encode a node's phandle into a property named "linux,phandle". The ePAPR specification, however - aiming as it is to not be a Linux specific spec - requires that phandles be encoded in a property named simply "phandle". This patch adds support for this newer approach to dtc and libfdt. Specifically: - fdt_get_phandle() will now return the correct phandle if it is supplied in either of these properties - fdt_node_offset_by_phandle() will correctly find a node with the given phandle encoded in either property. - By default, when auto-generating phandles, dtc will encode it into both properties for maximum compatibility. A new -H option allows either only old-style or only new-style properties to be generated. - If phandle properties are explicitly supplied in the dts file, dtc will not auto-generate ones in the alternate format. - If both properties are supplied, dtc will check that they have the same value. - Some existing testcases are updated to use a mix of old and new-style phandles, partially testing the changes. - A new phandle_format test further tests the libfdt support, and the -H option. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> This was extracted from the DTC commit: d75b33af676d0beac8398651a7f09037555a550b Mon Sep 17 00:00:00 2001 Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
2010-04-13Move libfdt/ into lib/Peter Tyser
Move the libfdt directory into the common lib/ directory to clean up the top-level directory. Signed-off-by: Peter Tyser <ptyser@xes-inc.com>