hothd: Pass usb-device to USB helper scripts
When sourcing helper scripts from .../hothd/usb-config/*.sh,
provide the current USB device (provided by udev) as the first argument
to the script.
This allows simplification of those sourced scripts and improved
maintainability.
Google-Bug-Id: 413123154
Change-Id: Ia094c961ddcf93464b3a50e32ba810936f616551
Signed-off-by: Tom Craig <craigt@google.com>
diff --git a/hothd_usb.sh.in b/hothd_usb.sh.in
index 9f13941..49d104d 100644
--- a/hothd_usb.sh.in
+++ b/hothd_usb.sh.in
@@ -5,13 +5,15 @@
declare -A IGNORE_ADDRESS_MODE=()
declare -A UART_CHANNEL_ID=()
shopt -s nullglob
+
+usb="$(basename "$1")"
+
for cfg in '@datadir@'/hothd/usb-config/*.sh; do
# Followed https://www.shellcheck.net/wiki/SC1090 for dynamic source target
# shellcheck source=/dev/null
- source "$cfg" || exit
+ source "$cfg" "$usb" || exit
done
-usb="$(basename "$1")"
name="${HOTH_USB_NAMES["$usb"]}"
if [ -z "$name" ]; then
echo "Missing mapping for $usb" >&2