ubus: update to the latest version, adds a race fix for wait_for
[openwrt/openwrt.git] / package / kernel / mac80211 / files / lib / wifi / mac80211.sh
index a7c4d2dbc2bce08b95ee3f5bbaf86a6d01180a2f..9b15de55a8986fa9d354ccb5c92d65edf2b4f514 100644 (file)
@@ -9,11 +9,10 @@ lookup_phy() {
        local devpath
        config_get devpath "$device" path
        [ -n "$devpath" ] && {
-               for _phy in /sys/devices/$devpath/ieee80211/phy*; do
-                       [ -e "$_phy" ] && {
-                               phy="${_phy##*/}"
-                               return
-                       }
+               for phy in $(ls /sys/class/ieee80211 2>/dev/null); do
+                       case "$(readlink -f /sys/class/ieee80211/$phy/device)" in
+                               *$devpath) return;;
+                       esac
                done
        }
 
@@ -86,7 +85,8 @@ detect_mac80211() {
                iw phy "$dev" info | grep -q '2412 MHz' || { mode_band="a"; channel="36"; }
 
                vht_cap=$(iw phy "$dev" info | grep -c 'VHT Capabilities')
-               [ "$vht_cap" -gt 0 ] && {
+               cap_5ghz=$(iw phy "$dev" info | grep -c "Band 2")
+               [ "$vht_cap" -gt 0 -a "$cap_5ghz" -gt 0 ] && {
                        mode_band="a";
                        channel="36"
                        htmode="VHT80"
@@ -101,6 +101,9 @@ detect_mac80211() {
                fi
                if [ -n "$path" ]; then
                        path="${path##/sys/devices/}"
+                       case "$path" in
+                               platform*/pci*) path="${path##platform/}";;
+                       esac
                        dev_id="        option path     '$path'"
                else
                        dev_id="        option macaddr  $(cat /sys/class/ieee80211/${dev}/macaddress)"
@@ -120,7 +123,7 @@ config wifi-iface
        option device   radio$devidx
        option network  lan
        option mode     ap
-       option ssid     OpenWrt
+       option ssid     LEDE
        option encryption none
 
 EOF