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>
This commit is contained in:
parent
8127fbdc41
commit
44ac91ea84
|
@ -80,6 +80,11 @@ struct minstrel_priv {
|
||||||
unsigned int lookaround_rate_mrr;
|
unsigned int lookaround_rate_mrr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct minstrel_debugfs_info {
|
||||||
|
size_t len;
|
||||||
|
char buf[];
|
||||||
|
};
|
||||||
|
|
||||||
void minstrel_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir);
|
void minstrel_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir);
|
||||||
void minstrel_remove_sta_debugfs(void *priv, void *priv_sta);
|
void minstrel_remove_sta_debugfs(void *priv, void *priv_sta);
|
||||||
|
|
||||||
|
|
|
@ -52,21 +52,15 @@
|
||||||
#include <net/mac80211.h>
|
#include <net/mac80211.h>
|
||||||
#include "rc80211_minstrel.h"
|
#include "rc80211_minstrel.h"
|
||||||
|
|
||||||
struct minstrel_stats_info {
|
|
||||||
struct minstrel_sta_info *mi;
|
|
||||||
char buf[4096];
|
|
||||||
size_t len;
|
|
||||||
};
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
minstrel_stats_open(struct inode *inode, struct file *file)
|
minstrel_stats_open(struct inode *inode, struct file *file)
|
||||||
{
|
{
|
||||||
struct minstrel_sta_info *mi = inode->i_private;
|
struct minstrel_sta_info *mi = inode->i_private;
|
||||||
struct minstrel_stats_info *ms;
|
struct minstrel_debugfs_info *ms;
|
||||||
unsigned int i, tp, prob, eprob;
|
unsigned int i, tp, prob, eprob;
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
ms = kmalloc(sizeof(*ms), GFP_KERNEL);
|
ms = kmalloc(sizeof(*ms) + 4096, GFP_KERNEL);
|
||||||
if (!ms)
|
if (!ms)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
@ -107,35 +101,18 @@ minstrel_stats_open(struct inode *inode, struct file *file)
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t
|
static ssize_t
|
||||||
minstrel_stats_read(struct file *file, char __user *buf, size_t len, loff_t *o)
|
minstrel_stats_read(struct file *file, char __user *buf, size_t len, loff_t *ppos)
|
||||||
{
|
{
|
||||||
struct minstrel_stats_info *ms;
|
struct minstrel_debugfs_info *ms;
|
||||||
char *src;
|
|
||||||
|
|
||||||
ms = file->private_data;
|
ms = file->private_data;
|
||||||
src = ms->buf;
|
return simple_read_from_buffer(buf, len, ppos, ms->buf, ms->len);
|
||||||
|
|
||||||
len = min(len, ms->len);
|
|
||||||
if (len <= *o)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
src += *o;
|
|
||||||
len -= *o;
|
|
||||||
*o += len;
|
|
||||||
|
|
||||||
if (copy_to_user(buf, src, len))
|
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
return len;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
minstrel_stats_release(struct inode *inode, struct file *file)
|
minstrel_stats_release(struct inode *inode, struct file *file)
|
||||||
{
|
{
|
||||||
struct minstrel_stats_info *ms = file->private_data;
|
kfree(file->private_data);
|
||||||
|
|
||||||
kfree(ms);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue