diff options
author | Teemu Paasikivi <ext-teemu.3.paasikivi@nokia.com> | 2010-02-22 01:38:24 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2010-03-09 15:02:58 -0500 |
commit | b42f91ba49ff135392b8f6140e21f85fb0467285 (patch) | |
tree | 8ad4c875518b75d014229f9bfbaa134f45ca9616 /drivers/net/wireless | |
parent | 8197b7118add28f9aaa99c1fb73c0e201c8cde52 (diff) |
wl1271: Inlined IO functions
Changed IO functions to static inline.
Signed-off-by: Teemu Paasikivi <ext-teemu.3.paasikivi@nokia.com>
Reviewed-by: Juuso Oikarinen <juuso.oikarinen@nokia.com>
Signed-off-by: Juuso Oikarinen <juuso.oikarinen@nokia.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r-- | drivers/net/wireless/wl12xx/wl1271_io.c | 70 | ||||
-rw-r--r-- | drivers/net/wireless/wl12xx/wl1271_io.h | 96 | ||||
-rw-r--r-- | drivers/net/wireless/wl12xx/wl1271_spi.c | 2 |
3 files changed, 78 insertions, 90 deletions
diff --git a/drivers/net/wireless/wl12xx/wl1271_io.c b/drivers/net/wireless/wl12xx/wl1271_io.c index d00f7ed7f21c..c0826585a497 100644 --- a/drivers/net/wireless/wl12xx/wl1271_io.c +++ b/drivers/net/wireless/wl12xx/wl1271_io.c | |||
@@ -31,11 +31,6 @@ | |||
31 | #include "wl1271_spi.h" | 31 | #include "wl1271_spi.h" |
32 | #include "wl1271_io.h" | 32 | #include "wl1271_io.h" |
33 | 33 | ||
34 | struct device *wl1271_wl_to_dev(struct wl1271 *wl) | ||
35 | { | ||
36 | return wl->if_ops->dev(wl); | ||
37 | } | ||
38 | |||
39 | void wl1271_disable_interrupts(struct wl1271 *wl) | 34 | void wl1271_disable_interrupts(struct wl1271 *wl) |
40 | { | 35 | { |
41 | wl->if_ops->disable_irq(wl); | 36 | wl->if_ops->disable_irq(wl); |
@@ -46,29 +41,6 @@ void wl1271_enable_interrupts(struct wl1271 *wl) | |||
46 | wl->if_ops->enable_irq(wl); | 41 | wl->if_ops->enable_irq(wl); |
47 | } | 42 | } |
48 | 43 | ||
49 | static int wl1271_translate_addr(struct wl1271 *wl, int addr) | ||
50 | { | ||
51 | /* | ||
52 | * To translate, first check to which window of addresses the | ||
53 | * particular address belongs. Then subtract the starting address | ||
54 | * of that window from the address. Then, add offset of the | ||
55 | * translated region. | ||
56 | * | ||
57 | * The translated regions occur next to each other in physical device | ||
58 | * memory, so just add the sizes of the preceeding address regions to | ||
59 | * get the offset to the new region. | ||
60 | * | ||
61 | * Currently, only the two first regions are addressed, and the | ||
62 | * assumption is that all addresses will fall into either of those | ||
63 | * two. | ||
64 | */ | ||
65 | if ((addr >= wl->part.reg.start) && | ||
66 | (addr < wl->part.reg.start + wl->part.reg.size)) | ||
67 | return addr - wl->part.reg.start + wl->part.mem.size; | ||
68 | else | ||
69 | return addr - wl->part.mem.start; | ||
70 | } | ||
71 | |||
72 | /* Set the SPI partitions to access the chip addresses | 44 | /* Set the SPI partitions to access the chip addresses |
73 | * | 45 | * |
74 | * To simplify driver code, a fixed (virtual) memory map is defined for | 46 | * To simplify driver code, a fixed (virtual) memory map is defined for |
@@ -140,48 +112,6 @@ void wl1271_io_init(struct wl1271 *wl) | |||
140 | wl->if_ops->init(wl); | 112 | wl->if_ops->init(wl); |
141 | } | 113 | } |
142 | 114 | ||
143 | void wl1271_raw_write(struct wl1271 *wl, int addr, void *buf, | ||
144 | size_t len, bool fixed) | ||
145 | { | ||
146 | wl->if_ops->write(wl, addr, buf, len, fixed); | ||
147 | } | ||
148 | |||
149 | void wl1271_raw_read(struct wl1271 *wl, int addr, void *buf, | ||
150 | size_t len, bool fixed) | ||
151 | { | ||
152 | wl->if_ops->read(wl, addr, buf, len, fixed); | ||
153 | } | ||
154 | |||
155 | void wl1271_read(struct wl1271 *wl, int addr, void *buf, size_t len, | ||
156 | bool fixed) | ||
157 | { | ||
158 | int physical; | ||
159 | |||
160 | physical = wl1271_translate_addr(wl, addr); | ||
161 | |||
162 | wl1271_raw_read(wl, physical, buf, len, fixed); | ||
163 | } | ||
164 | |||
165 | void wl1271_write(struct wl1271 *wl, int addr, void *buf, size_t len, | ||
166 | bool fixed) | ||
167 | { | ||
168 | int physical; | ||
169 | |||
170 | physical = wl1271_translate_addr(wl, addr); | ||
171 | |||
172 | wl1271_raw_write(wl, physical, buf, len, fixed); | ||
173 | } | ||
174 | |||
175 | u32 wl1271_read32(struct wl1271 *wl, int addr) | ||
176 | { | ||
177 | return wl1271_raw_read32(wl, wl1271_translate_addr(wl, addr)); | ||
178 | } | ||
179 | |||
180 | void wl1271_write32(struct wl1271 *wl, int addr, u32 val) | ||
181 | { | ||
182 | wl1271_raw_write32(wl, wl1271_translate_addr(wl, addr), val); | ||
183 | } | ||
184 | |||
185 | void wl1271_top_reg_write(struct wl1271 *wl, int addr, u16 val) | 115 | void wl1271_top_reg_write(struct wl1271 *wl, int addr, u16 val) |
186 | { | 116 | { |
187 | /* write address >> 1 + 0x30000 to OCP_POR_CTR */ | 117 | /* write address >> 1 + 0x30000 to OCP_POR_CTR */ |
diff --git a/drivers/net/wireless/wl12xx/wl1271_io.h b/drivers/net/wireless/wl12xx/wl1271_io.h index f2b6325ba2a7..8501898950db 100644 --- a/drivers/net/wireless/wl12xx/wl1271_io.h +++ b/drivers/net/wireless/wl12xx/wl1271_io.h | |||
@@ -33,28 +33,24 @@ void wl1271_enable_interrupts(struct wl1271 *wl); | |||
33 | void wl1271_io_reset(struct wl1271 *wl); | 33 | void wl1271_io_reset(struct wl1271 *wl); |
34 | void wl1271_io_init(struct wl1271 *wl); | 34 | void wl1271_io_init(struct wl1271 *wl); |
35 | 35 | ||
36 | struct device *wl1271_wl_to_dev(struct wl1271 *wl); | 36 | static inline struct device *wl1271_wl_to_dev(struct wl1271 *wl) |
37 | 37 | { | |
38 | /* Raw target IO, address is not translated */ | 38 | return wl->if_ops->dev(wl); |
39 | void wl1271_raw_write(struct wl1271 *wl, int addr, void *buf, | 39 | } |
40 | size_t len, bool fixed); | ||
41 | void wl1271_raw_read(struct wl1271 *wl, int addr, void *buf, | ||
42 | size_t len, bool fixed); | ||
43 | 40 | ||
44 | /* Translated target IO */ | ||
45 | void wl1271_read(struct wl1271 *wl, int addr, void *buf, size_t len, | ||
46 | bool fixed); | ||
47 | void wl1271_write(struct wl1271 *wl, int addr, void *buf, size_t len, | ||
48 | bool fixed); | ||
49 | u32 wl1271_read32(struct wl1271 *wl, int addr); | ||
50 | void wl1271_write32(struct wl1271 *wl, int addr, u32 val); | ||
51 | 41 | ||
52 | /* Top Register IO */ | 42 | /* Raw target IO, address is not translated */ |
53 | void wl1271_top_reg_write(struct wl1271 *wl, int addr, u16 val); | 43 | static inline void wl1271_raw_write(struct wl1271 *wl, int addr, void *buf, |
54 | u16 wl1271_top_reg_read(struct wl1271 *wl, int addr); | 44 | size_t len, bool fixed) |
45 | { | ||
46 | wl->if_ops->write(wl, addr, buf, len, fixed); | ||
47 | } | ||
55 | 48 | ||
56 | int wl1271_set_partition(struct wl1271 *wl, | 49 | static inline void wl1271_raw_read(struct wl1271 *wl, int addr, void *buf, |
57 | struct wl1271_partition_set *p); | 50 | size_t len, bool fixed) |
51 | { | ||
52 | wl->if_ops->read(wl, addr, buf, len, fixed); | ||
53 | } | ||
58 | 54 | ||
59 | static inline u32 wl1271_raw_read32(struct wl1271 *wl, int addr) | 55 | static inline u32 wl1271_raw_read32(struct wl1271 *wl, int addr) |
60 | { | 56 | { |
@@ -71,6 +67,68 @@ static inline void wl1271_raw_write32(struct wl1271 *wl, int addr, u32 val) | |||
71 | sizeof(wl->buffer_32), false); | 67 | sizeof(wl->buffer_32), false); |
72 | } | 68 | } |
73 | 69 | ||
70 | /* Translated target IO */ | ||
71 | static inline int wl1271_translate_addr(struct wl1271 *wl, int addr) | ||
72 | { | ||
73 | /* | ||
74 | * To translate, first check to which window of addresses the | ||
75 | * particular address belongs. Then subtract the starting address | ||
76 | * of that window from the address. Then, add offset of the | ||
77 | * translated region. | ||
78 | * | ||
79 | * The translated regions occur next to each other in physical device | ||
80 | * memory, so just add the sizes of the preceeding address regions to | ||
81 | * get the offset to the new region. | ||
82 | * | ||
83 | * Currently, only the two first regions are addressed, and the | ||
84 | * assumption is that all addresses will fall into either of those | ||
85 | * two. | ||
86 | */ | ||
87 | if ((addr >= wl->part.reg.start) && | ||
88 | (addr < wl->part.reg.start + wl->part.reg.size)) | ||
89 | return addr - wl->part.reg.start + wl->part.mem.size; | ||
90 | else | ||
91 | return addr - wl->part.mem.start; | ||
92 | } | ||
93 | |||
94 | static inline void wl1271_read(struct wl1271 *wl, int addr, void *buf, | ||
95 | size_t len, bool fixed) | ||
96 | { | ||
97 | int physical; | ||
98 | |||
99 | physical = wl1271_translate_addr(wl, addr); | ||
100 | |||
101 | wl1271_raw_read(wl, physical, buf, len, fixed); | ||
102 | } | ||
103 | |||
104 | static inline void wl1271_write(struct wl1271 *wl, int addr, void *buf, | ||
105 | size_t len, bool fixed) | ||
106 | { | ||
107 | int physical; | ||
108 | |||
109 | physical = wl1271_translate_addr(wl, addr); | ||
110 | |||
111 | wl1271_raw_write(wl, physical, buf, len, fixed); | ||
112 | } | ||
113 | |||
114 | static inline u32 wl1271_read32(struct wl1271 *wl, int addr) | ||
115 | { | ||
116 | return wl1271_raw_read32(wl, wl1271_translate_addr(wl, addr)); | ||
117 | } | ||
118 | |||
119 | static inline void wl1271_write32(struct wl1271 *wl, int addr, u32 val) | ||
120 | { | ||
121 | wl1271_raw_write32(wl, wl1271_translate_addr(wl, addr), val); | ||
122 | } | ||
123 | |||
124 | |||
125 | /* Top Register IO */ | ||
126 | void wl1271_top_reg_write(struct wl1271 *wl, int addr, u16 val); | ||
127 | u16 wl1271_top_reg_read(struct wl1271 *wl, int addr); | ||
128 | |||
129 | int wl1271_set_partition(struct wl1271 *wl, | ||
130 | struct wl1271_partition_set *p); | ||
131 | |||
74 | /* Functions from wl1271_main.c */ | 132 | /* Functions from wl1271_main.c */ |
75 | 133 | ||
76 | int wl1271_register_hw(struct wl1271 *wl); | 134 | int wl1271_register_hw(struct wl1271 *wl); |
diff --git a/drivers/net/wireless/wl12xx/wl1271_spi.c b/drivers/net/wireless/wl12xx/wl1271_spi.c index a0f416972be2..f89e1b3ac1bb 100644 --- a/drivers/net/wireless/wl12xx/wl1271_spi.c +++ b/drivers/net/wireless/wl12xx/wl1271_spi.c | |||
@@ -33,7 +33,7 @@ | |||
33 | #include "wl1271_spi.h" | 33 | #include "wl1271_spi.h" |
34 | #include "wl1271_io.h" | 34 | #include "wl1271_io.h" |
35 | 35 | ||
36 | static struct spi_device *wl_to_spi(struct wl1271 *wl) | 36 | static inline struct spi_device *wl_to_spi(struct wl1271 *wl) |
37 | { | 37 | { |
38 | return wl->if_priv; | 38 | return wl->if_priv; |
39 | } | 39 | } |