1238737Simp#! /bin/bash
2238737Simp
3238737Simp# This script uses the bash <(...) extension.
4238737Simp# If you want to change this to work with a generic /bin/sh, make sure
5238737Simp# you fix that.
6238737Simp
7238737Simp
8238737SimpDTC=dtc
9238737Simp
10238737Simpsource_and_sort () {
11238737Simp    DT="$1"
12238737Simp    if [ -d "$DT" ]; then
13238737Simp	IFORMAT=fs
14238737Simp    elif [ -f "$DT" ]; then
15238737Simp	case "$DT" in
16238737Simp	    *.dts)
17238737Simp		IFORMAT=dts
18238737Simp		;;
19238737Simp	    *.dtb)
20238737Simp		IFORMAT=dtb
21238737Simp		;;
22238737Simp	esac
23238737Simp    fi
24238737Simp
25238737Simp    if [ -z "$IFORMAT" ]; then
26238737Simp	echo "Unrecognized format for $DT" >&2
27238737Simp	exit 2
28238737Simp    fi
29238737Simp
30238737Simp    $DTC -I $IFORMAT -O dts -qq -f -s -o - "$DT"
31238737Simp}
32238737Simp
33238737Simpif [ $# != 2 ]; then
34238737Simp    echo "Usage: dtdiff <device tree> <device tree>" >&2
35238737Simp    exit 1
36238737Simpfi
37238737Simp
38238737Simpdiff -u <(source_and_sort "$1") <(source_and_sort "$2")
39