summaryrefslogtreecommitdiffstats
path: root/commands/of_diff.c
Commit message (Collapse)AuthorAgeFilesLines
* of: don't report failure to of_read_file twiceAhmad Fatoum2024-03-051-3/+2
| | | | | | | | | of_read_file already prints to log messages when it fails, so duplicating the error message in the caller is needlessly verbose. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-11-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: of_diff: support applying fixups on arbitrary device treesAhmad Fatoum2023-06-091-8/+22
| | | | | | | | | | | | | | | | | | | | of_diff - + is quite useful to find what fixups barebox would apply to its own device tree. But for some cases, like barebox-state or OP-TEE reservations, the nodes that would be fixed up into the kernel device tree already exist within the barebox device tree and wouldn't be shown by of_diff - +. To make them visible, let's redefine +: - Previously, it always meant the fixed up barebox DT - Now, it means the other DT with fixups applied That way, of_diff - + continues to work, but kernel DTs can now be diffed against their fixed up version by doing: of_diff /mnt/tftp/afa-oftree-myboard + Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230608134040.2123869-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: of_diff: simplify error handlingAhmad Fatoum2023-06-091-36/+19
| | | | | | | | | | | | The error check and message is duplicated for each argument and could be unified if we move it to get_tree instead. While at it, we limit argc to exactly 3 in case we want to add options in the future. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230608134040.2123869-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: add function to read a file as unflattened device treeSascha Hauer2023-05-221-12/+1
| | | | | | | | There are several places in the tree that read in a dtb file and unflatten it. Add a of_read_file() helper function for that and use it where appropriately. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: report whether of_diff found differences in return codeAhmad Fatoum2022-02-071-3/+1
| | | | | | | | | | | Tests may want to leverage of_diff to verify that fixups proceeded as expected. of_diff lends itself nicely to that by being silent in case of success and just reporting diff on error. Add a return code to make it usable in follow-up tests. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220207082801.1052894-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fdt: Check blob size during unflatteningSascha Hauer2021-06-251-1/+1
| | | | | | | | | | | of_unflatten_dtb() doesn't check the size of the device tree blob passed to it. Add a size argument end add checks for the size. Some callers have no idea of the buffer size themselves, INT_MAX is passed in these cases. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210624085223.14616-4-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: Add function to duplicate a device treeSascha Hauer2021-06-251-2/+2
| | | | | | | | | | | | | | This adds of_dup() to duplicate a device tree. Previously of_copy_node() was used for this, but of_copy_node() has issues with potentially duplicated phandle values when the new tree is inserted to an existing tree, that is when the parent argument of of_copy_node() is non NULL. All users of of_copy_node() with a NULL parent argument are converted to of_dup() which is safe to use leaving only the problematic users of of_copy_node(). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210624085223.14616-3-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* vsprintf: retire strerrorp in favor of %peAhmad Fatoum2020-09-291-2/+2
| | | | | | | | | strerrorp() is only used along with printf. We now have a format specifier for printing error pointers directly, so use that and remove strerrorp. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands/*: Replace license and copyright boilerplate by SPDX identfiersUwe Kleine-König2020-04-271-7/+4
| | | | | | | | | | | | | While at it also drop references to the non-existing CREDITS file and do some small rearrangements for some uniform formatting. (SPDX-License-Identifier first, then copyright texts and then an empty line.) The advantage is that these specifiers are machine-parseable which helps license conformance. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* add of_diff commandSascha Hauer2019-09-121-0/+108
The of_diff command compares two device trees against each other and prints a diff-like result. This can be handy to find out the differences between the barebox live tree and the one we start the kernel with. Another usecase would be to examine the changes our of_fixup process introduces (of_diff - +) Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>