[package] mac80211: add preliminary support for the AR913x SoCs
[openwrt/svn-archive/archive.git] / package / mac80211 / patches / 406-ath9k-convert-to-struct-device.patch
1 From 5e7bcb74706e6398ea582001fe025e6eb0c5c998 Mon Sep 17 00:00:00 2001
2 From: Gabor Juhos <juhosg@openwrt.org>
3 Date: Fri, 2 Jan 2009 16:10:55 +0100
4 Subject: [RFC 06/12] ath9k: convert to struct device
5
6 Now that we have converted all bus specific routines to replaceable, we
7 can move the PCI specific codes into a separate file.
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/core.h | 5 +++--
13 drivers/net/wireless/ath9k/pci.c | 35 ++++++++++++++++++++---------------
14 2 files changed, 23 insertions(+), 17 deletions(-)
15
16 --- a/drivers/net/wireless/ath9k/core.h
17 +++ b/drivers/net/wireless/ath9k/core.h
18 @@ -18,7 +18,8 @@
19 #define CORE_H
20
21 #include <linux/etherdevice.h>
22 -#include <linux/pci.h>
23 +#include <linux/device.h>
24 +#include <linux/types.h>
25 #include <net/mac80211.h>
26 #include <linux/leds.h>
27 #include <linux/rfkill.h>
28 @@ -729,7 +730,7 @@ struct ath_bus_ops {
29
30 struct ath_softc {
31 struct ieee80211_hw *hw;
32 - struct pci_dev *pdev;
33 + struct device *dev;
34 struct tasklet_struct intr_tq;
35 struct tasklet_struct bcon_tasklet;
36 struct ath_hal *sc_ah;
37 --- a/drivers/net/wireless/ath9k/pci.c
38 +++ b/drivers/net/wireless/ath9k/pci.c
39 @@ -15,6 +15,8 @@
40 */
41
42 #include <linux/nl80211.h>
43 +#include <linux/pci.h>
44 +
45 #include "core.h"
46 #include "reg.h"
47 #include "hw.h"
48 @@ -34,7 +36,8 @@ static void ath_pci_read_cachesize(struc
49 {
50 u8 u8tmp;
51
52 - pci_read_config_byte(sc->pdev, PCI_CACHE_LINE_SIZE, (u8 *)&u8tmp);
53 + pci_read_config_byte(to_pci_dev(sc->dev), PCI_CACHE_LINE_SIZE,
54 + (u8 *)&u8tmp);
55 *csz = (int)u8tmp;
56
57 /*
58 @@ -50,49 +53,49 @@ static void ath_pci_read_cachesize(struc
59 static dma_addr_t ath_pci_map_single_to_device(struct ath_softc *sc,
60 void *p, size_t size)
61 {
62 - return pci_map_single(sc->pdev, p, size, PCI_DMA_TODEVICE);
63 + return pci_map_single(to_pci_dev(sc->dev), p, size, PCI_DMA_TODEVICE);
64 }
65
66 static void ath_pci_unmap_single_to_device(struct ath_softc *sc,
67 dma_addr_t da, size_t size)
68 {
69 - pci_unmap_single(sc->pdev, da, size, PCI_DMA_TODEVICE);
70 + pci_unmap_single(to_pci_dev(sc->dev), da, size, PCI_DMA_TODEVICE);
71 }
72
73 static dma_addr_t ath_pci_map_single_from_device(struct ath_softc *sc,
74 void *p, size_t size)
75 {
76 - return pci_map_single(sc->pdev, p, size, PCI_DMA_FROMDEVICE);
77 + return pci_map_single(to_pci_dev(sc->dev), p, size, PCI_DMA_FROMDEVICE);
78 }
79
80 static void ath_pci_unmap_single_from_device(struct ath_softc *sc,
81 dma_addr_t da, size_t size)
82 {
83 - pci_unmap_single(sc->pdev, da, size, PCI_DMA_FROMDEVICE);
84 + pci_unmap_single(to_pci_dev(sc->dev), da, size, PCI_DMA_FROMDEVICE);
85 }
86
87 static int ath_pci_dma_mapping_error(struct ath_softc *sc, dma_addr_t da)
88 {
89 - return pci_dma_mapping_error(sc->pdev, da);
90 + return pci_dma_mapping_error(to_pci_dev(sc->dev), da);
91 }
92
93 static void ath_pci_sync_single_for_cpu(struct ath_softc *sc, dma_addr_t da,
94 size_t size)
95 {
96 - pci_dma_sync_single_for_cpu(sc->pdev, da, size,
97 + pci_dma_sync_single_for_cpu(to_pci_dev(sc->dev), da, size,
98 PCI_DMA_FROMDEVICE);
99 }
100
101 static void *ath_pci_dma_alloc(struct ath_softc *sc, size_t size,
102 dma_addr_t *pda)
103 {
104 - return pci_alloc_consistent(sc->pdev, size, pda);
105 + return pci_alloc_consistent(to_pci_dev(sc->dev), size, pda);
106 }
107
108 static void ath_pci_dma_free(struct ath_softc *sc, size_t size,
109 void *p, dma_addr_t da)
110 {
111 - pci_free_consistent(sc->pdev, size, p, da);
112 + pci_free_consistent(to_pci_dev(sc->dev), size, p, da);
113 }
114
115 static u32 ath_pci_reg_read(struct ath_hal *ah, unsigned reg)
116 @@ -107,12 +110,14 @@ static void ath_pci_reg_write(struct ath
117
118 static void ath_pci_cleanup(struct ath_softc *sc)
119 {
120 + struct pci_dev *pdev = to_pci_dev(sc->dev);
121 +
122 ath_detach(sc);
123 - if (sc->pdev->irq)
124 - free_irq(sc->pdev->irq, sc);
125 - pci_iounmap(sc->pdev, sc->mem);
126 - pci_release_region(sc->pdev, 0);
127 - pci_disable_device(sc->pdev);
128 + if (pdev->irq)
129 + free_irq(pdev->irq, sc);
130 + pci_iounmap(pdev, sc->mem);
131 + pci_release_region(pdev, 0);
132 + pci_disable_device(pdev);
133 ieee80211_free_hw(sc->hw);
134 }
135
136 @@ -221,7 +226,7 @@ static int ath_pci_probe(struct pci_dev
137
138 sc = hw->priv;
139 sc->hw = hw;
140 - sc->pdev = pdev;
141 + sc->dev = &pdev->dev;
142 sc->mem = mem;
143 sc->bus_ops = &ath_pci_bus_ops;
144