With considerable delay due to the workload at Ceata and Tehnoetic, support for ath9k_htc WiFi adapters is now enabled in a modified nonofficial version of Replicant 4.2 (tested with Tehnoetic S2 i9100 and S3 i9300 phones for now). A big thank you to Paul, Replicant lead developer, for answering Tiberiu's technical questions, to our Tehnoetic colleague Florentin for the assistance with testing the WiFi support and of course to our wonderful customers and donor(s).
For using the Tehonetic WiFi in Replicant 4.2, one has to do one of the following:
OR…
For S2 i9100:
md5sum replicant-4.2-i9100-nonofficial-tehnoetic.zip 2eda7d1e49dfd299e59ffdb881bc1a17 replicant-4.2-i9100-nonofficial-tehnoetic.zip
For S3 i9300:
md5sum replicant-4.2-i9300-nonofficial-tehnoetic.zip 089e9de83a6e62aad63cf1a0dc37b115 replicant-4.2-i9300-nonofficial-tehnoetic.zip
To have WiFi using this modified nonofficial Replicant version we use command line. The plan was and still is to have full ath9k_htc integration with the GUI, but this proved to involve heavy changes due to the fact the Android Java and C++ code for S2 is written for the way the internal Broadcom chip works. We will do our best to develop GUI integration in newer version of Replicant. Your orders from Tehnoetic and your donations to Tiberiu can help speed up the development.
Tested on Tehnoetic S2 phone and Tehnoetic S2 phone to work with AR9271-based adapters:
For orders at Tehnoetic, we accept credit card (don't need to log into PayPal), PayPal, Bitcoin and for EU customers, bank transfer too.
To donate, you don't need to have a PayPal account or to log in your PayPal account. You can donate by credit card by clicking on the Continue link at the bottom of the page.
Warning! This modified nonofficial Replicant version is experimental and until this moment we haven't been able to get WiFi working after a reboot without reformatting /data partition. We are not responsible for any loss of your applications and settings you had saved in /data partition. That's why we recommend backing up the /data partition.
First, we recommed you back up your /data partition using `adb pull' or `adb backup'. For installing ADB, see ToolsInstallation at Replicant wiki.
Get root shell with ADB after you connect the phone to your computer in Debugging mode.
adb root adb shell
Or get root shell using the free Terminal application. Open it and type:
su
Grant the Terminal application the rights to use root.
Insert driver modules in this correct order using insmod.
adb shell cd /system/lib/modules/ insmod mac80211.ko && insmod ath.ko && insmod ath9k_hw.ko && insmod ath9k_common.ko && insmod ath9k_htc.ko
Inserting these drivers using dependencies with `modprobe ath9k_htc' seems to throw warnings regarding missing symbols, as shown by dmesg. So for now don't use modprobe, use insmod instead.
Extract and copy in the anonical location the free firmware v1.3.1 from the Trisquel package
adb push htc_9271.fw /sdcard/ adb shell mount -o rw,remount /system # /system fs is read-only mkdir /etc/firmware/ cp /sdcard/htc_9271.fw /etc/firmware/ mount -o ro,remount /system
Save the name (SSID) and password of your WPA2 network.
adb shell nano /data/misc/wifi/wpa_supplicant.conf
Or create the file locally with your favorite editor:
network={ ssid="My Network Name" psk="MyNetworkPassword" }
and then upload it onto the phone:
adb push wpa_supplicant.conf /data/misc/wifi/
Create this small script file which launches wpa_supplicant and sends a DHCP request to your WiFi router.
adb shell nano /data/misc/wifi/connect.sh
wpa_supplicant -B -iwlan0 -c/data/misc/wifi/wpa_supplicant.conf dhcpcd wlan0
Use an OTG cable to connect the Tehnoetic WiFi mini adapter (AR9271-based) to the phone. If you can use a “Y” one or a USB hub to power the adapter from an external current source, that can save you from system crashes that can happen because of potential power consumption spikes.
Use the Terminal application to login as root and run the connect script:
su bash /data/misc/wifi/connect.sh dhcpcd[3566]: version 5.5.6 starting dhcpcd[3566]: wlan0: waiting for carrier dhcpcd[3566]: wlan0: carrier acquired dhcpcd[3566]: wlan0: broadcasting for a lease dhcpcd[3566]: wlan0: offered 192.168.0.104 from 192.168.0.1 dhcpcd[3566]: wlan0: acknowledged 192.168.0.104 from 192.168.0.1 dhcpcd[3566]: wlan0: checking for 192.168.0.104 dhcpcd[3566]: wlan0: leased 192.168.0.104 for 7200 seconds dhcpcd[3566]: forked to background, chid pid 3624
Test the Internet connection using ping:
ping replicant.us
If replicant.us can't be resolved, ping a public IP:
ping <some-public-IP-here>
If this doesn't work either, then reboot in Recovery mode, wipe user data (format /data partition), reboot again and repeat the steps starting with wpa_supplicant.conf
If pinging an IP address works, but not a domain name, then it means the WiFi router hasn't offered a (working) DNS server, so set one or two:
setprop net.dns1 <some-DNS-IP-you-know> setprop net.dns2 <some-other-DNS-IP-you-know>
Feel free to add these setprop lines to the connect.sh script.
Long press Power button, select Reboot, and select to reboot to Recovery. Once in recovery mode, use Volume buttons to select “wipe data/factory reset” and confirm “Wipe all user data”. Upon finishing the wiping process, select “reboot system now”.
Formatting /data... Formatting /cache... Formatting /sd-ext... Formatting /sdcard/.android_secure... Data wipe complete.
The Replicant system will take a lit bit longer to boot up.
We couldn't find a better solution to recover from a system crash and have the WiFi working again. We will try to find one and if you find one before us, please let us know at info@tehnoetic.com.
To have the WiFi working again, start again from the step wpa_supplicant.conf.
Enabling the support in Replicant for the Tehnoetic WiFi (ath9k_htc) took development time. Please consider donating to Tiberiu or order from Tehnoetic as a way to thank you for having WiFi on your Replicant-powered phone and to help the development of support for future external adapters (Bluetooth, GPS, etc).
To order from Tehnoetic, please visit the catalog of products at tehnoetic.com. We accept credit card, PayPal, Bitcoin and for EU customers, bank transfer too.
To donate to Tiberiu, you don't need to have a PayPal account or to log in your PayPal account. You can donate by credit card by clicking on the Continue link at the bottom of the page.
Don't have a PayPal account? Use your credit card or bank account (where available). _Continue_
Thank you for your donations below and for your Tehnoetic orders!
All modifications presented below are released under GNU GPL.
Git repository: kernel/samsung/smdk4412
Apply the main patch which enables building the kernel with ath9k_htc driver:
diff --git a/arch/arm/configs/cyanogenmod_i9100_defconfig b/arch/arm/configs/cyanogenmod_i9100_defconfig index fc3c88f..e5d11b0 100644 --- a/arch/arm/configs/cyanogenmod_i9100_defconfig +++ b/arch/arm/configs/cyanogenmod_i9100_defconfig @@ -893,6 +893,7 @@ CONFIG_NETFILTER_XT_TARGET_CONNMARK=y # CONFIG_NETFILTER_XT_TARGET_DSCP is not set # CONFIG_NETFILTER_XT_TARGET_HL is not set # CONFIG_NETFILTER_XT_TARGET_IDLETIMER is not set +# CONFIG_NETFILTER_XT_TARGET_LED is not set CONFIG_NETFILTER_XT_TARGET_MARK=y CONFIG_NETFILTER_XT_TARGET_NFLOG=y CONFIG_NETFILTER_XT_TARGET_NFQUEUE=y @@ -1157,10 +1158,21 @@ CONFIG_CFG80211_WEXT=y CONFIG_WIRELESS_EXT_SYSFS=y # CONFIG_LIB80211 is not set # CONFIG_CFG80211_ALLOW_RECONNECT is not set -# CONFIG_MAC80211 is not set +CONFIG_MAC80211=m +CONFIG_MAC80211_HAS_RC=y +# CONFIG_MAC80211_RC_PID is not set +CONFIG_MAC80211_RC_MINSTREL=y +CONFIG_MAC80211_RC_MINSTREL_HT=y +CONFIG_MAC80211_RC_DEFAULT_MINSTREL=y +CONFIG_MAC80211_RC_DEFAULT="minstrel_ht" +# CONFIG_MAC80211_MESH is not set +CONFIG_MAC80211_LEDS=y +# CONFIG_MAC80211_DEBUGFS is not set +# CONFIG_MAC80211_DEBUG_MENU is not set # CONFIG_WIMAX is not set CONFIG_RFKILL=y CONFIG_RFKILL_PM=y +CONFIG_RFKILL_LEDS=y # CONFIG_RFKILL_INPUT is not set # CONFIG_RFKILL_REGULATOR is not set # CONFIG_RFKILL_GPIO is not set @@ -1366,10 +1378,24 @@ CONFIG_TUN=y # CONFIG_NETDEV_1000 is not set # CONFIG_NETDEV_10000 is not set CONFIG_WLAN=y +# CONFIG_LIBERTAS_THINFIRM is not set +# CONFIG_AT76C50X_USB is not set # CONFIG_USB_ZD1201 is not set # CONFIG_USB_NET_RNDIS_WLAN is not set +# CONFIG_RTL8187 is not set +# CONFIG_MAC80211_HWSIM is not set CONFIG_WIFI_CONTROL_FUNC=y -# CONFIG_ATH_COMMON is not set +CONFIG_ATH_COMMON=m +# CONFIG_ATH_DEBUG is not set +# CONFIG_ATH6KL is not set +CONFIG_5GH_WLAN_COUNTRY_CODE=y +CONFIG_ATH9K_HW=m +CONFIG_ATH9K_COMMON=m +# CONFIG_ATH9K is not set +CONFIG_ATH9K_HTC=m +# CONFIG_ATH9K_HTC_DEBUGFS is not set +# CONFIG_B43 is not set +# CONFIG_B43LEGACY is not set CONFIG_BCM4330=m # CONFIG_BCM4334 is not set # CONFIG_BCM4335 is not set @@ -1382,6 +1408,13 @@ CONFIG_WLAN_REGION_CODE=100 # CONFIG_HOSTAP is not set # CONFIG_IWM is not set # CONFIG_LIBERTAS is not set +# CONFIG_P54_COMMON is not set +# CONFIG_RT2X00 is not set +# CONFIG_RTL8192SE is not set +# CONFIG_RTL8192CU is not set +# CONFIG_WL1251 is not set +# CONFIG_WL12XX_MENU is not set +# CONFIG_ZD1211RW is not set # CONFIG_MWIFIEX is not set # @@ -1455,6 +1488,7 @@ CONFIG_KEYBOARD_ATKBD=y CONFIG_KEYBOARD_GPIO=y # CONFIG_KEYBOARD_TCA6416 is not set # CONFIG_KEYBOARD_MATRIX is not set +# CONFIG_KEYBOARD_LM8323 is not set # CONFIG_KEYBOARD_MAX7359 is not set # CONFIG_KEYBOARD_MCS is not set # CONFIG_KEYBOARD_MPR121 is not set @@ -2326,6 +2360,7 @@ CONFIG_HID_PICOLCD=y # CONFIG_HID_PICOLCD_FB is not set # CONFIG_HID_PICOLCD_BACKLIGHT is not set # CONFIG_HID_PICOLCD_LCD is not set +# CONFIG_HID_PICOLCD_LEDS is not set CONFIG_HID_QUANTA=y CONFIG_HID_ROCCAT=y CONFIG_HID_ROCCAT_COMMON=y @@ -2550,7 +2585,44 @@ CONFIG_MMC_SDHCI_S3C_DMA=y # CONFIG_MMC_USHC is not set # CONFIG_MEMSTICK is not set # CONFIG_LEDS_SPFCW043 is not set -# CONFIG_NEW_LEDS is not set +CONFIG_NEW_LEDS=y +CONFIG_LEDS_CLASS=y + +# +# LED drivers +# +# CONFIG_LEDS_LM3530 is not set +# CONFIG_LEDS_PCA9532 is not set +# CONFIG_LEDS_GPIO is not set +# CONFIG_LEDS_LP3944 is not set +# CONFIG_LEDS_AN30259A is not set +# CONFIG_LEDS_LP5521 is not set +# CONFIG_LEDS_LP5523 is not set +# CONFIG_LEDS_PCA955X is not set +# CONFIG_LEDS_DAC124S085 is not set +# CONFIG_LEDS_PWM is not set +# CONFIG_LEDS_REGULATOR is not set +# CONFIG_LEDS_MAX8997 is not set +# CONFIG_LEDS_BD2802 is not set +# CONFIG_LEDS_LT3593 is not set +# CONFIG_LEDS_SWITCH is not set +# CONFIG_LEDS_AAT1290A is not set +CONFIG_LEDS_TRIGGERS=y + +# +# LED Triggers +# +# CONFIG_LEDS_TRIGGER_TIMER is not set +# CONFIG_LEDS_TRIGGER_HEARTBEAT is not set +# CONFIG_LEDS_TRIGGER_BACKLIGHT is not set +# CONFIG_LEDS_TRIGGER_GPIO is not set +# CONFIG_LEDS_TRIGGER_DEFAULT_ON is not set +# CONFIG_LEDS_TRIGGER_SLEEP is not set +# CONFIG_LEDS_TRIGGER_NOTIFICATION is not set + +# +# iptables trigger is under Netfilter config (LED target) +# # CONFIG_NFC_DEVICES is not set CONFIG_SWITCH=y CONFIG_SWITCH_GPIO=y @@ -2639,6 +2711,7 @@ CONFIG_RTC_DRV_S3C=y CONFIG_STAGING=y # CONFIG_VIDEO_TM6000 is not set # CONFIG_USBIP_CORE is not set +# CONFIG_W35UND is not set # CONFIG_PRISM2_USB is not set # CONFIG_ECHO is not set # CONFIG_BRCMUTIL is not set @@ -3181,4 +3254,4 @@ CONFIG_HAS_IOMEM=y CONFIG_HAS_DMA=y CONFIG_CPU_RMAP=y CONFIG_NLATTR=y -# CONFIG_AVERAGE is not set +CONFIG_AVERAGE=y diff --git a/drivers/net/wireless/ath/Kconfig b/drivers/net/wireless/ath/Kconfig index 3945707..d1b2306 100755 --- a/drivers/net/wireless/ath/Kconfig +++ b/drivers/net/wireless/ath/Kconfig @@ -1,6 +1,6 @@ menuconfig ATH_COMMON tristate "Atheros Wireless Cards" - depends on CFG80211 && (!UML || BROKEN) + depends on CFG80211 ---help--- This will enable the support for the Atheros wireless drivers. ath5k, ath9k, ath9k_htc and ar9170 drivers share some common code, this option @@ -22,6 +22,8 @@ config ATH_DEBUG Say Y, if you want to debug atheros wireless drivers. Right now only ath9k makes use of this. -source "drivers/net/wireless/ath/ath6kl/Kconfig" +source "drivers/net/wireless/ath/ath5k/Kconfig" +source "drivers/net/wireless/ath/ath9k/Kconfig" +source "drivers/net/wireless/ath/carl9170/Kconfig" endif diff --git a/drivers/net/wireless/ath/Makefile b/drivers/net/wireless/ath/Makefile index 214def7..0e8f528 100755 --- a/drivers/net/wireless/ath/Makefile +++ b/drivers/net/wireless/ath/Makefile @@ -1,12 +1,12 @@ -NOSTDINC_FLAGS := -I$(srctree)/include/compat/ \ - -include $(srctree)/include/compat/linux/compat-2.6.h \ - $(CFLAGS) +obj-$(CONFIG_ATH5K) += ath5k/ +obj-$(CONFIG_ATH9K_HW) += ath9k/ +obj-$(CONFIG_CARL9170) += carl9170/ -obj-$(CONFIG_ATH6KL) += ath6kl/ obj-$(CONFIG_ATH_COMMON) += ath.o ath-objs := main.o \ regd.o \ hw.o \ key.o + ath-$(CONFIG_ATH_DEBUG) += debug.o
Revert these three commits:
git revert c421809918b7106b40a81134f9fb5103146fc715 git revert 44655588a0b361afa15761b5c58f5a558c1c181c git revert 3cedbff33e9884fdf3f7aaaa83ab9774d8145d1f
And apply this patch to undo changes in big commit “samsung update 1” which broke ath9k_htc build:
diff --git a/drivers/net/wireless/ath/ath.h b/drivers/net/wireless/ath/ath.h index 4596c33..7cf4317 100755 --- a/drivers/net/wireless/ath/ath.h +++ b/drivers/net/wireless/ath/ath.h @@ -71,7 +71,9 @@ struct ath_regulatory { char alpha2[2]; u16 country_code; u16 max_power_level; + u32 tp_scale; u16 current_rd; + u16 current_rd_ext; int16_t power_limit; struct reg_dmn_pair_mapping *regpair; }; @@ -138,6 +140,9 @@ struct ath_common { u8 curbssid[ETH_ALEN]; u8 bssidmask[ETH_ALEN]; + u8 tx_chainmask; + u8 rx_chainmask; + u32 rx_bufsize; u32 keymax; @@ -156,7 +161,6 @@ struct ath_common { const struct ath_bus_ops *bus_ops; bool btcoex_enabled; - bool disable_ani; }; struct sk_buff *ath_rxbuf_alloc(struct ath_common *common, @@ -173,28 +177,23 @@ bool ath_hw_keyreset(struct ath_common *common, u16 entry); void ath_hw_cycle_counters_update(struct ath_common *common); int32_t ath_hw_get_listen_time(struct ath_common *common); -extern __printf(2, 3) void ath_printk(const char *level, const char *fmt, ...); - -#define _ath_printk(level, common, fmt, ...) \ -do { \ - __always_unused struct ath_common *unused = common; \ - ath_printk(level, fmt, ##__VA_ARGS__); \ -} while (0) +extern __attribute__ ((format (printf, 3, 4))) int +ath_printk(const char *level, struct ath_common *common, const char *fmt, ...); #define ath_emerg(common, fmt, ...) \ - _ath_printk(KERN_EMERG, common, fmt, ##__VA_ARGS__) + ath_printk(KERN_EMERG, common, fmt, ##__VA_ARGS__) #define ath_alert(common, fmt, ...) \ - _ath_printk(KERN_ALERT, common, fmt, ##__VA_ARGS__) + ath_printk(KERN_ALERT, common, fmt, ##__VA_ARGS__) #define ath_crit(common, fmt, ...) \ - _ath_printk(KERN_CRIT, common, fmt, ##__VA_ARGS__) + ath_printk(KERN_CRIT, common, fmt, ##__VA_ARGS__) #define ath_err(common, fmt, ...) \ - _ath_printk(KERN_ERR, common, fmt, ##__VA_ARGS__) + ath_printk(KERN_ERR, common, fmt, ##__VA_ARGS__) #define ath_warn(common, fmt, ...) \ - _ath_printk(KERN_WARNING, common, fmt, ##__VA_ARGS__) + ath_printk(KERN_WARNING, common, fmt, ##__VA_ARGS__) #define ath_notice(common, fmt, ...) \ - _ath_printk(KERN_NOTICE, common, fmt, ##__VA_ARGS__) + ath_printk(KERN_NOTICE, common, fmt, ##__VA_ARGS__) #define ath_info(common, fmt, ...) \ - _ath_printk(KERN_INFO, common, fmt, ##__VA_ARGS__) + ath_printk(KERN_INFO, common, fmt, ##__VA_ARGS__) /** * enum ath_debug_level - atheros wireless debug level @@ -239,7 +238,6 @@ enum ATH_DEBUG { ATH_DBG_BTCOEX = 0x00002000, ATH_DBG_WMI = 0x00004000, ATH_DBG_BSTUCK = 0x00008000, - ATH_DBG_MCI = 0x00010000, ATH_DBG_ANY = 0xffffffff }; @@ -247,21 +245,27 @@ enum ATH_DEBUG { #ifdef CONFIG_ATH_DEBUG -#define ath_dbg(common, dbg_mask, fmt, ...) \ -do { \ - if ((common)->debug_mask & dbg_mask) \ - _ath_printk(KERN_DEBUG, common, fmt, ##__VA_ARGS__); \ -} while (0) - +#define ath_dbg(common, dbg_mask, fmt, ...) \ +({ \ + int rtn; \ + if ((common)->debug_mask & dbg_mask) \ + rtn = ath_printk(KERN_DEBUG, common, fmt, \ + ##__VA_ARGS__); \ + else \ + rtn = 0; \ + \ + rtn; \ +}) #define ATH_DBG_WARN(foo, arg...) WARN(foo, arg) #define ATH_DBG_WARN_ON_ONCE(foo) WARN_ON_ONCE(foo) #else -static inline __attribute__ ((format (printf, 3, 4))) -void ath_dbg(struct ath_common *common, enum ATH_DEBUG dbg_mask, - const char *fmt, ...) +static inline __attribute__ ((format (printf, 3, 4))) int +ath_dbg(struct ath_common *common, enum ATH_DEBUG dbg_mask, + const char *fmt, ...) { + return 0; } #define ATH_DBG_WARN(foo, arg...) do {} while (0) #define ATH_DBG_WARN_ON_ONCE(foo) ({ \ diff --git a/drivers/net/wireless/ath/debug.c b/drivers/net/wireless/ath/debug.c index 508eccf..5367b10 100755 --- a/drivers/net/wireless/ath/debug.c +++ b/drivers/net/wireless/ath/debug.c @@ -14,7 +14,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <linux/export.h> #include "ath.h" const char *ath_opmode_to_string(enum nl80211_iftype opmode) diff --git a/drivers/net/wireless/ath/hw.c b/drivers/net/wireless/ath/hw.c index 19befb3..3f508e5 100755 --- a/drivers/net/wireless/ath/hw.c +++ b/drivers/net/wireless/ath/hw.c @@ -14,7 +14,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <linux/export.h> #include <asm/unaligned.h> #include "ath.h" diff --git a/drivers/net/wireless/ath/key.c b/drivers/net/wireless/ath/key.c index 4cf7c5e..a61ef3d6 100755 --- a/drivers/net/wireless/ath/key.c +++ b/drivers/net/wireless/ath/key.c @@ -15,7 +15,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <linux/export.h> #include <asm/unaligned.h> #include <net/mac80211.h> @@ -106,8 +105,11 @@ static bool ath_hw_keysetmac(struct ath_common *common, if (mac[0] & 0x01) unicast_flag = 0; - macLo = get_unaligned_le32(mac); - macHi = get_unaligned_le16(mac + 4); + macHi = (mac[5] << 8) | mac[4]; + macLo = (mac[3] << 24) | + (mac[2] << 16) | + (mac[1] << 8) | + mac[0]; macLo >>= 1; macLo |= (macHi & 1) << 31; macHi >>= 1; diff --git a/drivers/net/wireless/ath/main.c b/drivers/net/wireless/ath/main.c index 947ef45..c325202 100755 --- a/drivers/net/wireless/ath/main.c +++ b/drivers/net/wireless/ath/main.c @@ -57,25 +57,22 @@ struct sk_buff *ath_rxbuf_alloc(struct ath_common *common, } EXPORT_SYMBOL(ath_rxbuf_alloc); -void ath_printk(const char *level, const char *fmt, ...) +int ath_printk(const char *level, struct ath_common *common, + const char *fmt, ...) { -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) struct va_format vaf; -#endif va_list args; + int rtn; va_start(args, fmt); -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) vaf.fmt = fmt; vaf.va = &args; - printk("%sath: %pV", level, &vaf); -#else - printk("%sath: ", level); - vprintk(fmt, args); -#endif + rtn = printk("%sath: %pV", level, &vaf); va_end(args); + + return rtn; } EXPORT_SYMBOL(ath_printk); diff --git a/drivers/net/wireless/ath/regd.c b/drivers/net/wireless/ath/regd.c index 65ecb5b..028310f 100755 --- a/drivers/net/wireless/ath/regd.c +++ b/drivers/net/wireless/ath/regd.c @@ -15,7 +15,6 @@ */ #include <linux/kernel.h> -#include <linux/export.h> #include <net/cfg80211.h> #include <net/mac80211.h> #include "regd.h" @@ -254,8 +253,6 @@ ath_reg_apply_active_scan_flags(struct wiphy *wiphy, int r; sband = wiphy->bands[IEEE80211_BAND_2GHZ]; - if (!sband) - return; /* * If no country IE has been received always enable active scan diff --git a/drivers/net/wireless/ath/regd.h b/drivers/net/wireless/ath/regd.h index 03a8268..172f63f 100755 --- a/drivers/net/wireless/ath/regd.h +++ b/drivers/net/wireless/ath/regd.h @@ -101,7 +101,7 @@ enum CountryCode { CTRY_GERMANY = 276, CTRY_GREECE = 300, CTRY_GREENLAND = 304, - CTRY_GRENADA = 308, + CTRY_GRENEDA = 308, CTRY_GUAM = 316, CTRY_GUATEMALA = 320, CTRY_HAITI = 332, diff --git a/drivers/net/wireless/ath/regd_common.h b/drivers/net/wireless/ath/regd_common.h index bdd2b4d..24b5383 100755 --- a/drivers/net/wireless/ath/regd_common.h +++ b/drivers/net/wireless/ath/regd_common.h @@ -332,7 +332,7 @@ static struct country_code_to_enum_rd allCountries[] = { {CTRY_GERMANY, ETSI1_WORLD, "DE"}, {CTRY_GREECE, ETSI1_WORLD, "GR"}, {CTRY_GREENLAND, ETSI1_WORLD, "GL"}, - {CTRY_GRENADA, FCC3_FCCA, "GD"}, + {CTRY_GRENEDA, FCC3_FCCA, "GD"}, {CTRY_GUAM, FCC1_FCCA, "GU"}, {CTRY_GUATEMALA, FCC1_FCCA, "GT"}, {CTRY_HAITI, ETSI1_WORLD, "HT"}, diff --git a/lib/genalloc.c b/lib/genalloc.c index bb1d323..ceaa003 100644 --- a/lib/genalloc.c +++ b/lib/genalloc.c @@ -14,7 +14,7 @@ #include <linux/module.h> #include <linux/bitmap.h> #include <linux/genalloc.h> - +#include <linux/vmalloc.h> /* General purpose special memory pool descriptor. */ struct gen_pool { @@ -33,7 +33,6 @@ struct gen_pool_chunk { unsigned long bits[0]; /* bitmap for allocating memory chunk */ }; - /** * gen_pool_create() - create a new special memory pool * @order: Log base 2 of number of bytes each bitmap bit @@ -63,28 +62,25 @@ EXPORT_SYMBOL(gen_pool_create); /** * gen_pool_add_virt - add a new chunk of special memory to the pool - * @pool: Pool to add new memory chunk to - * @virt: Virtual starting address of memory chunk to add to pool - * @phys: Physical starting address of memory chunk to add to pool - * @size: Size in bytes of the memory chunk to add to pool - * @nid: Node id of the node the chunk structure and bitmap should be - * allocated on, or -1 + * @pool: pool to add new memory chunk to + * @virt: virtual starting address of memory chunk to add to pool + * @phys: physical starting address of memory chunk to add to pool + * @size: size in bytes of the memory chunk to add to pool + * @nid: node id of the node the chunk structure and bitmap should be + * allocated on, or -1 * * Add a new chunk of special memory to the specified pool. * * Returns 0 on success or a -ve errno on failure. */ -int __must_check -gen_pool_add_virt(struct gen_pool *pool, unsigned long virt, phys_addr_t phys, - size_t size, int nid) +int __must_check gen_pool_add_virt(struct gen_pool *pool, unsigned long virt, phys_addr_t phys, + size_t size, int nid) { struct gen_pool_chunk *chunk; - int nbits = size >> pool->min_alloc_order; - int nbytes = sizeof(struct gen_pool_chunk) + - BITS_TO_LONGS(nbits) * sizeof(long); + size_t nbytes; if (WARN_ON(!virt || virt + size < virt || - (virt & ((1 << pool->order) - 1)))) + (virt & ((1 << pool->order) - 1)))) return -EINVAL; size = size >> pool->order; @@ -92,14 +88,22 @@ gen_pool_add_virt(struct gen_pool *pool, unsigned long virt, phys_addr_t phys, return -EINVAL; nbytes = sizeof *chunk + BITS_TO_LONGS(size) * sizeof *chunk->bits; - chunk = kzalloc_node(nbytes, GFP_KERNEL, nid); + + if (nbytes <= PAGE_SIZE) + chunk = kzalloc_node(nbytes, GFP_KERNEL, nid); + else + chunk = vmalloc(nbytes); + if (!chunk) return -ENOMEM; + if (nbytes > PAGE_SIZE) + memset(chunk, 0, nbytes); + spin_lock_init(&chunk->lock); + chunk->phys_addr = phys; chunk->start = virt >> pool->order; chunk->size = size; - chunk->phys_addr = phys; write_lock(&pool->lock); list_add(&chunk->next_chunk, &pool->chunks); @@ -123,12 +127,11 @@ phys_addr_t gen_pool_virt_to_phys(struct gen_pool *pool, unsigned long addr) read_lock(&pool->lock); list_for_each(_chunk, &pool->chunks) { - unsigned long start_addr; chunk = list_entry(_chunk, struct gen_pool_chunk, next_chunk); - start_addr = chunk->start << pool->order; - if (addr >= start_addr && addr < start_addr + chunk->size) - return chunk->phys_addr + addr - start_addr; + if (addr >= chunk->start && + addr < (chunk->start + chunk->size)) + return chunk->phys_addr + addr - chunk->start; } read_unlock(&pool->lock); @@ -147,6 +150,7 @@ void gen_pool_destroy(struct gen_pool *pool) { struct gen_pool_chunk *chunk; int bit; + size_t nbytes; while (!list_empty(&pool->chunks)) { chunk = list_entry(pool->chunks.next, struct gen_pool_chunk, @@ -156,7 +160,13 @@ void gen_pool_destroy(struct gen_pool *pool) bit = find_next_bit(chunk->bits, chunk->size, 0); BUG_ON(bit < chunk->size); - kfree(chunk); + nbytes = sizeof *chunk + BITS_TO_LONGS(chunk->size) * + sizeof *chunk->bits; + + if (nbytes <= PAGE_SIZE) + kfree(chunk); + else + vfree(chunk); } kfree(pool); }