1 This patch backports the interface of the b43 and b43legacy driver from
2 the new to the old ssb API. This patch is needed as long the old ssb
3 version is used in the kernel for broadcom devices. After upgrading to
4 ssb version out of kernel 2.6.27 or later this patch is not needed any more.
6 diff --git a/drivers/net/wireless/b43/dma.c b/drivers/net/wireless/b43/dma.c
7 index 098f886..8a09a1d 100644
8 --- a/drivers/net/wireless/b43/dma.c
9 +++ b/drivers/net/wireless/b43/dma.c
10 @@ -328,11 +328,11 @@ static inline
14 - dmaaddr = ssb_dma_map_single(ring->dev->dev,
15 - buf, len, DMA_TO_DEVICE);
16 + dmaaddr = dma_map_single(ring->dev->dev->dma_dev,
17 + buf, len, DMA_TO_DEVICE);
19 - dmaaddr = ssb_dma_map_single(ring->dev->dev,
20 - buf, len, DMA_FROM_DEVICE);
21 + dmaaddr = dma_map_single(ring->dev->dev->dma_dev,
22 + buf, len, DMA_FROM_DEVICE);
26 @@ -343,11 +343,11 @@ static inline
27 dma_addr_t addr, size_t len, int tx)
30 - ssb_dma_unmap_single(ring->dev->dev,
31 - addr, len, DMA_TO_DEVICE);
32 + dma_unmap_single(ring->dev->dev->dma_dev,
33 + addr, len, DMA_TO_DEVICE);
35 - ssb_dma_unmap_single(ring->dev->dev,
36 - addr, len, DMA_FROM_DEVICE);
37 + dma_unmap_single(ring->dev->dev->dma_dev,
38 + addr, len, DMA_FROM_DEVICE);
42 @@ -356,8 +356,8 @@ static inline
43 dma_addr_t addr, size_t len)
45 B43_WARN_ON(ring->tx);
46 - ssb_dma_sync_single_for_cpu(ring->dev->dev,
47 - addr, len, DMA_FROM_DEVICE);
48 + dma_sync_single_for_cpu(ring->dev->dev->dma_dev,
49 + addr, len, DMA_FROM_DEVICE);
53 @@ -365,8 +365,8 @@ static inline
54 dma_addr_t addr, size_t len)
56 B43_WARN_ON(ring->tx);
57 - ssb_dma_sync_single_for_device(ring->dev->dev,
58 - addr, len, DMA_FROM_DEVICE);
59 + dma_sync_single_for_device(ring->dev->dev->dma_dev,
60 + addr, len, DMA_FROM_DEVICE);
64 @@ -381,6 +381,7 @@ static inline
66 static int alloc_ringmemory(struct b43_dmaring *ring)
68 + struct device *dma_dev = ring->dev->dev->dma_dev;
69 gfp_t flags = GFP_KERNEL;
71 /* The specs call for 4K buffers for 30- and 32-bit DMA with 4K
72 @@ -391,14 +392,11 @@ static int alloc_ringmemory(struct b43_dmaring *ring)
73 * For unknown reasons - possibly a hardware error - the BCM4311 rev
74 * 02, which uses 64-bit DMA, needs the ring buffer in very low memory,
75 * which accounts for the GFP_DMA flag below.
77 - * The flags here must match the flags in free_ringmemory below!
79 if (ring->type == B43_DMA_64BIT)
81 - ring->descbase = ssb_dma_alloc_consistent(ring->dev->dev,
82 - B43_DMA_RINGMEMSIZE,
83 - &(ring->dmabase), flags);
84 + ring->descbase = dma_alloc_coherent(dma_dev, B43_DMA_RINGMEMSIZE,
85 + &(ring->dmabase), flags);
86 if (!ring->descbase) {
87 b43err(ring->dev->wl, "DMA ringmemory allocation failed\n");
89 @@ -410,13 +408,10 @@ static int alloc_ringmemory(struct b43_dmaring *ring)
91 static void free_ringmemory(struct b43_dmaring *ring)
93 - gfp_t flags = GFP_KERNEL;
95 - if (ring->type == B43_DMA_64BIT)
97 + struct device *dma_dev = ring->dev->dev->dma_dev;
99 - ssb_dma_free_consistent(ring->dev->dev, B43_DMA_RINGMEMSIZE,
100 - ring->descbase, ring->dmabase, flags);
101 + dma_free_coherent(dma_dev, B43_DMA_RINGMEMSIZE,
102 + ring->descbase, ring->dmabase);
105 /* Reset the RX DMA channel */
106 @@ -523,7 +518,7 @@ static bool b43_dma_mapping_error(struct b43_dmaring *ring,
108 size_t buffersize, bool dma_to_device)
110 - if (unlikely(ssb_dma_mapping_error(ring->dev->dev, addr)))
111 + if (unlikely(dma_mapping_error(addr)))
114 switch (ring->type) {
115 @@ -849,10 +844,10 @@ struct b43_dmaring *b43_setup_dmaring(struct b43_wldev *dev,
118 /* test for ability to dma to txhdr_cache */
119 - dma_test = ssb_dma_map_single(dev->dev,
121 - b43_txhdr_size(dev),
123 + dma_test = dma_map_single(dev->dev->dma_dev,
125 + b43_txhdr_size(dev),
128 if (b43_dma_mapping_error(ring, dma_test,
129 b43_txhdr_size(dev), 1)) {
130 @@ -864,10 +859,10 @@ struct b43_dmaring *b43_setup_dmaring(struct b43_wldev *dev,
131 if (!ring->txhdr_cache)
134 - dma_test = ssb_dma_map_single(dev->dev,
136 - b43_txhdr_size(dev),
138 + dma_test = dma_map_single(dev->dev->dma_dev,
140 + b43_txhdr_size(dev),
143 if (b43_dma_mapping_error(ring, dma_test,
144 b43_txhdr_size(dev), 1)) {
145 @@ -878,9 +873,9 @@ struct b43_dmaring *b43_setup_dmaring(struct b43_wldev *dev,
149 - ssb_dma_unmap_single(dev->dev,
150 - dma_test, b43_txhdr_size(dev),
152 + dma_unmap_single(dev->dev->dma_dev,
153 + dma_test, b43_txhdr_size(dev),
157 err = alloc_ringmemory(ring);
158 diff --git a/drivers/net/wireless/b43legacy/dma.c b/drivers/net/wireless/b43legacy/dma.c
159 index fb6819e..87b1049 100644
160 --- a/drivers/net/wireless/b43legacy/dma.c
161 +++ b/drivers/net/wireless/b43legacy/dma.c
162 @@ -393,13 +393,13 @@ dma_addr_t map_descbuffer(struct b43legacy_dmaring *ring,
166 - dmaaddr = ssb_dma_map_single(ring->dev->dev,
169 + dmaaddr = dma_map_single(ring->dev->dev->dma_dev,
173 - dmaaddr = ssb_dma_map_single(ring->dev->dev,
176 + dmaaddr = dma_map_single(ring->dev->dev->dma_dev,
182 @@ -411,13 +411,13 @@ void unmap_descbuffer(struct b43legacy_dmaring *ring,
186 - ssb_dma_unmap_single(ring->dev->dev,
189 + dma_unmap_single(ring->dev->dev->dma_dev,
193 - ssb_dma_unmap_single(ring->dev->dev,
196 + dma_unmap_single(ring->dev->dev->dma_dev,
202 @@ -427,8 +427,8 @@ void sync_descbuffer_for_cpu(struct b43legacy_dmaring *ring,
204 B43legacy_WARN_ON(ring->tx);
206 - ssb_dma_sync_single_for_cpu(ring->dev->dev,
207 - addr, len, DMA_FROM_DEVICE);
208 + dma_sync_single_for_cpu(ring->dev->dev->dma_dev,
209 + addr, len, DMA_FROM_DEVICE);
213 @@ -438,8 +438,8 @@ void sync_descbuffer_for_device(struct b43legacy_dmaring *ring,
215 B43legacy_WARN_ON(ring->tx);
217 - ssb_dma_sync_single_for_device(ring->dev->dev,
218 - addr, len, DMA_FROM_DEVICE);
219 + dma_sync_single_for_device(ring->dev->dev->dma_dev,
220 + addr, len, DMA_FROM_DEVICE);
224 @@ -458,11 +458,10 @@ void free_descriptor_buffer(struct b43legacy_dmaring *ring,
226 static int alloc_ringmemory(struct b43legacy_dmaring *ring)
228 - /* GFP flags must match the flags in free_ringmemory()! */
229 - ring->descbase = ssb_dma_alloc_consistent(ring->dev->dev,
230 - B43legacy_DMA_RINGMEMSIZE,
233 + struct device *dma_dev = ring->dev->dev->dma_dev;
235 + ring->descbase = dma_alloc_coherent(dma_dev, B43legacy_DMA_RINGMEMSIZE,
236 + &(ring->dmabase), GFP_KERNEL);
237 if (!ring->descbase) {
238 b43legacyerr(ring->dev->wl, "DMA ringmemory allocation"
240 @@ -475,8 +474,10 @@ static int alloc_ringmemory(struct b43legacy_dmaring *ring)
242 static void free_ringmemory(struct b43legacy_dmaring *ring)
244 - ssb_dma_free_consistent(ring->dev->dev, B43legacy_DMA_RINGMEMSIZE,
245 - ring->descbase, ring->dmabase, GFP_KERNEL);
246 + struct device *dma_dev = ring->dev->dev->dma_dev;
248 + dma_free_coherent(dma_dev, B43legacy_DMA_RINGMEMSIZE,
249 + ring->descbase, ring->dmabase);
252 /* Reset the RX DMA channel */
253 @@ -588,7 +589,7 @@ static bool b43legacy_dma_mapping_error(struct b43legacy_dmaring *ring,
257 - if (unlikely(ssb_dma_mapping_error(ring->dev->dev, addr)))
258 + if (unlikely(dma_mapping_error(addr)))
261 switch (ring->type) {
262 @@ -905,9 +906,9 @@ struct b43legacy_dmaring *b43legacy_setup_dmaring(struct b43legacy_wldev *dev,
265 /* test for ability to dma to txhdr_cache */
266 - dma_test = ssb_dma_map_single(dev->dev, ring->txhdr_cache,
267 - sizeof(struct b43legacy_txhdr_fw3),
269 + dma_test = dma_map_single(dev->dev->dma_dev, ring->txhdr_cache,
270 + sizeof(struct b43legacy_txhdr_fw3),
273 if (b43legacy_dma_mapping_error(ring, dma_test,
274 sizeof(struct b43legacy_txhdr_fw3), 1)) {
275 @@ -919,7 +920,7 @@ struct b43legacy_dmaring *b43legacy_setup_dmaring(struct b43legacy_wldev *dev,
276 if (!ring->txhdr_cache)
279 - dma_test = ssb_dma_map_single(dev->dev,
280 + dma_test = dma_map_single(dev->dev->dma_dev,
282 sizeof(struct b43legacy_txhdr_fw3),
284 @@ -929,9 +930,9 @@ struct b43legacy_dmaring *b43legacy_setup_dmaring(struct b43legacy_wldev *dev,
285 goto err_kfree_txhdr_cache;
288 - ssb_dma_unmap_single(dev->dev, dma_test,
289 - sizeof(struct b43legacy_txhdr_fw3),
291 + dma_unmap_single(dev->dev->dma_dev,
292 + dma_test, sizeof(struct b43legacy_txhdr_fw3),
296 ring->nr_slots = nr_slots;