summaryrefslogtreecommitdiff
path: root/dtdiff
blob: 5fa772b0ab6215531ee46f6f9936024ca2bb4782 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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")