summaryrefslogtreecommitdiff
path: root/package/mac80211/patches/401-ath9k-convert-to-struct-device.patch
blob: 29ad4e9fe22cf77544a361f8254815395c93fbc1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
From 3ded580cd6f24776395649b301857d075a5121fb Mon Sep 17 00:00:00 2001
From: Gabor Juhos <juhosg@openwrt.org>
Date: Mon, 5 Jan 2009 10:45:00 +0100
Subject: [PATCH v2 01/11] ath9k: convert to struct device

Convert 'struct pci_dev' to 'struct device' to make it usable on the AHB
bus as well.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
---
 drivers/net/wireless/ath9k/beacon.c |   17 ++++++++++-------
 drivers/net/wireless/ath9k/core.h   |    2 +-
 drivers/net/wireless/ath9k/main.c   |   21 +++++++++++----------
 drivers/net/wireless/ath9k/recv.c   |   15 +++++++++------
 drivers/net/wireless/ath9k/xmit.c   |    7 ++++---
 5 files changed, 35 insertions(+), 27 deletions(-)

--- a/drivers/net/wireless/ath9k/beacon.c
+++ b/drivers/net/wireless/ath9k/beacon.c
@@ -164,7 +164,7 @@ static struct ath_buf *ath_beacon_genera
 	bf = avp->av_bcbuf;
 	skb = (struct sk_buff *)bf->bf_mpdu;
 	if (skb) {
-		pci_unmap_single(sc->pdev, bf->bf_dmacontext,
+		pci_unmap_single(to_pci_dev(sc->dev), bf->bf_dmacontext,
 				 skb->len,
 				 PCI_DMA_TODEVICE);
 		dev_kfree_skb_any(skb);
@@ -188,10 +188,11 @@ static struct ath_buf *ath_beacon_genera
 	}
 
 	bf->bf_buf_addr = bf->bf_dmacontext =
-		pci_map_single(sc->pdev, skb->data,
+		pci_map_single(to_pci_dev(sc->dev), skb->data,
 			       skb->len,
 			       PCI_DMA_TODEVICE);
-	if (unlikely(pci_dma_mapping_error(sc->pdev, bf->bf_buf_addr))) {
+	if (unlikely(pci_dma_mapping_error(to_pci_dev(sc->dev),
+					   bf->bf_buf_addr))) {
 		dev_kfree_skb_any(skb);
 		bf->bf_mpdu = NULL;
 		DPRINTF(sc, ATH_DBG_CONFIG,
@@ -343,7 +344,7 @@ int ath_beacon_alloc(struct ath_softc *s
 	bf = avp->av_bcbuf;
 	if (bf->bf_mpdu != NULL) {
 		skb = (struct sk_buff *)bf->bf_mpdu;
-		pci_unmap_single(sc->pdev, bf->bf_dmacontext,
+		pci_unmap_single(to_pci_dev(sc->dev), bf->bf_dmacontext,
 				 skb->len,
 				 PCI_DMA_TODEVICE);
 		dev_kfree_skb_any(skb);
@@ -402,10 +403,11 @@ int ath_beacon_alloc(struct ath_softc *s
 
 	bf->bf_mpdu = skb;
 	bf->bf_buf_addr = bf->bf_dmacontext =
-		pci_map_single(sc->pdev, skb->data,
+		pci_map_single(to_pci_dev(sc->dev), skb->data,
 			       skb->len,
 			       PCI_DMA_TODEVICE);
-	if (unlikely(pci_dma_mapping_error(sc->pdev, bf->bf_buf_addr))) {
+	if (unlikely(pci_dma_mapping_error(to_pci_dev(sc->dev),
+					   bf->bf_buf_addr))) {
 		dev_kfree_skb_any(skb);
 		bf->bf_mpdu = NULL;
 		DPRINTF(sc, ATH_DBG_CONFIG,
@@ -429,7 +431,8 @@ void ath_beacon_return(struct ath_softc 
 		bf = avp->av_bcbuf;
 		if (bf->bf_mpdu != NULL) {
 			struct sk_buff *skb = (struct sk_buff *)bf->bf_mpdu;
-			pci_unmap_single(sc->pdev, bf->bf_dmacontext,
+			pci_unmap_single(to_pci_dev(sc->dev),
+					 bf->bf_dmacontext,
 					 skb->len,
 					 PCI_DMA_TODEVICE);
 			dev_kfree_skb_any(skb);
--- a/drivers/net/wireless/ath9k/core.h
+++ b/drivers/net/wireless/ath9k/core.h
@@ -695,7 +695,7 @@ enum PROT_MODE {
 
 struct ath_softc {
 	struct ieee80211_hw *hw;
-	struct pci_dev *pdev;
+	struct device *dev;
 	struct tasklet_struct intr_tq;
 	struct tasklet_struct bcon_tasklet;
 	struct ath_hal *sc_ah;
--- a/drivers/net/wireless/ath9k/main.c
+++ b/drivers/net/wireless/ath9k/main.c
@@ -46,7 +46,8 @@ static void bus_read_cachesize(struct at
 {
 	u8 u8tmp;
 
-	pci_read_config_byte(sc->pdev, PCI_CACHE_LINE_SIZE, (u8 *)&u8tmp);
+	pci_read_config_byte(to_pci_dev(sc->dev), PCI_CACHE_LINE_SIZE,
+			     (u8 *)&u8tmp);
 	*csz = (int)u8tmp;
 
 	/*
@@ -1267,11 +1268,11 @@ static int ath_start_rfkill_poll(struct 
 
 			/* Deinitialize the device */
 			ath_detach(sc);
-			if (sc->pdev->irq)
-				free_irq(sc->pdev->irq, sc);
-			pci_iounmap(sc->pdev, sc->mem);
-			pci_release_region(sc->pdev, 0);
-			pci_disable_device(sc->pdev);
+			if (to_pci_dev(sc->dev)->irq)
+				free_irq(to_pci_dev(sc->dev)->irq, sc);
+			pci_iounmap(to_pci_dev(sc->dev), sc->mem);
+			pci_release_region(to_pci_dev(sc->dev), 0);
+			pci_disable_device(to_pci_dev(sc->dev));
 			ieee80211_free_hw(sc->hw);
 			return -EIO;
 		} else {
@@ -1708,7 +1709,7 @@ int ath_descdma_setup(struct ath_softc *
 	}
 
 	/* allocate descriptors */
-	dd->dd_desc = pci_alloc_consistent(sc->pdev,
+	dd->dd_desc = pci_alloc_consistent(to_pci_dev(sc->dev),
 			      dd->dd_desc_len,
 			      &dd->dd_desc_paddr);
 	if (dd->dd_desc == NULL) {
@@ -1756,7 +1757,7 @@ int ath_descdma_setup(struct ath_softc *
 	}
 	return 0;
 fail2:
-	pci_free_consistent(sc->pdev,
+	pci_free_consistent(to_pci_dev(sc->dev),
 		dd->dd_desc_len, dd->dd_desc, dd->dd_desc_paddr);
 fail:
 	memset(dd, 0, sizeof(*dd));
@@ -1770,7 +1771,7 @@ void ath_descdma_cleanup(struct ath_soft
 			 struct ath_descdma *dd,
 			 struct list_head *head)
 {
-	pci_free_consistent(sc->pdev,
+	pci_free_consistent(to_pci_dev(sc->dev),
 		dd->dd_desc_len, dd->dd_desc, dd->dd_desc_paddr);
 
 	INIT_LIST_HEAD(head);
@@ -2615,7 +2616,7 @@ static int ath_pci_probe(struct pci_dev 
 
 	sc = hw->priv;
 	sc->hw = hw;
-	sc->pdev = pdev;
+	sc->dev = &pdev->dev;
 	sc->mem = mem;
 
 	if (ath_attach(id->device, sc) != 0) {
--- a/drivers/net/wireless/ath9k/recv.c
+++ b/drivers/net/wireless/ath9k/recv.c
@@ -291,10 +291,11 @@ int ath_rx_init(struct ath_softc *sc, in
 			}
 
 			bf->bf_mpdu = skb;
-			bf->bf_buf_addr = pci_map_single(sc->pdev, skb->data,
+			bf->bf_buf_addr = pci_map_single(to_pci_dev(sc->dev),
+							 skb->data,
 							 sc->rx.bufsize,
 							 PCI_DMA_FROMDEVICE);
-			if (unlikely(pci_dma_mapping_error(sc->pdev,
+			if (unlikely(pci_dma_mapping_error(to_pci_dev(sc->dev),
 				  bf->bf_buf_addr))) {
 				dev_kfree_skb_any(skb);
 				bf->bf_mpdu = NULL;
@@ -524,7 +525,8 @@ int ath_rx_tasklet(struct ath_softc *sc,
 		 * 1. accessing the frame
 		 * 2. requeueing the same buffer to h/w
 		 */
-		pci_dma_sync_single_for_cpu(sc->pdev, bf->bf_buf_addr,
+		pci_dma_sync_single_for_cpu(to_pci_dev(sc->dev),
+				bf->bf_buf_addr,
 				sc->rx.bufsize,
 				PCI_DMA_FROMDEVICE);
 
@@ -557,7 +559,7 @@ int ath_rx_tasklet(struct ath_softc *sc,
 			goto requeue;
 
 		/* Unmap the frame */
-		pci_unmap_single(sc->pdev, bf->bf_buf_addr,
+		pci_unmap_single(to_pci_dev(sc->dev), bf->bf_buf_addr,
 				 sc->rx.bufsize,
 				 PCI_DMA_FROMDEVICE);
 
@@ -599,10 +601,11 @@ int ath_rx_tasklet(struct ath_softc *sc,
 
 		/* We will now give hardware our shiny new allocated skb */
 		bf->bf_mpdu = requeue_skb;
-		bf->bf_buf_addr = pci_map_single(sc->pdev, requeue_skb->data,
+		bf->bf_buf_addr = pci_map_single(to_pci_dev(sc->dev),
+					 requeue_skb->data,
 					 sc->rx.bufsize,
 					 PCI_DMA_FROMDEVICE);
-		if (unlikely(pci_dma_mapping_error(sc->pdev,
+		if (unlikely(pci_dma_mapping_error(to_pci_dev(sc->dev),
 			  bf->bf_buf_addr))) {
 			dev_kfree_skb_any(requeue_skb);
 			bf->bf_mpdu = NULL;
--- a/drivers/net/wireless/ath9k/xmit.c
+++ b/drivers/net/wireless/ath9k/xmit.c
@@ -340,7 +340,7 @@ static void ath_tx_complete_buf(struct a
 	}
 
 	/* Unmap this frame */
-	pci_unmap_single(sc->pdev,
+	pci_unmap_single(to_pci_dev(sc->dev),
 			 bf->bf_dmacontext,
 			 skb->len,
 			 PCI_DMA_TODEVICE);
@@ -1716,9 +1716,10 @@ static int ath_tx_setup_buffer(struct at
 	/* DMA setup */
 	bf->bf_mpdu = skb;
 
-	bf->bf_dmacontext = pci_map_single(sc->pdev, skb->data,
+	bf->bf_dmacontext = pci_map_single(to_pci_dev(sc->dev), skb->data,
 					   skb->len, PCI_DMA_TODEVICE);
-	if (unlikely(pci_dma_mapping_error(sc->pdev, bf->bf_dmacontext))) {
+	if (unlikely(pci_dma_mapping_error(to_pci_dev(sc->dev),
+					   bf->bf_dmacontext))) {
 		bf->bf_mpdu = NULL;
 		DPRINTF(sc, ATH_DBG_CONFIG,
 			"pci_dma_mapping_error() on TX\n");