[openwrt/openwrt] mac80211: change the default config for a renamed wiphy

LEDE Commits lede-commits at lists.infradead.org
Fri Oct 14 04:19:01 PDT 2022


nbd pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/50a03decdf32624c19cbcdd8713eda5e0011eaac

commit 50a03decdf32624c19cbcdd8713eda5e0011eaac
Author: Felix Fietkau <nbd at nbd.name>
AuthorDate: Fri Sep 23 14:39:59 2022 +0200

    mac80211: change the default config for a renamed wiphy
    
    use option phy to reference the device instead of path/macaddr
    
    Signed-off-by: Felix Fietkau <nbd at nbd.name>
---
 package/kernel/mac80211/files/lib/wifi/mac80211.sh | 49 ++++++++++++----------
 1 file changed, 28 insertions(+), 21 deletions(-)

diff --git a/package/kernel/mac80211/files/lib/wifi/mac80211.sh b/package/kernel/mac80211/files/lib/wifi/mac80211.sh
index c46498b0d4..7166f3a12c 100644
--- a/package/kernel/mac80211/files/lib/wifi/mac80211.sh
+++ b/package/kernel/mac80211/files/lib/wifi/mac80211.sh
@@ -165,31 +165,38 @@ detect_mac80211() {
 
 		get_band_defaults "$dev"
 
-		path="$(iwinfo nl80211 path "$dev")"
-		if [ -n "$path" ]; then
-			dev_id="set wireless.radio${devidx}.path='$path'"
-		else
-			dev_id="set wireless.radio${devidx}.macaddr=$(cat /sys/class/ieee80211/${dev}/macaddress)"
-		fi
+		name="radio${devidx}"
+		devidx=$(($devidx + 1))
+		case "$dev" in
+			phy*)
+				path="$(iwinfo nl80211 path "$dev")"
+				if [ -n "$path" ]; then
+					dev_id="set wireless.${name}.path='$path'"
+				else
+					dev_id="set wireless.${name}.macaddr=$(cat /sys/class/ieee80211/${dev}/macaddress)"
+				fi
+				;;
+			*)
+				dev_id="set wireless.${name}.phy='$dev'"
+				;;
+		esac
 
 		uci -q batch <<-EOF
-			set wireless.radio${devidx}=wifi-device
-			set wireless.radio${devidx}.type=mac80211
+			set wireless.${name}=wifi-device
+			set wireless.${name}.type=mac80211
 			${dev_id}
-			set wireless.radio${devidx}.channel=${channel}
-			set wireless.radio${devidx}.band=${mode_band}
-			set wireless.radio${devidx}.htmode=$htmode
-			set wireless.radio${devidx}.disabled=1
-
-			set wireless.default_radio${devidx}=wifi-iface
-			set wireless.default_radio${devidx}.device=radio${devidx}
-			set wireless.default_radio${devidx}.network=lan
-			set wireless.default_radio${devidx}.mode=ap
-			set wireless.default_radio${devidx}.ssid=OpenWrt
-			set wireless.default_radio${devidx}.encryption=none
+			set wireless.${name}.channel=${channel}
+			set wireless.${name}.band=${mode_band}
+			set wireless.${name}.htmode=$htmode
+			set wireless.${name}.disabled=1
+
+			set wireless.default_${name}=wifi-iface
+			set wireless.default_${name}.device=${name}
+			set wireless.default_${name}.network=lan
+			set wireless.default_${name}.mode=ap
+			set wireless.default_${name}.ssid=OpenWrt
+			set wireless.default_${name}.encryption=none
 EOF
 		uci -q commit wireless
-
-		devidx=$(($devidx + 1))
 	done
 }




More information about the lede-commits mailing list