From eb59d14aacc23d2401d91411eeb2cd55df4033fa Mon Sep 17 00:00:00 2001
From: Felix Fietkau <nbd@openwrt.org>
Date: Fri, 2 Oct 2009 19:41:04 +0000
Subject: [PATCH] mac80211: autodetect the default phy mode based on 11n and
 freq capabilities

SVN-Revision: 17825
---
 package/mac80211/files/lib/wifi/mac80211.sh | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/package/mac80211/files/lib/wifi/mac80211.sh b/package/mac80211/files/lib/wifi/mac80211.sh
index 3acb3dc1cc..a7b3005dd9 100644
--- a/package/mac80211/files/lib/wifi/mac80211.sh
+++ b/package/mac80211/files/lib/wifi/mac80211.sh
@@ -272,12 +272,17 @@ detect_mac80211() {
 			[ -n "$type" ] || break
 			devidx=$(($devidx + 1))
 		done
+		mode_11n=""
+		mode_band="g"
+		iw phy "$dev" info | grep -q 'HT cap' && mode_11n="n"
+		iw phy "$dev" info | grep -q '2412 MHz' || mode_band="a"
 
 		cat <<EOF
 config wifi-device  wifi$devidx
 	option type     mac80211
 	option channel  5
 	option macaddr	$(cat /sys/class/ieee80211/${dev}/macaddress)
+	option hwmode	11${mode_11n}${mode_band}
 	# REMOVE THIS LINE TO ENABLE WIFI:
 	option disabled 1
 
-- 
GitLab