kernel-module-qualcomm: add lock file to avoid endless call to script in failure

Add a lock file to avoid to call the file continuously if the initial probe
failed.

Signed-off-by: Isaac Hermida <isaac.hermida@digi.com>
This commit is contained in:
Isaac Hermida 2024-06-25 19:52:39 +02:00
parent b4f48a6361
commit fbe6481cd3
1 changed files with 13 additions and 1 deletions

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# Copyright (c) 2023 Digi International Inc. # Copyright (c) 2023,2024 Digi International Inc.
# #
# This Source Code Form is subject to the terms of the Mozilla Public # This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this # License, v. 2.0. If a copy of the MPL was not distributed with this
@ -16,6 +16,8 @@
# #
MMC_NODE="##NODE##" MMC_NODE="##NODE##"
# Lock file to track and prevent to re-run the script when rebinding the MMC node.
LOCKFILE="/tmp/qca65x4.lock"
# At this point of the boot (udev script), the system log (syslog) is not # At this point of the boot (udev script), the system log (syslog) is not
# available yet, so use the kernel log buffer from userspace. # available yet, so use the kernel log buffer from userspace.
@ -23,6 +25,12 @@ log() {
printf "<$1>qca65x4: $2\n" >/dev/kmsg printf "<$1>qca65x4: $2\n" >/dev/kmsg
} }
if test -f "$LOCKFILE"; then
# Script called due to rebinding of mmc. Ignore it and remove the lock file.
rm $LOCKFILE
exit 1
fi
# Force re-detection of the mmc node # Force re-detection of the mmc node
rebind_mmc_node() { rebind_mmc_node() {
DRIVER_NODE=$(find /sys/bus/platform/drivers -name ${MMC_NODE} | xargs dirname 2> /dev/null) || return 1 DRIVER_NODE=$(find /sys/bus/platform/drivers -name ${MMC_NODE} | xargs dirname 2> /dev/null) || return 1
@ -48,6 +56,10 @@ load_and_check && log "3" "[INFO] wlan module loaded" && exit 0
# If we are here, the load has failed. Retry. # If we are here, the load has failed. Retry.
log "3" "[WARN] Loading wlan module failed, retrying..." log "3" "[WARN] Loading wlan module failed, retrying..."
# Create a lock file, as rebinding the mmc node will trigger the udev rules
# Do not remove the file at the end, it will be called by the script in the rebind call
touch $LOCKFILE
# Try by re-binding the mmc node. # Try by re-binding the mmc node.
rebind_mmc_node && load_and_check && log "3" "[INFO] wlan module loaded" && exit 0 rebind_mmc_node && load_and_check && log "3" "[INFO] wlan module loaded" && exit 0