forked from Minki/linux
rtl8192u: Don't use create_proc_read_entry()
Don't use create_proc_read_entry() as that is deprecated, but rather use proc_create_data() and seq_file instead. Whilst we're at it, reduce the number of show functions where we can share them. Note: proc_get_stats_ap() should probably use seq_file iteration rather than list_for_each_entry(). Further note: There appears to be a lot of locking missing in this file to defend against concurrent access by the driver doing normal operations. Notably, ieee->network_list traversal and RWCAM/RCAMO command/response access. Further, do any of the registers read have side effects upon reading? Signed-off-by: David Howells <dhowells@redhat.com> cc: Jerry Chuang <jerry-chuang@realtek.com> cc: Mauro Carvalho Chehab <mchehab@redhat.com> cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> cc: linux-wireless@vger.kernel.org cc: devel@driverdev.osuosl.org Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
d0206fb555
commit
0541f9d08a
@ -71,6 +71,8 @@ double __extendsfdf2(float a) {return a;}
|
|||||||
//#include "r8192xU_phyreg.h"
|
//#include "r8192xU_phyreg.h"
|
||||||
#include <linux/usb.h>
|
#include <linux/usb.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
|
#include <linux/proc_fs.h>
|
||||||
|
#include <linux/seq_file.h>
|
||||||
// FIXME: check if 2.6.7 is ok
|
// FIXME: check if 2.6.7 is ok
|
||||||
|
|
||||||
#ifdef CONFIG_RTL8192_PM
|
#ifdef CONFIG_RTL8192_PM
|
||||||
@ -472,103 +474,73 @@ void watch_dog_timer_callback(unsigned long data);
|
|||||||
|
|
||||||
static struct proc_dir_entry *rtl8192_proc;
|
static struct proc_dir_entry *rtl8192_proc;
|
||||||
|
|
||||||
static int proc_get_stats_ap(char *page, char **start, off_t offset, int count,
|
static int proc_get_stats_ap(struct seq_file *m, void *v)
|
||||||
int *eof, void *data)
|
|
||||||
{
|
{
|
||||||
struct net_device *dev = data;
|
struct net_device *dev = m->private;
|
||||||
struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
|
struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
|
||||||
struct ieee80211_device *ieee = priv->ieee80211;
|
struct ieee80211_device *ieee = priv->ieee80211;
|
||||||
struct ieee80211_network *target;
|
struct ieee80211_network *target;
|
||||||
|
|
||||||
int len = 0;
|
|
||||||
|
|
||||||
list_for_each_entry(target, &ieee->network_list, list) {
|
list_for_each_entry(target, &ieee->network_list, list) {
|
||||||
|
const char *wpa = "non_WPA";
|
||||||
len += snprintf(page + len, count - len, "%s ", target->ssid);
|
|
||||||
|
|
||||||
if (target->wpa_ie_len > 0 || target->rsn_ie_len > 0)
|
if (target->wpa_ie_len > 0 || target->rsn_ie_len > 0)
|
||||||
len += snprintf(page + len, count - len, "WPA\n");
|
wpa = "WPA";
|
||||||
else
|
|
||||||
len += snprintf(page + len, count - len, "non_WPA\n");
|
seq_printf(m, "%s %s\n", target->ssid, wpa);
|
||||||
}
|
}
|
||||||
|
|
||||||
*eof = 1;
|
return 0;
|
||||||
return len;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int proc_get_registers(char *page, char **start,
|
static int proc_get_registers(struct seq_file *m, void *v)
|
||||||
off_t offset, int count,
|
|
||||||
int *eof, void *data)
|
|
||||||
{
|
{
|
||||||
struct net_device *dev = data;
|
struct net_device *dev = m->private;
|
||||||
// struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
|
int i,n, max = 0xff;
|
||||||
|
|
||||||
int len = 0;
|
seq_puts(m, "\n####################page 0##################\n ");
|
||||||
int i,n;
|
|
||||||
|
|
||||||
int max=0xff;
|
|
||||||
|
|
||||||
/* This dump the current register page */
|
|
||||||
len += snprintf(page + len, count - len,
|
|
||||||
"\n####################page 0##################\n ");
|
|
||||||
|
|
||||||
for (n=0;n<=max;) {
|
for (n=0;n<=max;) {
|
||||||
//printk( "\nD: %2x> ", n);
|
//printk( "\nD: %2x> ", n);
|
||||||
len += snprintf(page + len, count - len,
|
seq_printf(m, "\nD: %2x > ",n);
|
||||||
"\nD: %2x > ",n);
|
|
||||||
|
|
||||||
for (i=0;i<16 && n<=max;i++,n++)
|
for (i=0;i<16 && n<=max;i++,n++)
|
||||||
len += snprintf(page + len, count - len,
|
seq_printf(m, "%2x ",read_nic_byte(dev,0x000|n));
|
||||||
"%2x ",read_nic_byte(dev,0x000|n));
|
|
||||||
|
|
||||||
// printk("%2x ",read_nic_byte(dev,n));
|
// printk("%2x ",read_nic_byte(dev,n));
|
||||||
}
|
}
|
||||||
len += snprintf(page + len, count - len,
|
|
||||||
"\n####################page 1##################\n ");
|
seq_puts(m, "\n####################page 1##################\n ");
|
||||||
for (n=0;n<=max;) {
|
for (n=0;n<=max;) {
|
||||||
//printk( "\nD: %2x> ", n);
|
//printk( "\nD: %2x> ", n);
|
||||||
len += snprintf(page + len, count - len,
|
seq_printf(m, "\nD: %2x > ",n);
|
||||||
"\nD: %2x > ",n);
|
|
||||||
|
|
||||||
for (i=0;i<16 && n<=max;i++,n++)
|
for (i=0;i<16 && n<=max;i++,n++)
|
||||||
len += snprintf(page + len, count - len,
|
seq_printf(m, "%2x ",read_nic_byte(dev,0x100|n));
|
||||||
"%2x ",read_nic_byte(dev,0x100|n));
|
|
||||||
|
|
||||||
// printk("%2x ",read_nic_byte(dev,n));
|
// printk("%2x ",read_nic_byte(dev,n));
|
||||||
}
|
}
|
||||||
len += snprintf(page + len, count - len,
|
|
||||||
"\n####################page 3##################\n ");
|
seq_puts(m, "\n####################page 3##################\n ");
|
||||||
for (n=0;n<=max;) {
|
for (n=0;n<=max;) {
|
||||||
//printk( "\nD: %2x> ", n);
|
//printk( "\nD: %2x> ", n);
|
||||||
len += snprintf(page + len, count - len,
|
seq_printf(m, "\nD: %2x > ",n);
|
||||||
"\nD: %2x > ",n);
|
|
||||||
|
|
||||||
for(i=0;i<16 && n<=max;i++,n++)
|
for(i=0;i<16 && n<=max;i++,n++)
|
||||||
len += snprintf(page + len, count - len,
|
seq_printf(m, "%2x ",read_nic_byte(dev,0x300|n));
|
||||||
"%2x ",read_nic_byte(dev,0x300|n));
|
|
||||||
|
|
||||||
// printk("%2x ",read_nic_byte(dev,n));
|
// printk("%2x ",read_nic_byte(dev,n));
|
||||||
}
|
}
|
||||||
|
|
||||||
len += snprintf(page + len, count - len,"\n");
|
seq_putc(m, '\n');
|
||||||
*eof = 1;
|
return 0;
|
||||||
return len;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int proc_get_stats_tx(struct seq_file *m, void *v)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int proc_get_stats_tx(char *page, char **start,
|
|
||||||
off_t offset, int count,
|
|
||||||
int *eof, void *data)
|
|
||||||
{
|
{
|
||||||
struct net_device *dev = data;
|
struct net_device *dev = m->private;
|
||||||
struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
|
struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
|
||||||
|
|
||||||
int len = 0;
|
seq_printf(m,
|
||||||
|
|
||||||
len += snprintf(page + len, count - len,
|
|
||||||
"TX VI priority ok int: %lu\n"
|
"TX VI priority ok int: %lu\n"
|
||||||
"TX VI priority error int: %lu\n"
|
"TX VI priority error int: %lu\n"
|
||||||
"TX VO priority ok int: %lu\n"
|
"TX VO priority ok int: %lu\n"
|
||||||
@ -629,22 +601,15 @@ static int proc_get_stats_tx(char *page, char **start,
|
|||||||
// priv->stats.txbeaconerr
|
// priv->stats.txbeaconerr
|
||||||
);
|
);
|
||||||
|
|
||||||
*eof = 1;
|
return 0;
|
||||||
return len;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int proc_get_stats_rx(struct seq_file *m, void *v)
|
||||||
|
|
||||||
static int proc_get_stats_rx(char *page, char **start,
|
|
||||||
off_t offset, int count,
|
|
||||||
int *eof, void *data)
|
|
||||||
{
|
{
|
||||||
struct net_device *dev = data;
|
struct net_device *dev = m->private;
|
||||||
struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
|
struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
|
||||||
|
|
||||||
int len = 0;
|
seq_printf(m,
|
||||||
|
|
||||||
len += snprintf(page + len, count - len,
|
|
||||||
"RX packets: %lu\n"
|
"RX packets: %lu\n"
|
||||||
"RX urb status error: %lu\n"
|
"RX urb status error: %lu\n"
|
||||||
"RX invalid urb error: %lu\n",
|
"RX invalid urb error: %lu\n",
|
||||||
@ -652,9 +617,9 @@ static int proc_get_stats_rx(char *page, char **start,
|
|||||||
priv->stats.rxstaterr,
|
priv->stats.rxstaterr,
|
||||||
priv->stats.rxurberr);
|
priv->stats.rxurberr);
|
||||||
|
|
||||||
*eof = 1;
|
return 0;
|
||||||
return len;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void rtl8192_proc_module_init(void)
|
void rtl8192_proc_module_init(void)
|
||||||
{
|
{
|
||||||
RT_TRACE(COMP_INIT, "Initializing proc filesystem");
|
RT_TRACE(COMP_INIT, "Initializing proc filesystem");
|
||||||
@ -667,74 +632,77 @@ void rtl8192_proc_module_remove(void)
|
|||||||
remove_proc_entry(RTL819xU_MODULE_NAME, init_net.proc_net);
|
remove_proc_entry(RTL819xU_MODULE_NAME, init_net.proc_net);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* seq_file wrappers for procfile show routines.
|
||||||
|
*/
|
||||||
|
static int rtl8192_proc_open(struct inode *inode, struct file *file)
|
||||||
|
{
|
||||||
|
struct net_device *dev = PDE(inode)->parent->data;
|
||||||
|
int (*show)(struct seq_file *, void *) = PDE_DATA(inode);
|
||||||
|
|
||||||
|
return single_open(file, show, dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct file_operations rtl8192_proc_fops = {
|
||||||
|
.open = rtl8192_proc_open,
|
||||||
|
.read = seq_read,
|
||||||
|
.llseek = seq_lseek,
|
||||||
|
.release = seq_release,
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Table of proc files we need to create.
|
||||||
|
*/
|
||||||
|
struct rtl8192_proc_file {
|
||||||
|
char name[12];
|
||||||
|
int (*show)(struct seq_file *, void *);
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct rtl8192_proc_file rtl8192_proc_files[] = {
|
||||||
|
{ "stats-rx", &proc_get_stats_rx },
|
||||||
|
{ "stats-tx", &proc_get_stats_tx },
|
||||||
|
{ "stats-ap", &proc_get_stats_ap },
|
||||||
|
{ "registers", &proc_get_registers },
|
||||||
|
{ "" }
|
||||||
|
};
|
||||||
|
|
||||||
|
void rtl8192_proc_init_one(struct net_device *dev)
|
||||||
|
{
|
||||||
|
const struct rtl8192_proc_file *f;
|
||||||
|
struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
|
||||||
|
|
||||||
|
if (rtl8192_proc) {
|
||||||
|
priv->dir_dev = proc_mkdir(dev->name, rtl8192_proc);
|
||||||
|
if (!priv->dir_dev) {
|
||||||
|
RT_TRACE(COMP_ERR, "Unable to initialize /proc/net/rtl8192/%s\n",
|
||||||
|
dev->name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
priv->dir_dev->data = dev;
|
||||||
|
|
||||||
|
for (f = rtl8192_proc_files; f->name[0]; f++) {
|
||||||
|
if (!proc_create_data(f->name, S_IFREG | S_IRUGO,
|
||||||
|
priv->dir_dev,
|
||||||
|
rtl8192_proc_fops, f->show)) {
|
||||||
|
RT_TRACE(COMP_ERR, "Unable to initialize "
|
||||||
|
"/proc/net/rtl8192/%s/%s\n",
|
||||||
|
dev->name, f->name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void rtl8192_proc_remove_one(struct net_device *dev)
|
void rtl8192_proc_remove_one(struct net_device *dev)
|
||||||
{
|
{
|
||||||
struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
|
struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
|
||||||
|
|
||||||
|
|
||||||
if (priv->dir_dev) {
|
if (priv->dir_dev) {
|
||||||
// remove_proc_entry("stats-hw", priv->dir_dev);
|
remove_proc_subtree(dev->name, rtl8192_proc);
|
||||||
remove_proc_entry("stats-tx", priv->dir_dev);
|
|
||||||
remove_proc_entry("stats-rx", priv->dir_dev);
|
|
||||||
// remove_proc_entry("stats-ieee", priv->dir_dev);
|
|
||||||
remove_proc_entry("stats-ap", priv->dir_dev);
|
|
||||||
remove_proc_entry("registers", priv->dir_dev);
|
|
||||||
// remove_proc_entry("cck-registers",priv->dir_dev);
|
|
||||||
// remove_proc_entry("ofdm-registers",priv->dir_dev);
|
|
||||||
//remove_proc_entry(dev->name, rtl8192_proc);
|
|
||||||
remove_proc_entry("wlan0", rtl8192_proc);
|
|
||||||
priv->dir_dev = NULL;
|
priv->dir_dev = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void rtl8192_proc_init_one(struct net_device *dev)
|
|
||||||
{
|
|
||||||
struct proc_dir_entry *e;
|
|
||||||
struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
|
|
||||||
priv->dir_dev = proc_mkdir(dev->name, rtl8192_proc);
|
|
||||||
if (!priv->dir_dev) {
|
|
||||||
RT_TRACE(COMP_ERR, "Unable to initialize /proc/net/rtl8192/%s\n",
|
|
||||||
dev->name);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO,
|
|
||||||
priv->dir_dev, proc_get_stats_rx, dev);
|
|
||||||
|
|
||||||
if (!e) {
|
|
||||||
RT_TRACE(COMP_ERR,"Unable to initialize "
|
|
||||||
"/proc/net/rtl8192/%s/stats-rx\n",
|
|
||||||
dev->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO,
|
|
||||||
priv->dir_dev, proc_get_stats_tx, dev);
|
|
||||||
|
|
||||||
if (!e) {
|
|
||||||
RT_TRACE(COMP_ERR, "Unable to initialize "
|
|
||||||
"/proc/net/rtl8192/%s/stats-tx\n",
|
|
||||||
dev->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO,
|
|
||||||
priv->dir_dev, proc_get_stats_ap, dev);
|
|
||||||
|
|
||||||
if (!e) {
|
|
||||||
RT_TRACE(COMP_ERR, "Unable to initialize "
|
|
||||||
"/proc/net/rtl8192/%s/stats-ap\n",
|
|
||||||
dev->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
e = create_proc_read_entry("registers", S_IFREG | S_IRUGO,
|
|
||||||
priv->dir_dev, proc_get_registers, dev);
|
|
||||||
if (!e) {
|
|
||||||
RT_TRACE(COMP_ERR, "Unable to initialize "
|
|
||||||
"/proc/net/rtl8192/%s/registers\n",
|
|
||||||
dev->name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
-----------------------------MISC STUFF-------------------------
|
-----------------------------MISC STUFF-------------------------
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
Loading…
Reference in New Issue
Block a user