-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dtc: Add code to make diffing trees easier
This patch adds a "dtdiff" script to do a useful form diff of two device trees. This automatically converts the tree to dts form (if it's not already) and uses a new "-s" option in dtc to "sort" the tree. That is, it sorts the reserve entries, it sorts the properties within each node by name, and it sorts nodes by name within their parent. This gives a pretty sensible diff between the trees, which will ignore semantically null internal rearrangements (directly diffing the dts files can give a lot of noise due to the order changes). Signed-off-by: David Gibson <[email protected]>
- Loading branch information
Showing
6 changed files
with
196 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#! /bin/bash | ||
|
||
# This script uses the bash <(...) extension. | ||
# If you want to change this to work with a generic /bin/sh, make sure | ||
# you fix that. | ||
|
||
|
||
DTC=dtc | ||
|
||
source_and_sort () { | ||
DT="$1" | ||
if [ -d "$DT" ]; then | ||
IFORMAT=fs | ||
elif [ -f "$DT" ]; then | ||
case "$DT" in | ||
*.dts) | ||
IFORMAT=dts | ||
;; | ||
*.dtb) | ||
IFORMAT=dtb | ||
;; | ||
esac | ||
fi | ||
|
||
if [ -z "$IFORMAT" ]; then | ||
echo "Unrecognized format for $DT" >&2 | ||
exit 2 | ||
fi | ||
|
||
$DTC -I $IFORMAT -O dts -qq -f -s -o - "$DT" | ||
} | ||
|
||
if [ $# != 2 ]; then | ||
echo "Usage: dtdiff <device tree> <device tree>" >&2 | ||
exit 1 | ||
fi | ||
|
||
diff -u <(source_and_sort "$1") <(source_and_sort "$2") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters