X-Git-Url: http://git.openwrt.org/?p=openwrt%2Fopenwrt.git;a=blobdiff_plain;f=package%2Fkernel%2Fmac80211%2Ffiles%2Flib%2Fwifi%2Fmac80211.sh;h=940fb52ac273a421823e3169907e39c84fedc2ea;hp=1f69b47193a35d743286b685599eb03ba0cdc7be;hb=fd84ecda7d3bfebb4237110b8efe2ab2713ea8e1;hpb=58bda3a0e158f93929c41fcce0849c835581b77e diff --git a/package/kernel/mac80211/files/lib/wifi/mac80211.sh b/package/kernel/mac80211/files/lib/wifi/mac80211.sh index 1f69b47193..940fb52ac2 100644 --- a/package/kernel/mac80211/files/lib/wifi/mac80211.sh +++ b/package/kernel/mac80211/files/lib/wifi/mac80211.sh @@ -8,16 +8,21 @@ lookup_phy() { local devpath config_get devpath "$device" path - [ -n "$devpath" -a -d "/sys/devices/$devpath/ieee80211" ] && { - phy="$(ls /sys/devices/$devpath/ieee80211 | grep -m 1 phy)" - [ -n "$phy" ] && return + [ -n "$devpath" ] && { + 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 } @@ -61,55 +66,67 @@ 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 - mode_11n="" mode_band="g" channel="11" htmode="" + ht_capab="" iw phy "$dev" info | grep -q 'Capabilities:' && htmode=HT20 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" } - [ -n $htmode ] && append ht_capab " option htmode $htmode" "$N" + [ -n "$htmode" ] && ht_capab="set wireless.radio${devidx}.htmode=$htmode" - 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/}" - dev_id=" option path '$path'" + case "$path" in + platform*/pci*) path="${path##platform/}";; + esac + dev_id="set wireless.radio${devidx}.path='$path'" else - dev_id=" option macaddr $(cat /sys/class/ieee80211/${dev}/macaddress)" + dev_id="set wireless.radio${devidx}.macaddr=$(cat /sys/class/ieee80211/${dev}/macaddress)" fi - cat <