Commit dba5e428 authored by Christoph Hellwig's avatar Christoph Hellwig

staging/rtl8192u: simplify procfs code

Unwind the registration loop into individual calls.  Switch to use
proc_create_single where applicable.

Also don't bother handling proc_create* failures - the driver works
perfectly fine without the proc files, and the cleanup will handle
missing files gracefully.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent 07a3b8ed
......@@ -646,64 +646,25 @@ static void rtl8192_proc_module_init(void)
rtl8192_proc = proc_mkdir(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 = proc_get_parent_data(inode);
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 = single_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 },
{ "" }
};
static void rtl8192_proc_init_one(struct net_device *dev)
{
const struct rtl8192_proc_file *f;
struct proc_dir_entry *dir;
if (rtl8192_proc) {
dir = proc_mkdir_data(dev->name, 0, rtl8192_proc, dev);
if (!dir) {
RT_TRACE(COMP_ERR,
"Unable to initialize /proc/net/rtl8192/%s\n",
dev->name);
if (!rtl8192_proc)
return;
}
for (f = rtl8192_proc_files; f->name[0]; f++) {
if (!proc_create_data(f->name, S_IFREG | S_IRUGO, dir,
&rtl8192_proc_fops, f->show)) {
RT_TRACE(COMP_ERR,
"Unable to initialize /proc/net/rtl8192/%s/%s\n",
dev->name, f->name);
dir = proc_mkdir_data(dev->name, 0, rtl8192_proc, dev);
if (!dir)
return;
}
}
}
proc_create_single("stats-rx", S_IFREG | S_IRUGO, dir,
proc_get_stats_rx);
proc_create_single("stats-tx", S_IFREG | S_IRUGO, dir,
proc_get_stats_tx);
proc_create_single("stats-ap", S_IFREG | S_IRUGO, dir,
proc_get_stats_ap);
proc_create_single("registers", S_IFREG | S_IRUGO, dir,
proc_get_registers);
}
static void rtl8192_proc_remove_one(struct net_device *dev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment