aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2007-12-19 17:55:43 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:08:59 -0500
commitb8c06bc1f39a0311cb0f41099be03ee2b202aeae (patch)
tree4cda20a77efe3db20a6f53671be5178e61693a30
parent0dd2212fb6872d8f5dd90391a12fb3fcb877c7c1 (diff)
bap_read()/bap_write() work with fixed-endian buffers
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/airo.c56
1 files changed, 29 insertions, 27 deletions
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index c4ae44142a67..ad91996acc47 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -1101,11 +1101,11 @@ static void enable_interrupts(struct airo_info*);
1101static void disable_interrupts(struct airo_info*); 1101static void disable_interrupts(struct airo_info*);
1102static u16 issuecommand(struct airo_info*, Cmd *pCmd, Resp *pRsp); 1102static u16 issuecommand(struct airo_info*, Cmd *pCmd, Resp *pRsp);
1103static int bap_setup(struct airo_info*, u16 rid, u16 offset, int whichbap); 1103static int bap_setup(struct airo_info*, u16 rid, u16 offset, int whichbap);
1104static int aux_bap_read(struct airo_info*, u16 *pu16Dst, int bytelen, 1104static int aux_bap_read(struct airo_info*, __le16 *pu16Dst, int bytelen,
1105 int whichbap); 1105 int whichbap);
1106static int fast_bap_read(struct airo_info*, u16 *pu16Dst, int bytelen, 1106static int fast_bap_read(struct airo_info*, __le16 *pu16Dst, int bytelen,
1107 int whichbap); 1107 int whichbap);
1108static int bap_write(struct airo_info*, const u16 *pu16Src, int bytelen, 1108static int bap_write(struct airo_info*, const __le16 *pu16Src, int bytelen,
1109 int whichbap); 1109 int whichbap);
1110static int PC4500_accessrid(struct airo_info*, u16 rid, u16 accmd); 1110static int PC4500_accessrid(struct airo_info*, u16 rid, u16 accmd);
1111static int PC4500_readrid(struct airo_info*, u16 rid, void *pBuf, int len, int lock); 1111static int PC4500_readrid(struct airo_info*, u16 rid, void *pBuf, int len, int lock);
@@ -1188,7 +1188,7 @@ struct airo_info {
1188#define JOB_WSTATS 8 1188#define JOB_WSTATS 8
1189#define JOB_SCAN_RESULTS 9 1189#define JOB_SCAN_RESULTS 9
1190 unsigned long jobs; 1190 unsigned long jobs;
1191 int (*bap_read)(struct airo_info*, u16 *pu16Dst, int bytelen, 1191 int (*bap_read)(struct airo_info*, __le16 *pu16Dst, int bytelen,
1192 int whichbap); 1192 int whichbap);
1193 unsigned short *flash; 1193 unsigned short *flash;
1194 tdsRssiEntry *rssi; 1194 tdsRssiEntry *rssi;
@@ -1236,8 +1236,9 @@ struct airo_info {
1236 BSSListElement *networks; 1236 BSSListElement *networks;
1237}; 1237};
1238 1238
1239static inline int bap_read(struct airo_info *ai, u16 *pu16Dst, int bytelen, 1239static inline int bap_read(struct airo_info *ai, __le16 *pu16Dst, int bytelen,
1240 int whichbap) { 1240 int whichbap)
1241{
1241 return ai->bap_read(ai, pu16Dst, bytelen, whichbap); 1242 return ai->bap_read(ai, pu16Dst, bytelen, whichbap);
1242} 1243}
1243 1244
@@ -2125,7 +2126,7 @@ static void get_tx_error(struct airo_info *ai, s32 fid)
2125 /* Faster to skip over useless data than to do 2126 /* Faster to skip over useless data than to do
2126 * another bap_setup(). We are at offset 0x6 and 2127 * another bap_setup(). We are at offset 0x6 and
2127 * need to go to 0x18 and read 6 bytes - Jean II */ 2128 * need to go to 0x18 and read 6 bytes - Jean II */
2128 bap_read(ai, (u16 *) junk, 0x18, BAP0); 2129 bap_read(ai, (__le16 *) junk, 0x18, BAP0);
2129 2130
2130 /* Copy 802.11 dest address. 2131 /* Copy 802.11 dest address.
2131 * We use the 802.11 header because the frame may 2132 * We use the 802.11 header because the frame may
@@ -3287,7 +3288,8 @@ static irqreturn_t airo_interrupt(int irq, void *dev_id)
3287 /* Check to see if there is something to receive */ 3288 /* Check to see if there is something to receive */
3288 if ( status & EV_RX ) { 3289 if ( status & EV_RX ) {
3289 struct sk_buff *skb = NULL; 3290 struct sk_buff *skb = NULL;
3290 u16 fc, len, hdrlen = 0; 3291 __le16 fc, v;
3292 u16 len, hdrlen = 0;
3291#pragma pack(1) 3293#pragma pack(1)
3292 struct { 3294 struct {
3293 __le16 status, len; 3295 __le16 status, len;
@@ -3298,8 +3300,8 @@ static irqreturn_t airo_interrupt(int irq, void *dev_id)
3298 } hdr; 3300 } hdr;
3299#pragma pack() 3301#pragma pack()
3300 u16 gap; 3302 u16 gap;
3301 u16 tmpbuf[4]; 3303 __le16 tmpbuf[4];
3302 u16 *buffer; 3304 __le16 *buffer;
3303 3305
3304 if (test_bit(FLAG_MPI,&apriv->flags)) { 3306 if (test_bit(FLAG_MPI,&apriv->flags)) {
3305 if (test_bit(FLAG_802_11, &apriv->flags)) 3307 if (test_bit(FLAG_802_11, &apriv->flags))
@@ -3315,7 +3317,7 @@ static irqreturn_t airo_interrupt(int irq, void *dev_id)
3315 /* Get the packet length */ 3317 /* Get the packet length */
3316 if (test_bit(FLAG_802_11, &apriv->flags)) { 3318 if (test_bit(FLAG_802_11, &apriv->flags)) {
3317 bap_setup (apriv, fid, 4, BAP0); 3319 bap_setup (apriv, fid, 4, BAP0);
3318 bap_read (apriv, (u16*)&hdr, sizeof(hdr), BAP0); 3320 bap_read (apriv, (__le16*)&hdr, sizeof(hdr), BAP0);
3319 /* Bad CRC. Ignore packet */ 3321 /* Bad CRC. Ignore packet */
3320 if (le16_to_cpu(hdr.status) & 2) 3322 if (le16_to_cpu(hdr.status) & 2)
3321 hdr.len = 0; 3323 hdr.len = 0;
@@ -3323,7 +3325,7 @@ static irqreturn_t airo_interrupt(int irq, void *dev_id)
3323 hdr.len = 0; 3325 hdr.len = 0;
3324 } else { 3326 } else {
3325 bap_setup (apriv, fid, 0x36, BAP0); 3327 bap_setup (apriv, fid, 0x36, BAP0);
3326 bap_read (apriv, (u16*)&hdr.len, 2, BAP0); 3328 bap_read (apriv, &hdr.len, 2, BAP0);
3327 } 3329 }
3328 len = le16_to_cpu(hdr.len); 3330 len = le16_to_cpu(hdr.len);
3329 3331
@@ -3346,15 +3348,15 @@ static irqreturn_t airo_interrupt(int irq, void *dev_id)
3346 goto badrx; 3348 goto badrx;
3347 } 3349 }
3348 skb_reserve(skb, 2); /* This way the IP header is aligned */ 3350 skb_reserve(skb, 2); /* This way the IP header is aligned */
3349 buffer = (u16*)skb_put (skb, len + hdrlen); 3351 buffer = (__le16*)skb_put (skb, len + hdrlen);
3350 if (test_bit(FLAG_802_11, &apriv->flags)) { 3352 if (test_bit(FLAG_802_11, &apriv->flags)) {
3351 buffer[0] = fc; 3353 buffer[0] = fc;
3352 bap_read (apriv, buffer + 1, hdrlen - 2, BAP0); 3354 bap_read (apriv, buffer + 1, hdrlen - 2, BAP0);
3353 if (hdrlen == 24) 3355 if (hdrlen == 24)
3354 bap_read (apriv, tmpbuf, 6, BAP0); 3356 bap_read (apriv, tmpbuf, 6, BAP0);
3355 3357
3356 bap_read (apriv, &gap, sizeof(gap), BAP0); 3358 bap_read (apriv, &v, sizeof(v), BAP0);
3357 gap = le16_to_cpu(gap); 3359 gap = le16_to_cpu(v);
3358 if (gap) { 3360 if (gap) {
3359 if (gap <= 8) { 3361 if (gap <= 8) {
3360 bap_read (apriv, tmpbuf, gap, BAP0); 3362 bap_read (apriv, tmpbuf, gap, BAP0);
@@ -3368,7 +3370,7 @@ static irqreturn_t airo_interrupt(int irq, void *dev_id)
3368 MICBuffer micbuf; 3370 MICBuffer micbuf;
3369 bap_read (apriv, buffer, ETH_ALEN*2, BAP0); 3371 bap_read (apriv, buffer, ETH_ALEN*2, BAP0);
3370 if (apriv->micstats.enabled) { 3372 if (apriv->micstats.enabled) {
3371 bap_read (apriv,(u16*)&micbuf,sizeof(micbuf),BAP0); 3373 bap_read (apriv,(__le16*)&micbuf,sizeof(micbuf),BAP0);
3372 if (ntohs(micbuf.typelen) > 0x05DC) 3374 if (ntohs(micbuf.typelen) > 0x05DC)
3373 bap_setup (apriv, fid, 0x44, BAP0); 3375 bap_setup (apriv, fid, 0x44, BAP0);
3374 else { 3376 else {
@@ -3396,7 +3398,7 @@ badrx:
3396 if (!test_bit(FLAG_802_11, &apriv->flags)) { 3398 if (!test_bit(FLAG_802_11, &apriv->flags)) {
3397 sa = (char*)buffer + 6; 3399 sa = (char*)buffer + 6;
3398 bap_setup (apriv, fid, 8, BAP0); 3400 bap_setup (apriv, fid, 8, BAP0);
3399 bap_read (apriv, (u16*)hdr.rssi, 2, BAP0); 3401 bap_read (apriv, (__le16*)hdr.rssi, 2, BAP0);
3400 } else 3402 } else
3401 sa = (char*)buffer + 10; 3403 sa = (char*)buffer + 10;
3402 wstats.qual = hdr.rssi[0]; 3404 wstats.qual = hdr.rssi[0];
@@ -4015,7 +4017,7 @@ static u16 aux_setup(struct airo_info *ai, u16 page,
4015} 4017}
4016 4018
4017/* requires call to bap_setup() first */ 4019/* requires call to bap_setup() first */
4018static int aux_bap_read(struct airo_info *ai, u16 *pu16Dst, 4020static int aux_bap_read(struct airo_info *ai, __le16 *pu16Dst,
4019 int bytelen, int whichbap) 4021 int bytelen, int whichbap)
4020{ 4022{
4021 u16 len; 4023 u16 len;
@@ -4052,7 +4054,7 @@ static int aux_bap_read(struct airo_info *ai, u16 *pu16Dst,
4052 4054
4053 4055
4054/* requires call to bap_setup() first */ 4056/* requires call to bap_setup() first */
4055static int fast_bap_read(struct airo_info *ai, u16 *pu16Dst, 4057static int fast_bap_read(struct airo_info *ai, __le16 *pu16Dst,
4056 int bytelen, int whichbap) 4058 int bytelen, int whichbap)
4057{ 4059{
4058 bytelen = (bytelen + 1) & (~1); // round up to even value 4060 bytelen = (bytelen + 1) & (~1); // round up to even value
@@ -4064,7 +4066,7 @@ static int fast_bap_read(struct airo_info *ai, u16 *pu16Dst,
4064} 4066}
4065 4067
4066/* requires call to bap_setup() first */ 4068/* requires call to bap_setup() first */
4067static int bap_write(struct airo_info *ai, const u16 *pu16Src, 4069static int bap_write(struct airo_info *ai, const __le16 *pu16Src,
4068 int bytelen, int whichbap) 4070 int bytelen, int whichbap)
4069{ 4071{
4070 bytelen = (bytelen + 1) & (~1); // round up to even value 4072 bytelen = (bytelen + 1) & (~1); // round up to even value
@@ -4150,7 +4152,7 @@ static int PC4500_readrid(struct airo_info *ai, u16 rid, void *pBuf, int len, in
4150 goto done; 4152 goto done;
4151 } 4153 }
4152 // read remainder of the rid 4154 // read remainder of the rid
4153 rc = bap_read(ai, ((u16*)pBuf)+1, len, BAP1); 4155 rc = bap_read(ai, ((__le16*)pBuf)+1, len, BAP1);
4154 } 4156 }
4155done: 4157done:
4156 if (lock) 4158 if (lock)
@@ -4322,10 +4324,10 @@ static int transmit_802_3_packet(struct airo_info *ai, int len, char *pPacket)
4322 * we have to subtract the 12 bytes for the addresses off */ 4324 * we have to subtract the 12 bytes for the addresses off */
4323 payloadLen = cpu_to_le16(len + miclen); 4325 payloadLen = cpu_to_le16(len + miclen);
4324 bap_write(ai, &payloadLen, sizeof(payloadLen),BAP1); 4326 bap_write(ai, &payloadLen, sizeof(payloadLen),BAP1);
4325 bap_write(ai, (const u16*)pPacket, sizeof(etherHead), BAP1); 4327 bap_write(ai, (__le16*)pPacket, sizeof(etherHead), BAP1);
4326 if (miclen) 4328 if (miclen)
4327 bap_write(ai, (const u16*)&pMic, miclen, BAP1); 4329 bap_write(ai, (__le16*)&pMic, miclen, BAP1);
4328 bap_write(ai, (const u16*)(pPacket + sizeof(etherHead)), len, BAP1); 4330 bap_write(ai, (__le16*)(pPacket + sizeof(etherHead)), len, BAP1);
4329 // issue the transmit command 4331 // issue the transmit command
4330 memset( &cmd, 0, sizeof( cmd ) ); 4332 memset( &cmd, 0, sizeof( cmd ) );
4331 cmd.cmd = CMD_TRANSMIT; 4333 cmd.cmd = CMD_TRANSMIT;
@@ -4362,10 +4364,10 @@ static int transmit_802_11_packet(struct airo_info *ai, int len, char *pPacket)
4362 payloadLen = cpu_to_le16(len-hdrlen); 4364 payloadLen = cpu_to_le16(len-hdrlen);
4363 bap_write(ai, &payloadLen, sizeof(payloadLen),BAP1); 4365 bap_write(ai, &payloadLen, sizeof(payloadLen),BAP1);
4364 if (bap_setup(ai, txFid, 0x0014, BAP1) != SUCCESS) return ERROR; 4366 if (bap_setup(ai, txFid, 0x0014, BAP1) != SUCCESS) return ERROR;
4365 bap_write(ai, (const u16*)pPacket, hdrlen, BAP1); 4367 bap_write(ai, (__le16 *)pPacket, hdrlen, BAP1);
4366 bap_write(ai, (u16 *)(tail + (hdrlen - 10)), 38 - hdrlen, BAP1); 4368 bap_write(ai, (__le16 *)(tail + (hdrlen - 10)), 38 - hdrlen, BAP1);
4367 4369
4368 bap_write(ai, (const u16*)(pPacket + hdrlen), len - hdrlen, BAP1); 4370 bap_write(ai, (__le16 *)(pPacket + hdrlen), len - hdrlen, BAP1);
4369 // issue the transmit command 4371 // issue the transmit command
4370 memset( &cmd, 0, sizeof( cmd ) ); 4372 memset( &cmd, 0, sizeof( cmd ) );
4371 cmd.cmd = CMD_TRANSMIT; 4373 cmd.cmd = CMD_TRANSMIT;