Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5ba02e35 authored by David Howells's avatar David Howells Committed by Al Viro
Browse files

rtl8187se: 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.

Question: Do any of the registers read by proc_get_registers() have side
effects upon reading?  If so, locking will be required.

Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
cc: Maxim Mikityanskiy <maxtram95@gmail.com>
cc: YAMANE Toshiaki <yamanetoshi@gmail.com>
cc: Bill Pemberton <wfp5p@virginia.edu>
cc: Andrea Merello <andreamrl@tiscali.it>
cc: linux-wireless@vger.kernel.org
cc: devel@driverdev.osuosl.org
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 0541f9d0
Loading
Loading
Loading
Loading
+63 −71
Original line number Original line Diff line number Diff line
@@ -36,6 +36,8 @@
#include <linux/syscalls.h>
#include <linux/syscalls.h>
#include <linux/eeprom_93cx6.h>
#include <linux/eeprom_93cx6.h>
#include <linux/interrupt.h>
#include <linux/interrupt.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>


#include "r8180_hw.h"
#include "r8180_hw.h"
#include "r8180.h"
#include "r8180.h"
@@ -204,51 +206,35 @@ void rtl8180_start_tx_beacon(struct net_device *dev);


static struct proc_dir_entry *rtl8180_proc;
static struct proc_dir_entry *rtl8180_proc;


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;
	int len = 0;
	int i, n, max = 0xff;
	int i, n;
	int max = 0xff;


	/* This dump the current register page */
	/* This dump the current register page */
	for (n = 0; n <= max;) {
	for (n = 0; n <= max;) {
		len += snprintf(page + len, count - len, "\nD:  %2x > ", n);
		seq_printf(m, "\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, "%2x ",
			seq_printf(m, "%2x ", read_nic_byte(dev, n));
					read_nic_byte(dev, n));
	}
	}
	len += snprintf(page + len, count - len, "\n");
	seq_putc(m, '\n');

	return 0;
	*eof = 1;
	return len;
}
}


int get_curr_tx_free_desc(struct net_device *dev, int priority);
int get_curr_tx_free_desc(struct net_device *dev, int priority);


static int proc_get_stats_hw(char *page, char **start,
static int proc_get_stats_hw(struct seq_file *m, void *v)
			  off_t offset, int count,
			  int *eof, void *data)
{
{
	int len = 0;
	return 0;

	*eof = 1;
	return len;
}
}


static int proc_get_stats_rx(char *page, char **start,
static int proc_get_stats_rx(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 r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);


	int len = 0;
	seq_printf(m,

	len += snprintf(page + len, count - len,
		"RX OK: %lu\n"
		"RX OK: %lu\n"
		"RX Retry: %lu\n"
		"RX Retry: %lu\n"
		"RX CRC Error(0-500): %lu\n"
		"RX CRC Error(0-500): %lu\n"
@@ -263,22 +249,17 @@ static int proc_get_stats_rx(char *page, char **start,
		priv->stats.rxicverr
		priv->stats.rxicverr
		);
		);


	*eof = 1;
	return 0;
	return len;
}
}


static int proc_get_stats_tx(char *page, char **start,
static int proc_get_stats_tx(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 r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);

	int len = 0;
	unsigned long totalOK;
	unsigned long totalOK;


	totalOK = priv->stats.txnpokint+priv->stats.txhpokint+priv->stats.txlpokint;
	totalOK = priv->stats.txnpokint+priv->stats.txhpokint+priv->stats.txlpokint;
	len += snprintf(page + len, count - len,
	seq_printf(m,
		"TX OK: %lu\n"
		"TX OK: %lu\n"
		"TX Error: %lu\n"
		"TX Error: %lu\n"
		"TX Retry: %lu\n"
		"TX Retry: %lu\n"
@@ -291,8 +272,7 @@ static int proc_get_stats_tx(char *page, char **start,
		priv->stats.txbeaconerr
		priv->stats.txbeaconerr
	);
	);


	*eof = 1;
	return 0;
	return len;
}
}


void rtl8180_proc_module_init(void)
void rtl8180_proc_module_init(void)
@@ -318,9 +298,43 @@ void rtl8180_proc_remove_one(struct net_device *dev)
	}
	}
}
}


/*
 * seq_file wrappers for procfile show routines.
 */
static int rtl8180_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 rtl8180_proc_fops = {
	.open		= rtl8180_proc_open,
	.read		= seq_read,
	.llseek		= seq_lseek,
	.release	= seq_release,
};

/*
 * Table of proc files we need to create.
 */
struct rtl8180_proc_file {
	char name[12];
	int (*show)(struct seq_file *, void *);
};

static const struct rtl8180_proc_file rtl8180_proc_files[] = {
	{ "stats-hw",	&proc_get_stats_hw },
	{ "stats-rx",	&proc_get_stats_rx },
	{ "stats-tx",	&proc_get_stats_tx },
	{ "registers",	&proc_get_registers },
	{ "" }
};

void rtl8180_proc_init_one(struct net_device *dev)
void rtl8180_proc_init_one(struct net_device *dev)
{
{
	struct proc_dir_entry *e;
	const struct rtl8180_proc_file *f;
	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);


	priv->dir_dev = rtl8180_proc;
	priv->dir_dev = rtl8180_proc;
@@ -329,38 +343,16 @@ void rtl8180_proc_init_one(struct net_device *dev)
		      dev->name);
		      dev->name);
		return;
		return;
	}
	}
	priv->dir_dev->data = dev;


	e = create_proc_read_entry("stats-hw", S_IFREG | S_IRUGO,
	for (f = rtl8180_proc_files; f->name[0]; f++) {
				   priv->dir_dev, proc_get_stats_hw, dev);
		if (!proc_create_data(f->name, S_IFREG | S_IRUGO,
	if (!e) {
				      priv->dir_dev,
		DMESGE("Unable to initialize "
				      &rtl8180_proc_fops, f->show)) {
		      "/proc/net/r8180/%s/stats-hw\n",
			DMESGE("Unable to initialize /proc/net/r8180/%s\n",
		      dev->name);
			       f->name);
	}
			return;

	e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO,
				   priv->dir_dev, proc_get_stats_rx, dev);
	if (!e) {
		DMESGE("Unable to initialize "
		      "/proc/net/r8180/%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) {
		DMESGE("Unable to initialize "
		      "/proc/net/r8180/%s/stats-tx\n",
		      dev->name);
		}
		}

	e = create_proc_read_entry("registers", S_IFREG | S_IRUGO,
				   priv->dir_dev, proc_get_registers, dev);
	if (!e) {
		DMESGE("Unable to initialize "
		      "/proc/net/r8180/%s/registers\n",
		      dev->name);
	}
	}
}
}