broadcom-wl: align with mac80211 config
[openwrt/svn-archive/archive.git] / package / kernel / broadcom-wl / files / lib / wifi / broadcom.sh
index 69e3132967595fa686fa8fdee0e454a22c3c7597..65179a569274b3c195ce02703c4b21b77f3180d0 100644 (file)
@@ -199,11 +199,20 @@ enable_broadcom() {
        }
 
        # Use 'chanspec' instead of 'channel' for 'N' modes (See bcmwifi.h)
        }
 
        # Use 'chanspec' instead of 'channel' for 'N' modes (See bcmwifi.h)
-       [ ${nmode:-0} -ne 0 -a -n "$band" -a -n "$channel" ] && {
+       [ -n "$nmode" -a -n "$band" -a -n "$channel" ] && {
                case "$htmode" in
                case "$htmode" in
-                       HT40-)  chanspec=$(printf 0x%x%x%02x $band 0xe $(($channel - 2))); channel=;;
-                       HT40+)  chanspec=$(printf 0x%x%x%02x $band 0xd $(($channel + 2))); channel=;;
-                       HT20)   chanspec=$(printf 0x%x%x%02x $band 0xb $channel); channel=;;
+                       HT40)
+                               if [ -n "$gmode" ]; then
+                                       [ $channel -lt 7 ] && htmode="HT40+" || htmode="HT40-"
+                               else
+                                       [ $(( ($channel / 4) % 2 )) -eq 1 ] && htmode="HT40+" || htmode="HT40-"
+                               fi
+                       ;;
+               esac
+               case "$htmode" in
+                       HT40-)  chanspec=$(printf 0x%x%x%02x $band 0xe $(($channel - 2))); nmode=1; channel=;;
+                       HT40+)  chanspec=$(printf 0x%x%x%02x $band 0xd $(($channel + 2))); nmode=1; channel=;;
+                       HT20)   chanspec=$(printf 0x%x%x%02x $band 0xb $channel); nmode=1; channel=;;
                        *) ;;
                esac
        }
                        *) ;;
                esac
        }