[Madwifi-cvs] revision 2284 committed
Status: Beta
Brought to you by:
otaku
From: Matthew W. S. B. <svn...@ma...> - 2007-04-22 00:07:38
|
Project : madwifi Revision : 2284 Author : mentor (Matthew W. S. Bell) Date : 2007-04-22 02:07:33 +0200 (Sun, 22 Apr 2007) Log Message : Use OS primitives for unaligned access; appropriate changes to ath5k headers for this. Affected Files: * branches/madwifi-old-openhal/ath/if_ath.c updated * branches/madwifi-old-openhal/net80211/ieee80211_input.c updated * branches/madwifi-old-openhal/openhal/ah_osdep.h updated * branches/madwifi-old-openhal/openhal/ath5k_hw.c updated * branches/madwifi-old-openhal/openhal/ath5k_hw.h updated Modified: branches/madwifi-old-openhal/ath/if_ath.c =================================================================== --- branches/madwifi-old-openhal/ath/if_ath.c 2007-04-21 03:59:57 UTC (rev 2283) +++ branches/madwifi-old-openhal/ath/if_ath.c 2007-04-22 00:07:33 UTC (rev 2284) @@ -61,6 +61,7 @@ #include <net/iw_handler.h> #include <asm/uaccess.h> +#include <asm/unaligned.h> #include "if_ethersubr.h" /* for ETHER_IS_MULTICAST */ #include "if_media.h" @@ -91,13 +92,8 @@ #include "ath_hw.h" /* unaligned little endian access */ -#define LE_READ_2(p) \ - ((u_int16_t) \ - ((((u_int8_t *)(p))[0] ) | (((u_int8_t *)(p))[1] << 8))) -#define LE_READ_4(p) \ - ((u_int32_t) \ - ((((u_int8_t *)(p))[0] ) | (((u_int8_t *)(p))[1] << 8) | \ - (((u_int8_t *)(p))[2] << 16) | (((u_int8_t *)(p))[3] << 24))) +#define LE_READ_2(_p) (le16_to_cpu(get_unaligned((__le16 *)(_p)))) +#define LE_READ_4(_p) (le32_to_cpu(get_unaligned((__le32 *)(_p)))) enum { ATH_LED_TX, Modified: branches/madwifi-old-openhal/net80211/ieee80211_input.c =================================================================== --- branches/madwifi-old-openhal/net80211/ieee80211_input.c 2007-04-21 03:59:57 UTC (rev 2283) +++ branches/madwifi-old-openhal/net80211/ieee80211_input.c 2007-04-22 00:07:33 UTC (rev 2284) @@ -49,6 +49,8 @@ #include <linux/random.h> #include <linux/if_vlan.h> +#include <asm/unaligned.h> + #include "if_llc.h" #include "if_ethersubr.h" #include "if_media.h" @@ -1333,16 +1335,8 @@ #endif /* !IEEE80211_DEBUG */ /* unalligned little endian access */ -#define LE_READ_2(p) \ - ((u_int16_t) \ - ((((const u_int8_t *)(p))[0] ) | \ - (((const u_int8_t *)(p))[1] << 8))) -#define LE_READ_4(p) \ - ((u_int32_t) \ - ((((const u_int8_t *)(p))[0] ) | \ - (((const u_int8_t *)(p))[1] << 8) | \ - (((const u_int8_t *)(p))[2] << 16) | \ - (((const u_int8_t *)(p))[3] << 24))) +#define LE_READ_2(_p) (le16_to_cpu(get_unaligned((__le16 *)(_p)))) +#define LE_READ_4(_p) (le32_to_cpu(get_unaligned((__le32 *)(_p)))) static __inline int iswpaoui(const u_int8_t *frm) Modified: branches/madwifi-old-openhal/openhal/ah_osdep.h =================================================================== --- branches/madwifi-old-openhal/openhal/ah_osdep.h 2007-04-21 03:59:57 UTC (rev 2283) +++ branches/madwifi-old-openhal/openhal/ah_osdep.h 2007-04-22 00:07:33 UTC (rev 2284) @@ -34,6 +34,7 @@ //#include <linux/cpufreq.h> #include <asm/byteorder.h> +#include <asm/unaligned.h> #include <asm/uaccess.h> #include <asm/io.h> Modified: branches/madwifi-old-openhal/openhal/ath5k_hw.c =================================================================== --- branches/madwifi-old-openhal/openhal/ath5k_hw.c 2007-04-21 03:59:57 UTC (rev 2283) +++ branches/madwifi-old-openhal/openhal/ath5k_hw.c 2007-04-22 00:07:33 UTC (rev 2284) @@ -296,6 +296,26 @@ writel(val, hal->ah_sh + reg); } +static inline __u16 ath5k_hw_unaligned_read_16(__le16 *p) +{ + return le16_to_cpu(get_unaligned(p)); +} + +static inline void ath5k_hw_unaligned_write_16(__u16 v, __le16* p) +{ + put_unaligned(cpu_to_le16(v), p); +} + +static inline __u32 ath5k_hw_unaligned_read_32(__le32 *p) +{ + return le32_to_cpu(get_unaligned(p)); +} + +static inline void ath5k_hw_unaligned_write_32(__u32 v, __le32 *p) +{ + put_unaligned(cpu_to_le32(v), p); +} + /* * Check if a register write has been completed */ Modified: branches/madwifi-old-openhal/openhal/ath5k_hw.h =================================================================== --- branches/madwifi-old-openhal/openhal/ath5k_hw.h 2007-04-21 03:59:57 UTC (rev 2283) +++ branches/madwifi-old-openhal/openhal/ath5k_hw.h 2007-04-22 00:07:33 UTC (rev 2284) @@ -20,6 +20,7 @@ /* * Gain settings */ + typedef enum { AR5K_RFGAIN_INACTIVE = 0, AR5K_RFGAIN_READ_REQUESTED, @@ -265,21 +266,10 @@ /* * Unaligned little endian access */ -#define AR5K_LE_READ_2(_p) \ - (((const u_int8_t *)(_p))[0] | (((const u_int8_t *)(_p))[1] << 8)) -#define AR5K_LE_READ_4(_p) \ - (((const u_int8_t *)(_p))[0] | \ - (((const u_int8_t *)(_p))[1] << 8) | \ - (((const u_int8_t *)(_p))[2] << 16) | \ - (((const u_int8_t *)(_p))[3] << 24)) -#define AR5K_LE_WRITE_2(_p, _val) \ - ((((u_int8_t *)(_p))[0] = ((u_int32_t)(_val) & 0xff)), \ - (((u_int8_t *)(_p))[1] = (((u_int32_t)(_val) >> 8) & 0xff))) -#define AR5K_LE_WRITE_4(_p, _val) \ - ((((u_int8_t *)(_p))[0] = ((u_int32_t)(_val) & 0xff)), \ - (((u_int8_t *)(_p))[1] = (((u_int32_t)(_val) >> 8) & 0xff)), \ - (((u_int8_t *)(_p))[2] = (((u_int32_t)(_val) >> 16) & 0xff)), \ - (((u_int8_t *)(_p))[3] = (((u_int32_t)(_val) >> 24) & 0xff))) +#define AR5K_LE_READ_2 ath5k_hw_read_unaligned_16 +#define AR5K_LE_READ_4 ath5k_hw_read_unaligned_32 +#define AR5K_LE_WRITE_2 ath5k_hw_write_unaligned_16 +#define AR5K_LE_WRITE_4 ath5k_hw_write_unaligned_32 #define AR5K_LOW_ID(_a)( \ (_a)[0] | (_a)[1] << 8 | (_a)[2] << 16 | (_a)[3] << 24 \ |