mac80211: fix detecting highest radio* config section index
authorFelix Fietkau <nbd@nbd.name>
Mon, 10 Oct 2022 11:26:32 +0000 (13:26 +0200)
committerFelix Fietkau <nbd@nbd.name>
Fri, 14 Oct 2022 11:12:49 +0000 (13:12 +0200)
Deal with gaps by iterating over existing sections instead of counting

Signed-off-by: Felix Fietkau <nbd@nbd.name>
package/kernel/mac80211/files/lib/wifi/mac80211.sh

index 6aa46b0c747c023e5e02020e0f9212c00eda9cc8..c46498b0d402f12b89f5ea04cdf0e9f7d19a554e 100644 (file)
@@ -135,14 +135,19 @@ get_band_defaults() {
        done
 }
 
+check_devidx() {
+       case "$1" in
+       radio[0-9]*)
+               local idx="${1#radio}"
+               [ "$devidx" -ge "${1#radio}" ] && devidx=$((idx + 1))
+               ;;
+       esac
+}
+
 detect_mac80211() {
        devidx=0
        config_load wireless
-       while :; do
-               config_get type "radio$devidx" type
-               [ -n "$type" ] || break
-               devidx=$(($devidx + 1))
-       done
+       config_foreach check_devidx wifi-device
 
        for _dev in /sys/class/ieee80211/*; do
                [ -e "$_dev" ] || continue