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

rt2x00: Move Move pci_dev specific access to rt2x00pci

pci_dev->irq and pci_name(pci_dev) access should be limited
to rt2x00pci only. This is more generic and allows a rt2x00 pci
driver to be controlled as PCI device but also as platform driver
(needed for rt2800pci SoC support).

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

authored by

Ivo van Doorn and committed by
John W. Linville
440ddada 32c1628f

+33 -18
+1 -1
drivers/net/wireless/rt2x00/rt2400pci.c
··· 1361 1361 */ 1362 1362 value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE); 1363 1363 rt2x00pci_register_read(rt2x00dev, CSR0, &reg); 1364 - rt2x00_set_chip(rt2x00dev, RT2460, value, reg); 1364 + rt2x00_set_chip_rf(rt2x00dev, value, reg); 1365 1365 1366 1366 if (!rt2x00_rf(&rt2x00dev->chip, RF2420) && 1367 1367 !rt2x00_rf(&rt2x00dev->chip, RF2421)) {
+1 -1
drivers/net/wireless/rt2x00/rt2500pci.c
··· 1525 1525 */ 1526 1526 value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE); 1527 1527 rt2x00pci_register_read(rt2x00dev, CSR0, &reg); 1528 - rt2x00_set_chip(rt2x00dev, RT2560, value, reg); 1528 + rt2x00_set_chip_rf(rt2x00dev, value, reg); 1529 1529 1530 1530 if (!rt2x00_rf(&rt2x00dev->chip, RF2522) && 1531 1531 !rt2x00_rf(&rt2x00dev->chip, RF2523) &&
+18
drivers/net/wireless/rt2x00/rt2x00.h
··· 672 672 unsigned long flags; 673 673 674 674 /* 675 + * Device information, Bus IRQ and name (PCI, SoC) 676 + */ 677 + int irq; 678 + const char *name; 679 + 680 + /* 675 681 * Chipset identification. 676 682 */ 677 683 struct rt2x00_chip chip; ··· 864 858 rt2x00dev->chip.rt = rt; 865 859 rt2x00dev->chip.rf = rf; 866 860 rt2x00dev->chip.rev = rev; 861 + } 862 + 863 + static inline void rt2x00_set_chip_rt(struct rt2x00_dev *rt2x00dev, 864 + const u16 rt) 865 + { 866 + rt2x00dev->chip.rt = rt; 867 + } 868 + 869 + static inline void rt2x00_set_chip_rf(struct rt2x00_dev *rt2x00dev, 870 + const u16 rf, const u32 rev) 871 + { 872 + rt2x00_set_chip(rt2x00dev, rt2x00dev->chip.rt, rf, rev); 867 873 } 868 874 869 875 static inline char rt2x00_rt(const struct rt2x00_chip *chipset, const u16 chip)
+12 -4
drivers/net/wireless/rt2x00/rt2x00pci.c
··· 170 170 171 171 int rt2x00pci_initialize(struct rt2x00_dev *rt2x00dev) 172 172 { 173 - struct pci_dev *pci_dev = to_pci_dev(rt2x00dev->dev); 174 173 struct data_queue *queue; 175 174 int status; 176 175 ··· 185 186 /* 186 187 * Register interrupt handler. 187 188 */ 188 - status = request_irq(pci_dev->irq, rt2x00dev->ops->lib->irq_handler, 189 - IRQF_SHARED, pci_name(pci_dev), rt2x00dev); 189 + status = request_irq(rt2x00dev->irq, rt2x00dev->ops->lib->irq_handler, 190 + IRQF_SHARED, rt2x00dev->name, rt2x00dev); 190 191 if (status) { 191 192 ERROR(rt2x00dev, "IRQ %d allocation failed (error %d).\n", 192 - pci_dev->irq, status); 193 + rt2x00dev->irq, status); 193 194 goto exit; 194 195 } 195 196 ··· 269 270 struct ieee80211_hw *hw; 270 271 struct rt2x00_dev *rt2x00dev; 271 272 int retval; 273 + u16 chip; 272 274 273 275 retval = pci_request_regions(pci_dev, pci_name(pci_dev)); 274 276 if (retval) { ··· 307 307 rt2x00dev->dev = &pci_dev->dev; 308 308 rt2x00dev->ops = ops; 309 309 rt2x00dev->hw = hw; 310 + rt2x00dev->irq = pci_dev->irq; 311 + rt2x00dev->name = pci_name(pci_dev); 312 + 313 + /* 314 + * Determine RT chipset by reading PCI header. 315 + */ 316 + pci_read_config_word(pci_dev, PCI_DEVICE_ID, &chip); 317 + rt2x00_set_chip_rt(rt2x00dev, chip); 310 318 311 319 retval = rt2x00pci_alloc_reg(rt2x00dev); 312 320 if (retval)
+1 -6
drivers/net/wireless/rt2x00/rt61pci.c
··· 2308 2308 u32 reg; 2309 2309 u16 value; 2310 2310 u16 eeprom; 2311 - u16 device; 2312 2311 2313 2312 /* 2314 2313 * Read EEPROM word for configuration. ··· 2316 2317 2317 2318 /* 2318 2319 * Identify RF chipset. 2319 - * To determine the RT chip we have to read the 2320 - * PCI header of the device. 2321 2320 */ 2322 - pci_read_config_word(to_pci_dev(rt2x00dev->dev), 2323 - PCI_CONFIG_HEADER_DEVICE, &device); 2324 2321 value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE); 2325 2322 rt2x00pci_register_read(rt2x00dev, MAC_CSR0, &reg); 2326 - rt2x00_set_chip(rt2x00dev, device, value, reg); 2323 + rt2x00_set_chip_rf(rt2x00dev, value, reg); 2327 2324 2328 2325 if (!rt2x00_rf(&rt2x00dev->chip, RF5225) && 2329 2326 !rt2x00_rf(&rt2x00dev->chip, RF5325) &&
-6
drivers/net/wireless/rt2x00/rt61pci.h
··· 63 63 */ 64 64 65 65 /* 66 - * PCI Configuration Header 67 - */ 68 - #define PCI_CONFIG_HEADER_VENDOR 0x0000 69 - #define PCI_CONFIG_HEADER_DEVICE 0x0002 70 - 71 - /* 72 66 * HOST_CMD_CSR: For HOST to interrupt embedded processor 73 67 */ 74 68 #define HOST_CMD_CSR 0x0008