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