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.c191
1 files changed, 87 insertions, 104 deletions
diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c
index de2caac11dd6..651a79c8de8a 100644
--- a/drivers/net/wireless/libertas/debugfs.c
+++ b/drivers/net/wireless/libertas/debugfs.c
@@ -1,18 +1,13 @@
1#include <linux/module.h>
2#include <linux/dcache.h> 1#include <linux/dcache.h>
3#include <linux/debugfs.h> 2#include <linux/debugfs.h>
4#include <linux/delay.h> 3#include <linux/delay.h>
5#include <linux/mm.h> 4#include <linux/mm.h>
6#include <linux/string.h> 5#include <linux/string.h>
7#include <linux/slab.h> 6#include <linux/slab.h>
8#include <net/iw_handler.h>
9#include <net/lib80211.h>
10 7
11#include "dev.h"
12#include "decl.h" 8#include "decl.h"
13#include "host.h"
14#include "debugfs.h"
15#include "cmd.h" 9#include "cmd.h"
10#include "debugfs.h"
16 11
17static struct dentry *lbs_dir; 12static struct dentry *lbs_dir;
18static char *szStates[] = { 13static char *szStates[] = {
@@ -60,51 +55,6 @@ static ssize_t lbs_dev_info(struct file *file, char __user *userbuf,
60 return res; 55 return res;
61} 56}
62 57
63
64static ssize_t lbs_getscantable(struct file *file, char __user *userbuf,
65 size_t count, loff_t *ppos)
66{
67 struct lbs_private *priv = file->private_data;
68 size_t pos = 0;
69 int numscansdone = 0, res;
70 unsigned long addr = get_zeroed_page(GFP_KERNEL);
71 char *buf = (char *)addr;
72 DECLARE_SSID_BUF(ssid);
73 struct bss_descriptor * iter_bss;
74 if (!buf)
75 return -ENOMEM;
76
77 pos += snprintf(buf+pos, len-pos,
78 "# | ch | rssi | bssid | cap | Qual | SSID\n");
79
80 mutex_lock(&priv->lock);
81 list_for_each_entry (iter_bss, &priv->network_list, list) {
82 u16 ibss = (iter_bss->capability & WLAN_CAPABILITY_IBSS);
83 u16 privacy = (iter_bss->capability & WLAN_CAPABILITY_PRIVACY);
84 u16 spectrum_mgmt = (iter_bss->capability & WLAN_CAPABILITY_SPECTRUM_MGMT);
85
86 pos += snprintf(buf+pos, len-pos, "%02u| %03d | %04d | %pM |",
87 numscansdone, iter_bss->channel, iter_bss->rssi,
88 iter_bss->bssid);
89 pos += snprintf(buf+pos, len-pos, " %04x-", iter_bss->capability);
90 pos += snprintf(buf+pos, len-pos, "%c%c%c |",
91 ibss ? 'A' : 'I', privacy ? 'P' : ' ',
92 spectrum_mgmt ? 'S' : ' ');
93 pos += snprintf(buf+pos, len-pos, " %04d |", SCAN_RSSI(iter_bss->rssi));
94 pos += snprintf(buf+pos, len-pos, " %s\n",
95 print_ssid(ssid, iter_bss->ssid,
96 iter_bss->ssid_len));
97
98 numscansdone++;
99 }
100 mutex_unlock(&priv->lock);
101
102 res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
103
104 free_page(addr);
105 return res;
106}
107
108static ssize_t lbs_sleepparams_write(struct file *file, 58static ssize_t lbs_sleepparams_write(struct file *file,
109 const char __user *user_buf, size_t count, 59 const char __user *user_buf, size_t count,
110 loff_t *ppos) 60 loff_t *ppos)
@@ -174,6 +124,70 @@ out_unlock:
174 return ret; 124 return ret;
175} 125}
176 126
127static ssize_t lbs_host_sleep_write(struct file *file,
128 const char __user *user_buf, size_t count,
129 loff_t *ppos)
130{
131 struct lbs_private *priv = file->private_data;
132 ssize_t buf_size, ret;
133 int host_sleep;
134 unsigned long addr = get_zeroed_page(GFP_KERNEL);
135 char *buf = (char *)addr;
136 if (!buf)
137 return -ENOMEM;
138
139 buf_size = min(count, len - 1);
140 if (copy_from_user(buf, user_buf, buf_size)) {
141 ret = -EFAULT;
142 goto out_unlock;
143 }
144 ret = sscanf(buf, "%d", &host_sleep);
145 if (ret != 1) {
146 ret = -EINVAL;
147 goto out_unlock;
148 }
149
150 if (host_sleep == 0)
151 ret = lbs_set_host_sleep(priv, 0);
152 else if (host_sleep == 1) {
153 if (priv->wol_criteria == EHS_REMOVE_WAKEUP) {
154 lbs_pr_info("wake parameters not configured");
155 ret = -EINVAL;
156 goto out_unlock;
157 }
158 ret = lbs_set_host_sleep(priv, 1);
159 } else {
160 lbs_pr_err("invalid option\n");
161 ret = -EINVAL;
162 }
163
164 if (!ret)
165 ret = count;
166
167out_unlock:
168 free_page(addr);
169 return ret;
170}
171
172static ssize_t lbs_host_sleep_read(struct file *file, char __user *userbuf,
173 size_t count, loff_t *ppos)
174{
175 struct lbs_private *priv = file->private_data;
176 ssize_t ret;
177 size_t pos = 0;
178 unsigned long addr = get_zeroed_page(GFP_KERNEL);
179 char *buf = (char *)addr;
180 if (!buf)
181 return -ENOMEM;
182
183 pos += snprintf(buf, len, "%d\n", priv->is_host_sleep_activated);
184
185 ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
186
187 free_page(addr);
188 return ret;
189}
190
177/* 191/*
178 * When calling CMD_802_11_SUBSCRIBE_EVENT with CMD_ACT_GET, me might 192 * When calling CMD_802_11_SUBSCRIBE_EVENT with CMD_ACT_GET, me might
179 * get a bunch of vendor-specific TLVs (a.k.a. IEs) back from the 193 * get a bunch of vendor-specific TLVs (a.k.a. IEs) back from the
@@ -432,30 +446,24 @@ static ssize_t lbs_bcnmiss_write(struct file *file, const char __user *userbuf,
432} 446}
433 447
434 448
435
436static ssize_t lbs_rdmac_read(struct file *file, char __user *userbuf, 449static ssize_t lbs_rdmac_read(struct file *file, char __user *userbuf,
437 size_t count, loff_t *ppos) 450 size_t count, loff_t *ppos)
438{ 451{
439 struct lbs_private *priv = file->private_data; 452 struct lbs_private *priv = file->private_data;
440 struct lbs_offset_value offval;
441 ssize_t pos = 0; 453 ssize_t pos = 0;
442 int ret; 454 int ret;
443 unsigned long addr = get_zeroed_page(GFP_KERNEL); 455 unsigned long addr = get_zeroed_page(GFP_KERNEL);
444 char *buf = (char *)addr; 456 char *buf = (char *)addr;
457 u32 val = 0;
458
445 if (!buf) 459 if (!buf)
446 return -ENOMEM; 460 return -ENOMEM;
447 461
448 offval.offset = priv->mac_offset; 462 ret = lbs_get_reg(priv, CMD_MAC_REG_ACCESS, priv->mac_offset, &val);
449 offval.value = 0;
450
451 ret = lbs_prepare_and_send_command(priv,
452 CMD_MAC_REG_ACCESS, 0,
453 CMD_OPTION_WAITFORRSP, 0, &offval);
454 mdelay(10); 463 mdelay(10);
455 if (!ret) { 464 if (!ret) {
456 pos += snprintf(buf+pos, len-pos, "MAC[0x%x] = 0x%08x\n", 465 pos = snprintf(buf, len, "MAC[0x%x] = 0x%08x\n",
457 priv->mac_offset, priv->offsetvalue.value); 466 priv->mac_offset, val);
458
459 ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos); 467 ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
460 } 468 }
461 free_page(addr); 469 free_page(addr);
@@ -493,7 +501,6 @@ static ssize_t lbs_wrmac_write(struct file *file,
493 struct lbs_private *priv = file->private_data; 501 struct lbs_private *priv = file->private_data;
494 ssize_t res, buf_size; 502 ssize_t res, buf_size;
495 u32 offset, value; 503 u32 offset, value;
496 struct lbs_offset_value offval;
497 unsigned long addr = get_zeroed_page(GFP_KERNEL); 504 unsigned long addr = get_zeroed_page(GFP_KERNEL);
498 char *buf = (char *)addr; 505 char *buf = (char *)addr;
499 if (!buf) 506 if (!buf)
@@ -510,11 +517,7 @@ static ssize_t lbs_wrmac_write(struct file *file,
510 goto out_unlock; 517 goto out_unlock;
511 } 518 }
512 519
513 offval.offset = offset; 520 res = lbs_set_reg(priv, CMD_MAC_REG_ACCESS, offset, value);
514 offval.value = value;
515 res = lbs_prepare_and_send_command(priv,
516 CMD_MAC_REG_ACCESS, 1,
517 CMD_OPTION_WAITFORRSP, 0, &offval);
518 mdelay(10); 521 mdelay(10);
519 522
520 if (!res) 523 if (!res)
@@ -528,25 +531,20 @@ static ssize_t lbs_rdbbp_read(struct file *file, char __user *userbuf,
528 size_t count, loff_t *ppos) 531 size_t count, loff_t *ppos)
529{ 532{
530 struct lbs_private *priv = file->private_data; 533 struct lbs_private *priv = file->private_data;
531 struct lbs_offset_value offval;
532 ssize_t pos = 0; 534 ssize_t pos = 0;
533 int ret; 535 int ret;
534 unsigned long addr = get_zeroed_page(GFP_KERNEL); 536 unsigned long addr = get_zeroed_page(GFP_KERNEL);
535 char *buf = (char *)addr; 537 char *buf = (char *)addr;
538 u32 val;
539
536 if (!buf) 540 if (!buf)
537 return -ENOMEM; 541 return -ENOMEM;
538 542
539 offval.offset = priv->bbp_offset; 543 ret = lbs_get_reg(priv, CMD_BBP_REG_ACCESS, priv->bbp_offset, &val);
540 offval.value = 0;
541
542 ret = lbs_prepare_and_send_command(priv,
543 CMD_BBP_REG_ACCESS, 0,
544 CMD_OPTION_WAITFORRSP, 0, &offval);
545 mdelay(10); 544 mdelay(10);
546 if (!ret) { 545 if (!ret) {
547 pos += snprintf(buf+pos, len-pos, "BBP[0x%x] = 0x%08x\n", 546 pos = snprintf(buf, len, "BBP[0x%x] = 0x%08x\n",
548 priv->bbp_offset, priv->offsetvalue.value); 547 priv->bbp_offset, val);
549
550 ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos); 548 ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
551 } 549 }
552 free_page(addr); 550 free_page(addr);
@@ -585,7 +583,6 @@ static ssize_t lbs_wrbbp_write(struct file *file,
585 struct lbs_private *priv = file->private_data; 583 struct lbs_private *priv = file->private_data;
586 ssize_t res, buf_size; 584 ssize_t res, buf_size;
587 u32 offset, value; 585 u32 offset, value;
588 struct lbs_offset_value offval;
589 unsigned long addr = get_zeroed_page(GFP_KERNEL); 586 unsigned long addr = get_zeroed_page(GFP_KERNEL);
590 char *buf = (char *)addr; 587 char *buf = (char *)addr;
591 if (!buf) 588 if (!buf)
@@ -602,11 +599,7 @@ static ssize_t lbs_wrbbp_write(struct file *file,
602 goto out_unlock; 599 goto out_unlock;
603 } 600 }
604 601
605 offval.offset = offset; 602 res = lbs_set_reg(priv, CMD_BBP_REG_ACCESS, offset, value);
606 offval.value = value;
607 res = lbs_prepare_and_send_command(priv,
608 CMD_BBP_REG_ACCESS, 1,
609 CMD_OPTION_WAITFORRSP, 0, &offval);
610 mdelay(10); 603 mdelay(10);
611 604
612 if (!res) 605 if (!res)
@@ -620,25 +613,20 @@ static ssize_t lbs_rdrf_read(struct file *file, char __user *userbuf,
620 size_t count, loff_t *ppos) 613 size_t count, loff_t *ppos)
621{ 614{
622 struct lbs_private *priv = file->private_data; 615 struct lbs_private *priv = file->private_data;
623 struct lbs_offset_value offval;
624 ssize_t pos = 0; 616 ssize_t pos = 0;
625 int ret; 617 int ret;
626 unsigned long addr = get_zeroed_page(GFP_KERNEL); 618 unsigned long addr = get_zeroed_page(GFP_KERNEL);
627 char *buf = (char *)addr; 619 char *buf = (char *)addr;
620 u32 val;
621
628 if (!buf) 622 if (!buf)
629 return -ENOMEM; 623 return -ENOMEM;
630 624
631 offval.offset = priv->rf_offset; 625 ret = lbs_get_reg(priv, CMD_RF_REG_ACCESS, priv->rf_offset, &val);
632 offval.value = 0;
633
634 ret = lbs_prepare_and_send_command(priv,
635 CMD_RF_REG_ACCESS, 0,
636 CMD_OPTION_WAITFORRSP, 0, &offval);
637 mdelay(10); 626 mdelay(10);
638 if (!ret) { 627 if (!ret) {
639 pos += snprintf(buf+pos, len-pos, "RF[0x%x] = 0x%08x\n", 628 pos = snprintf(buf, len, "RF[0x%x] = 0x%08x\n",
640 priv->rf_offset, priv->offsetvalue.value); 629 priv->rf_offset, val);
641
642 ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos); 630 ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
643 } 631 }
644 free_page(addr); 632 free_page(addr);
@@ -677,7 +665,6 @@ static ssize_t lbs_wrrf_write(struct file *file,
677 struct lbs_private *priv = file->private_data; 665 struct lbs_private *priv = file->private_data;
678 ssize_t res, buf_size; 666 ssize_t res, buf_size;
679 u32 offset, value; 667 u32 offset, value;
680 struct lbs_offset_value offval;
681 unsigned long addr = get_zeroed_page(GFP_KERNEL); 668 unsigned long addr = get_zeroed_page(GFP_KERNEL);
682 char *buf = (char *)addr; 669 char *buf = (char *)addr;
683 if (!buf) 670 if (!buf)
@@ -694,11 +681,7 @@ static ssize_t lbs_wrrf_write(struct file *file,
694 goto out_unlock; 681 goto out_unlock;
695 } 682 }
696 683
697 offval.offset = offset; 684 res = lbs_set_reg(priv, CMD_RF_REG_ACCESS, offset, value);
698 offval.value = value;
699 res = lbs_prepare_and_send_command(priv,
700 CMD_RF_REG_ACCESS, 1,
701 CMD_OPTION_WAITFORRSP, 0, &offval);
702 mdelay(10); 685 mdelay(10);
703 686
704 if (!res) 687 if (!res)
@@ -723,10 +706,10 @@ struct lbs_debugfs_files {
723 706
724static const struct lbs_debugfs_files debugfs_files[] = { 707static const struct lbs_debugfs_files debugfs_files[] = {
725 { "info", 0444, FOPS(lbs_dev_info, write_file_dummy), }, 708 { "info", 0444, FOPS(lbs_dev_info, write_file_dummy), },
726 { "getscantable", 0444, FOPS(lbs_getscantable,
727 write_file_dummy), },
728 { "sleepparams", 0644, FOPS(lbs_sleepparams_read, 709 { "sleepparams", 0644, FOPS(lbs_sleepparams_read,
729 lbs_sleepparams_write), }, 710 lbs_sleepparams_write), },
711 { "hostsleep", 0644, FOPS(lbs_host_sleep_read,
712 lbs_host_sleep_write), },
730}; 713};
731 714
732static const struct lbs_debugfs_files debugfs_events_files[] = { 715static const struct lbs_debugfs_files debugfs_events_files[] = {
@@ -891,7 +874,7 @@ static ssize_t lbs_debugfs_read(struct file *file, char __user *userbuf,
891 874
892 p = buf; 875 p = buf;
893 876
894 d = (struct debug_data *)file->private_data; 877 d = file->private_data;
895 878
896 for (i = 0; i < num_of_items; i++) { 879 for (i = 0; i < num_of_items; i++) {
897 if (d[i].size == 1) 880 if (d[i].size == 1)
@@ -930,7 +913,7 @@ static ssize_t lbs_debugfs_write(struct file *f, const char __user *buf,
930 char *p0; 913 char *p0;
931 char *p1; 914 char *p1;
932 char *p2; 915 char *p2;
933 struct debug_data *d = (struct debug_data *)f->private_data; 916 struct debug_data *d = f->private_data;
934 917
935 pdata = kmalloc(cnt, GFP_KERNEL); 918 pdata = kmalloc(cnt, GFP_KERNEL);
936 if (pdata == NULL) 919 if (pdata == NULL)