diff options
author | Jiri Slaby <jirislaby@gmail.com> | 2009-02-12 16:29:40 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-02-27 14:52:34 -0500 |
commit | 1788bcd155a2cbb7fad6bb30c2ae3786ceee8b4c (patch) | |
tree | 48e680cc4836ff88f587ee98d62f9ec62c8daa41 /drivers/net/wireless/ipw2x00/ipw2200.c | |
parent | 191a99b748a080d9ec896f35352da741b556119e (diff) |
ipw2200, fix ipw io functions
- some of them are defined as follows:
#define ipw_write32 expr1; expr2
and are called from loops or ifs without a compound statement, so
they are broken. Fix it by putting them into do {} while (0) for
writes and ({ }) for reads.
- also unify and cleanup them while at it -- convert them from
macros to inline functions, so that we get some basic typechecking
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Acked-by: Zhu Yi <yi.zhu@intel.com>
Cc: James Ketrenos <jketreno@linux.intel.com>
Cc: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ipw2x00/ipw2200.c')
-rw-r--r-- | drivers/net/wireless/ipw2x00/ipw2200.c | 106 |
1 files changed, 60 insertions, 46 deletions
diff --git a/drivers/net/wireless/ipw2x00/ipw2200.c b/drivers/net/wireless/ipw2x00/ipw2200.c index 0420d3d35dd4..01c4ede90662 100644 --- a/drivers/net/wireless/ipw2x00/ipw2200.c +++ b/drivers/net/wireless/ipw2x00/ipw2200.c | |||
@@ -301,88 +301,102 @@ static inline void ipw_write_reg32(struct ipw_priv *a, u32 b, u32 c) | |||
301 | } | 301 | } |
302 | 302 | ||
303 | /* 8-bit direct write (low 4K) */ | 303 | /* 8-bit direct write (low 4K) */ |
304 | #define _ipw_write8(ipw, ofs, val) writeb((val), (ipw)->hw_base + (ofs)) | 304 | static inline void _ipw_write8(struct ipw_priv *ipw, unsigned long ofs, |
305 | u8 val) | ||
306 | { | ||
307 | writeb(val, ipw->hw_base + ofs); | ||
308 | } | ||
305 | 309 | ||
306 | /* 8-bit direct write (for low 4K of SRAM/regs), with debug wrapper */ | 310 | /* 8-bit direct write (for low 4K of SRAM/regs), with debug wrapper */ |
307 | #define ipw_write8(ipw, ofs, val) do { \ | 311 | #define ipw_write8(ipw, ofs, val) do { \ |
308 | IPW_DEBUG_IO("%s %d: write_direct8(0x%08X, 0x%08X)\n", __FILE__, __LINE__, (u32)(ofs), (u32)(val)); \ | 312 | IPW_DEBUG_IO("%s %d: write_direct8(0x%08X, 0x%08X)\n", __FILE__, \ |
309 | _ipw_write8(ipw, ofs, val); \ | 313 | __LINE__, (u32)(ofs), (u32)(val)); \ |
310 | } while (0) | 314 | _ipw_write8(ipw, ofs, val); \ |
315 | } while (0) | ||
311 | 316 | ||
312 | /* 16-bit direct write (low 4K) */ | 317 | /* 16-bit direct write (low 4K) */ |
313 | #define _ipw_write16(ipw, ofs, val) writew((val), (ipw)->hw_base + (ofs)) | 318 | static inline void _ipw_write16(struct ipw_priv *ipw, unsigned long ofs, |
319 | u16 val) | ||
320 | { | ||
321 | writew(val, ipw->hw_base + ofs); | ||
322 | } | ||
314 | 323 | ||
315 | /* 16-bit direct write (for low 4K of SRAM/regs), with debug wrapper */ | 324 | /* 16-bit direct write (for low 4K of SRAM/regs), with debug wrapper */ |
316 | #define ipw_write16(ipw, ofs, val) \ | 325 | #define ipw_write16(ipw, ofs, val) do { \ |
317 | IPW_DEBUG_IO("%s %d: write_direct16(0x%08X, 0x%08X)\n", __FILE__, __LINE__, (u32)(ofs), (u32)(val)); \ | 326 | IPW_DEBUG_IO("%s %d: write_direct16(0x%08X, 0x%08X)\n", __FILE__, \ |
318 | _ipw_write16(ipw, ofs, val) | 327 | __LINE__, (u32)(ofs), (u32)(val)); \ |
328 | _ipw_write16(ipw, ofs, val); \ | ||
329 | } while (0) | ||
319 | 330 | ||
320 | /* 32-bit direct write (low 4K) */ | 331 | /* 32-bit direct write (low 4K) */ |
321 | #define _ipw_write32(ipw, ofs, val) writel((val), (ipw)->hw_base + (ofs)) | 332 | static inline void _ipw_write32(struct ipw_priv *ipw, unsigned long ofs, |
333 | u32 val) | ||
334 | { | ||
335 | writel(val, ipw->hw_base + ofs); | ||
336 | } | ||
322 | 337 | ||
323 | /* 32-bit direct write (for low 4K of SRAM/regs), with debug wrapper */ | 338 | /* 32-bit direct write (for low 4K of SRAM/regs), with debug wrapper */ |
324 | #define ipw_write32(ipw, ofs, val) \ | 339 | #define ipw_write32(ipw, ofs, val) do { \ |
325 | IPW_DEBUG_IO("%s %d: write_direct32(0x%08X, 0x%08X)\n", __FILE__, __LINE__, (u32)(ofs), (u32)(val)); \ | 340 | IPW_DEBUG_IO("%s %d: write_direct32(0x%08X, 0x%08X)\n", __FILE__, \ |
326 | _ipw_write32(ipw, ofs, val) | 341 | __LINE__, (u32)(ofs), (u32)(val)); \ |
342 | _ipw_write32(ipw, ofs, val); \ | ||
343 | } while (0) | ||
327 | 344 | ||
328 | /* 8-bit direct read (low 4K) */ | 345 | /* 8-bit direct read (low 4K) */ |
329 | #define _ipw_read8(ipw, ofs) readb((ipw)->hw_base + (ofs)) | 346 | static inline u8 _ipw_read8(struct ipw_priv *ipw, unsigned long ofs) |
330 | |||
331 | /* 8-bit direct read (low 4K), with debug wrapper */ | ||
332 | static inline u8 __ipw_read8(char *f, u32 l, struct ipw_priv *ipw, u32 ofs) | ||
333 | { | 347 | { |
334 | IPW_DEBUG_IO("%s %d: read_direct8(0x%08X)\n", f, l, (u32) (ofs)); | 348 | return readb(ipw->hw_base + ofs); |
335 | return _ipw_read8(ipw, ofs); | ||
336 | } | 349 | } |
337 | 350 | ||
338 | /* alias to 8-bit direct read (low 4K of SRAM/regs), with debug wrapper */ | 351 | /* alias to 8-bit direct read (low 4K of SRAM/regs), with debug wrapper */ |
339 | #define ipw_read8(ipw, ofs) __ipw_read8(__FILE__, __LINE__, ipw, ofs) | 352 | #define ipw_read8(ipw, ofs) ({ \ |
353 | IPW_DEBUG_IO("%s %d: read_direct8(0x%08X)\n", __FILE__, __LINE__, \ | ||
354 | (u32)(ofs)); \ | ||
355 | _ipw_read8(ipw, ofs); \ | ||
356 | }) | ||
340 | 357 | ||
341 | /* 16-bit direct read (low 4K) */ | 358 | /* 16-bit direct read (low 4K) */ |
342 | #define _ipw_read16(ipw, ofs) readw((ipw)->hw_base + (ofs)) | 359 | static inline u16 _ipw_read16(struct ipw_priv *ipw, unsigned long ofs) |
343 | |||
344 | /* 16-bit direct read (low 4K), with debug wrapper */ | ||
345 | static inline u16 __ipw_read16(char *f, u32 l, struct ipw_priv *ipw, u32 ofs) | ||
346 | { | 360 | { |
347 | IPW_DEBUG_IO("%s %d: read_direct16(0x%08X)\n", f, l, (u32) (ofs)); | 361 | return readw(ipw->hw_base + ofs); |
348 | return _ipw_read16(ipw, ofs); | ||
349 | } | 362 | } |
350 | 363 | ||
351 | /* alias to 16-bit direct read (low 4K of SRAM/regs), with debug wrapper */ | 364 | /* alias to 16-bit direct read (low 4K of SRAM/regs), with debug wrapper */ |
352 | #define ipw_read16(ipw, ofs) __ipw_read16(__FILE__, __LINE__, ipw, ofs) | 365 | #define ipw_read16(ipw, ofs) ({ \ |
366 | IPW_DEBUG_IO("%s %d: read_direct16(0x%08X)\n", __FILE__, __LINE__, \ | ||
367 | (u32)(ofs)); \ | ||
368 | _ipw_read16(ipw, ofs); \ | ||
369 | }) | ||
353 | 370 | ||
354 | /* 32-bit direct read (low 4K) */ | 371 | /* 32-bit direct read (low 4K) */ |
355 | #define _ipw_read32(ipw, ofs) readl((ipw)->hw_base + (ofs)) | 372 | static inline u32 _ipw_read32(struct ipw_priv *ipw, unsigned long ofs) |
356 | |||
357 | /* 32-bit direct read (low 4K), with debug wrapper */ | ||
358 | static inline u32 __ipw_read32(char *f, u32 l, struct ipw_priv *ipw, u32 ofs) | ||
359 | { | 373 | { |
360 | IPW_DEBUG_IO("%s %d: read_direct32(0x%08X)\n", f, l, (u32) (ofs)); | 374 | return readl(ipw->hw_base + ofs); |
361 | return _ipw_read32(ipw, ofs); | ||
362 | } | 375 | } |
363 | 376 | ||
364 | /* alias to 32-bit direct read (low 4K of SRAM/regs), with debug wrapper */ | 377 | /* alias to 32-bit direct read (low 4K of SRAM/regs), with debug wrapper */ |
365 | #define ipw_read32(ipw, ofs) __ipw_read32(__FILE__, __LINE__, ipw, ofs) | 378 | #define ipw_read32(ipw, ofs) ({ \ |
379 | IPW_DEBUG_IO("%s %d: read_direct32(0x%08X)\n", __FILE__, __LINE__, \ | ||
380 | (u32)(ofs)); \ | ||
381 | _ipw_read32(ipw, ofs); \ | ||
382 | }) | ||
366 | 383 | ||
367 | /* multi-byte read (above 4K), with debug wrapper */ | ||
368 | static void _ipw_read_indirect(struct ipw_priv *, u32, u8 *, int); | 384 | static void _ipw_read_indirect(struct ipw_priv *, u32, u8 *, int); |
369 | static inline void __ipw_read_indirect(const char *f, int l, | ||
370 | struct ipw_priv *a, u32 b, u8 * c, int d) | ||
371 | { | ||
372 | IPW_DEBUG_IO("%s %d: read_indirect(0x%08X) %d bytes\n", f, l, (u32) (b), | ||
373 | d); | ||
374 | _ipw_read_indirect(a, b, c, d); | ||
375 | } | ||
376 | |||
377 | /* alias to multi-byte read (SRAM/regs above 4K), with debug wrapper */ | 385 | /* alias to multi-byte read (SRAM/regs above 4K), with debug wrapper */ |
378 | #define ipw_read_indirect(a, b, c, d) __ipw_read_indirect(__FILE__, __LINE__, a, b, c, d) | 386 | #define ipw_read_indirect(a, b, c, d) ({ \ |
387 | IPW_DEBUG_IO("%s %d: read_indirect(0x%08X) %u bytes\n", __FILE__, \ | ||
388 | __LINE__, (u32)(b), (u32)(d)); \ | ||
389 | _ipw_read_indirect(a, b, c, d); \ | ||
390 | }) | ||
379 | 391 | ||
380 | /* alias to multi-byte read (SRAM/regs above 4K), with debug wrapper */ | 392 | /* alias to multi-byte read (SRAM/regs above 4K), with debug wrapper */ |
381 | static void _ipw_write_indirect(struct ipw_priv *priv, u32 addr, u8 * data, | 393 | static void _ipw_write_indirect(struct ipw_priv *priv, u32 addr, u8 * data, |
382 | int num); | 394 | int num); |
383 | #define ipw_write_indirect(a, b, c, d) \ | 395 | #define ipw_write_indirect(a, b, c, d) do { \ |
384 | IPW_DEBUG_IO("%s %d: write_indirect(0x%08X) %d bytes\n", __FILE__, __LINE__, (u32)(b), d); \ | 396 | IPW_DEBUG_IO("%s %d: write_indirect(0x%08X) %u bytes\n", __FILE__, \ |
385 | _ipw_write_indirect(a, b, c, d) | 397 | __LINE__, (u32)(b), (u32)(d)); \ |
398 | _ipw_write_indirect(a, b, c, d); \ | ||
399 | } while (0) | ||
386 | 400 | ||
387 | /* 32-bit indirect write (above 4K) */ | 401 | /* 32-bit indirect write (above 4K) */ |
388 | static void _ipw_write_reg32(struct ipw_priv *priv, u32 reg, u32 value) | 402 | static void _ipw_write_reg32(struct ipw_priv *priv, u32 reg, u32 value) |