aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2010-03-01 16:17:38 -0500
committerJohn W. Linville <linville@tuxdriver.com>2010-03-10 17:44:17 -0500
commit44ac91ea8450b0e7a27b4a1fd64aefd35a144728 (patch)
tree9f47f06d46bb42c9a9e00a6dfde76e44eb8e9fb6 /net
parent8127fbdc417b5916b82e91400a4be1d9555feee7 (diff)
minstrel: simplify and fix debugfs code
This patch cleans up the debugfs read function for the statistics by using simple_read_from_buffer instead of its own semi-broken hack. Also removes a useless member of the minstrel debugfs info struct. Signed-off-by: Felix Fietkau <nbd@openwrt.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net')
-rw-r--r--net/mac80211/rc80211_minstrel.h5
-rw-r--r--net/mac80211/rc80211_minstrel_debugfs.c35
2 files changed, 11 insertions, 29 deletions
diff --git a/net/mac80211/rc80211_minstrel.h b/net/mac80211/rc80211_minstrel.h
index 38bf4168fc3a..9372656f3f5e 100644
--- a/net/mac80211/rc80211_minstrel.h
+++ b/net/mac80211/rc80211_minstrel.h
@@ -80,6 +80,11 @@ struct minstrel_priv {
80 unsigned int lookaround_rate_mrr; 80 unsigned int lookaround_rate_mrr;
81}; 81};
82 82
83struct minstrel_debugfs_info {
84 size_t len;
85 char buf[];
86};
87
83void minstrel_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir); 88void minstrel_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir);
84void minstrel_remove_sta_debugfs(void *priv, void *priv_sta); 89void minstrel_remove_sta_debugfs(void *priv, void *priv_sta);
85 90
diff --git a/net/mac80211/rc80211_minstrel_debugfs.c b/net/mac80211/rc80211_minstrel_debugfs.c
index a715d9454f64..3e83402ece17 100644
--- a/net/mac80211/rc80211_minstrel_debugfs.c
+++ b/net/mac80211/rc80211_minstrel_debugfs.c
@@ -52,21 +52,15 @@
52#include <net/mac80211.h> 52#include <net/mac80211.h>
53#include "rc80211_minstrel.h" 53#include "rc80211_minstrel.h"
54 54
55struct minstrel_stats_info {
56 struct minstrel_sta_info *mi;
57 char buf[4096];
58 size_t len;
59};
60
61static int 55static int
62minstrel_stats_open(struct inode *inode, struct file *file) 56minstrel_stats_open(struct inode *inode, struct file *file)
63{ 57{
64 struct minstrel_sta_info *mi = inode->i_private; 58 struct minstrel_sta_info *mi = inode->i_private;
65 struct minstrel_stats_info *ms; 59 struct minstrel_debugfs_info *ms;
66 unsigned int i, tp, prob, eprob; 60 unsigned int i, tp, prob, eprob;
67 char *p; 61 char *p;
68 62
69 ms = kmalloc(sizeof(*ms), GFP_KERNEL); 63 ms = kmalloc(sizeof(*ms) + 4096, GFP_KERNEL);
70 if (!ms) 64 if (!ms)
71 return -ENOMEM; 65 return -ENOMEM;
72 66
@@ -107,35 +101,18 @@ minstrel_stats_open(struct inode *inode, struct file *file)
107} 101}
108 102
109static ssize_t 103static ssize_t
110minstrel_stats_read(struct file *file, char __user *buf, size_t len, loff_t *o) 104minstrel_stats_read(struct file *file, char __user *buf, size_t len, loff_t *ppos)
111{ 105{
112 struct minstrel_stats_info *ms; 106 struct minstrel_debugfs_info *ms;
113 char *src;
114 107
115 ms = file->private_data; 108 ms = file->private_data;
116 src = ms->buf; 109 return simple_read_from_buffer(buf, len, ppos, ms->buf, ms->len);
117
118 len = min(len, ms->len);
119 if (len <= *o)
120 return 0;
121
122 src += *o;
123 len -= *o;
124 *o += len;
125
126 if (copy_to_user(buf, src, len))
127 return -EFAULT;
128
129 return len;
130} 110}
131 111
132static int 112static int
133minstrel_stats_release(struct inode *inode, struct file *file) 113minstrel_stats_release(struct inode *inode, struct file *file)
134{ 114{
135 struct minstrel_stats_info *ms = file->private_data; 115 kfree(file->private_data);
136
137 kfree(ms);
138
139 return 0; 116 return 0;
140} 117}
141 118