1 From 313314263fda19db8eed94a7d7259b595634212e Mon Sep 17 00:00:00 2001
2 From: Ivo van Doorn <IvDoorn@gmail.com>
3 Date: Sat, 14 Mar 2009 20:02:51 +0100
4 Subject: [PATCH] rt2x00: Move Move pci_dev specific access to rt2x00pci
6 pci_dev->irq and pci_name(pci_dev) access should be limited
7 to rt2x00pci only. This is more generic and allows a rt2x00 pci
8 driver to be controlled as PCI device but also as platform driver
9 (needed for rt2800pci SoC support).
11 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
12 Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
14 drivers/net/wireless/rt2x00/rt2400pci.c | 2 +-
15 drivers/net/wireless/rt2x00/rt2500pci.c | 2 +-
16 drivers/net/wireless/rt2x00/rt2x00.h | 18 ++++++++++++++++++
17 drivers/net/wireless/rt2x00/rt2x00pci.c | 16 ++++++++++++----
18 drivers/net/wireless/rt2x00/rt61pci.c | 7 +------
19 5 files changed, 33 insertions(+), 12 deletions(-)
21 --- a/drivers/net/wireless/rt2x00/rt2400pci.c
22 +++ b/drivers/net/wireless/rt2x00/rt2400pci.c
23 @@ -1361,7 +1361,7 @@ static int rt2400pci_init_eeprom(struct
25 value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
26 rt2x00pci_register_read(rt2x00dev, CSR0, ®);
27 - rt2x00_set_chip(rt2x00dev, RT2460, value, reg);
28 + rt2x00_set_chip_rf(rt2x00dev, value, reg);
30 if (!rt2x00_rf(&rt2x00dev->chip, RF2420) &&
31 !rt2x00_rf(&rt2x00dev->chip, RF2421)) {
32 --- a/drivers/net/wireless/rt2x00/rt2500pci.c
33 +++ b/drivers/net/wireless/rt2x00/rt2500pci.c
34 @@ -1525,7 +1525,7 @@ static int rt2500pci_init_eeprom(struct
36 value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
37 rt2x00pci_register_read(rt2x00dev, CSR0, ®);
38 - rt2x00_set_chip(rt2x00dev, RT2560, value, reg);
39 + rt2x00_set_chip_rf(rt2x00dev, value, reg);
41 if (!rt2x00_rf(&rt2x00dev->chip, RF2522) &&
42 !rt2x00_rf(&rt2x00dev->chip, RF2523) &&
43 --- a/drivers/net/wireless/rt2x00/rt2x00.h
44 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
45 @@ -672,6 +672,12 @@ struct rt2x00_dev {
49 + * Device information, Bus IRQ and name (PCI, SoC)
55 * Chipset identification.
57 struct rt2x00_chip chip;
58 @@ -860,6 +866,18 @@ static inline void rt2x00_set_chip(struc
59 rt2x00dev->chip.rev = rev;
62 +static inline void rt2x00_set_chip_rt(struct rt2x00_dev *rt2x00dev,
65 + rt2x00dev->chip.rt = rt;
68 +static inline void rt2x00_set_chip_rf(struct rt2x00_dev *rt2x00dev,
69 + const u16 rf, const u32 rev)
71 + rt2x00_set_chip(rt2x00dev, rt2x00dev->chip.rt, rf, rev);
74 static inline char rt2x00_rt(const struct rt2x00_chip *chipset, const u16 chip)
76 return (chipset->rt == chip);
77 --- a/drivers/net/wireless/rt2x00/rt2x00pci.c
78 +++ b/drivers/net/wireless/rt2x00/rt2x00pci.c
79 @@ -170,7 +170,6 @@ static void rt2x00pci_free_queue_dma(str
81 int rt2x00pci_initialize(struct rt2x00_dev *rt2x00dev)
83 - struct pci_dev *pci_dev = to_pci_dev(rt2x00dev->dev);
84 struct data_queue *queue;
87 @@ -186,11 +185,11 @@ int rt2x00pci_initialize(struct rt2x00_d
89 * Register interrupt handler.
91 - status = request_irq(pci_dev->irq, rt2x00dev->ops->lib->irq_handler,
92 - IRQF_SHARED, pci_name(pci_dev), rt2x00dev);
93 + status = request_irq(rt2x00dev->irq, rt2x00dev->ops->lib->irq_handler,
94 + IRQF_SHARED, rt2x00dev->name, rt2x00dev);
96 ERROR(rt2x00dev, "IRQ %d allocation failed (error %d).\n",
97 - pci_dev->irq, status);
98 + rt2x00dev->irq, status);
102 @@ -270,6 +269,7 @@ int rt2x00pci_probe(struct pci_dev *pci_
103 struct ieee80211_hw *hw;
104 struct rt2x00_dev *rt2x00dev;
108 retval = pci_request_regions(pci_dev, pci_name(pci_dev));
110 @@ -307,6 +307,14 @@ int rt2x00pci_probe(struct pci_dev *pci_
111 rt2x00dev->dev = &pci_dev->dev;
112 rt2x00dev->ops = ops;
114 + rt2x00dev->irq = pci_dev->irq;
115 + rt2x00dev->name = pci_name(pci_dev);
118 + * Determine RT chipset by reading PCI header.
120 + pci_read_config_word(pci_dev, PCI_DEVICE_ID, &chip);
121 + rt2x00_set_chip_rt(rt2x00dev, chip);
123 retval = rt2x00pci_alloc_reg(rt2x00dev);
125 --- a/drivers/net/wireless/rt2x00/rt61pci.c
126 +++ b/drivers/net/wireless/rt2x00/rt61pci.c
127 @@ -2308,7 +2308,6 @@ static int rt61pci_init_eeprom(struct rt
134 * Read EEPROM word for configuration.
135 @@ -2317,14 +2316,10 @@ static int rt61pci_init_eeprom(struct rt
138 * Identify RF chipset.
139 - * To determine the RT chip we have to read the
140 - * PCI header of the device.
142 - pci_read_config_word(to_pci_dev(rt2x00dev->dev),
143 - PCI_CONFIG_HEADER_DEVICE, &device);
144 value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
145 rt2x00pci_register_read(rt2x00dev, MAC_CSR0, ®);
146 - rt2x00_set_chip(rt2x00dev, device, value, reg);
147 + rt2x00_set_chip_rf(rt2x00dev, value, reg);
149 if (!rt2x00_rf(&rt2x00dev->chip, RF5225) &&
150 !rt2x00_rf(&rt2x00dev->chip, RF5325) &&