blob: cdbf0791e00c896ac2fa388153dd59fbe66b147a [file] [log] [blame]
David Gibson37c0b6a2010-11-10 09:51:09 +11001#! /bin/bash
Rob Herring4097bbf2019-06-20 15:19:43 -06002# SPDX-License-Identifier: GPL-2.0-or-later
David Gibson37c0b6a2010-11-10 09:51:09 +11003
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
9DTC=dtc
10
11source_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
34if [ $# != 2 ]; then
35 echo "Usage: dtdiff <device tree> <device tree>" >&2
36 exit 1
37fi
38
39diff -u <(source_and_sort "$1") <(source_and_sort "$2")