From 4fd60b9b33d0ac240349ea179fbb0a15535e7693 Mon Sep 17 00:00:00 2001 From: nbd Date: Thu, 21 Jan 2016 13:28:04 +0000 Subject: [PATCH] mac80211: make the path phy lookup more robust regarding config upgrades, allow partial path matching Signed-off-by: Felix Fietkau git-svn-id: svn://svn.openwrt.org/openwrt/trunk@48425 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh | 9 ++++----- package/kernel/mac80211/files/lib/wifi/mac80211.sh | 7 +++---- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh index 29dd4de400..02c195e1fa 100644 --- a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh +++ b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh @@ -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" ] && { diff --git a/package/kernel/mac80211/files/lib/wifi/mac80211.sh b/package/kernel/mac80211/files/lib/wifi/mac80211.sh index ea229d6c03..3fc39c26f2 100644 --- a/package/kernel/mac80211/files/lib/wifi/mac80211.sh +++ b/package/kernel/mac80211/files/lib/wifi/mac80211.sh @@ -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 } -- 2.11.0