aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/libertas/debugfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/libertas/debugfs.c')
-rw-r--r--drivers/net/wireless/libertas/debugfs.c432
1 files changed, 207 insertions, 225 deletions
diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c
index 7d7bc5e86a56..715cbdaa1d4b 100644
--- a/drivers/net/wireless/libertas/debugfs.c
+++ b/drivers/net/wireless/libertas/debugfs.c
@@ -4,6 +4,7 @@
4#include <linux/delay.h> 4#include <linux/delay.h>
5#include <linux/mm.h> 5#include <linux/mm.h>
6#include <net/iw_handler.h> 6#include <net/iw_handler.h>
7
7#include "dev.h" 8#include "dev.h"
8#include "decl.h" 9#include "decl.h"
9#include "host.h" 10#include "host.h"
@@ -15,7 +16,9 @@ static char *szStates[] = {
15 "Disconnected" 16 "Disconnected"
16}; 17};
17 18
18void libertas_debug_init(wlan_private * priv, struct net_device *dev); 19#ifdef PROC_DEBUG
20static void libertas_debug_init(wlan_private * priv, struct net_device *dev);
21#endif
19 22
20static int open_file_generic(struct inode *inode, struct file *file) 23static int open_file_generic(struct inode *inode, struct file *file)
21{ 24{
@@ -60,43 +63,33 @@ static ssize_t libertas_getscantable(struct file *file, char __user *userbuf,
60 int numscansdone = 0, res; 63 int numscansdone = 0, res;
61 unsigned long addr = get_zeroed_page(GFP_KERNEL); 64 unsigned long addr = get_zeroed_page(GFP_KERNEL);
62 char *buf = (char *)addr; 65 char *buf = (char *)addr;
66 struct bss_descriptor * iter_bss;
63 67
64 pos += snprintf(buf+pos, len-pos, 68 pos += snprintf(buf+pos, len-pos,
65 "---------------------------------------");
66 pos += snprintf(buf+pos, len-pos,
67 "---------------------------------------\n");
68 pos += snprintf(buf+pos, len-pos,
69 "# | ch | ss | bssid | cap | TSF | Qual | SSID \n"); 69 "# | ch | ss | bssid | cap | TSF | Qual | SSID \n");
70 pos += snprintf(buf+pos, len-pos,
71 "---------------------------------------");
72 pos += snprintf(buf+pos, len-pos,
73 "---------------------------------------\n");
74 70
75 while (numscansdone < priv->adapter->numinscantable) { 71 mutex_lock(&priv->adapter->lock);
76 struct bss_descriptor *pbssinfo; 72 list_for_each_entry (iter_bss, &priv->adapter->network_list, list) {
77 u16 cap; 73 u16 cap;
78 74
79 pbssinfo = &priv->adapter->scantable[numscansdone]; 75 memcpy(&cap, &iter_bss->cap, sizeof(cap));
80 memcpy(&cap, &pbssinfo->cap, sizeof(cap));
81 pos += snprintf(buf+pos, len-pos, 76 pos += snprintf(buf+pos, len-pos,
82 "%02u| %03d | %03ld | %02x:%02x:%02x:%02x:%02x:%02x |", 77 "%02u| %03d | %03ld | " MAC_FMT " |",
83 numscansdone, pbssinfo->channel, pbssinfo->rssi, 78 numscansdone, iter_bss->channel, iter_bss->rssi,
84 pbssinfo->macaddress[0], pbssinfo->macaddress[1], 79 MAC_ARG(iter_bss->bssid));
85 pbssinfo->macaddress[2], pbssinfo->macaddress[3],
86 pbssinfo->macaddress[4], pbssinfo->macaddress[5]);
87 pos += snprintf(buf+pos, len-pos, " %04x-", cap); 80 pos += snprintf(buf+pos, len-pos, " %04x-", cap);
88 pos += snprintf(buf+pos, len-pos, "%c%c%c |", 81 pos += snprintf(buf+pos, len-pos, "%c%c%c |",
89 pbssinfo->cap.ibss ? 'A' : 'I', 82 iter_bss->cap.ibss ? 'A' : 'I',
90 pbssinfo->cap.privacy ? 'P' : ' ', 83 iter_bss->cap.privacy ? 'P' : ' ',
91 pbssinfo->cap.spectrummgmt ? 'S' : ' '); 84 iter_bss->cap.spectrummgmt ? 'S' : ' ');
92 pos += snprintf(buf+pos, len-pos, " %08llx |", pbssinfo->networktsf); 85 pos += snprintf(buf+pos, len-pos, " %08llx |", iter_bss->networktsf);
93 pos += snprintf(buf+pos, len-pos, " %d |", 86 pos += snprintf(buf+pos, len-pos, " %d |", SCAN_RSSI(iter_bss->rssi));
94 SCAN_RSSI(priv->adapter->scantable[numscansdone].rssi)); 87 pos += snprintf(buf+pos, len-pos, " %s\n",
95 88 escape_essid(iter_bss->ssid, iter_bss->ssid_len));
96 pos += snprintf(buf+pos, len-pos, " %s\n", pbssinfo->ssid.ssid);
97 89
98 numscansdone++; 90 numscansdone++;
99 } 91 }
92 mutex_unlock(&priv->adapter->lock);
100 93
101 res = simple_read_from_buffer(userbuf, count, ppos, buf, pos); 94 res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
102 95
@@ -111,7 +104,6 @@ static ssize_t libertas_sleepparams_write(struct file *file,
111 wlan_private *priv = file->private_data; 104 wlan_private *priv = file->private_data;
112 ssize_t buf_size, res; 105 ssize_t buf_size, res;
113 int p1, p2, p3, p4, p5, p6; 106 int p1, p2, p3, p4, p5, p6;
114 struct sleep_params sp;
115 unsigned long addr = get_zeroed_page(GFP_KERNEL); 107 unsigned long addr = get_zeroed_page(GFP_KERNEL);
116 char *buf = (char *)addr; 108 char *buf = (char *)addr;
117 109
@@ -125,14 +117,12 @@ static ssize_t libertas_sleepparams_write(struct file *file,
125 res = -EFAULT; 117 res = -EFAULT;
126 goto out_unlock; 118 goto out_unlock;
127 } 119 }
128 sp.sp_error = p1; 120 priv->adapter->sp.sp_error = p1;
129 sp.sp_offset = p2; 121 priv->adapter->sp.sp_offset = p2;
130 sp.sp_stabletime = p3; 122 priv->adapter->sp.sp_stabletime = p3;
131 sp.sp_calcontrol = p4; 123 priv->adapter->sp.sp_calcontrol = p4;
132 sp.sp_extsleepclk = p5; 124 priv->adapter->sp.sp_extsleepclk = p5;
133 sp.sp_reserved = p6; 125 priv->adapter->sp.sp_reserved = p6;
134
135 memcpy(&priv->adapter->sp, &sp, sizeof(struct sleep_params));
136 126
137 res = libertas_prepare_and_send_command(priv, 127 res = libertas_prepare_and_send_command(priv,
138 cmd_802_11_sleep_params, 128 cmd_802_11_sleep_params,
@@ -185,7 +175,6 @@ static ssize_t libertas_extscan(struct file *file, const char __user *userbuf,
185{ 175{
186 wlan_private *priv = file->private_data; 176 wlan_private *priv = file->private_data;
187 ssize_t res, buf_size; 177 ssize_t res, buf_size;
188 struct WLAN_802_11_SSID extscan_ssid;
189 union iwreq_data wrqu; 178 union iwreq_data wrqu;
190 unsigned long addr = get_zeroed_page(GFP_KERNEL); 179 unsigned long addr = get_zeroed_page(GFP_KERNEL);
191 char *buf = (char *)addr; 180 char *buf = (char *)addr;
@@ -196,13 +185,10 @@ static ssize_t libertas_extscan(struct file *file, const char __user *userbuf,
196 goto out_unlock; 185 goto out_unlock;
197 } 186 }
198 187
199 memcpy(&extscan_ssid.ssid, buf, strlen(buf)-1); 188 libertas_send_specific_ssid_scan(priv, buf, strlen(buf)-1, 0);
200 extscan_ssid.ssidlength = strlen(buf)-1;
201
202 libertas_send_specific_SSID_scan(priv, &extscan_ssid, 1);
203 189
204 memset(&wrqu, 0, sizeof(union iwreq_data)); 190 memset(&wrqu, 0, sizeof(union iwreq_data));
205 wireless_send_event(priv->wlan_dev.netdev, SIOCGIWSCAN, &wrqu, NULL); 191 wireless_send_event(priv->dev, SIOCGIWSCAN, &wrqu, NULL);
206 192
207out_unlock: 193out_unlock:
208 free_page(addr); 194 free_page(addr);
@@ -251,16 +237,13 @@ static void libertas_parse_bssid(char *buf, size_t count,
251{ 237{
252 char *hold; 238 char *hold;
253 unsigned int mac[ETH_ALEN]; 239 unsigned int mac[ETH_ALEN];
254 int i;
255 240
256 hold = strstr(buf, "bssid="); 241 hold = strstr(buf, "bssid=");
257 if (!hold) 242 if (!hold)
258 return; 243 return;
259 hold += 6; 244 hold += 6;
260 sscanf(hold, "%2x:%2x:%2x:%2x:%2x:%2x", mac, mac+1, mac+2, mac+3, 245 sscanf(hold, MAC_FMT, mac, mac+1, mac+2, mac+3, mac+4, mac+5);
261 mac+4, mac+5); 246 memcpy(scan_cfg->bssid, mac, ETH_ALEN);
262 for(i=0;i<ETH_ALEN;i++)
263 scan_cfg->specificBSSID[i] = mac[i];
264} 247}
265 248
266static void libertas_parse_ssid(char *buf, size_t count, 249static void libertas_parse_ssid(char *buf, size_t count,
@@ -278,28 +261,26 @@ static void libertas_parse_ssid(char *buf, size_t count,
278 end = buf + count - 1; 261 end = buf + count - 1;
279 262
280 size = min((size_t)IW_ESSID_MAX_SIZE, (size_t) (end - hold)); 263 size = min((size_t)IW_ESSID_MAX_SIZE, (size_t) (end - hold));
281 strncpy(scan_cfg->specificSSID, hold, size); 264 strncpy(scan_cfg->ssid, hold, size);
282 265
283 return; 266 return;
284} 267}
285 268
286static void libertas_parse_keep(char *buf, size_t count, 269static int libertas_parse_clear(char *buf, size_t count, const char *tag)
287 struct wlan_ioctl_user_scan_cfg *scan_cfg)
288{ 270{
289 char *hold; 271 char *hold;
290 int val; 272 int val;
291 273
292 hold = strstr(buf, "keep="); 274 hold = strstr(buf, tag);
293 if (!hold) 275 if (!hold)
294 return; 276 return 0;
295 hold += 5; 277 hold += strlen(tag);
296 sscanf(hold, "%d", &val); 278 sscanf(hold, "%d", &val);
297 279
298 if (val != 0) 280 if (val != 0)
299 val = 1; 281 val = 1;
300 282
301 scan_cfg->keeppreviousscan = val; 283 return val;
302 return;
303} 284}
304 285
305static int libertas_parse_dur(char *buf, size_t count, 286static int libertas_parse_dur(char *buf, size_t count,
@@ -382,17 +363,18 @@ static ssize_t libertas_setuserscan(struct file *file,
382 dur = libertas_parse_dur(buf, count, scan_cfg); 363 dur = libertas_parse_dur(buf, count, scan_cfg);
383 libertas_parse_chan(buf, count, scan_cfg, dur); 364 libertas_parse_chan(buf, count, scan_cfg, dur);
384 libertas_parse_bssid(buf, count, scan_cfg); 365 libertas_parse_bssid(buf, count, scan_cfg);
366 scan_cfg->clear_bssid = libertas_parse_clear(buf, count, "clear_bssid=");
385 libertas_parse_ssid(buf, count, scan_cfg); 367 libertas_parse_ssid(buf, count, scan_cfg);
386 libertas_parse_keep(buf, count, scan_cfg); 368 scan_cfg->clear_ssid = libertas_parse_clear(buf, count, "clear_ssid=");
387 libertas_parse_probes(buf, count, scan_cfg); 369 libertas_parse_probes(buf, count, scan_cfg);
388 libertas_parse_type(buf, count, scan_cfg); 370 libertas_parse_type(buf, count, scan_cfg);
389 371
390 wlan_scan_networks(priv, scan_cfg); 372 wlan_scan_networks(priv, scan_cfg, 1);
391 wait_event_interruptible(priv->adapter->cmd_pending, 373 wait_event_interruptible(priv->adapter->cmd_pending,
392 !priv->adapter->nr_cmd_pending); 374 !priv->adapter->nr_cmd_pending);
393 375
394 memset(&wrqu, 0x00, sizeof(union iwreq_data)); 376 memset(&wrqu, 0x00, sizeof(union iwreq_data));
395 wireless_send_event(priv->wlan_dev.netdev, SIOCGIWSCAN, &wrqu, NULL); 377 wireless_send_event(priv->dev, SIOCGIWSCAN, &wrqu, NULL);
396 378
397out_unlock: 379out_unlock:
398 free_page(addr); 380 free_page(addr);
@@ -407,11 +389,11 @@ static int libertas_event_initcmd(wlan_private *priv, void **response_buf,
407 u16 wait_option = cmd_option_waitforrsp; 389 u16 wait_option = cmd_option_waitforrsp;
408 390
409 if (!(*cmdnode = libertas_get_free_cmd_ctrl_node(priv))) { 391 if (!(*cmdnode = libertas_get_free_cmd_ctrl_node(priv))) {
410 lbs_pr_debug(1, "failed libertas_get_free_cmd_ctrl_node\n"); 392 lbs_deb_debugfs("failed libertas_get_free_cmd_ctrl_node\n");
411 return -ENOMEM; 393 return -ENOMEM;
412 } 394 }
413 if (!(*response_buf = kmalloc(3000, GFP_KERNEL))) { 395 if (!(*response_buf = kmalloc(3000, GFP_KERNEL))) {
414 lbs_pr_debug(1, "failed to allocate response buffer!\n"); 396 lbs_deb_debugfs("failed to allocate response buffer!\n");
415 return -ENOMEM; 397 return -ENOMEM;
416 } 398 }
417 libertas_set_cmd_ctrl_node(priv, *cmdnode, 0, wait_option, NULL); 399 libertas_set_cmd_ctrl_node(priv, *cmdnode, 0, wait_option, NULL);
@@ -420,8 +402,8 @@ static int libertas_event_initcmd(wlan_private *priv, void **response_buf,
420 (*cmdnode)->cmdflags |= CMD_F_HOSTCMD; 402 (*cmdnode)->cmdflags |= CMD_F_HOSTCMD;
421 (*cmdnode)->cmdwaitqwoken = 0; 403 (*cmdnode)->cmdwaitqwoken = 0;
422 *cmd = (struct cmd_ds_command *)(*cmdnode)->bufvirtualaddr; 404 *cmd = (struct cmd_ds_command *)(*cmdnode)->bufvirtualaddr;
423 (*cmd)->command = cmd_802_11_subscribe_event; 405 (*cmd)->command = cpu_to_le16(cmd_802_11_subscribe_event);
424 (*cmd)->seqnum = ++priv->adapter->seqnum; 406 (*cmd)->seqnum = cpu_to_le16(++priv->adapter->seqnum);
425 (*cmd)->result = 0; 407 (*cmd)->result = 0;
426 return 0; 408 return 0;
427} 409}
@@ -447,26 +429,25 @@ static ssize_t libertas_lowrssi_read(struct file *file, char __user *userbuf,
447 } 429 }
448 430
449 event = &pcmdptr->params.subscribe_event; 431 event = &pcmdptr->params.subscribe_event;
450 event->action = cmd_act_get; 432 event->action = cpu_to_le16(cmd_act_get);
451 pcmdptr->size = 433 pcmdptr->size = cpu_to_le16(sizeof(*event) + S_DS_GEN);
452 cpu_to_le16(sizeof(struct cmd_ds_802_11_subscribe_event) + S_DS_GEN);
453 libertas_queue_cmd(adapter, pcmdnode, 1); 434 libertas_queue_cmd(adapter, pcmdnode, 1);
454 wake_up_interruptible(&priv->mainthread.waitq); 435 wake_up_interruptible(&priv->mainthread.waitq);
455 436
456 /* Sleep until response is generated by FW */ 437 /* Sleep until response is generated by FW */
457 wait_event_interruptible(pcmdnode->cmdwait_q, 438 wait_event_interruptible(pcmdnode->cmdwait_q,
458 pcmdnode->cmdwaitqwoken); 439 pcmdnode->cmdwaitqwoken);
459 440
460 pcmdptr = response_buf; 441 pcmdptr = response_buf;
461 if (pcmdptr->result) { 442 if (pcmdptr->result) {
462 lbs_pr_err("%s: fail, result=%d\n", __FUNCTION__, 443 lbs_pr_err("%s: fail, result=%d\n", __func__,
463 pcmdptr->result); 444 le16_to_cpu(pcmdptr->result));
464 kfree(response_buf); 445 kfree(response_buf);
465 free_page(addr); 446 free_page(addr);
466 return 0; 447 return 0;
467 } 448 }
468 449
469 if (pcmdptr->command != cmd_ret_802_11_subscribe_event) { 450 if (pcmdptr->command != cpu_to_le16(cmd_ret_802_11_subscribe_event)) {
470 lbs_pr_err("command response incorrect!\n"); 451 lbs_pr_err("command response incorrect!\n");
471 kfree(response_buf); 452 kfree(response_buf);
472 free_page(addr); 453 free_page(addr);
@@ -474,17 +455,17 @@ static ssize_t libertas_lowrssi_read(struct file *file, char __user *userbuf,
474 } 455 }
475 456
476 cmd_len = S_DS_GEN + sizeof(struct cmd_ds_802_11_subscribe_event); 457 cmd_len = S_DS_GEN + sizeof(struct cmd_ds_802_11_subscribe_event);
477 event = (struct cmd_ds_802_11_subscribe_event *)(response_buf + S_DS_GEN); 458 event = (void *)(response_buf + S_DS_GEN);
478 while (cmd_len < pcmdptr->size) { 459 while (cmd_len < le16_to_cpu(pcmdptr->size)) {
479 struct mrvlietypesheader *header = (struct mrvlietypesheader *)(response_buf + cmd_len); 460 struct mrvlietypesheader *header = (void *)(response_buf + cmd_len);
480 switch(header->type) { 461 switch (header->type) {
481 struct mrvlietypes_rssithreshold *Lowrssi; 462 struct mrvlietypes_rssithreshold *Lowrssi;
482 case TLV_TYPE_RSSI_LOW: 463 case __constant_cpu_to_le16(TLV_TYPE_RSSI_LOW):
483 Lowrssi = (struct mrvlietypes_rssithreshold *)(response_buf + cmd_len); 464 Lowrssi = (void *)(response_buf + cmd_len);
484 pos += snprintf(buf+pos, len-pos, "%d %d %d\n", 465 pos += snprintf(buf+pos, len-pos, "%d %d %d\n",
485 Lowrssi->rssivalue, 466 Lowrssi->rssivalue,
486 Lowrssi->rssifreq, 467 Lowrssi->rssifreq,
487 (event->events & 0x0001)?1:0); 468 (event->events & cpu_to_le16(0x0001))?1:0);
488 default: 469 default:
489 cmd_len += sizeof(struct mrvlietypes_snrthreshold); 470 cmd_len += sizeof(struct mrvlietypes_snrthreshold);
490 break; 471 break;
@@ -512,21 +493,20 @@ static u16 libertas_get_events_bitmap(wlan_private *priv)
512 return res; 493 return res;
513 494
514 event = &pcmdptr->params.subscribe_event; 495 event = &pcmdptr->params.subscribe_event;
515 event->action = cmd_act_get; 496 event->action = cpu_to_le16(cmd_act_get);
516 pcmdptr->size = 497 pcmdptr->size = cpu_to_le16(sizeof(*event) + S_DS_GEN);
517 cpu_to_le16(sizeof(struct cmd_ds_802_11_subscribe_event) + S_DS_GEN);
518 libertas_queue_cmd(adapter, pcmdnode, 1); 498 libertas_queue_cmd(adapter, pcmdnode, 1);
519 wake_up_interruptible(&priv->mainthread.waitq); 499 wake_up_interruptible(&priv->mainthread.waitq);
520 500
521 /* Sleep until response is generated by FW */ 501 /* Sleep until response is generated by FW */
522 wait_event_interruptible(pcmdnode->cmdwait_q, 502 wait_event_interruptible(pcmdnode->cmdwait_q,
523 pcmdnode->cmdwaitqwoken); 503 pcmdnode->cmdwaitqwoken);
524 504
525 pcmdptr = response_buf; 505 pcmdptr = response_buf;
526 506
527 if (pcmdptr->result) { 507 if (pcmdptr->result) {
528 lbs_pr_err("%s: fail, result=%d\n", __FUNCTION__, 508 lbs_pr_err("%s: fail, result=%d\n", __func__,
529 pcmdptr->result); 509 le16_to_cpu(pcmdptr->result));
530 kfree(response_buf); 510 kfree(response_buf);
531 return 0; 511 return 0;
532 } 512 }
@@ -538,7 +518,7 @@ static u16 libertas_get_events_bitmap(wlan_private *priv)
538 } 518 }
539 519
540 event = (struct cmd_ds_802_11_subscribe_event *)(response_buf + S_DS_GEN); 520 event = (struct cmd_ds_802_11_subscribe_event *)(response_buf + S_DS_GEN);
541 event_bitmap = event->events; 521 event_bitmap = le16_to_cpu(event->events);
542 kfree(response_buf); 522 kfree(response_buf);
543 return event_bitmap; 523 return event_bitmap;
544} 524}
@@ -579,7 +559,7 @@ static ssize_t libertas_lowrssi_write(struct file *file,
579 goto out_unlock; 559 goto out_unlock;
580 560
581 event = &pcmdptr->params.subscribe_event; 561 event = &pcmdptr->params.subscribe_event;
582 event->action = cmd_act_set; 562 event->action = cpu_to_le16(cmd_act_set);
583 pcmdptr->size = cpu_to_le16(S_DS_GEN + 563 pcmdptr->size = cpu_to_le16(S_DS_GEN +
584 sizeof(struct cmd_ds_802_11_subscribe_event) + 564 sizeof(struct cmd_ds_802_11_subscribe_event) +
585 sizeof(struct mrvlietypes_rssithreshold)); 565 sizeof(struct mrvlietypes_rssithreshold));
@@ -588,30 +568,30 @@ static ssize_t libertas_lowrssi_write(struct file *file,
588 ptr = (u8*) pcmdptr+cmd_len; 568 ptr = (u8*) pcmdptr+cmd_len;
589 rssi_threshold = (struct mrvlietypes_rssithreshold *)(ptr); 569 rssi_threshold = (struct mrvlietypes_rssithreshold *)(ptr);
590 rssi_threshold->header.type = cpu_to_le16(0x0104); 570 rssi_threshold->header.type = cpu_to_le16(0x0104);
591 rssi_threshold->header.len = 2; 571 rssi_threshold->header.len = cpu_to_le16(2);
592 rssi_threshold->rssivalue = cpu_to_le16(value); 572 rssi_threshold->rssivalue = value;
593 rssi_threshold->rssifreq = cpu_to_le16(freq); 573 rssi_threshold->rssifreq = freq;
594 event_bitmap |= subscribed ? 0x0001 : 0x0; 574 event_bitmap |= subscribed ? 0x0001 : 0x0;
595 event->events = event_bitmap; 575 event->events = cpu_to_le16(event_bitmap);
596 576
597 libertas_queue_cmd(adapter, pcmdnode, 1); 577 libertas_queue_cmd(adapter, pcmdnode, 1);
598 wake_up_interruptible(&priv->mainthread.waitq); 578 wake_up_interruptible(&priv->mainthread.waitq);
599 579
600 /* Sleep until response is generated by FW */ 580 /* Sleep until response is generated by FW */
601 wait_event_interruptible(pcmdnode->cmdwait_q, 581 wait_event_interruptible(pcmdnode->cmdwait_q,
602 pcmdnode->cmdwaitqwoken); 582 pcmdnode->cmdwaitqwoken);
603 583
604 pcmdptr = response_buf; 584 pcmdptr = response_buf;
605 585
606 if (pcmdptr->result) { 586 if (pcmdptr->result) {
607 lbs_pr_err("%s: fail, result=%d\n", __FUNCTION__, 587 lbs_pr_err("%s: fail, result=%d\n", __func__,
608 pcmdptr->result); 588 le16_to_cpu(pcmdptr->result));
609 kfree(response_buf); 589 kfree(response_buf);
610 free_page(addr); 590 free_page(addr);
611 return 0; 591 return 0;
612 } 592 }
613 593
614 if (pcmdptr->command != cmd_ret_802_11_subscribe_event) { 594 if (pcmdptr->command != cpu_to_le16(cmd_ret_802_11_subscribe_event)) {
615 lbs_pr_err("command response incorrect!\n"); 595 lbs_pr_err("command response incorrect!\n");
616 kfree(response_buf); 596 kfree(response_buf);
617 free_page(addr); 597 free_page(addr);
@@ -645,27 +625,26 @@ static ssize_t libertas_lowsnr_read(struct file *file, char __user *userbuf,
645 } 625 }
646 626
647 event = &pcmdptr->params.subscribe_event; 627 event = &pcmdptr->params.subscribe_event;
648 event->action = cmd_act_get; 628 event->action = cpu_to_le16(cmd_act_get);
649 pcmdptr->size = 629 pcmdptr->size = cpu_to_le16(sizeof(*event) + S_DS_GEN);
650 cpu_to_le16(sizeof(struct cmd_ds_802_11_subscribe_event) + S_DS_GEN);
651 libertas_queue_cmd(adapter, pcmdnode, 1); 630 libertas_queue_cmd(adapter, pcmdnode, 1);
652 wake_up_interruptible(&priv->mainthread.waitq); 631 wake_up_interruptible(&priv->mainthread.waitq);
653 632
654 /* Sleep until response is generated by FW */ 633 /* Sleep until response is generated by FW */
655 wait_event_interruptible(pcmdnode->cmdwait_q, 634 wait_event_interruptible(pcmdnode->cmdwait_q,
656 pcmdnode->cmdwaitqwoken); 635 pcmdnode->cmdwaitqwoken);
657 636
658 pcmdptr = response_buf; 637 pcmdptr = response_buf;
659 638
660 if (pcmdptr->result) { 639 if (pcmdptr->result) {
661 lbs_pr_err("%s: fail, result=%d\n", __FUNCTION__, 640 lbs_pr_err("%s: fail, result=%d\n", __func__,
662 pcmdptr->result); 641 le16_to_cpu(pcmdptr->result));
663 kfree(response_buf); 642 kfree(response_buf);
664 free_page(addr); 643 free_page(addr);
665 return 0; 644 return 0;
666 } 645 }
667 646
668 if (pcmdptr->command != cmd_ret_802_11_subscribe_event) { 647 if (pcmdptr->command != cpu_to_le16(cmd_ret_802_11_subscribe_event)) {
669 lbs_pr_err("command response incorrect!\n"); 648 lbs_pr_err("command response incorrect!\n");
670 kfree(response_buf); 649 kfree(response_buf);
671 free_page(addr); 650 free_page(addr);
@@ -673,17 +652,17 @@ static ssize_t libertas_lowsnr_read(struct file *file, char __user *userbuf,
673 } 652 }
674 653
675 cmd_len = S_DS_GEN + sizeof(struct cmd_ds_802_11_subscribe_event); 654 cmd_len = S_DS_GEN + sizeof(struct cmd_ds_802_11_subscribe_event);
676 event = (struct cmd_ds_802_11_subscribe_event *)(response_buf + S_DS_GEN); 655 event = (void *)(response_buf + S_DS_GEN);
677 while (cmd_len < pcmdptr->size) { 656 while (cmd_len < le16_to_cpu(pcmdptr->size)) {
678 struct mrvlietypesheader *header = (struct mrvlietypesheader *)(response_buf + cmd_len); 657 struct mrvlietypesheader *header = (void *)(response_buf + cmd_len);
679 switch(header->type) { 658 switch (header->type) {
680 struct mrvlietypes_snrthreshold *LowSnr; 659 struct mrvlietypes_snrthreshold *LowSnr;
681 case TLV_TYPE_SNR_LOW: 660 case __constant_cpu_to_le16(TLV_TYPE_SNR_LOW):
682 LowSnr = (struct mrvlietypes_snrthreshold *)(response_buf + cmd_len); 661 LowSnr = (void *)(response_buf + cmd_len);
683 pos += snprintf(buf+pos, len-pos, "%d %d %d\n", 662 pos += snprintf(buf+pos, len-pos, "%d %d %d\n",
684 LowSnr->snrvalue, 663 LowSnr->snrvalue,
685 LowSnr->snrfreq, 664 LowSnr->snrfreq,
686 (event->events & 0x0002)?1:0); 665 (event->events & cpu_to_le16(0x0002))?1:0);
687 default: 666 default:
688 cmd_len += sizeof(struct mrvlietypes_snrthreshold); 667 cmd_len += sizeof(struct mrvlietypes_snrthreshold);
689 break; 668 break;
@@ -733,7 +712,7 @@ static ssize_t libertas_lowsnr_write(struct file *file,
733 goto out_unlock; 712 goto out_unlock;
734 713
735 event = &pcmdptr->params.subscribe_event; 714 event = &pcmdptr->params.subscribe_event;
736 event->action = cmd_act_set; 715 event->action = cpu_to_le16(cmd_act_set);
737 pcmdptr->size = cpu_to_le16(S_DS_GEN + 716 pcmdptr->size = cpu_to_le16(S_DS_GEN +
738 sizeof(struct cmd_ds_802_11_subscribe_event) + 717 sizeof(struct cmd_ds_802_11_subscribe_event) +
739 sizeof(struct mrvlietypes_snrthreshold)); 718 sizeof(struct mrvlietypes_snrthreshold));
@@ -741,30 +720,30 @@ static ssize_t libertas_lowsnr_write(struct file *file,
741 ptr = (u8*) pcmdptr+cmd_len; 720 ptr = (u8*) pcmdptr+cmd_len;
742 snr_threshold = (struct mrvlietypes_snrthreshold *)(ptr); 721 snr_threshold = (struct mrvlietypes_snrthreshold *)(ptr);
743 snr_threshold->header.type = cpu_to_le16(TLV_TYPE_SNR_LOW); 722 snr_threshold->header.type = cpu_to_le16(TLV_TYPE_SNR_LOW);
744 snr_threshold->header.len = 2; 723 snr_threshold->header.len = cpu_to_le16(2);
745 snr_threshold->snrvalue = cpu_to_le16(value); 724 snr_threshold->snrvalue = value;
746 snr_threshold->snrfreq = cpu_to_le16(freq); 725 snr_threshold->snrfreq = freq;
747 event_bitmap |= subscribed ? 0x0002 : 0x0; 726 event_bitmap |= subscribed ? 0x0002 : 0x0;
748 event->events = event_bitmap; 727 event->events = cpu_to_le16(event_bitmap);
749 728
750 libertas_queue_cmd(adapter, pcmdnode, 1); 729 libertas_queue_cmd(adapter, pcmdnode, 1);
751 wake_up_interruptible(&priv->mainthread.waitq); 730 wake_up_interruptible(&priv->mainthread.waitq);
752 731
753 /* Sleep until response is generated by FW */ 732 /* Sleep until response is generated by FW */
754 wait_event_interruptible(pcmdnode->cmdwait_q, 733 wait_event_interruptible(pcmdnode->cmdwait_q,
755 pcmdnode->cmdwaitqwoken); 734 pcmdnode->cmdwaitqwoken);
756 735
757 pcmdptr = response_buf; 736 pcmdptr = response_buf;
758 737
759 if (pcmdptr->result) { 738 if (pcmdptr->result) {
760 lbs_pr_err("%s: fail, result=%d\n", __FUNCTION__, 739 lbs_pr_err("%s: fail, result=%d\n", __func__,
761 pcmdptr->result); 740 le16_to_cpu(pcmdptr->result));
762 kfree(response_buf); 741 kfree(response_buf);
763 free_page(addr); 742 free_page(addr);
764 return 0; 743 return 0;
765 } 744 }
766 745
767 if (pcmdptr->command != cmd_ret_802_11_subscribe_event) { 746 if (pcmdptr->command != cpu_to_le16(cmd_ret_802_11_subscribe_event)) {
768 lbs_pr_err("command response incorrect!\n"); 747 lbs_pr_err("command response incorrect!\n");
769 kfree(response_buf); 748 kfree(response_buf);
770 free_page(addr); 749 free_page(addr);
@@ -799,27 +778,26 @@ static ssize_t libertas_failcount_read(struct file *file, char __user *userbuf,
799 } 778 }
800 779
801 event = &pcmdptr->params.subscribe_event; 780 event = &pcmdptr->params.subscribe_event;
802 event->action = cmd_act_get; 781 event->action = cpu_to_le16(cmd_act_get);
803 pcmdptr->size = 782 pcmdptr->size = cpu_to_le16(sizeof(*event) + S_DS_GEN);
804 cpu_to_le16(sizeof(struct cmd_ds_802_11_subscribe_event) + S_DS_GEN);
805 libertas_queue_cmd(adapter, pcmdnode, 1); 783 libertas_queue_cmd(adapter, pcmdnode, 1);
806 wake_up_interruptible(&priv->mainthread.waitq); 784 wake_up_interruptible(&priv->mainthread.waitq);
807 785
808 /* Sleep until response is generated by FW */ 786 /* Sleep until response is generated by FW */
809 wait_event_interruptible(pcmdnode->cmdwait_q, 787 wait_event_interruptible(pcmdnode->cmdwait_q,
810 pcmdnode->cmdwaitqwoken); 788 pcmdnode->cmdwaitqwoken);
811 789
812 pcmdptr = response_buf; 790 pcmdptr = response_buf;
813 791
814 if (pcmdptr->result) { 792 if (pcmdptr->result) {
815 lbs_pr_err("%s: fail, result=%d\n", __FUNCTION__, 793 lbs_pr_err("%s: fail, result=%d\n", __func__,
816 pcmdptr->result); 794 le16_to_cpu(pcmdptr->result));
817 kfree(response_buf); 795 kfree(response_buf);
818 free_page(addr); 796 free_page(addr);
819 return 0; 797 return 0;
820 } 798 }
821 799
822 if (pcmdptr->command != cmd_ret_802_11_subscribe_event) { 800 if (pcmdptr->command != cpu_to_le16(cmd_ret_802_11_subscribe_event)) {
823 lbs_pr_err("command response incorrect!\n"); 801 lbs_pr_err("command response incorrect!\n");
824 kfree(response_buf); 802 kfree(response_buf);
825 free_page(addr); 803 free_page(addr);
@@ -827,17 +805,17 @@ static ssize_t libertas_failcount_read(struct file *file, char __user *userbuf,
827 } 805 }
828 806
829 cmd_len = S_DS_GEN + sizeof(struct cmd_ds_802_11_subscribe_event); 807 cmd_len = S_DS_GEN + sizeof(struct cmd_ds_802_11_subscribe_event);
830 event = (struct cmd_ds_802_11_subscribe_event *)(response_buf + S_DS_GEN); 808 event = (void *)(response_buf + S_DS_GEN);
831 while (cmd_len < pcmdptr->size) { 809 while (cmd_len < le16_to_cpu(pcmdptr->size)) {
832 struct mrvlietypesheader *header = (struct mrvlietypesheader *)(response_buf + cmd_len); 810 struct mrvlietypesheader *header = (void *)(response_buf + cmd_len);
833 switch(header->type) { 811 switch (header->type) {
834 struct mrvlietypes_failurecount *failcount; 812 struct mrvlietypes_failurecount *failcount;
835 case TLV_TYPE_FAILCOUNT: 813 case __constant_cpu_to_le16(TLV_TYPE_FAILCOUNT):
836 failcount = (struct mrvlietypes_failurecount *)(response_buf + cmd_len); 814 failcount = (void *)(response_buf + cmd_len);
837 pos += snprintf(buf+pos, len-pos, "%d %d %d\n", 815 pos += snprintf(buf+pos, len-pos, "%d %d %d\n",
838 failcount->failvalue, 816 failcount->failvalue,
839 failcount->Failfreq, 817 failcount->Failfreq,
840 (event->events & 0x0004)?1:0); 818 (event->events & cpu_to_le16(0x0004))?1:0);
841 default: 819 default:
842 cmd_len += sizeof(struct mrvlietypes_failurecount); 820 cmd_len += sizeof(struct mrvlietypes_failurecount);
843 break; 821 break;
@@ -886,7 +864,7 @@ static ssize_t libertas_failcount_write(struct file *file,
886 goto out_unlock; 864 goto out_unlock;
887 865
888 event = &pcmdptr->params.subscribe_event; 866 event = &pcmdptr->params.subscribe_event;
889 event->action = cmd_act_set; 867 event->action = cpu_to_le16(cmd_act_set);
890 pcmdptr->size = cpu_to_le16(S_DS_GEN + 868 pcmdptr->size = cpu_to_le16(S_DS_GEN +
891 sizeof(struct cmd_ds_802_11_subscribe_event) + 869 sizeof(struct cmd_ds_802_11_subscribe_event) +
892 sizeof(struct mrvlietypes_failurecount)); 870 sizeof(struct mrvlietypes_failurecount));
@@ -894,30 +872,30 @@ static ssize_t libertas_failcount_write(struct file *file,
894 ptr = (u8*) pcmdptr+cmd_len; 872 ptr = (u8*) pcmdptr+cmd_len;
895 failcount = (struct mrvlietypes_failurecount *)(ptr); 873 failcount = (struct mrvlietypes_failurecount *)(ptr);
896 failcount->header.type = cpu_to_le16(TLV_TYPE_FAILCOUNT); 874 failcount->header.type = cpu_to_le16(TLV_TYPE_FAILCOUNT);
897 failcount->header.len = 2; 875 failcount->header.len = cpu_to_le16(2);
898 failcount->failvalue = cpu_to_le16(value); 876 failcount->failvalue = value;
899 failcount->Failfreq = cpu_to_le16(freq); 877 failcount->Failfreq = freq;
900 event_bitmap |= subscribed ? 0x0004 : 0x0; 878 event_bitmap |= subscribed ? 0x0004 : 0x0;
901 event->events = event_bitmap; 879 event->events = cpu_to_le16(event_bitmap);
902 880
903 libertas_queue_cmd(adapter, pcmdnode, 1); 881 libertas_queue_cmd(adapter, pcmdnode, 1);
904 wake_up_interruptible(&priv->mainthread.waitq); 882 wake_up_interruptible(&priv->mainthread.waitq);
905 883
906 /* Sleep until response is generated by FW */ 884 /* Sleep until response is generated by FW */
907 wait_event_interruptible(pcmdnode->cmdwait_q, 885 wait_event_interruptible(pcmdnode->cmdwait_q,
908 pcmdnode->cmdwaitqwoken); 886 pcmdnode->cmdwaitqwoken);
909 887
910 pcmdptr = (struct cmd_ds_command *)response_buf; 888 pcmdptr = (struct cmd_ds_command *)response_buf;
911 889
912 if (pcmdptr->result) { 890 if (pcmdptr->result) {
913 lbs_pr_err("%s: fail, result=%d\n", __FUNCTION__, 891 lbs_pr_err("%s: fail, result=%d\n", __func__,
914 pcmdptr->result); 892 le16_to_cpu(pcmdptr->result));
915 kfree(response_buf); 893 kfree(response_buf);
916 free_page(addr); 894 free_page(addr);
917 return 0; 895 return 0;
918 } 896 }
919 897
920 if (pcmdptr->command != cmd_ret_802_11_subscribe_event) { 898 if (pcmdptr->command != cpu_to_le16(cmd_ret_802_11_subscribe_event)) {
921 lbs_pr_err("command response incorrect!\n"); 899 lbs_pr_err("command response incorrect!\n");
922 kfree(response_buf); 900 kfree(response_buf);
923 free_page(addr); 901 free_page(addr);
@@ -951,27 +929,26 @@ static ssize_t libertas_bcnmiss_read(struct file *file, char __user *userbuf,
951 } 929 }
952 930
953 event = &pcmdptr->params.subscribe_event; 931 event = &pcmdptr->params.subscribe_event;
954 event->action = cmd_act_get; 932 event->action = cpu_to_le16(cmd_act_get);
955 pcmdptr->size = 933 pcmdptr->size = cpu_to_le16(sizeof(*event) + S_DS_GEN);
956 cpu_to_le16(sizeof(struct cmd_ds_802_11_subscribe_event) + S_DS_GEN);
957 libertas_queue_cmd(adapter, pcmdnode, 1); 934 libertas_queue_cmd(adapter, pcmdnode, 1);
958 wake_up_interruptible(&priv->mainthread.waitq); 935 wake_up_interruptible(&priv->mainthread.waitq);
959 936
960 /* Sleep until response is generated by FW */ 937 /* Sleep until response is generated by FW */
961 wait_event_interruptible(pcmdnode->cmdwait_q, 938 wait_event_interruptible(pcmdnode->cmdwait_q,
962 pcmdnode->cmdwaitqwoken); 939 pcmdnode->cmdwaitqwoken);
963 940
964 pcmdptr = response_buf; 941 pcmdptr = response_buf;
965 942
966 if (pcmdptr->result) { 943 if (pcmdptr->result) {
967 lbs_pr_err("%s: fail, result=%d\n", __FUNCTION__, 944 lbs_pr_err("%s: fail, result=%d\n", __func__,
968 pcmdptr->result); 945 le16_to_cpu(pcmdptr->result));
969 free_page(addr); 946 free_page(addr);
970 kfree(response_buf); 947 kfree(response_buf);
971 return 0; 948 return 0;
972 } 949 }
973 950
974 if (pcmdptr->command != cmd_ret_802_11_subscribe_event) { 951 if (pcmdptr->command != cpu_to_le16(cmd_ret_802_11_subscribe_event)) {
975 lbs_pr_err("command response incorrect!\n"); 952 lbs_pr_err("command response incorrect!\n");
976 free_page(addr); 953 free_page(addr);
977 kfree(response_buf); 954 kfree(response_buf);
@@ -979,16 +956,16 @@ static ssize_t libertas_bcnmiss_read(struct file *file, char __user *userbuf,
979 } 956 }
980 957
981 cmd_len = S_DS_GEN + sizeof(struct cmd_ds_802_11_subscribe_event); 958 cmd_len = S_DS_GEN + sizeof(struct cmd_ds_802_11_subscribe_event);
982 event = (struct cmd_ds_802_11_subscribe_event *)(response_buf + S_DS_GEN); 959 event = (void *)(response_buf + S_DS_GEN);
983 while (cmd_len < pcmdptr->size) { 960 while (cmd_len < le16_to_cpu(pcmdptr->size)) {
984 struct mrvlietypesheader *header = (struct mrvlietypesheader *)(response_buf + cmd_len); 961 struct mrvlietypesheader *header = (void *)(response_buf + cmd_len);
985 switch(header->type) { 962 switch (header->type) {
986 struct mrvlietypes_beaconsmissed *bcnmiss; 963 struct mrvlietypes_beaconsmissed *bcnmiss;
987 case TLV_TYPE_BCNMISS: 964 case __constant_cpu_to_le16(TLV_TYPE_BCNMISS):
988 bcnmiss = (struct mrvlietypes_beaconsmissed *)(response_buf + cmd_len); 965 bcnmiss = (void *)(response_buf + cmd_len);
989 pos += snprintf(buf+pos, len-pos, "%d N/A %d\n", 966 pos += snprintf(buf+pos, len-pos, "%d N/A %d\n",
990 bcnmiss->beaconmissed, 967 bcnmiss->beaconmissed,
991 (event->events & 0x0008)?1:0); 968 (event->events & cpu_to_le16(0x0008))?1:0);
992 default: 969 default:
993 cmd_len += sizeof(struct mrvlietypes_beaconsmissed); 970 cmd_len += sizeof(struct mrvlietypes_beaconsmissed);
994 break; 971 break;
@@ -1038,7 +1015,7 @@ static ssize_t libertas_bcnmiss_write(struct file *file,
1038 goto out_unlock; 1015 goto out_unlock;
1039 1016
1040 event = &pcmdptr->params.subscribe_event; 1017 event = &pcmdptr->params.subscribe_event;
1041 event->action = cmd_act_set; 1018 event->action = cpu_to_le16(cmd_act_set);
1042 pcmdptr->size = cpu_to_le16(S_DS_GEN + 1019 pcmdptr->size = cpu_to_le16(S_DS_GEN +
1043 sizeof(struct cmd_ds_802_11_subscribe_event) + 1020 sizeof(struct cmd_ds_802_11_subscribe_event) +
1044 sizeof(struct mrvlietypes_beaconsmissed)); 1021 sizeof(struct mrvlietypes_beaconsmissed));
@@ -1046,29 +1023,29 @@ static ssize_t libertas_bcnmiss_write(struct file *file,
1046 ptr = (u8*) pcmdptr+cmd_len; 1023 ptr = (u8*) pcmdptr+cmd_len;
1047 bcnmiss = (struct mrvlietypes_beaconsmissed *)(ptr); 1024 bcnmiss = (struct mrvlietypes_beaconsmissed *)(ptr);
1048 bcnmiss->header.type = cpu_to_le16(TLV_TYPE_BCNMISS); 1025 bcnmiss->header.type = cpu_to_le16(TLV_TYPE_BCNMISS);
1049 bcnmiss->header.len = 2; 1026 bcnmiss->header.len = cpu_to_le16(2);
1050 bcnmiss->beaconmissed = cpu_to_le16(value); 1027 bcnmiss->beaconmissed = value;
1051 event_bitmap |= subscribed ? 0x0008 : 0x0; 1028 event_bitmap |= subscribed ? 0x0008 : 0x0;
1052 event->events = event_bitmap; 1029 event->events = cpu_to_le16(event_bitmap);
1053 1030
1054 libertas_queue_cmd(adapter, pcmdnode, 1); 1031 libertas_queue_cmd(adapter, pcmdnode, 1);
1055 wake_up_interruptible(&priv->mainthread.waitq); 1032 wake_up_interruptible(&priv->mainthread.waitq);
1056 1033
1057 /* Sleep until response is generated by FW */ 1034 /* Sleep until response is generated by FW */
1058 wait_event_interruptible(pcmdnode->cmdwait_q, 1035 wait_event_interruptible(pcmdnode->cmdwait_q,
1059 pcmdnode->cmdwaitqwoken); 1036 pcmdnode->cmdwaitqwoken);
1060 1037
1061 pcmdptr = response_buf; 1038 pcmdptr = response_buf;
1062 1039
1063 if (pcmdptr->result) { 1040 if (pcmdptr->result) {
1064 lbs_pr_err("%s: fail, result=%d\n", __FUNCTION__, 1041 lbs_pr_err("%s: fail, result=%d\n", __func__,
1065 pcmdptr->result); 1042 le16_to_cpu(pcmdptr->result));
1066 kfree(response_buf); 1043 kfree(response_buf);
1067 free_page(addr); 1044 free_page(addr);
1068 return 0; 1045 return 0;
1069 } 1046 }
1070 1047
1071 if (pcmdptr->command != cmd_ret_802_11_subscribe_event) { 1048 if (pcmdptr->command != cpu_to_le16(cmd_ret_802_11_subscribe_event)) {
1072 lbs_pr_err("command response incorrect!\n"); 1049 lbs_pr_err("command response incorrect!\n");
1073 free_page(addr); 1050 free_page(addr);
1074 kfree(response_buf); 1051 kfree(response_buf);
@@ -1102,27 +1079,26 @@ static ssize_t libertas_highrssi_read(struct file *file, char __user *userbuf,
1102 } 1079 }
1103 1080
1104 event = &pcmdptr->params.subscribe_event; 1081 event = &pcmdptr->params.subscribe_event;
1105 event->action = cmd_act_get; 1082 event->action = cpu_to_le16(cmd_act_get);
1106 pcmdptr->size = 1083 pcmdptr->size = cpu_to_le16(sizeof(*event) + S_DS_GEN);
1107 cpu_to_le16(sizeof(struct cmd_ds_802_11_subscribe_event) + S_DS_GEN);
1108 libertas_queue_cmd(adapter, pcmdnode, 1); 1084 libertas_queue_cmd(adapter, pcmdnode, 1);
1109 wake_up_interruptible(&priv->mainthread.waitq); 1085 wake_up_interruptible(&priv->mainthread.waitq);
1110 1086
1111 /* Sleep until response is generated by FW */ 1087 /* Sleep until response is generated by FW */
1112 wait_event_interruptible(pcmdnode->cmdwait_q, 1088 wait_event_interruptible(pcmdnode->cmdwait_q,
1113 pcmdnode->cmdwaitqwoken); 1089 pcmdnode->cmdwaitqwoken);
1114 1090
1115 pcmdptr = response_buf; 1091 pcmdptr = response_buf;
1116 1092
1117 if (pcmdptr->result) { 1093 if (pcmdptr->result) {
1118 lbs_pr_err("%s: fail, result=%d\n", __FUNCTION__, 1094 lbs_pr_err("%s: fail, result=%d\n", __func__,
1119 pcmdptr->result); 1095 le16_to_cpu(pcmdptr->result));
1120 kfree(response_buf); 1096 kfree(response_buf);
1121 free_page(addr); 1097 free_page(addr);
1122 return 0; 1098 return 0;
1123 } 1099 }
1124 1100
1125 if (pcmdptr->command != cmd_ret_802_11_subscribe_event) { 1101 if (pcmdptr->command != cpu_to_le16(cmd_ret_802_11_subscribe_event)) {
1126 lbs_pr_err("command response incorrect!\n"); 1102 lbs_pr_err("command response incorrect!\n");
1127 kfree(response_buf); 1103 kfree(response_buf);
1128 free_page(addr); 1104 free_page(addr);
@@ -1130,17 +1106,17 @@ static ssize_t libertas_highrssi_read(struct file *file, char __user *userbuf,
1130 } 1106 }
1131 1107
1132 cmd_len = S_DS_GEN + sizeof(struct cmd_ds_802_11_subscribe_event); 1108 cmd_len = S_DS_GEN + sizeof(struct cmd_ds_802_11_subscribe_event);
1133 event = (struct cmd_ds_802_11_subscribe_event *)(response_buf + S_DS_GEN); 1109 event = (void *)(response_buf + S_DS_GEN);
1134 while (cmd_len < pcmdptr->size) { 1110 while (cmd_len < le16_to_cpu(pcmdptr->size)) {
1135 struct mrvlietypesheader *header = (struct mrvlietypesheader *)(response_buf + cmd_len); 1111 struct mrvlietypesheader *header = (void *)(response_buf + cmd_len);
1136 switch(header->type) { 1112 switch (header->type) {
1137 struct mrvlietypes_rssithreshold *Highrssi; 1113 struct mrvlietypes_rssithreshold *Highrssi;
1138 case TLV_TYPE_RSSI_HIGH: 1114 case __constant_cpu_to_le16(TLV_TYPE_RSSI_HIGH):
1139 Highrssi = (struct mrvlietypes_rssithreshold *)(response_buf + cmd_len); 1115 Highrssi = (void *)(response_buf + cmd_len);
1140 pos += snprintf(buf+pos, len-pos, "%d %d %d\n", 1116 pos += snprintf(buf+pos, len-pos, "%d %d %d\n",
1141 Highrssi->rssivalue, 1117 Highrssi->rssivalue,
1142 Highrssi->rssifreq, 1118 Highrssi->rssifreq,
1143 (event->events & 0x0010)?1:0); 1119 (event->events & cpu_to_le16(0x0010))?1:0);
1144 default: 1120 default:
1145 cmd_len += sizeof(struct mrvlietypes_snrthreshold); 1121 cmd_len += sizeof(struct mrvlietypes_snrthreshold);
1146 break; 1122 break;
@@ -1190,7 +1166,7 @@ static ssize_t libertas_highrssi_write(struct file *file,
1190 goto out_unlock; 1166 goto out_unlock;
1191 1167
1192 event = &pcmdptr->params.subscribe_event; 1168 event = &pcmdptr->params.subscribe_event;
1193 event->action = cmd_act_set; 1169 event->action = cpu_to_le16(cmd_act_set);
1194 pcmdptr->size = cpu_to_le16(S_DS_GEN + 1170 pcmdptr->size = cpu_to_le16(S_DS_GEN +
1195 sizeof(struct cmd_ds_802_11_subscribe_event) + 1171 sizeof(struct cmd_ds_802_11_subscribe_event) +
1196 sizeof(struct mrvlietypes_rssithreshold)); 1172 sizeof(struct mrvlietypes_rssithreshold));
@@ -1198,29 +1174,29 @@ static ssize_t libertas_highrssi_write(struct file *file,
1198 ptr = (u8*) pcmdptr+cmd_len; 1174 ptr = (u8*) pcmdptr+cmd_len;
1199 rssi_threshold = (struct mrvlietypes_rssithreshold *)(ptr); 1175 rssi_threshold = (struct mrvlietypes_rssithreshold *)(ptr);
1200 rssi_threshold->header.type = cpu_to_le16(TLV_TYPE_RSSI_HIGH); 1176 rssi_threshold->header.type = cpu_to_le16(TLV_TYPE_RSSI_HIGH);
1201 rssi_threshold->header.len = 2; 1177 rssi_threshold->header.len = cpu_to_le16(2);
1202 rssi_threshold->rssivalue = cpu_to_le16(value); 1178 rssi_threshold->rssivalue = value;
1203 rssi_threshold->rssifreq = cpu_to_le16(freq); 1179 rssi_threshold->rssifreq = freq;
1204 event_bitmap |= subscribed ? 0x0010 : 0x0; 1180 event_bitmap |= subscribed ? 0x0010 : 0x0;
1205 event->events = event_bitmap; 1181 event->events = cpu_to_le16(event_bitmap);
1206 1182
1207 libertas_queue_cmd(adapter, pcmdnode, 1); 1183 libertas_queue_cmd(adapter, pcmdnode, 1);
1208 wake_up_interruptible(&priv->mainthread.waitq); 1184 wake_up_interruptible(&priv->mainthread.waitq);
1209 1185
1210 /* Sleep until response is generated by FW */ 1186 /* Sleep until response is generated by FW */
1211 wait_event_interruptible(pcmdnode->cmdwait_q, 1187 wait_event_interruptible(pcmdnode->cmdwait_q,
1212 pcmdnode->cmdwaitqwoken); 1188 pcmdnode->cmdwaitqwoken);
1213 1189
1214 pcmdptr = response_buf; 1190 pcmdptr = response_buf;
1215 1191
1216 if (pcmdptr->result) { 1192 if (pcmdptr->result) {
1217 lbs_pr_err("%s: fail, result=%d\n", __FUNCTION__, 1193 lbs_pr_err("%s: fail, result=%d\n", __func__,
1218 pcmdptr->result); 1194 le16_to_cpu(pcmdptr->result));
1219 kfree(response_buf); 1195 kfree(response_buf);
1220 return 0; 1196 return 0;
1221 } 1197 }
1222 1198
1223 if (pcmdptr->command != cmd_ret_802_11_subscribe_event) { 1199 if (pcmdptr->command != cpu_to_le16(cmd_ret_802_11_subscribe_event)) {
1224 lbs_pr_err("command response incorrect!\n"); 1200 lbs_pr_err("command response incorrect!\n");
1225 kfree(response_buf); 1201 kfree(response_buf);
1226 return 0; 1202 return 0;
@@ -1253,27 +1229,26 @@ static ssize_t libertas_highsnr_read(struct file *file, char __user *userbuf,
1253 } 1229 }
1254 1230
1255 event = &pcmdptr->params.subscribe_event; 1231 event = &pcmdptr->params.subscribe_event;
1256 event->action = cmd_act_get; 1232 event->action = cpu_to_le16(cmd_act_get);
1257 pcmdptr->size = 1233 pcmdptr->size = cpu_to_le16(sizeof(*event) + S_DS_GEN);
1258 cpu_to_le16(sizeof(struct cmd_ds_802_11_subscribe_event) + S_DS_GEN);
1259 libertas_queue_cmd(adapter, pcmdnode, 1); 1234 libertas_queue_cmd(adapter, pcmdnode, 1);
1260 wake_up_interruptible(&priv->mainthread.waitq); 1235 wake_up_interruptible(&priv->mainthread.waitq);
1261 1236
1262 /* Sleep until response is generated by FW */ 1237 /* Sleep until response is generated by FW */
1263 wait_event_interruptible(pcmdnode->cmdwait_q, 1238 wait_event_interruptible(pcmdnode->cmdwait_q,
1264 pcmdnode->cmdwaitqwoken); 1239 pcmdnode->cmdwaitqwoken);
1265 1240
1266 pcmdptr = response_buf; 1241 pcmdptr = response_buf;
1267 1242
1268 if (pcmdptr->result) { 1243 if (pcmdptr->result) {
1269 lbs_pr_err("%s: fail, result=%d\n", __FUNCTION__, 1244 lbs_pr_err("%s: fail, result=%d\n", __func__,
1270 pcmdptr->result); 1245 le16_to_cpu(pcmdptr->result));
1271 kfree(response_buf); 1246 kfree(response_buf);
1272 free_page(addr); 1247 free_page(addr);
1273 return 0; 1248 return 0;
1274 } 1249 }
1275 1250
1276 if (pcmdptr->command != cmd_ret_802_11_subscribe_event) { 1251 if (pcmdptr->command != cpu_to_le16(cmd_ret_802_11_subscribe_event)) {
1277 lbs_pr_err("command response incorrect!\n"); 1252 lbs_pr_err("command response incorrect!\n");
1278 kfree(response_buf); 1253 kfree(response_buf);
1279 free_page(addr); 1254 free_page(addr);
@@ -1281,17 +1256,17 @@ static ssize_t libertas_highsnr_read(struct file *file, char __user *userbuf,
1281 } 1256 }
1282 1257
1283 cmd_len = S_DS_GEN + sizeof(struct cmd_ds_802_11_subscribe_event); 1258 cmd_len = S_DS_GEN + sizeof(struct cmd_ds_802_11_subscribe_event);
1284 event = (struct cmd_ds_802_11_subscribe_event *)(response_buf + S_DS_GEN); 1259 event = (void *)(response_buf + S_DS_GEN);
1285 while (cmd_len < pcmdptr->size) { 1260 while (cmd_len < le16_to_cpu(pcmdptr->size)) {
1286 struct mrvlietypesheader *header = (struct mrvlietypesheader *)(response_buf + cmd_len); 1261 struct mrvlietypesheader *header = (void *)(response_buf + cmd_len);
1287 switch(header->type) { 1262 switch (header->type) {
1288 struct mrvlietypes_snrthreshold *HighSnr; 1263 struct mrvlietypes_snrthreshold *HighSnr;
1289 case TLV_TYPE_SNR_HIGH: 1264 case __constant_cpu_to_le16(TLV_TYPE_SNR_HIGH):
1290 HighSnr = (struct mrvlietypes_snrthreshold *)(response_buf + cmd_len); 1265 HighSnr = (void *)(response_buf + cmd_len);
1291 pos += snprintf(buf+pos, len-pos, "%d %d %d\n", 1266 pos += snprintf(buf+pos, len-pos, "%d %d %d\n",
1292 HighSnr->snrvalue, 1267 HighSnr->snrvalue,
1293 HighSnr->snrfreq, 1268 HighSnr->snrfreq,
1294 (event->events & 0x0020)?1:0); 1269 (event->events & cpu_to_le16(0x0020))?1:0);
1295 default: 1270 default:
1296 cmd_len += sizeof(struct mrvlietypes_snrthreshold); 1271 cmd_len += sizeof(struct mrvlietypes_snrthreshold);
1297 break; 1272 break;
@@ -1341,7 +1316,7 @@ static ssize_t libertas_highsnr_write(struct file *file,
1341 goto out_unlock; 1316 goto out_unlock;
1342 1317
1343 event = &pcmdptr->params.subscribe_event; 1318 event = &pcmdptr->params.subscribe_event;
1344 event->action = cmd_act_set; 1319 event->action = cpu_to_le16(cmd_act_set);
1345 pcmdptr->size = cpu_to_le16(S_DS_GEN + 1320 pcmdptr->size = cpu_to_le16(S_DS_GEN +
1346 sizeof(struct cmd_ds_802_11_subscribe_event) + 1321 sizeof(struct cmd_ds_802_11_subscribe_event) +
1347 sizeof(struct mrvlietypes_snrthreshold)); 1322 sizeof(struct mrvlietypes_snrthreshold));
@@ -1349,30 +1324,30 @@ static ssize_t libertas_highsnr_write(struct file *file,
1349 ptr = (u8*) pcmdptr+cmd_len; 1324 ptr = (u8*) pcmdptr+cmd_len;
1350 snr_threshold = (struct mrvlietypes_snrthreshold *)(ptr); 1325 snr_threshold = (struct mrvlietypes_snrthreshold *)(ptr);
1351 snr_threshold->header.type = cpu_to_le16(TLV_TYPE_SNR_HIGH); 1326 snr_threshold->header.type = cpu_to_le16(TLV_TYPE_SNR_HIGH);
1352 snr_threshold->header.len = 2; 1327 snr_threshold->header.len = cpu_to_le16(2);
1353 snr_threshold->snrvalue = cpu_to_le16(value); 1328 snr_threshold->snrvalue = value;
1354 snr_threshold->snrfreq = cpu_to_le16(freq); 1329 snr_threshold->snrfreq = freq;
1355 event_bitmap |= subscribed ? 0x0020 : 0x0; 1330 event_bitmap |= subscribed ? 0x0020 : 0x0;
1356 event->events = event_bitmap; 1331 event->events = cpu_to_le16(event_bitmap);
1357 1332
1358 libertas_queue_cmd(adapter, pcmdnode, 1); 1333 libertas_queue_cmd(adapter, pcmdnode, 1);
1359 wake_up_interruptible(&priv->mainthread.waitq); 1334 wake_up_interruptible(&priv->mainthread.waitq);
1360 1335
1361 /* Sleep until response is generated by FW */ 1336 /* Sleep until response is generated by FW */
1362 wait_event_interruptible(pcmdnode->cmdwait_q, 1337 wait_event_interruptible(pcmdnode->cmdwait_q,
1363 pcmdnode->cmdwaitqwoken); 1338 pcmdnode->cmdwaitqwoken);
1364 1339
1365 pcmdptr = response_buf; 1340 pcmdptr = response_buf;
1366 1341
1367 if (pcmdptr->result) { 1342 if (pcmdptr->result) {
1368 lbs_pr_err("%s: fail, result=%d\n", __FUNCTION__, 1343 lbs_pr_err("%s: fail, result=%d\n", __func__,
1369 pcmdptr->result); 1344 le16_to_cpu(pcmdptr->result));
1370 kfree(response_buf); 1345 kfree(response_buf);
1371 free_page(addr); 1346 free_page(addr);
1372 return 0; 1347 return 0;
1373 } 1348 }
1374 1349
1375 if (pcmdptr->command != cmd_ret_802_11_subscribe_event) { 1350 if (pcmdptr->command != cpu_to_le16(cmd_ret_802_11_subscribe_event)) {
1376 lbs_pr_err("command response incorrect!\n"); 1351 lbs_pr_err("command response incorrect!\n");
1377 kfree(response_buf); 1352 kfree(response_buf);
1378 free_page(addr); 1353 free_page(addr);
@@ -1760,7 +1735,7 @@ void libertas_debugfs_remove_one(wlan_private *priv)
1760 1735
1761 debugfs_remove(priv->regs_dir); 1736 debugfs_remove(priv->regs_dir);
1762 1737
1763 for(i=0; i<ARRAY_SIZE(debugfs_files); i++) 1738 for(i=0; i<ARRAY_SIZE(debugfs_events_files); i++)
1764 debugfs_remove(priv->debugfs_events_files[i]); 1739 debugfs_remove(priv->debugfs_events_files[i]);
1765 1740
1766 debugfs_remove(priv->events_dir); 1741 debugfs_remove(priv->events_dir);
@@ -1769,13 +1744,19 @@ void libertas_debugfs_remove_one(wlan_private *priv)
1769#endif 1744#endif
1770 for(i=0; i<ARRAY_SIZE(debugfs_files); i++) 1745 for(i=0; i<ARRAY_SIZE(debugfs_files); i++)
1771 debugfs_remove(priv->debugfs_files[i]); 1746 debugfs_remove(priv->debugfs_files[i]);
1747 debugfs_remove(priv->debugfs_dir);
1772} 1748}
1773 1749
1750
1751
1774/* debug entry */ 1752/* debug entry */
1775 1753
1754#ifdef PROC_DEBUG
1755
1776#define item_size(n) (FIELD_SIZEOF(wlan_adapter, n)) 1756#define item_size(n) (FIELD_SIZEOF(wlan_adapter, n))
1777#define item_addr(n) (offsetof(wlan_adapter, n)) 1757#define item_addr(n) (offsetof(wlan_adapter, n))
1778 1758
1759
1779struct debug_data { 1760struct debug_data {
1780 char name[32]; 1761 char name[32];
1781 u32 size; 1762 u32 size;
@@ -1863,7 +1844,7 @@ static ssize_t wlan_debugfs_write(struct file *f, const char __user *buf,
1863 return 0; 1844 return 0;
1864 1845
1865 if (copy_from_user(pdata, buf, cnt)) { 1846 if (copy_from_user(pdata, buf, cnt)) {
1866 lbs_pr_debug(1, "Copy from user failed\n"); 1847 lbs_deb_debugfs("Copy from user failed\n");
1867 kfree(pdata); 1848 kfree(pdata);
1868 return 0; 1849 return 0;
1869 } 1850 }
@@ -1913,7 +1894,7 @@ static struct file_operations libertas_debug_fops = {
1913 * @param dev pointer net_device 1894 * @param dev pointer net_device
1914 * @return N/A 1895 * @return N/A
1915 */ 1896 */
1916void libertas_debug_init(wlan_private * priv, struct net_device *dev) 1897static void libertas_debug_init(wlan_private * priv, struct net_device *dev)
1917{ 1898{
1918 int i; 1899 int i;
1919 1900
@@ -1927,4 +1908,5 @@ void libertas_debug_init(wlan_private * priv, struct net_device *dev)
1927 priv->debugfs_dir, &items[0], 1908 priv->debugfs_dir, &items[0],
1928 &libertas_debug_fops); 1909 &libertas_debug_fops);
1929} 1910}
1911#endif
1930 1912