aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/sfc
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2010-12-06 17:55:33 -0500
committerBen Hutchings <bhutchings@solarflare.com>2010-12-06 17:55:33 -0500
commit1a29cc40115c011895143c5f8278dee49423d5df (patch)
tree8084812cb134b878a1227eaa9fd71b9c7a9712cc /drivers/net/sfc
parent494bdf1b0fd58688d055f1b66c34b0844dcfc1fa (diff)
sfc: Add compile-time checks for correctness of paged register writes
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Diffstat (limited to 'drivers/net/sfc')
-rw-r--r--drivers/net/sfc/io.h31
1 files changed, 23 insertions, 8 deletions
diff --git a/drivers/net/sfc/io.h b/drivers/net/sfc/io.h
index 896b31e8606d..7f3adf29d6f6 100644
--- a/drivers/net/sfc/io.h
+++ b/drivers/net/sfc/io.h
@@ -226,29 +226,40 @@ static inline void efx_readd_table(struct efx_nic *efx, efx_dword_t *value,
226 ((page) * EFX_PAGE_BLOCK_SIZE + (reg)) 226 ((page) * EFX_PAGE_BLOCK_SIZE + (reg))
227 227
228/* Write the whole of RX_DESC_UPD or TX_DESC_UPD */ 228/* Write the whole of RX_DESC_UPD or TX_DESC_UPD */
229static inline void efx_writeo_page(struct efx_nic *efx, efx_oword_t *value, 229static inline void _efx_writeo_page(struct efx_nic *efx, efx_oword_t *value,
230 unsigned int reg, unsigned int page) 230 unsigned int reg, unsigned int page)
231{ 231{
232 efx_writeo(efx, value, EFX_PAGED_REG(page, reg)); 232 efx_writeo(efx, value, EFX_PAGED_REG(page, reg));
233} 233}
234#define efx_writeo_page(efx, value, reg, page) \
235 _efx_writeo_page(efx, value, \
236 reg + \
237 BUILD_BUG_ON_ZERO((reg) != 0x830 && (reg) != 0xa10), \
238 page)
234 239
235/* Write a page-mapped 32-bit CSR (EVQ_RPTR or the high bits of 240/* Write a page-mapped 32-bit CSR (EVQ_RPTR or the high bits of
236 * RX_DESC_UPD or TX_DESC_UPD) 241 * RX_DESC_UPD or TX_DESC_UPD)
237 */ 242 */
238static inline void efx_writed_page(struct efx_nic *efx, efx_dword_t *value, 243static inline void _efx_writed_page(struct efx_nic *efx, efx_dword_t *value,
239 unsigned int reg, unsigned int page) 244 unsigned int reg, unsigned int page)
240{ 245{
241 efx_writed(efx, value, EFX_PAGED_REG(page, reg)); 246 efx_writed(efx, value, EFX_PAGED_REG(page, reg));
242} 247}
248#define efx_writed_page(efx, value, reg, page) \
249 _efx_writed_page(efx, value, \
250 reg + \
251 BUILD_BUG_ON_ZERO((reg) != 0x400 && (reg) != 0x83c \
252 && (reg) != 0xa1c), \
253 page)
243 254
244/* Write TIMER_COMMAND. This is a page-mapped 32-bit CSR, but a bug 255/* Write TIMER_COMMAND. This is a page-mapped 32-bit CSR, but a bug
245 * in the BIU means that writes to TIMER_COMMAND[0] invalidate the 256 * in the BIU means that writes to TIMER_COMMAND[0] invalidate the
246 * collector register. 257 * collector register.
247 */ 258 */
248static inline void efx_writed_page_locked(struct efx_nic *efx, 259static inline void _efx_writed_page_locked(struct efx_nic *efx,
249 efx_dword_t *value, 260 efx_dword_t *value,
250 unsigned int reg, 261 unsigned int reg,
251 unsigned int page) 262 unsigned int page)
252{ 263{
253 unsigned long flags __attribute__ ((unused)); 264 unsigned long flags __attribute__ ((unused));
254 265
@@ -260,5 +271,9 @@ static inline void efx_writed_page_locked(struct efx_nic *efx,
260 efx_writed(efx, value, EFX_PAGED_REG(page, reg)); 271 efx_writed(efx, value, EFX_PAGED_REG(page, reg));
261 } 272 }
262} 273}
274#define efx_writed_page_locked(efx, value, reg, page) \
275 _efx_writed_page_locked(efx, value, \
276 reg + BUILD_BUG_ON_ZERO((reg) != 0x420), \
277 page)
263 278
264#endif /* EFX_IO_H */ 279#endif /* EFX_IO_H */