Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rtlwifi: Fix build errors for unusual cases

The present build configuration for the rtlwifi family of drivers will
fail under two known conditions:

(1) If rtlwifi is selected without selecting any of the dependent drivers,
there are errors in the build.
(2) If the PCI drivers are built into the kernel and the USB drivers are modules,
or vice versa, there are missing globals.

The first condition is fixed by never building rtlwifi unless at least one
of the device drivers is selected. The second failure is fixed by splitting
the PCI and USB codes out of rtlwifi, and creating their own mini drivers.
If the drivers that use them are modules, they will also be modules.

Although a number of files are touched by this patch, only Makefile and Kconfig
have undergone significant changes. The only modifications to the other files
were to export entry points needed by the new rtl_pci and rtl_usb units, or to
rename two variables that had names that were likely to cause namespace collisions.

Reported-by: Fengguang Wu <fengguang.wu@intel.com> [Condition 1]
Reported-by: Ben Hutchings <bhutchings@solarflare.com> [Condition 2]
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Ben Hutchings <bhutchings@solarflare.com>
Cc: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

authored by

Larry Finger and committed by
John W. Linville
6f334c2b f287cbd0

+132 -76
+89 -65
drivers/net/wireless/rtlwifi/Kconfig
··· 1 - config RTLWIFI 2 - tristate "Realtek wireless card support" 3 - depends on MAC80211 4 - select FW_LOADER 1 + menuconfig RTL_CARDS 2 + tristate "Realtek rtlwifi family of devices" 3 + depends on MAC80211 && (PCI || USB) 4 + default y 5 5 ---help--- 6 - This is common code for RTL8192CE/RTL8192CU/RTL8192SE/RTL8723AE 7 - drivers. This module does nothing by itself - the various front-end 8 - drivers need to be enabled to support any desired devices. 6 + This option will enable support for the Realtek mac80211-based 7 + wireless drivers. Drivers rtl8192ce, rtl8192cu, rtl8192se, rtl8192de, 8 + rtl8723eu, and rtl8188eu share some common code. 9 9 10 - If you choose to build as a module, it'll be called rtlwifi. 10 + if RTL_CARDS 11 + 12 + config RTL8192CE 13 + tristate "Realtek RTL8192CE/RTL8188CE Wireless Network Adapter" 14 + depends on PCI 15 + select RTL8192C_COMMON 16 + select RTLWIFI 17 + select RTLWIFI_PCI 18 + ---help--- 19 + This is the driver for Realtek RTL8192CE/RTL8188CE 802.11n PCIe 20 + wireless network adapters. 21 + 22 + If you choose to build it as a module, it will be called rtl8192ce 23 + 24 + config RTL8192SE 25 + tristate "Realtek RTL8192SE/RTL8191SE PCIe Wireless Network Adapter" 26 + depends on PCI 27 + select RTLWIFI 28 + select RTLWIFI_PCI 29 + ---help--- 30 + This is the driver for Realtek RTL8192SE/RTL8191SE 802.11n PCIe 31 + wireless network adapters. 32 + 33 + If you choose to build it as a module, it will be called rtl8192se 34 + 35 + config RTL8192DE 36 + tristate "Realtek RTL8192DE/RTL8188DE PCIe Wireless Network Adapter" 37 + depends on PCI 38 + select RTLWIFI 39 + select RTLWIFI_PCI 40 + ---help--- 41 + This is the driver for Realtek RTL8192DE/RTL8188DE 802.11n PCIe 42 + wireless network adapters. 43 + 44 + If you choose to build it as a module, it will be called rtl8192de 45 + 46 + config RTL8723AE 47 + tristate "Realtek RTL8723AE PCIe Wireless Network Adapter" 48 + depends on PCI 49 + select RTLWIFI 50 + select RTLWIFI_PCI 51 + ---help--- 52 + This is the driver for Realtek RTL8723AE 802.11n PCIe 53 + wireless network adapters. 54 + 55 + If you choose to build it as a module, it will be called rtl8723ae 56 + 57 + config RTL8188EE 58 + tristate "Realtek RTL8188EE Wireless Network Adapter" 59 + depends on PCI 60 + select RTLWIFI 61 + select RTLWIFI_PCI 62 + ---help--- 63 + This is the driver for Realtek RTL8188EE 802.11n PCIe 64 + wireless network adapters. 65 + 66 + If you choose to build it as a module, it will be called rtl8188ee 67 + 68 + config RTL8192CU 69 + tristate "Realtek RTL8192CU/RTL8188CU USB Wireless Network Adapter" 70 + depends on USB 71 + select RTLWIFI 72 + select RTLWIFI_USB 73 + select RTL8192C_COMMON 74 + ---help--- 75 + This is the driver for Realtek RTL8192CU/RTL8188CU 802.11n USB 76 + wireless network adapters. 77 + 78 + If you choose to build it as a module, it will be called rtl8192cu 79 + 80 + config RTLWIFI 81 + tristate 82 + select FW_LOADER 83 + 84 + config RTLWIFI_PCI 85 + tristate 86 + 87 + config RTLWIFI_USB 88 + tristate 11 89 12 90 config RTLWIFI_DEBUG 13 91 bool "Debugging output for rtlwifi driver family" ··· 96 18 the front-end driver, this parameter must be "Y". For memory-limited 97 19 systems, choose "N". If in doubt, choose "Y". 98 20 99 - config RTL8192CE 100 - tristate "Realtek RTL8192CE/RTL8188CE Wireless Network Adapter" 101 - depends on RTLWIFI && PCI 102 - select RTL8192C_COMMON 103 - ---help--- 104 - This is the driver for Realtek RTL8192CE/RTL8188CE 802.11n PCIe 105 - wireless network adapters. 106 - 107 - If you choose to build it as a module, it will be called rtl8192ce 108 - 109 - config RTL8192SE 110 - tristate "Realtek RTL8192SE/RTL8191SE PCIe Wireless Network Adapter" 111 - depends on RTLWIFI && PCI 112 - ---help--- 113 - This is the driver for Realtek RTL8192SE/RTL8191SE 802.11n PCIe 114 - wireless network adapters. 115 - 116 - If you choose to build it as a module, it will be called rtl8192se 117 - 118 - config RTL8192DE 119 - tristate "Realtek RTL8192DE/RTL8188DE PCIe Wireless Network Adapter" 120 - depends on RTLWIFI && PCI 121 - ---help--- 122 - This is the driver for Realtek RTL8192DE/RTL8188DE 802.11n PCIe 123 - wireless network adapters. 124 - 125 - If you choose to build it as a module, it will be called rtl8192de 126 - 127 - config RTL8723AE 128 - tristate "Realtek RTL8723AE PCIe Wireless Network Adapter" 129 - depends on RTLWIFI && PCI 130 - ---help--- 131 - This is the driver for Realtek RTL8723AE 802.11n PCIe 132 - wireless network adapters. 133 - 134 - If you choose to build it as a module, it will be called rtl8723ae 135 - 136 - config RTL8188EE 137 - tristate "Realtek RTL8188EE Wireless Network Adapter" 138 - depends on RTLWIFI && PCI 139 - ---help--- 140 - This is the driver for Realtek RTL8188EE 802.11n PCIe 141 - wireless network adapters. 142 - 143 - If you choose to build it as a module, it will be called rtl8188ee 144 - 145 - config RTL8192CU 146 - tristate "Realtek RTL8192CU/RTL8188CU USB Wireless Network Adapter" 147 - depends on RTLWIFI && USB 148 - select RTL8192C_COMMON 149 - ---help--- 150 - This is the driver for Realtek RTL8192CU/RTL8188CU 802.11n USB 151 - wireless network adapters. 152 - 153 - If you choose to build it as a module, it will be called rtl8192cu 154 - 155 21 config RTL8192C_COMMON 156 22 tristate 157 23 depends on RTL8192CE || RTL8192CU 158 - default m 24 + default y 25 + 26 + endif
+4 -6
drivers/net/wireless/rtlwifi/Makefile
··· 12 12 13 13 rtl8192c_common-objs += \ 14 14 15 - ifneq ($(CONFIG_PCI),) 16 - rtlwifi-objs += pci.o 17 - endif 15 + obj-$(CONFIG_RTLWIFI_PCI) += rtl_pci.o 16 + rtl_pci-objs := pci.o 18 17 19 - ifneq ($(CONFIG_USB),) 20 - rtlwifi-objs += usb.o 21 - endif 18 + obj-$(CONFIG_RTLWIFI_USB) += rtl_usb.o 19 + rtl_usb-objs := usb.o 22 20 23 21 obj-$(CONFIG_RTL8192C_COMMON) += rtl8192c/ 24 22 obj-$(CONFIG_RTL8192CE) += rtl8192ce/
+16 -3
drivers/net/wireless/rtlwifi/base.c
··· 172 172 { 173 173 return tid_to_ac[tid]; 174 174 } 175 + EXPORT_SYMBOL_GPL(rtl_tid_to_ac); 175 176 176 177 static void _rtl_init_hw_ht_capab(struct ieee80211_hw *hw, 177 178 struct ieee80211_sta_ht_cap *ht_cap) ··· 407 406 cancel_delayed_work(&rtlpriv->works.ps_rfon_wq); 408 407 cancel_delayed_work(&rtlpriv->works.fwevt_wq); 409 408 } 409 + EXPORT_SYMBOL_GPL(rtl_deinit_deferred_work); 410 410 411 411 void rtl_init_rfkill(struct ieee80211_hw *hw) 412 412 { ··· 441 439 { 442 440 wiphy_rfkill_stop_polling(hw->wiphy); 443 441 } 442 + EXPORT_SYMBOL_GPL(rtl_deinit_rfkill); 444 443 445 444 int rtl_init_core(struct ieee80211_hw *hw) 446 445 { ··· 492 489 493 490 return 0; 494 491 } 492 + EXPORT_SYMBOL_GPL(rtl_init_core); 495 493 496 494 void rtl_deinit_core(struct ieee80211_hw *hw) 497 495 { 498 496 } 497 + EXPORT_SYMBOL_GPL(rtl_deinit_core); 499 498 500 499 void rtl_init_rx_config(struct ieee80211_hw *hw) 501 500 { ··· 506 501 507 502 rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_RCR, (u8 *) (&mac->rx_conf)); 508 503 } 504 + EXPORT_SYMBOL_GPL(rtl_init_rx_config); 509 505 510 506 /********************************************************* 511 507 * ··· 885 879 886 880 return true; 887 881 } 882 + EXPORT_SYMBOL_GPL(rtl_tx_mgmt_proc); 888 883 889 884 void rtl_get_tcb_desc(struct ieee80211_hw *hw, 890 885 struct ieee80211_tx_info *info, ··· 1059 1052 1060 1053 return true; 1061 1054 } 1055 + EXPORT_SYMBOL_GPL(rtl_action_proc); 1062 1056 1063 1057 /*should call before software enc*/ 1064 1058 u8 rtl_is_special_data(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx) ··· 1133 1125 1134 1126 return false; 1135 1127 } 1128 + EXPORT_SYMBOL_GPL(rtl_is_special_data); 1136 1129 1137 1130 /********************************************************* 1138 1131 * ··· 1309 1300 1310 1301 rtlpriv->link_info.bcn_rx_inperiod++; 1311 1302 } 1303 + EXPORT_SYMBOL_GPL(rtl_beacon_statistic); 1312 1304 1313 1305 void rtl_watchdog_wq_callback(void *data) 1314 1306 { ··· 1803 1793 1804 1794 mac->vendor = vendor; 1805 1795 } 1796 + EXPORT_SYMBOL_GPL(rtl_recognize_peer); 1806 1797 1807 1798 /********************************************************* 1808 1799 * ··· 1860 1849 .name = "rtlsysfs", 1861 1850 .attrs = rtl_sysfs_entries, 1862 1851 }; 1852 + EXPORT_SYMBOL_GPL(rtl_attribute_group); 1863 1853 1864 1854 MODULE_AUTHOR("lizhaoming <chaoming_li@realsil.com.cn>"); 1865 1855 MODULE_AUTHOR("Realtek WlanFAE <wlanfae@realtek.com>"); ··· 1868 1856 MODULE_LICENSE("GPL"); 1869 1857 MODULE_DESCRIPTION("Realtek 802.11n PCI wireless core"); 1870 1858 1871 - struct rtl_global_var global_var = {}; 1859 + struct rtl_global_var rtl_global_var = {}; 1860 + EXPORT_SYMBOL_GPL(rtl_global_var); 1872 1861 1873 1862 static int __init rtl_core_module_init(void) 1874 1863 { ··· 1877 1864 pr_err("Unable to register rtl_rc, use default RC !!\n"); 1878 1865 1879 1866 /* init some global vars */ 1880 - INIT_LIST_HEAD(&global_var.glb_priv_list); 1881 - spin_lock_init(&global_var.glb_list_lock); 1867 + INIT_LIST_HEAD(&rtl_global_var.glb_priv_list); 1868 + spin_lock_init(&rtl_global_var.glb_list_lock); 1882 1869 1883 1870 return 0; 1884 1871 }
+1 -1
drivers/net/wireless/rtlwifi/base.h
··· 147 147 u8 rtl_tid_to_ac(u8 tid); 148 148 extern struct attribute_group rtl_attribute_group; 149 149 void rtl_easy_concurrent_retrytimer_callback(unsigned long data); 150 - extern struct rtl_global_var global_var; 150 + extern struct rtl_global_var rtl_global_var; 151 151 int rtlwifi_rate_mapping(struct ieee80211_hw *hw, 152 152 bool isht, u8 desc_rate, bool first_ampdu); 153 153 bool rtl_tx_mgmt_proc(struct ieee80211_hw *hw, struct sk_buff *skb);
+1
drivers/net/wireless/rtlwifi/core.c
··· 1330 1330 .rfkill_poll = rtl_op_rfkill_poll, 1331 1331 .flush = rtl_op_flush, 1332 1332 }; 1333 + EXPORT_SYMBOL_GPL(rtl_ops);
+1
drivers/net/wireless/rtlwifi/debug.c
··· 51 51 52 52 /*Init Debug flag enable condition */ 53 53 } 54 + EXPORT_SYMBOL_GPL(rtl_dbgp_flag_init);
+1
drivers/net/wireless/rtlwifi/efuse.c
··· 229 229 230 230 *pbuf = (u8) (value32 & 0xff); 231 231 } 232 + EXPORT_SYMBOL_GPL(read_efuse_byte); 232 233 233 234 void read_efuse(struct ieee80211_hw *hw, u16 _offset, u16 _size_byte, u8 *pbuf) 234 235 {
+8 -1
drivers/net/wireless/rtlwifi/pci.c
··· 35 35 #include "efuse.h" 36 36 #include <linux/export.h> 37 37 #include <linux/kmemleak.h> 38 + #include <linux/module.h> 39 + 40 + MODULE_AUTHOR("lizhaoming <chaoming_li@realsil.com.cn>"); 41 + MODULE_AUTHOR("Realtek WlanFAE <wlanfae@realtek.com>"); 42 + MODULE_AUTHOR("Larry Finger <Larry.FInger@lwfinger.net>"); 43 + MODULE_LICENSE("GPL"); 44 + MODULE_DESCRIPTION("PCI basic driver for rtlwifi"); 38 45 39 46 static const u16 pcibridge_vendors[PCI_BRIDGE_VENDOR_MAX] = { 40 47 PCI_VENDOR_ID_INTEL, ··· 1893 1886 rtlpriv->rtlhal.interface = INTF_PCI; 1894 1887 rtlpriv->cfg = (struct rtl_hal_cfg *)(id->driver_data); 1895 1888 rtlpriv->intf_ops = &rtl_pci_ops; 1896 - rtlpriv->glb_var = &global_var; 1889 + rtlpriv->glb_var = &rtl_global_var; 1897 1890 1898 1891 /* 1899 1892 *init dbgp flags before all
+4
drivers/net/wireless/rtlwifi/ps.c
··· 269 269 270 270 spin_unlock_irqrestore(&rtlpriv->locks.ips_lock, flags); 271 271 } 272 + EXPORT_SYMBOL_GPL(rtl_ips_nic_on); 272 273 273 274 /*for FW LPS*/ 274 275 ··· 519 518 "u_bufferd: %x, m_buffered: %x\n", u_buffed, m_buffed); 520 519 } 521 520 } 521 + EXPORT_SYMBOL_GPL(rtl_swlps_beacon); 522 522 523 523 void rtl_swlps_rf_awake(struct ieee80211_hw *hw) 524 524 { ··· 625 623 else 626 624 rtl_lps_leave(hw); 627 625 } 626 + EXPORT_SYMBOL_GPL(rtl_lps_change_work_callback); 628 627 629 628 void rtl_swlps_wq_callback(void *data) 630 629 { ··· 937 934 else 938 935 rtl_p2p_noa_ie(hw, data, len - FCS_LEN); 939 936 } 937 + EXPORT_SYMBOL_GPL(rtl_p2p_info);
+7
drivers/net/wireless/rtlwifi/usb.c
··· 32 32 #include "ps.h" 33 33 #include "rtl8192c/fw_common.h" 34 34 #include <linux/export.h> 35 + #include <linux/module.h> 36 + 37 + MODULE_AUTHOR("lizhaoming <chaoming_li@realsil.com.cn>"); 38 + MODULE_AUTHOR("Realtek WlanFAE <wlanfae@realtek.com>"); 39 + MODULE_AUTHOR("Larry Finger <Larry.FInger@lwfinger.net>"); 40 + MODULE_LICENSE("GPL"); 41 + MODULE_DESCRIPTION("USB basic driver for rtlwifi"); 35 42 36 43 #define REALTEK_USB_VENQT_READ 0xC0 37 44 #define REALTEK_USB_VENQT_WRITE 0x40