David Gibson | 37c0b6a | 2010-11-10 09:51:09 +1100 | [diff] [blame] | 1 | #! /bin/bash |
Rob Herring | 4097bbf | 2019-06-20 15:19:43 -0600 | [diff] [blame] | 2 | # SPDX-License-Identifier: GPL-2.0-or-later |
David Gibson | 37c0b6a | 2010-11-10 09:51:09 +1100 | [diff] [blame] | 3 | |
| 4 | # This script uses the bash <(...) extension. |
| 5 | # If you want to change this to work with a generic /bin/sh, make sure |
| 6 | # you fix that. |
| 7 | |
| 8 | |
| 9 | DTC=dtc |
| 10 | |
| 11 | source_and_sort () { |
| 12 | DT="$1" |
| 13 | if [ -d "$DT" ]; then |
| 14 | IFORMAT=fs |
| 15 | elif [ -f "$DT" ]; then |
| 16 | case "$DT" in |
| 17 | *.dts) |
| 18 | IFORMAT=dts |
| 19 | ;; |
| 20 | *.dtb) |
| 21 | IFORMAT=dtb |
| 22 | ;; |
| 23 | esac |
| 24 | fi |
| 25 | |
| 26 | if [ -z "$IFORMAT" ]; then |
| 27 | echo "Unrecognized format for $DT" >&2 |
| 28 | exit 2 |
| 29 | fi |
| 30 | |
| 31 | $DTC -I $IFORMAT -O dts -qq -f -s -o - "$DT" |
| 32 | } |
| 33 | |
| 34 | if [ $# != 2 ]; then |
| 35 | echo "Usage: dtdiff <device tree> <device tree>" >&2 |
| 36 | exit 1 |
| 37 | fi |
| 38 | |
| 39 | diff -u <(source_and_sort "$1") <(source_and_sort "$2") |