mac80211: make the path phy lookup more robust regarding config upgrades, allow parti...
authorFelix Fietkau <nbd@openwrt.org>
Thu, 21 Jan 2016 13:28:04 +0000 (13:28 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Thu, 21 Jan 2016 13:28:04 +0000 (13:28 +0000)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
SVN-Revision: 48425

package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
package/kernel/mac80211/files/lib/wifi/mac80211.sh

index 29dd4de40050a38221a9edb9ce8c97b57063e03e..02c195e1fa24ca1606d111d3ba364edaf29c41c3 100644 (file)
@@ -394,11 +394,10 @@ mac80211_generate_mac() {
 find_phy() {
        [ -n "$phy" -a -d /sys/class/ieee80211/$phy ] && return 0
        [ -n "$path" ] && {
-               for phy in /sys/devices/$path/ieee80211/phy*; do
-                       [ -e "$phy" ] && {
-                               phy="${phy##*/}"
-                               return 0
-                       }
+               for phy in $(ls /sys/class/ieee80211 2>/dev/null); do
+                       case "$(readlink -f /sys/class/ieee80211/$phy/device)" in
+                               *$path) return 0;;
+                       esac
                done
        }
        [ -n "$macaddr" ] && {
index ea229d6c03393d4673c733c99ead4c24ff92817d..3fc39c26f274a4dae8e54a8f6a14ddc4ad26f6ce 100644 (file)
@@ -10,10 +10,9 @@ lookup_phy() {
        config_get devpath "$device" path
        [ -n "$devpath" ] && {
                for _phy in /sys/devices/$devpath/ieee80211/phy*; do
-                       [ -e "$_phy" ] && {
-                               phy="${_phy##*/}"
-                               return
-                       }
+                       case "$(readlink -f /sys/class/ieee80211/$_phy/device)" in
+                               *$devpath) return 0;;
+                       esac
                done
        }