summarylogtreecommitdiffstats
path: root/lib_gpio-present.sh
blob: af6f9fc9c9805f937d79a00ff28cc038be53d581 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
gpio_present() {
    for CHIP in /sys/class/gpio/gpiochip*; do
        if [ -d "$CHIP" ]; then
            BASE=`cat "$CHIP/base" || true`
            NGPIO=`cat "$CHIP/ngpio" || true`
            if [ -n "$BASE" ] && [ -n "$NGPIO" ] && [ "$1" -ge "$BASE" ] && [ "$1" -lt "$(($BASE+$NGPIO))" ]; then
                return 0
            fi
        fi
    done
    return 1
}