From a992820b572e8fdfee4b876e22d0c7474284882f Mon Sep 17 00:00:00 2001 From: proski Date: Fri, 23 Nov 2007 09:38:18 +0000 Subject: [PATCH] Streamline _OS_REG_WRITE/_OS_REG_READ implementation Use a new is_reg_le macro to determine whether the register points to a little-endian area. git-svn-id: http://madwifi-project.org/svn/madwifi/trunk@2933 0192ed92-7a03-0410-a25b-9323aeb14dbd --- ath_hal/ah_os.h | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/ath_hal/ah_os.h b/ath_hal/ah_os.h index e49b1c9..21977c6 100644 --- a/ath_hal/ah_os.h +++ b/ath_hal/ah_os.h @@ -192,43 +192,32 @@ extern u_int32_t __ahdecl ath_hal_getuptime(struct ath_hal *); * need to suppress byte-swapping on big-endian systems outside the area used * by the PCI clock domain registers. */ +#if (AH_BYTE_ORDER == AH_BIG_ENDIAN) +#define is_reg_le(__reg) ((0x4000 <= (__reg) && (__reg) < 0x5000)) +#else +#define is_reg_le(__reg) 1 +#endif + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,12) -# if (AH_BYTE_ORDER == AH_BIG_ENDIAN) #define _OS_REG_WRITE(_ah, _reg, _val) do { \ - (0x4000 <= (_reg) && (_reg) < 0x5000) ? \ + is_reg_le(_reg) ? \ iowrite32((_val), (_ah)->ah_sh + (_reg)) : \ iowrite32be((_val), (_ah)->ah_sh + (_reg)); \ } while (0) #define _OS_REG_READ(_ah, _reg) \ - ((0x4000 <= (_reg) && (_reg) < 0x5000) ? \ + (is_reg_le(_reg) ? \ ioread32((_ah)->ah_sh + (_reg)) : \ - ioread32be((_ah)->ah_sh + (_reg))); -# else /* AH_LITTLE_ENDIAN */ -#define _OS_REG_WRITE(_ah, _reg, _val) do { \ - iowrite32(_val, (_ah)->ah_sh + (_reg)); \ - } while (0) -#define _OS_REG_READ(_ah, _reg) \ - ioread32((_ah)->ah_sh + (_reg)) - -# endif /* AH_BYTE_ORDER */ + ioread32be((_ah)->ah_sh + (_reg))) #else -# if (AH_BYTE_ORDER == AH_BIG_ENDIAN) #define _OS_REG_WRITE(_ah, _reg, _val) do { \ - writel((0x4000 <= (_reg) && (_reg) < 0x5000) ? \ + writel(is_reg_le(_reg) ? \ (_val) : cpu_to_le32(_val), \ (_ah)->ah_sh + (_reg)); \ } while (0) #define _OS_REG_READ(_ah, _reg) \ - ((0x4000 <= (_reg) && (_reg) < 0x5000) ? \ + (is_reg_le(_reg) ? \ readl((_ah)->ah_sh + (_reg)) : \ cpu_to_le32(readl((_ah)->ah_sh + (_reg)))) -# else /* AH_LITTLE_ENDIAN */ -#define _OS_REG_WRITE(_ah, _reg, _val) do { \ - writel(_val, (_ah)->ah_sh + (_reg)); \ - } while (0) -#define _OS_REG_READ(_ah, _reg) \ - readl((_ah)->ah_sh + (_reg)) -# endif /* AH_BYTE_ORDER */ #endif /* KERNEL_VERSION(2,6,12) */ /* -- 2.35.1