e71df0eb376dd70102b8ec5ada745ebd90b85dda
[openwrt/svn-archive/archive.git] / package / mac80211 / patches / 401-ath9k-convert-to-struct-device.patch
1 From 3ded580cd6f24776395649b301857d075a5121fb Mon Sep 17 00:00:00 2001
2 From: Gabor Juhos <juhosg@openwrt.org>
3 Date: Mon, 5 Jan 2009 10:45:00 +0100
4 Subject: [PATCH v2 01/11] ath9k: convert to struct device
5
6 Convert 'struct pci_dev' to 'struct device' to make it usable on the AHB
7 bus as well.
8
9 Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
10 Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
11 ---
12 drivers/net/wireless/ath9k/beacon.c | 17 ++++++++++-------
13 drivers/net/wireless/ath9k/core.h | 2 +-
14 drivers/net/wireless/ath9k/main.c | 21 +++++++++++----------
15 drivers/net/wireless/ath9k/recv.c | 15 +++++++++------
16 drivers/net/wireless/ath9k/xmit.c | 7 ++++---
17 5 files changed, 35 insertions(+), 27 deletions(-)
18
19 --- a/drivers/net/wireless/ath9k/beacon.c
20 +++ b/drivers/net/wireless/ath9k/beacon.c
21 @@ -164,7 +164,7 @@ static struct ath_buf *ath_beacon_genera
22 bf = avp->av_bcbuf;
23 skb = (struct sk_buff *)bf->bf_mpdu;
24 if (skb) {
25 - pci_unmap_single(sc->pdev, bf->bf_dmacontext,
26 + pci_unmap_single(to_pci_dev(sc->dev), bf->bf_dmacontext,
27 skb->len,
28 PCI_DMA_TODEVICE);
29 dev_kfree_skb_any(skb);
30 @@ -188,10 +188,11 @@ static struct ath_buf *ath_beacon_genera
31 }
32
33 bf->bf_buf_addr = bf->bf_dmacontext =
34 - pci_map_single(sc->pdev, skb->data,
35 + pci_map_single(to_pci_dev(sc->dev), skb->data,
36 skb->len,
37 PCI_DMA_TODEVICE);
38 - if (unlikely(pci_dma_mapping_error(sc->pdev, bf->bf_buf_addr))) {
39 + if (unlikely(pci_dma_mapping_error(to_pci_dev(sc->dev),
40 + bf->bf_buf_addr))) {
41 dev_kfree_skb_any(skb);
42 bf->bf_mpdu = NULL;
43 DPRINTF(sc, ATH_DBG_CONFIG,
44 @@ -343,7 +344,7 @@ int ath_beacon_alloc(struct ath_softc *s
45 bf = avp->av_bcbuf;
46 if (bf->bf_mpdu != NULL) {
47 skb = (struct sk_buff *)bf->bf_mpdu;
48 - pci_unmap_single(sc->pdev, bf->bf_dmacontext,
49 + pci_unmap_single(to_pci_dev(sc->dev), bf->bf_dmacontext,
50 skb->len,
51 PCI_DMA_TODEVICE);
52 dev_kfree_skb_any(skb);
53 @@ -402,10 +403,11 @@ int ath_beacon_alloc(struct ath_softc *s
54
55 bf->bf_mpdu = skb;
56 bf->bf_buf_addr = bf->bf_dmacontext =
57 - pci_map_single(sc->pdev, skb->data,
58 + pci_map_single(to_pci_dev(sc->dev), skb->data,
59 skb->len,
60 PCI_DMA_TODEVICE);
61 - if (unlikely(pci_dma_mapping_error(sc->pdev, bf->bf_buf_addr))) {
62 + if (unlikely(pci_dma_mapping_error(to_pci_dev(sc->dev),
63 + bf->bf_buf_addr))) {
64 dev_kfree_skb_any(skb);
65 bf->bf_mpdu = NULL;
66 DPRINTF(sc, ATH_DBG_CONFIG,
67 @@ -429,7 +431,8 @@ void ath_beacon_return(struct ath_softc
68 bf = avp->av_bcbuf;
69 if (bf->bf_mpdu != NULL) {
70 struct sk_buff *skb = (struct sk_buff *)bf->bf_mpdu;
71 - pci_unmap_single(sc->pdev, bf->bf_dmacontext,
72 + pci_unmap_single(to_pci_dev(sc->dev),
73 + bf->bf_dmacontext,
74 skb->len,
75 PCI_DMA_TODEVICE);
76 dev_kfree_skb_any(skb);
77 --- a/drivers/net/wireless/ath9k/core.h
78 +++ b/drivers/net/wireless/ath9k/core.h
79 @@ -695,7 +695,7 @@ enum PROT_MODE {
80
81 struct ath_softc {
82 struct ieee80211_hw *hw;
83 - struct pci_dev *pdev;
84 + struct device *dev;
85 struct tasklet_struct intr_tq;
86 struct tasklet_struct bcon_tasklet;
87 struct ath_hal *sc_ah;
88 --- a/drivers/net/wireless/ath9k/main.c
89 +++ b/drivers/net/wireless/ath9k/main.c
90 @@ -46,7 +46,8 @@ static void bus_read_cachesize(struct at
91 {
92 u8 u8tmp;
93
94 - pci_read_config_byte(sc->pdev, PCI_CACHE_LINE_SIZE, (u8 *)&u8tmp);
95 + pci_read_config_byte(to_pci_dev(sc->dev), PCI_CACHE_LINE_SIZE,
96 + (u8 *)&u8tmp);
97 *csz = (int)u8tmp;
98
99 /*
100 @@ -1269,11 +1270,11 @@ static int ath_start_rfkill_poll(struct
101
102 /* Deinitialize the device */
103 ath_detach(sc);
104 - if (sc->pdev->irq)
105 - free_irq(sc->pdev->irq, sc);
106 - pci_iounmap(sc->pdev, sc->mem);
107 - pci_release_region(sc->pdev, 0);
108 - pci_disable_device(sc->pdev);
109 + if (to_pci_dev(sc->dev)->irq)
110 + free_irq(to_pci_dev(sc->dev)->irq, sc);
111 + pci_iounmap(to_pci_dev(sc->dev), sc->mem);
112 + pci_release_region(to_pci_dev(sc->dev), 0);
113 + pci_disable_device(to_pci_dev(sc->dev));
114 ieee80211_free_hw(sc->hw);
115 return -EIO;
116 } else {
117 @@ -1716,7 +1717,7 @@ int ath_descdma_setup(struct ath_softc *
118 }
119
120 /* allocate descriptors */
121 - dd->dd_desc = pci_alloc_consistent(sc->pdev,
122 + dd->dd_desc = pci_alloc_consistent(to_pci_dev(sc->dev),
123 dd->dd_desc_len,
124 &dd->dd_desc_paddr);
125 if (dd->dd_desc == NULL) {
126 @@ -1764,7 +1765,7 @@ int ath_descdma_setup(struct ath_softc *
127 }
128 return 0;
129 fail2:
130 - pci_free_consistent(sc->pdev,
131 + pci_free_consistent(to_pci_dev(sc->dev),
132 dd->dd_desc_len, dd->dd_desc, dd->dd_desc_paddr);
133 fail:
134 memset(dd, 0, sizeof(*dd));
135 @@ -1778,7 +1779,7 @@ void ath_descdma_cleanup(struct ath_soft
136 struct ath_descdma *dd,
137 struct list_head *head)
138 {
139 - pci_free_consistent(sc->pdev,
140 + pci_free_consistent(to_pci_dev(sc->dev),
141 dd->dd_desc_len, dd->dd_desc, dd->dd_desc_paddr);
142
143 INIT_LIST_HEAD(head);
144 @@ -2624,7 +2625,7 @@ static int ath_pci_probe(struct pci_dev
145
146 sc = hw->priv;
147 sc->hw = hw;
148 - sc->pdev = pdev;
149 + sc->dev = &pdev->dev;
150 sc->mem = mem;
151
152 if (ath_attach(id->device, sc) != 0) {
153 --- a/drivers/net/wireless/ath9k/recv.c
154 +++ b/drivers/net/wireless/ath9k/recv.c
155 @@ -291,10 +291,11 @@ int ath_rx_init(struct ath_softc *sc, in
156 }
157
158 bf->bf_mpdu = skb;
159 - bf->bf_buf_addr = pci_map_single(sc->pdev, skb->data,
160 + bf->bf_buf_addr = pci_map_single(to_pci_dev(sc->dev),
161 + skb->data,
162 sc->rx.bufsize,
163 PCI_DMA_FROMDEVICE);
164 - if (unlikely(pci_dma_mapping_error(sc->pdev,
165 + if (unlikely(pci_dma_mapping_error(to_pci_dev(sc->dev),
166 bf->bf_buf_addr))) {
167 dev_kfree_skb_any(skb);
168 bf->bf_mpdu = NULL;
169 @@ -524,7 +525,8 @@ int ath_rx_tasklet(struct ath_softc *sc,
170 * 1. accessing the frame
171 * 2. requeueing the same buffer to h/w
172 */
173 - pci_dma_sync_single_for_cpu(sc->pdev, bf->bf_buf_addr,
174 + pci_dma_sync_single_for_cpu(to_pci_dev(sc->dev),
175 + bf->bf_buf_addr,
176 sc->rx.bufsize,
177 PCI_DMA_FROMDEVICE);
178
179 @@ -557,7 +559,7 @@ int ath_rx_tasklet(struct ath_softc *sc,
180 goto requeue;
181
182 /* Unmap the frame */
183 - pci_unmap_single(sc->pdev, bf->bf_buf_addr,
184 + pci_unmap_single(to_pci_dev(sc->dev), bf->bf_buf_addr,
185 sc->rx.bufsize,
186 PCI_DMA_FROMDEVICE);
187
188 @@ -605,10 +607,11 @@ int ath_rx_tasklet(struct ath_softc *sc,
189
190 /* We will now give hardware our shiny new allocated skb */
191 bf->bf_mpdu = requeue_skb;
192 - bf->bf_buf_addr = pci_map_single(sc->pdev, requeue_skb->data,
193 + bf->bf_buf_addr = pci_map_single(to_pci_dev(sc->dev),
194 + requeue_skb->data,
195 sc->rx.bufsize,
196 PCI_DMA_FROMDEVICE);
197 - if (unlikely(pci_dma_mapping_error(sc->pdev,
198 + if (unlikely(pci_dma_mapping_error(to_pci_dev(sc->dev),
199 bf->bf_buf_addr))) {
200 dev_kfree_skb_any(requeue_skb);
201 bf->bf_mpdu = NULL;
202 --- a/drivers/net/wireless/ath9k/xmit.c
203 +++ b/drivers/net/wireless/ath9k/xmit.c
204 @@ -340,7 +340,7 @@ static void ath_tx_complete_buf(struct a
205 }
206
207 /* Unmap this frame */
208 - pci_unmap_single(sc->pdev,
209 + pci_unmap_single(to_pci_dev(sc->dev),
210 bf->bf_dmacontext,
211 skb->len,
212 PCI_DMA_TODEVICE);
213 @@ -1716,9 +1716,10 @@ static int ath_tx_setup_buffer(struct at
214 /* DMA setup */
215 bf->bf_mpdu = skb;
216
217 - bf->bf_dmacontext = pci_map_single(sc->pdev, skb->data,
218 + bf->bf_dmacontext = pci_map_single(to_pci_dev(sc->dev), skb->data,
219 skb->len, PCI_DMA_TODEVICE);
220 - if (unlikely(pci_dma_mapping_error(sc->pdev, bf->bf_dmacontext))) {
221 + if (unlikely(pci_dma_mapping_error(to_pci_dev(sc->dev),
222 + bf->bf_dmacontext))) {
223 bf->bf_mpdu = NULL;
224 DPRINTF(sc, ATH_DBG_CONFIG,
225 "pci_dma_mapping_error() on TX\n");