meta-ampere: fix shellcheck issues
Fix all issues from the shellcheck checked on bash shells under
meta-ampere.
Tested: Verify the following features:
1. Power control (on,off, cycle, graceful shutdown, hard reset).
2. UART switching.
3. UEFI firmware update.
Signed-off-by: Thang Q. Nguyen <thang@os.amperecomputing.com>
Change-Id: Idabf839b7521ecadb642230cc8bb3472c787002e
diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/gpio-lib.sh b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/gpio-lib.sh
index 8d1aa61..c8721fe 100644
--- a/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/gpio-lib.sh
+++ b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/gpio-lib.sh
@@ -1,31 +1,33 @@
#!/bin/bash
+
+# shellcheck source=/dev/null
source /usr/sbin/gpio-defs.sh
function gpio_number() {
- GPIO_BASE=$(cat /sys/class/gpio/gpiochip$GPIO_CHIP0_BASE/base)
- echo $((${GPIO_BASE} + $1))
+ GPIO_BASE=$(cat /sys/class/gpio/gpiochip"$GPIO_CHIP0_BASE"/base)
+ echo $((GPIO_BASE + $1))
}
# Configure GPIO as output and set its value
function gpio_configure_output() {
- gpioId=$(gpio_number $1)
- echo $gpioId > /sys/class/gpio/export
- echo out > /sys/class/gpio/gpio${gpioId}/direction
- echo $2 > /sys/class/gpio/gpio${gpioId}/value
- echo $gpioId > /sys/class/gpio/unexport
+ gpioId=$(gpio_number "$1")
+ echo "$gpioId" > /sys/class/gpio/export
+ echo out > /sys/class/gpio/gpio"${gpioId}"/direction
+ echo "$2" > /sys/class/gpio/gpio"${gpioId}"/value
+ echo "$gpioId" > /sys/class/gpio/unexport
}
function gpio_get_val() {
- gpioId=$(gpio_number $1)
- echo $gpioId > /sys/class/gpio/export
- echo $(cat /sys/class/gpio/gpio$gpioId/value)
- echo $gpioId > /sys/class/gpio/unexport
+ gpioId=$(gpio_number "$1")
+ echo "$gpioId" > /sys/class/gpio/export
+ cat /sys/class/gpio/gpio"$gpioId"/value
+ echo "$gpioId" > /sys/class/gpio/unexport
}
# Configure GPIO as input
function gpio_configure_input() {
- gpioId=$(gpio_number $1)
- echo $gpioId > /sys/class/gpio/export
- echo "in" > /sys/class/gpio/gpio${gpioId}/direction
- echo $gpioId > /sys/class/gpio/unexport
+ gpioId=$(gpio_number "$1")
+ echo "$gpioId" > /sys/class/gpio/export
+ echo "in" > /sys/class/gpio/gpio"${gpioId}"/direction
+ echo "$gpioId" > /sys/class/gpio/unexport
}