aboutsummaryrefslogtreecommitdiffstats
path: root/package/mac80211/patches/406-ath9k-convert-to-struct-device.patch
blob: c8823d6551e9e85577a5ba8503dd2d035d8b68bf (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
From 5e7bcb74706e6398ea582001fe025e6eb0c5c998 Mon Sep 17 00:00:00 2001
From: Gabor Juhos <juhosg@openwrt.org>
Date: Fri, 2 Jan 2009 16:10:55 +0100
Subject: [RFC 06/12] ath9k: convert to struct device

Now that we have converted all bus specific routines to replaceable, we
can move the PCI specific codes into a separate file.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
---
 drivers/net/wireless/ath9k/core.h |    5 +++--
 drivers/net/wireless/ath9k/pci.c  |   35 ++++++++++++++++++++---------------
 2 files changed, 23 insertions(+), 17 deletions(-)

--- a/drivers/net/wireless/ath9k/core.h
+++ b/drivers/net/wireless/ath9k/core.h
@@ -18,7 +18,8 @@
 #define CORE_H
 
 #include <linux/etherdevice.h>
-#include <linux/pci.h>
+#include <linux/device.h>
+#include <linux/types.h>
 #include <net/mac80211.h>
 #include <linux/leds.h>
 #include <linux/rfkill.h>
@@ -729,7 +730,7 @@ struct ath_bus_ops {
 
 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/pci.c
+++ b/drivers/net/wireless/ath9k/pci.c
@@ -15,6 +15,8 @@
  */
 
 #include <linux/nl80211.h>
+#include <linux/pci.h>
+
 #include "core.h"
 #include "reg.h"
 #include "hw.h"
@@ -34,7 +36,8 @@ static void ath_pci_read_cachesize(struc
 {
 	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;
 
 	/*
@@ -50,49 +53,49 @@ static void ath_pci_read_cachesize(struc
 static dma_addr_t ath_pci_map_single_to_device(struct ath_softc *sc,
 					       void *p, size_t size)
 {
-	return pci_map_single(sc->pdev, p, size, PCI_DMA_TODEVICE);
+	return pci_map_single(to_pci_dev(sc->dev), p, size, PCI_DMA_TODEVICE);
 }
 
 static void ath_pci_unmap_single_to_device(struct ath_softc *sc,
 					   dma_addr_t da, size_t size)
 {
-	pci_unmap_single(sc->pdev, da, size, PCI_DMA_TODEVICE);
+	pci_unmap_single(to_pci_dev(sc->dev), da, size, PCI_DMA_TODEVICE);
 }
 
 static dma_addr_t ath_pci_map_single_from_device(struct ath_softc *sc,
 						 void *p, size_t size)
 {
-	return pci_map_single(sc->pdev, p, size, PCI_DMA_FROMDEVICE);
+	return pci_map_single(to_pci_dev(sc->dev), p, size, PCI_DMA_FROMDEVICE);
 }
 
 static void ath_pci_unmap_single_from_device(struct ath_softc *sc,
 					     dma_addr_t da, size_t size)
 {
-	pci_unmap_single(sc->pdev, da, size, PCI_DMA_FROMDEVICE);
+	pci_unmap_single(to_pci_dev(sc->dev), da, size, PCI_DMA_FROMDEVICE);
 }
 
 static int ath_pci_dma_mapping_error(struct ath_softc *sc, dma_addr_t da)
 {
-	return pci_dma_mapping_error(sc->pdev, da);
+	return pci_dma_mapping_error(to_pci_dev(sc->dev), da);
 }
 
 static void ath_pci_sync_single_for_cpu(struct ath_softc *sc, dma_addr_t da,
 				       size_t size)
 {
-	pci_dma_sync_single_for_cpu(sc->pdev, da, size,
+	pci_dma_sync_single_for_cpu(to_pci_dev(sc->dev), da, size,
 				    PCI_DMA_FROMDEVICE);
 }
 
 static void *ath_pci_dma_alloc(struct ath_softc *sc, size_t size,
 				       dma_addr_t *pda)
 {
-	return pci_alloc_consistent(sc->pdev, size, pda);
+	return pci_alloc_consistent(to_pci_dev(sc->dev), size, pda);
 }
 
 static void ath_pci_dma_free(struct ath_softc *sc, size_t size,
 				    void *p, dma_addr_t da)
 {
-	pci_free_consistent(sc->pdev, size, p, da);
+	pci_free_consistent(to_pci_dev(sc->dev), size, p, da);
 }
 
 static u32 ath_pci_reg_read(struct ath_hal *ah, unsigned reg)
@@ -107,12 +110,14 @@ static void ath_pci_reg_write(struct ath
 
 static void ath_pci_cleanup(struct ath_softc *sc)
 {
+	struct pci_dev *pdev = to_pci_dev(sc->dev);
+
 	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 (pdev->irq)
+		free_irq(pdev->irq, sc);
+	pci_iounmap(pdev, sc->mem);
+	pci_release_region(pdev, 0);
+	pci_disable_device(pdev);
 	ieee80211_free_hw(sc->hw);
 }
 
@@ -221,7 +226,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;
 	sc->bus_ops = &ath_pci_bus_ops;