branding: add LEDE branding
[openwrt/staging/florian.git] / package / kernel / mac80211 / files / lib / wifi / mac80211.sh
index a3b2199507f91fb44f5edb37d4445f0a420ea3ce..77247cb3993a18f62b1b87f8f889a7f2f39d2d80 100644 (file)
@@ -9,19 +9,20 @@ 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
        }
 
        local macaddr="$(config_get "$device" macaddr | tr 'A-Z' 'a-z')"
        [ -n "$macaddr" ] && {
-               for _phy in $(ls /sys/class/ieee80211 2>/dev/null); do
-                       [ "$macaddr" = "$(cat /sys/class/ieee80211/${_phy}/macaddress)" ] || continue
-                       phy="$_phy"
+               for _phy in /sys/class/ieee80211/*; do
+                       [ -e "$_phy" ] || continue
+
+                       [ "$macaddr" = "$(cat ${_phy}/macaddress)" ] || continue
+                       phy="${_phy##*/}"
                        return
                done
        }
@@ -65,7 +66,12 @@ detect_mac80211() {
                [ -n "$type" ] || break
                devidx=$(($devidx + 1))
        done
-       for dev in $(ls /sys/class/ieee80211); do
+
+       for _dev in /sys/class/ieee80211/*; do
+               [ -e "$_dev" ] || continue
+
+               dev="${_dev##*/}"
+
                found=0
                config_foreach check_mac80211_device wifi-device
                [ "$found" -gt 0 ] && continue
@@ -79,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"
@@ -87,9 +94,16 @@ detect_mac80211() {
 
                [ -n $htmode ] && append ht_capab "     option htmode   $htmode" "$N"
 
-               if [ -x /usr/bin/readlink ]; then
+               if [ -x /usr/bin/readlink -a -h /sys/class/ieee80211/${dev} ]; then
                        path="$(readlink -f /sys/class/ieee80211/${dev}/device)"
+               else
+                       path=""
+               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)"
@@ -109,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