aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/libertas/scan.c
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2007-05-25 23:36:54 -0400
committerJohn W. Linville <linville@tuxdriver.com>2007-06-11 14:28:45 -0400
commit981f187b7c4b237011d4175cae0120d5d203c0fd (patch)
treeb4508fc33a9aed0177c18c3a4db5c4e500fdb646 /drivers/net/wireless/libertas/scan.c
parent123e0e044091ca35a4766b38ae15032f2d41bcd6 (diff)
[PATCH] libertas: first pass at fixing up endianness issues
Signed-off-by: David Woodhouse <dwmw2@infradead.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/libertas/scan.c')
-rw-r--r--drivers/net/wireless/libertas/scan.c52
1 files changed, 23 insertions, 29 deletions
diff --git a/drivers/net/wireless/libertas/scan.c b/drivers/net/wireless/libertas/scan.c
index a1ab698088db..9799d87aaa3b 100644
--- a/drivers/net/wireless/libertas/scan.c
+++ b/drivers/net/wireless/libertas/scan.c
@@ -323,14 +323,12 @@ static void wlan_scan_create_channel_list(wlan_private * priv,
323 323
324 if (scantype == cmd_scan_type_passive) { 324 if (scantype == cmd_scan_type_passive) {
325 scanchanlist[chanidx].maxscantime = 325 scanchanlist[chanidx].maxscantime =
326 cpu_to_le16 326 cpu_to_le16(MRVDRV_PASSIVE_SCAN_CHAN_TIME);
327 (MRVDRV_PASSIVE_SCAN_CHAN_TIME);
328 scanchanlist[chanidx].chanscanmode.passivescan = 327 scanchanlist[chanidx].chanscanmode.passivescan =
329 1; 328 1;
330 } else { 329 } else {
331 scanchanlist[chanidx].maxscantime = 330 scanchanlist[chanidx].maxscantime =
332 cpu_to_le16 331 cpu_to_le16(MRVDRV_ACTIVE_SCAN_CHAN_TIME);
333 (MRVDRV_ACTIVE_SCAN_CHAN_TIME);
334 scanchanlist[chanidx].chanscanmode.passivescan = 332 scanchanlist[chanidx].chanscanmode.passivescan =
335 0; 333 0;
336 } 334 }
@@ -487,16 +485,11 @@ wlan_scan_setup_scan_config(wlan_private * priv,
487 /* If the input config or adapter has the number of Probes set, add tlv */ 485 /* If the input config or adapter has the number of Probes set, add tlv */
488 if (numprobes) { 486 if (numprobes) {
489 pnumprobestlv = (struct mrvlietypes_numprobes *) ptlvpos; 487 pnumprobestlv = (struct mrvlietypes_numprobes *) ptlvpos;
490 pnumprobestlv->header.type = 488 pnumprobestlv->header.type = cpu_to_le16(TLV_TYPE_NUMPROBES);
491 cpu_to_le16(TLV_TYPE_NUMPROBES); 489 pnumprobestlv->header.len = cpu_to_le16(2);
492 pnumprobestlv->header.len = sizeof(pnumprobestlv->numprobes);
493 pnumprobestlv->numprobes = cpu_to_le16(numprobes); 490 pnumprobestlv->numprobes = cpu_to_le16(numprobes);
494 491
495 ptlvpos += 492 ptlvpos += sizeof(*pnumprobestlv);
496 sizeof(pnumprobestlv->header) + pnumprobestlv->header.len;
497
498 pnumprobestlv->header.len =
499 cpu_to_le16(pnumprobestlv->header.len);
500 } 493 }
501 494
502 /* 495 /*
@@ -655,8 +648,11 @@ static int wlan_scan_channel_list(wlan_private * priv,
655 ptmpchan, sizeof(pchantlvout->chanscanparam)); 648 ptmpchan, sizeof(pchantlvout->chanscanparam));
656 649
657 /* Increment the TLV header length by the size appended */ 650 /* Increment the TLV header length by the size appended */
658 pchantlvout->header.len += 651 /* Ew, it would be _so_ nice if we could just declare the
659 sizeof(pchantlvout->chanscanparam); 652 variable little-endian and let GCC handle it for us */
653 pchantlvout->header.len =
654 cpu_to_le16(le16_to_cpu(pchantlvout->header.len) +
655 sizeof(pchantlvout->chanscanparam));
660 656
661 /* 657 /*
662 * The tlv buffer length is set to the number of bytes of the 658 * The tlv buffer length is set to the number of bytes of the
@@ -670,7 +666,7 @@ static int wlan_scan_channel_list(wlan_private * priv,
670 /* Add the size of the channel tlv header and the data length */ 666 /* Add the size of the channel tlv header and the data length */
671 pscancfgout->tlvbufferlen += 667 pscancfgout->tlvbufferlen +=
672 (sizeof(pchantlvout->header) 668 (sizeof(pchantlvout->header)
673 + pchantlvout->header.len); 669 + le16_to_cpu(pchantlvout->header.len));
674 670
675 /* Increment the index to the channel tlv we are constructing */ 671 /* Increment the index to the channel tlv we are constructing */
676 tlvidx++; 672 tlvidx++;
@@ -955,8 +951,7 @@ static int libertas_process_bss(struct bss_descriptor * bss,
955 951
956 if (*bytesleft >= sizeof(beaconsize)) { 952 if (*bytesleft >= sizeof(beaconsize)) {
957 /* Extract & convert beacon size from the command buffer */ 953 /* Extract & convert beacon size from the command buffer */
958 memcpy(&beaconsize, *pbeaconinfo, sizeof(beaconsize)); 954 beaconsize = le16_to_cpup((void *)*pbeaconinfo);
959 beaconsize = le16_to_cpu(beaconsize);
960 *bytesleft -= sizeof(beaconsize); 955 *bytesleft -= sizeof(beaconsize);
961 *pbeaconinfo += sizeof(beaconsize); 956 *pbeaconinfo += sizeof(beaconsize);
962 } 957 }
@@ -995,28 +990,25 @@ static int libertas_process_bss(struct bss_descriptor * bss,
995 */ 990 */
996 991
997 /* RSSI is 1 byte long */ 992 /* RSSI is 1 byte long */
998 bss->rssi = le32_to_cpu((long)(*pcurrentptr)); 993 bss->rssi = *pcurrentptr;
999 lbs_deb_scan("process_bss: RSSI=%02X\n", *pcurrentptr); 994 lbs_deb_scan("process_bss: RSSI=%02X\n", *pcurrentptr);
1000 pcurrentptr += 1; 995 pcurrentptr += 1;
1001 bytesleftforcurrentbeacon -= 1; 996 bytesleftforcurrentbeacon -= 1;
1002 997
1003 /* time stamp is 8 bytes long */ 998 /* time stamp is 8 bytes long */
1004 memcpy(fixedie.timestamp, pcurrentptr, 8); 999 fixedie.timestamp = bss->timestamp = le64_to_cpup((void *)pcurrentptr);
1005 memcpy(bss->timestamp, pcurrentptr, 8);
1006 pcurrentptr += 8; 1000 pcurrentptr += 8;
1007 bytesleftforcurrentbeacon -= 8; 1001 bytesleftforcurrentbeacon -= 8;
1008 1002
1009 /* beacon interval is 2 bytes long */ 1003 /* beacon interval is 2 bytes long */
1010 memcpy(&fixedie.beaconinterval, pcurrentptr, 2); 1004 fixedie.beaconinterval = bss->beaconperiod = le16_to_cpup((void *)pcurrentptr);
1011 bss->beaconperiod = le16_to_cpu(fixedie.beaconinterval);
1012 pcurrentptr += 2; 1005 pcurrentptr += 2;
1013 bytesleftforcurrentbeacon -= 2; 1006 bytesleftforcurrentbeacon -= 2;
1014 1007
1015 /* capability information is 2 bytes long */ 1008 /* capability information is 2 bytes long */
1016 memcpy(&fixedie.capabilities, pcurrentptr, 2); 1009 memcpy(&fixedie.capabilities, pcurrentptr, 2);
1017 lbs_deb_scan("process_bss: fixedie.capabilities=0x%X\n", 1010 lbs_deb_scan("process_bss: fixedie.capabilities=0x%X\n",
1018 fixedie.capabilities); 1011 fixedie.capabilities);
1019 fixedie.capabilities = le16_to_cpu(fixedie.capabilities);
1020 pcap = (struct ieeetypes_capinfo *) & fixedie.capabilities; 1012 pcap = (struct ieeetypes_capinfo *) & fixedie.capabilities;
1021 memcpy(&bss->cap, pcap, sizeof(struct ieeetypes_capinfo)); 1013 memcpy(&bss->cap, pcap, sizeof(struct ieeetypes_capinfo));
1022 pcurrentptr += 2; 1014 pcurrentptr += 2;
@@ -1077,8 +1069,10 @@ static int libertas_process_bss(struct bss_descriptor * bss,
1077 pFH = (struct ieeetypes_fhparamset *) pcurrentptr; 1069 pFH = (struct ieeetypes_fhparamset *) pcurrentptr;
1078 memmove(&bss->phyparamset.fhparamset, pFH, 1070 memmove(&bss->phyparamset.fhparamset, pFH,
1079 sizeof(struct ieeetypes_fhparamset)); 1071 sizeof(struct ieeetypes_fhparamset));
1072#if 0 /* I think we can store these LE */
1080 bss->phyparamset.fhparamset.dwelltime 1073 bss->phyparamset.fhparamset.dwelltime
1081 = le16_to_cpu(bss->phyparamset.fhparamset.dwelltime); 1074 = le16_to_cpu(bss->phyparamset.fhparamset.dwelltime);
1075#endif
1082 break; 1076 break;
1083 1077
1084 case DS_PARAM_SET: 1078 case DS_PARAM_SET:
@@ -1099,8 +1093,10 @@ static int libertas_process_bss(struct bss_descriptor * bss,
1099 bss->atimwindow = le32_to_cpu(pibss->atimwindow); 1093 bss->atimwindow = le32_to_cpu(pibss->atimwindow);
1100 memmove(&bss->ssparamset.ibssparamset, pibss, 1094 memmove(&bss->ssparamset.ibssparamset, pibss,
1101 sizeof(struct ieeetypes_ibssparamset)); 1095 sizeof(struct ieeetypes_ibssparamset));
1096#if 0
1102 bss->ssparamset.ibssparamset.atimwindow 1097 bss->ssparamset.ibssparamset.atimwindow
1103 = le16_to_cpu(bss->ssparamset.ibssparamset.atimwindow); 1098 = le16_to_cpu(bss->ssparamset.ibssparamset.atimwindow);
1099#endif
1104 break; 1100 break;
1105 1101
1106 /* Handle Country Info IE */ 1102 /* Handle Country Info IE */
@@ -1744,7 +1740,8 @@ int libertas_cmd_80211_scan(wlan_private * priv,
1744 + pscancfg->tlvbufferlen + S_DS_GEN); 1740 + pscancfg->tlvbufferlen + S_DS_GEN);
1745 1741
1746 lbs_deb_scan("SCAN_CMD: command=%x, size=%x, seqnum=%x\n", 1742 lbs_deb_scan("SCAN_CMD: command=%x, size=%x, seqnum=%x\n",
1747 cmd->command, cmd->size, cmd->seqnum); 1743 le16_to_cpu(cmd->command), le16_to_cpu(cmd->size),
1744 le16_to_cpu(cmd->seqnum));
1748 1745
1749 lbs_deb_leave(LBS_DEB_ASSOC); 1746 lbs_deb_leave(LBS_DEB_ASSOC);
1750 return 0; 1747 return 0;
@@ -1799,7 +1796,6 @@ int libertas_ret_80211_scan(wlan_private * priv, struct cmd_ds_command *resp)
1799 int bytesleft; 1796 int bytesleft;
1800 int idx; 1797 int idx;
1801 int tlvbufsize; 1798 int tlvbufsize;
1802 u64 tsfval;
1803 int ret; 1799 int ret;
1804 1800
1805 lbs_deb_enter(LBS_DEB_ASSOC); 1801 lbs_deb_enter(LBS_DEB_ASSOC);
@@ -1905,9 +1901,7 @@ int libertas_ret_80211_scan(wlan_private * priv, struct cmd_ds_command *resp)
1905 * beacon or probe response was received. 1901 * beacon or probe response was received.
1906 */ 1902 */
1907 if (ptsftlv) { 1903 if (ptsftlv) {
1908 memcpy(&tsfval, &ptsftlv->tsftable[idx], sizeof(tsfval)); 1904 new.networktsf = le64_to_cpup(&ptsftlv->tsftable[idx]);
1909 tsfval = le64_to_cpu(tsfval);
1910 memcpy(&new.networktsf, &tsfval, sizeof(new.networktsf));
1911 } 1905 }
1912 1906
1913 /* Copy the locally created newbssentry to the scan table */ 1907 /* Copy the locally created newbssentry to the scan table */