diff options
author | H Hartley Sweeten <hartleys@visionengravers.com> | 2011-09-20 14:06:17 -0400 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2011-09-21 11:41:48 -0400 |
commit | 7eb187b3cd3f6f285d91a196dbefac9b6adbb07c (patch) | |
tree | 2086865907f57e441d15ad16bd8bbdd07c29091a /drivers/spi/spi-dw.h | |
parent | 3e3ea716270dc64810f624ad6a3672440b45d3d4 (diff) |
spi: spi-dw: fix all sparse warnings
The dw_{read,write}[lw] macros produce sparse warnings everytime they
are used. The "read" ones cause:
warning: cast removes address space of expression
warning: incorrect type in argument 1 (different address spaces)
expected void const volatile [noderef] <asn:2>*addr
got unsigned int *<noident>
And the "write" ones:
warning: cast removes address space of expression
warning: incorrect type in argument 2 (different address spaces)
expected void volatile [noderef] <asn:2>*addr
got unsigned int *<noident>
Fix this by removing struct dw_spi_reg and converting all the register
offsets to #defines. Then convert the macros into inlined functions so
that proper type checking can occur.
While here, also fix the three sparse warnings in spi-dw-mid.c due to
the return value of ioremap_nocache being stored in a u32 * not a
void __iomem *.
With these changes the spi-dw* files all build with no sparse warnings.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Acked-by: Feng Tang <feng.tang@intel.com>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/spi/spi-dw.h')
-rw-r--r-- | drivers/spi/spi-dw.h | 97 |
1 files changed, 53 insertions, 44 deletions
diff --git a/drivers/spi/spi-dw.h b/drivers/spi/spi-dw.h index 8b7b07bf6c3f..9c57c078031e 100644 --- a/drivers/spi/spi-dw.h +++ b/drivers/spi/spi-dw.h | |||
@@ -4,6 +4,33 @@ | |||
4 | #include <linux/io.h> | 4 | #include <linux/io.h> |
5 | #include <linux/scatterlist.h> | 5 | #include <linux/scatterlist.h> |
6 | 6 | ||
7 | /* Register offsets */ | ||
8 | #define DW_SPI_CTRL0 0x00 | ||
9 | #define DW_SPI_CTRL1 0x04 | ||
10 | #define DW_SPI_SSIENR 0x08 | ||
11 | #define DW_SPI_MWCR 0x0c | ||
12 | #define DW_SPI_SER 0x10 | ||
13 | #define DW_SPI_BAUDR 0x14 | ||
14 | #define DW_SPI_TXFLTR 0x18 | ||
15 | #define DW_SPI_RXFLTR 0x1c | ||
16 | #define DW_SPI_TXFLR 0x20 | ||
17 | #define DW_SPI_RXFLR 0x24 | ||
18 | #define DW_SPI_SR 0x28 | ||
19 | #define DW_SPI_IMR 0x2c | ||
20 | #define DW_SPI_ISR 0x30 | ||
21 | #define DW_SPI_RISR 0x34 | ||
22 | #define DW_SPI_TXOICR 0x38 | ||
23 | #define DW_SPI_RXOICR 0x3c | ||
24 | #define DW_SPI_RXUICR 0x40 | ||
25 | #define DW_SPI_MSTICR 0x44 | ||
26 | #define DW_SPI_ICR 0x48 | ||
27 | #define DW_SPI_DMACR 0x4c | ||
28 | #define DW_SPI_DMATDLR 0x50 | ||
29 | #define DW_SPI_DMARDLR 0x54 | ||
30 | #define DW_SPI_IDR 0x58 | ||
31 | #define DW_SPI_VERSION 0x5c | ||
32 | #define DW_SPI_DR 0x60 | ||
33 | |||
7 | /* Bit fields in CTRLR0 */ | 34 | /* Bit fields in CTRLR0 */ |
8 | #define SPI_DFS_OFFSET 0 | 35 | #define SPI_DFS_OFFSET 0 |
9 | 36 | ||
@@ -55,35 +82,6 @@ enum dw_ssi_type { | |||
55 | SSI_NS_MICROWIRE, | 82 | SSI_NS_MICROWIRE, |
56 | }; | 83 | }; |
57 | 84 | ||
58 | struct dw_spi_reg { | ||
59 | u32 ctrl0; | ||
60 | u32 ctrl1; | ||
61 | u32 ssienr; | ||
62 | u32 mwcr; | ||
63 | u32 ser; | ||
64 | u32 baudr; | ||
65 | u32 txfltr; | ||
66 | u32 rxfltr; | ||
67 | u32 txflr; | ||
68 | u32 rxflr; | ||
69 | u32 sr; | ||
70 | u32 imr; | ||
71 | u32 isr; | ||
72 | u32 risr; | ||
73 | u32 txoicr; | ||
74 | u32 rxoicr; | ||
75 | u32 rxuicr; | ||
76 | u32 msticr; | ||
77 | u32 icr; | ||
78 | u32 dmacr; | ||
79 | u32 dmatdlr; | ||
80 | u32 dmardlr; | ||
81 | u32 idr; | ||
82 | u32 version; | ||
83 | u32 dr; /* Currently oper as 32 bits, | ||
84 | though only low 16 bits matters */ | ||
85 | } __packed; | ||
86 | |||
87 | struct dw_spi; | 85 | struct dw_spi; |
88 | struct dw_spi_dma_ops { | 86 | struct dw_spi_dma_ops { |
89 | int (*dma_init)(struct dw_spi *dws); | 87 | int (*dma_init)(struct dw_spi *dws); |
@@ -161,23 +159,34 @@ struct dw_spi { | |||
161 | #endif | 159 | #endif |
162 | }; | 160 | }; |
163 | 161 | ||
164 | #define dw_readl(dw, name) \ | 162 | static inline u32 dw_readl(struct dw_spi *dws, u32 offset) |
165 | __raw_readl(&(((struct dw_spi_reg *)dw->regs)->name)) | 163 | { |
166 | #define dw_writel(dw, name, val) \ | 164 | return __raw_readl(dws->regs + offset); |
167 | __raw_writel((val), &(((struct dw_spi_reg *)dw->regs)->name)) | 165 | } |
168 | #define dw_readw(dw, name) \ | 166 | |
169 | __raw_readw(&(((struct dw_spi_reg *)dw->regs)->name)) | 167 | static inline void dw_writel(struct dw_spi *dws, u32 offset, u32 val) |
170 | #define dw_writew(dw, name, val) \ | 168 | { |
171 | __raw_writew((val), &(((struct dw_spi_reg *)dw->regs)->name)) | 169 | __raw_writel(val, dws->regs + offset); |
170 | } | ||
171 | |||
172 | static inline u16 dw_readw(struct dw_spi *dws, u32 offset) | ||
173 | { | ||
174 | return __raw_readw(dws->regs + offset); | ||
175 | } | ||
176 | |||
177 | static inline void dw_writew(struct dw_spi *dws, u32 offset, u16 val) | ||
178 | { | ||
179 | __raw_writew(val, dws->regs + offset); | ||
180 | } | ||
172 | 181 | ||
173 | static inline void spi_enable_chip(struct dw_spi *dws, int enable) | 182 | static inline void spi_enable_chip(struct dw_spi *dws, int enable) |
174 | { | 183 | { |
175 | dw_writel(dws, ssienr, (enable ? 1 : 0)); | 184 | dw_writel(dws, DW_SPI_SSIENR, (enable ? 1 : 0)); |
176 | } | 185 | } |
177 | 186 | ||
178 | static inline void spi_set_clk(struct dw_spi *dws, u16 div) | 187 | static inline void spi_set_clk(struct dw_spi *dws, u16 div) |
179 | { | 188 | { |
180 | dw_writel(dws, baudr, div); | 189 | dw_writel(dws, DW_SPI_BAUDR, div); |
181 | } | 190 | } |
182 | 191 | ||
183 | static inline void spi_chip_sel(struct dw_spi *dws, u16 cs) | 192 | static inline void spi_chip_sel(struct dw_spi *dws, u16 cs) |
@@ -188,7 +197,7 @@ static inline void spi_chip_sel(struct dw_spi *dws, u16 cs) | |||
188 | if (dws->cs_control) | 197 | if (dws->cs_control) |
189 | dws->cs_control(1); | 198 | dws->cs_control(1); |
190 | 199 | ||
191 | dw_writel(dws, ser, 1 << cs); | 200 | dw_writel(dws, DW_SPI_SER, 1 << cs); |
192 | } | 201 | } |
193 | 202 | ||
194 | /* Disable IRQ bits */ | 203 | /* Disable IRQ bits */ |
@@ -196,8 +205,8 @@ static inline void spi_mask_intr(struct dw_spi *dws, u32 mask) | |||
196 | { | 205 | { |
197 | u32 new_mask; | 206 | u32 new_mask; |
198 | 207 | ||
199 | new_mask = dw_readl(dws, imr) & ~mask; | 208 | new_mask = dw_readl(dws, DW_SPI_IMR) & ~mask; |
200 | dw_writel(dws, imr, new_mask); | 209 | dw_writel(dws, DW_SPI_IMR, new_mask); |
201 | } | 210 | } |
202 | 211 | ||
203 | /* Enable IRQ bits */ | 212 | /* Enable IRQ bits */ |
@@ -205,8 +214,8 @@ static inline void spi_umask_intr(struct dw_spi *dws, u32 mask) | |||
205 | { | 214 | { |
206 | u32 new_mask; | 215 | u32 new_mask; |
207 | 216 | ||
208 | new_mask = dw_readl(dws, imr) | mask; | 217 | new_mask = dw_readl(dws, DW_SPI_IMR) | mask; |
209 | dw_writel(dws, imr, new_mask); | 218 | dw_writel(dws, DW_SPI_IMR, new_mask); |
210 | } | 219 | } |
211 | 220 | ||
212 | /* | 221 | /* |