mac80211: rely on iwinfo for phy->path and path->phy lookups
authorFelix Fietkau <nbd@nbd.name>
Wed, 9 Jun 2021 12:32:32 +0000 (14:32 +0200)
committerFelix Fietkau <nbd@nbd.name>
Thu, 10 Jun 2021 08:15:39 +0000 (10:15 +0200)
This avoids inconsistencies from having multiple implementations do the same thing

Signed-off-by: Felix Fietkau <nbd@nbd.name>
package/kernel/mac80211/Makefile
package/kernel/mac80211/files/lib/netifd/mac80211.sh [deleted file]
package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
package/kernel/mac80211/files/lib/wifi/mac80211.sh

index a8a84f843a79b3fcff23968e2cafd811c05edf2a..0ade95e35ee110246a98cd42dc89eb2fc631141b 100644 (file)
@@ -549,7 +549,6 @@ endef
 define KernelPackage/cfg80211/install
        $(INSTALL_DIR) $(1)/lib/wifi $(1)/lib/netifd/wireless
        $(INSTALL_DATA) ./files/lib/wifi/mac80211.sh $(1)/lib/wifi
-       $(INSTALL_DATA) ./files/lib/netifd/mac80211.sh $(1)/lib/netifd
        $(INSTALL_BIN) ./files/lib/netifd/wireless/mac80211.sh $(1)/lib/netifd/wireless
        $(INSTALL_DIR) $(1)/etc/hotplug.d/ieee80211
        $(INSTALL_DATA) ./files/mac80211.hotplug $(1)/etc/hotplug.d/ieee80211/10-wifi-detect
diff --git a/package/kernel/mac80211/files/lib/netifd/mac80211.sh b/package/kernel/mac80211/files/lib/netifd/mac80211.sh
deleted file mode 100644 (file)
index 92e5c0e..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-mac80211_phy_to_path() {
-       local phy="$1"
-
-       [ -x /usr/bin/readlink -a -h /sys/class/ieee80211/${phy} ] || return
-
-       local path="$(readlink -f /sys/class/ieee80211/${phy}/device)"
-       [ -n "$path" ] || return
-
-       path="${path##/sys/devices/}"
-       case "$path" in
-               platform*/pci*) path="${path##platform/}";;
-       esac
-
-       local p
-       local seq=""
-       for p in $(ls /sys/class/ieee80211/$phy/device/ieee80211); do
-               [ "$p" = "$phy" ] && {
-                       echo "$path${seq:++$seq}"
-                       break
-               }
-
-               seq=$((${seq:-0} + 1))
-       done
-}
-
-mac80211_path_to_phy() {
-       local path="$1"
-
-       local p
-       for p in $(ls /sys/class/ieee80211); do
-               local cur="$(mac80211_phy_to_path "$p")"
-               case "$cur" in
-                       *$path) echo "$p"; return;;
-               esac
-       done
-}
index f1ed47802a934b72ad39dbdd96a63d050b63cc07..c9a0fe542ac669dd78ff28330596fba890cd5503 100644 (file)
@@ -1,7 +1,6 @@
 #!/bin/sh
 . /lib/netifd/netifd-wireless.sh
 . /lib/netifd/hostapd.sh
-. /lib/netifd/mac80211.sh
 
 init_wireless_driver "$@"
 
@@ -546,7 +545,7 @@ mac80211_generate_mac() {
 find_phy() {
        [ -n "$phy" -a -d /sys/class/ieee80211/$phy ] && return 0
        [ -n "$path" ] && {
-               phy="$(mac80211_path_to_phy "$path")"
+               phy="$(iwinfo nl80211 phyname "path=$path")"
                [ -n "$phy" ] && return 0
        }
        [ -n "$macaddr" ] && {
index 5eb7cc4c610771a0b822201e9d86703b0cac9b8f..6aa46b0c747c023e5e02020e0f9212c00eda9cc8 100644 (file)
@@ -1,5 +1,4 @@
 #!/bin/sh
-. /lib/netifd/mac80211.sh
 
 append DRIVERS "mac80211"
 
@@ -11,7 +10,7 @@ lookup_phy() {
        local devpath
        config_get devpath "$device" path
        [ -n "$devpath" ] && {
-               phy="$(mac80211_path_to_phy "$devpath")"
+               phy="$(iwinfo nl80211 phyname "path=$devpath")"
                [ -n "$phy" ] && return
        }
 
@@ -161,7 +160,7 @@ detect_mac80211() {
 
                get_band_defaults "$dev"
 
-               path="$(mac80211_phy_to_path "$dev")"
+               path="$(iwinfo nl80211 path "$dev")"
                if [ -n "$path" ]; then
                        dev_id="set wireless.radio${devidx}.path='$path'"
                else