summaryrefslogtreecommitdiff
path: root/util/flash_fp_mcu
diff options
context:
space:
mode:
authorCraig Hesling <hesling@chromium.org>2021-02-10 11:01:22 -0800
committerCommit Bot <commit-bot@chromium.org>2021-04-29 00:17:23 +0000
commit4710b10f75d51e38725df5da00814a5a167a133b (patch)
treeb0f28cae545d10165b48406b26bfb0781fbf0860 /util/flash_fp_mcu
parent820adaf9da8b73cdb81bfe09b1132bc354afc85e (diff)
downloadchrome-ec-4710b10f75d51e38725df5da00814a5a167a133b.tar.gz
flash_fp_mcu: Clarify subshell func return behavior
Change functions whose return value we are interested in evaluating to return (instead of exit). Reserve exit syntax for explicit aborts from the script. Fix get_platform_name error case. BRANCH=none BUG=none TEST=scp util/flash_fp_mcu dut1:/usr/local/bin/flash_fp_mcu ssh dut1 flash_fp_mcu --hello TEST=# Add "return 1" in the top of get_spiid function. scp util/flash_fp_mcu dut1:/usr/local/bin/flash_fp_mcu ssh dut1 flash_fp_mcu --hello TEST=# Add "return 1" to the top of get_platform_name function. scp util/flash_fp_mcu dut1:/usr/local/bin/flash_fp_mcu ssh dut1 flash_fp_mcu --hello Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: I3acc8ef3b345db4e77b2e151f90707336c2bcead Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2686925 Reviewed-by: Josie Nordrum <josienordrum@google.com> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Diffstat (limited to 'util/flash_fp_mcu')
-rw-r--r--util/flash_fp_mcu18
1 files changed, 11 insertions, 7 deletions
diff --git a/util/flash_fp_mcu b/util/flash_fp_mcu
index a6c489e72e..552606adef 100644
--- a/util/flash_fp_mcu
+++ b/util/flash_fp_mcu
@@ -54,17 +54,17 @@ get_spiid() {
# TODO(b/179533783): Fix modalias on strongbad and remove this bypass.
if [[ -n "${DEVICEID}" ]]; then
echo "${DEVICEID}"
- exit 0
+ return 0
fi
for dev in /sys/bus/spi/devices/*; do
if [[ "$(cat "${dev}/modalias")" == "${CROS_EC_SPI_MODALIAS_STR}" ]]; then
echo "$(basename "${dev}")"
- exit 0
+ return 0
fi
done
- exit 1
+ return 1
}
# Get the uartid for the fingerprint sensor based on the modalias
@@ -73,12 +73,12 @@ get_uartid() {
if [ -f "${dev}/modalias" ]; then
if [[ "$(cat "${dev}/modalias")" == "${CROS_EC_UART_MODALIAS_STR}" ]]; then
echo "$(basename "${dev}")"
- exit 0
+ return 0
fi
fi
done
- exit 1
+ return 1
}
# Usage: gpio <unexport|export|in|out|0|1|get> <signal> [signal...]
@@ -153,7 +153,7 @@ get_platform_name() {
echo "Getting platform name from /etc/lsb-release." 1>&2
platform_name="$(lsbval "CHROMEOS_RELEASE_BOARD")"
if [[ -z "${platform_name}" ]]; then
- exit 1
+ return 1
fi
echo "${platform_name}"
@@ -485,7 +485,11 @@ config_guybrush() {
# function. Doing it in this manner allows us to reduce the number of
# configurations that we have to maintain (and reduces the amount of testing
# if we're only updating a specific config_<platform_name>).
-readonly PLATFORM_NAME="$(get_platform_name)"
+if ! PLATFORM_NAME="$(get_platform_name)"; then
+ echo "Failed to get platform name"
+ exit 1
+fi
+readonly PLATFORM_NAME
echo "Using config for ${PLATFORM_NAME}"