91f5a2ad822e35a251dcc10ca61b6c2f068d3b8e
[openwrt/svn-archive/archive.git] / package / mac80211 / patches / 300-rt2x00-Move-Move-pci_dev-specific-access-to-rt2x00p.patch
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
5
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).
10
11 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
12 Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
13 ---
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(-)
20
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
24 */
25 value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
26 rt2x00pci_register_read(rt2x00dev, CSR0, &reg);
27 - rt2x00_set_chip(rt2x00dev, RT2460, value, reg);
28 + rt2x00_set_chip_rf(rt2x00dev, value, reg);
29
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
35 */
36 value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
37 rt2x00pci_register_read(rt2x00dev, CSR0, &reg);
38 - rt2x00_set_chip(rt2x00dev, RT2560, value, reg);
39 + rt2x00_set_chip_rf(rt2x00dev, value, reg);
40
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 {
46 unsigned long flags;
47
48 /*
49 + * Device information, Bus IRQ and name (PCI, SoC)
50 + */
51 + int irq;
52 + const char *name;
53 +
54 + /*
55 * Chipset identification.
56 */
57 struct rt2x00_chip chip;
58 @@ -860,6 +866,18 @@ static inline void rt2x00_set_chip(struc
59 rt2x00dev->chip.rev = rev;
60 }
61
62 +static inline void rt2x00_set_chip_rt(struct rt2x00_dev *rt2x00dev,
63 + const u16 rt)
64 +{
65 + rt2x00dev->chip.rt = rt;
66 +}
67 +
68 +static inline void rt2x00_set_chip_rf(struct rt2x00_dev *rt2x00dev,
69 + const u16 rf, const u32 rev)
70 +{
71 + rt2x00_set_chip(rt2x00dev, rt2x00dev->chip.rt, rf, rev);
72 +}
73 +
74 static inline char rt2x00_rt(const struct rt2x00_chip *chipset, const u16 chip)
75 {
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
80
81 int rt2x00pci_initialize(struct rt2x00_dev *rt2x00dev)
82 {
83 - struct pci_dev *pci_dev = to_pci_dev(rt2x00dev->dev);
84 struct data_queue *queue;
85 int status;
86
87 @@ -186,11 +185,11 @@ int rt2x00pci_initialize(struct rt2x00_d
88 /*
89 * Register interrupt handler.
90 */
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);
95 if (status) {
96 ERROR(rt2x00dev, "IRQ %d allocation failed (error %d).\n",
97 - pci_dev->irq, status);
98 + rt2x00dev->irq, status);
99 goto exit;
100 }
101
102 @@ -270,6 +269,7 @@ int rt2x00pci_probe(struct pci_dev *pci_
103 struct ieee80211_hw *hw;
104 struct rt2x00_dev *rt2x00dev;
105 int retval;
106 + u16 chip;
107
108 retval = pci_request_regions(pci_dev, pci_name(pci_dev));
109 if (retval) {
110 @@ -307,6 +307,14 @@ int rt2x00pci_probe(struct pci_dev *pci_
111 rt2x00dev->dev = &pci_dev->dev;
112 rt2x00dev->ops = ops;
113 rt2x00dev->hw = hw;
114 + rt2x00dev->irq = pci_dev->irq;
115 + rt2x00dev->name = pci_name(pci_dev);
116 +
117 + /*
118 + * Determine RT chipset by reading PCI header.
119 + */
120 + pci_read_config_word(pci_dev, PCI_DEVICE_ID, &chip);
121 + rt2x00_set_chip_rt(rt2x00dev, chip);
122
123 retval = rt2x00pci_alloc_reg(rt2x00dev);
124 if (retval)
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
128 u32 reg;
129 u16 value;
130 u16 eeprom;
131 - u16 device;
132
133 /*
134 * Read EEPROM word for configuration.
135 @@ -2317,14 +2316,10 @@ static int rt61pci_init_eeprom(struct rt
136
137 /*
138 * Identify RF chipset.
139 - * To determine the RT chip we have to read the
140 - * PCI header of the device.
141 */
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, &reg);
146 - rt2x00_set_chip(rt2x00dev, device, value, reg);
147 + rt2x00_set_chip_rf(rt2x00dev, value, reg);
148
149 if (!rt2x00_rf(&rt2x00dev->chip, RF5225) &&
150 !rt2x00_rf(&rt2x00dev->chip, RF5325) &&