summarylogtreecommitdiffstats
path: root/lib_gpio-present.sh
diff options
context:
space:
mode:
Diffstat (limited to 'lib_gpio-present.sh')
-rw-r--r--lib_gpio-present.sh12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib_gpio-present.sh b/lib_gpio-present.sh
new file mode 100644
index 000000000000..af6f9fc9c980
--- /dev/null
+++ b/lib_gpio-present.sh
@@ -0,0 +1,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
+}