Commit 207e3909 authored by David Howells's avatar David Howells Committed by Al Viro

ft1000: 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.
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
cc: Marek Belisko <marek.belisko@gmail.com>
cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
cc: Ondrej Zary <linux@rainbow-software.org>
cc: devel@driverdev.osuosl.org
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 5ba02e35
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
...@@ -29,69 +30,54 @@ ...@@ -29,69 +30,54 @@
#define FT1000_PROC "ft1000" #define FT1000_PROC "ft1000"
#define MAX_FILE_LEN 255 #define MAX_FILE_LEN 255
#define PUTM_TO_PAGE(len, page, args...) \ #define seq_putx(m, message, size, var) \
len += snprintf(page+len, PAGE_SIZE - len, args) seq_printf(m, message); \
#define PUTX_TO_PAGE(len, page, message, size, var) \
len += snprintf(page+len, PAGE_SIZE - len, message); \
for(i = 0; i < (size - 1); i++) { \ for(i = 0; i < (size - 1); i++) { \
len += snprintf(page+len, PAGE_SIZE - len, "%02x:", var[i]); \ seq_printf(m, "%02x:", var[i]); \
} \ } \
len += snprintf(page+len, PAGE_SIZE - len, "%02x\n", var[i]) seq_printf(m, "%02x\n", var[i])
#define PUTD_TO_PAGE(len, page, message, size, var) \ #define seq_putd(m, message, size, var) \
len += snprintf(page+len, PAGE_SIZE - len, message); \ seq_printf(m, message); \
for(i = 0; i < (size - 1); i++) { \ for(i = 0; i < (size - 1); i++) { \
len += snprintf(page+len, PAGE_SIZE - len, "%d.", var[i]); \ seq_printf(m, "%d.", var[i]); \
} \ } \
len += snprintf(page+len, PAGE_SIZE - len, "%d\n", var[i]) seq_printf(m, "%d\n", var[i])
static int ft1000ReadProc(char *page, char **start, off_t off, static int ft1000ReadProc(struct seq_file *m, void *v)
int count, int *eof, void *data)
{ {
struct net_device *dev; static const char *status[] = {
int len;
int i;
struct ft1000_info *info;
char *status[] = {
"Idle (Disconnect)", "Searching", "Active (Connected)", "Idle (Disconnect)", "Searching", "Active (Connected)",
"Waiting for L2", "Sleep", "No Coverage", "", "" "Waiting for L2", "Sleep", "No Coverage", "", ""
}; };
char *signal[] = { "", "*", "**", "***", "****" }; static const char *signal[] = { "", "*", "**", "***", "****" };
struct net_device *dev = m->private;
struct ft1000_info *info = netdev_priv(dev);
int i;
int strength; int strength;
int quality; int quality;
struct timeval tv; struct timeval tv;
time_t delta; time_t delta;
dev = (struct net_device *)data;
info = netdev_priv(dev);
if (off > 0) {
*eof = 1;
return 0;
}
/* Wrap-around */
if (info->AsicID == ELECTRABUZZ_ID) { if (info->AsicID == ELECTRABUZZ_ID) {
if (info->ProgConStat != 0xFF) { if (info->ProgConStat != 0xFF) {
info->LedStat = info->LedStat =
ft1000_read_dpram(dev, FT1000_DSP_LED); ft1000_read_dpram(dev, FT1000_DSP_LED);
info->ConStat = info->ConStat =
ft1000_read_dpram(dev, ft1000_read_dpram(dev, FT1000_DSP_CON_STATE);
FT1000_DSP_CON_STATE);
} else { } else {
info->ConStat = 0xf; info->ConStat = 0xf;
} }
} else { } else {
if (info->ProgConStat != 0xFF) { if (info->ProgConStat != 0xFF) {
info->LedStat = info->LedStat =
ntohs(ft1000_read_dpram_mag_16 ntohs(ft1000_read_dpram_mag_16(
(dev, FT1000_MAG_DSP_LED, dev, FT1000_MAG_DSP_LED,
FT1000_MAG_DSP_LED_INDX)); FT1000_MAG_DSP_LED_INDX));
info->ConStat = info->ConStat =
ntohs(ft1000_read_dpram_mag_16 ntohs(ft1000_read_dpram_mag_16(
(dev, FT1000_MAG_DSP_CON_STATE, dev, FT1000_MAG_DSP_CON_STATE,
FT1000_MAG_DSP_CON_STATE_INDX)); FT1000_MAG_DSP_CON_STATE_INDX));
} else { } else {
info->ConStat = 0xf; info->ConStat = 0xf;
...@@ -135,36 +121,46 @@ static int ft1000ReadProc(char *page, char **start, off_t off, ...@@ -135,36 +121,46 @@ static int ft1000ReadProc(char *page, char **start, off_t off,
} }
do_gettimeofday(&tv); do_gettimeofday(&tv);
delta = (tv.tv_sec - info->ConTm); delta = tv.tv_sec - info->ConTm;
len = 0; seq_printf(m, "Connection Time: %02ld:%02ld:%02ld\n",
PUTM_TO_PAGE(len, page, "Connection Time: %02ld:%02ld:%02ld\n",
((delta / 3600) % 24), ((delta / 60) % 60), (delta % 60)); ((delta / 3600) % 24), ((delta / 60) % 60), (delta % 60));
PUTM_TO_PAGE(len, page, "Connection Time[s]: %ld\n", delta); seq_printf(m, "Connection Time[s]: %ld\n", delta);
PUTM_TO_PAGE(len, page, "Asic ID: %s\n", seq_printf(m, "Asic ID: %s\n",
(info->AsicID) == info->AsicID ==
ELECTRABUZZ_ID ? "ELECTRABUZZ ASIC" : "MAGNEMITE ASIC"); ELECTRABUZZ_ID ? "ELECTRABUZZ ASIC" : "MAGNEMITE ASIC");
PUTX_TO_PAGE(len, page, "SKU: ", SKUSZ, info->Sku); seq_putx(m, "SKU: ", SKUSZ, info->Sku);
PUTX_TO_PAGE(len, page, "EUI64: ", EUISZ, info->eui64); seq_putx(m, "EUI64: ", EUISZ, info->eui64);
PUTD_TO_PAGE(len, page, "DSP version number: ", DSPVERSZ, info->DspVer); seq_putd(m, "DSP version number: ", DSPVERSZ, info->DspVer);
PUTX_TO_PAGE(len, page, "Hardware Serial Number: ", HWSERNUMSZ, seq_putx(m, "Hardware Serial Number: ", HWSERNUMSZ, info->HwSerNum);
info->HwSerNum); seq_putx(m, "Caliberation Version: ", CALVERSZ, info->RfCalVer);
PUTX_TO_PAGE(len, page, "Caliberation Version: ", CALVERSZ, seq_putd(m, "Caliberation Date: ", CALDATESZ, info->RfCalDate);
info->RfCalVer); seq_printf(m, "Media State: %s\n",
PUTD_TO_PAGE(len, page, "Caliberation Date: ", CALDATESZ,
info->RfCalDate);
PUTM_TO_PAGE(len, page, "Media State: %s\n",
(info->mediastate) ? "link" : "no link"); (info->mediastate) ? "link" : "no link");
PUTM_TO_PAGE(len, page, "Connection Status: %s\n", seq_printf(m, "Connection Status: %s\n", status[info->ConStat & 0x7]);
status[((info->ConStat) & 0x7)]); seq_printf(m, "RX packets: %ld\n", info->stats.rx_packets);
PUTM_TO_PAGE(len, page, "RX packets: %ld\n", info->stats.rx_packets); seq_printf(m, "TX packets: %ld\n", info->stats.tx_packets);
PUTM_TO_PAGE(len, page, "TX packets: %ld\n", info->stats.tx_packets); seq_printf(m, "RX bytes: %ld\n", info->stats.rx_bytes);
PUTM_TO_PAGE(len, page, "RX bytes: %ld\n", info->stats.rx_bytes); seq_printf(m, "TX bytes: %ld\n", info->stats.tx_bytes);
PUTM_TO_PAGE(len, page, "TX bytes: %ld\n", info->stats.tx_bytes); seq_printf(m, "Signal Strength: %s\n", signal[strength]);
PUTM_TO_PAGE(len, page, "Signal Strength: %s\n", signal[strength]); seq_printf(m, "Signal Quality: %s\n", signal[quality]);
PUTM_TO_PAGE(len, page, "Signal Quality: %s\n", signal[quality]); return 0;
return len; }
/*
* seq_file wrappers for procfile show routines.
*/
static int ft1000_proc_open(struct inode *inode, struct file *file)
{
return single_open(file, ft1000ReadProc, PDE_DATA(inode));
} }
static const struct file_operations ft1000_proc_fops = {
.open = ft1000_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};
static int ft1000NotifyProc(struct notifier_block *this, unsigned long event, static int ft1000NotifyProc(struct notifier_block *this, unsigned long event,
void *ptr) void *ptr)
{ {
...@@ -176,8 +172,8 @@ static int ft1000NotifyProc(struct notifier_block *this, unsigned long event, ...@@ -176,8 +172,8 @@ static int ft1000NotifyProc(struct notifier_block *this, unsigned long event,
switch (event) { switch (event) {
case NETDEV_CHANGENAME: case NETDEV_CHANGENAME:
remove_proc_entry(info->netdevname, info->ft1000_proc_dir); remove_proc_entry(info->netdevname, info->ft1000_proc_dir);
create_proc_read_entry(dev->name, 0644, info->ft1000_proc_dir, proc_create_data(dev->name, 0644, info->ft1000_proc_dir,
ft1000ReadProc, dev); &ft1000_proc_fops, dev);
snprintf(info->netdevname, IFNAMSIZ, "%s", dev->name); snprintf(info->netdevname, IFNAMSIZ, "%s", dev->name);
break; break;
} }
...@@ -195,8 +191,10 @@ void ft1000InitProc(struct net_device *dev) ...@@ -195,8 +191,10 @@ void ft1000InitProc(struct net_device *dev)
info = netdev_priv(dev); info = netdev_priv(dev);
info->ft1000_proc_dir = proc_mkdir(FT1000_PROC, init_net.proc_net); info->ft1000_proc_dir = proc_mkdir(FT1000_PROC, init_net.proc_net);
create_proc_read_entry(dev->name, 0644, info->ft1000_proc_dir,
ft1000ReadProc, dev); proc_create_data(dev->name, 0644, info->ft1000_proc_dir,
&ft1000_proc_fops, dev);
snprintf(info->netdevname, IFNAMSIZ, "%s", dev->name); snprintf(info->netdevname, IFNAMSIZ, "%s", dev->name);
register_netdevice_notifier(&ft1000_netdev_notifier); register_netdevice_notifier(&ft1000_netdev_notifier);
} }
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
...@@ -30,22 +31,17 @@ ...@@ -30,22 +31,17 @@
#define FT1000_PROC_DIR "ft1000" #define FT1000_PROC_DIR "ft1000"
#define PUTM_TO_PAGE(len,page,args...) \ #define seq_putx(m, message, size, var) \
len += snprintf(page+len, PAGE_SIZE - len, args) seq_printf(m, message); \
for(i = 0; i < (size - 1); i++) \
seq_printf(m, "%02x:", var[i]); \
seq_printf(m, "%02x\n", var[i])
#define PUTX_TO_PAGE(len,page,message,size,var) \ #define seq_putd(m, message, size, var) \
len += snprintf(page+len, PAGE_SIZE - len, message); \ seq_printf(m, message); \
for (i = 0; i < (size - 1); i++) {\ for(i = 0; i < (size - 1); i++) \
len += snprintf(page+len, PAGE_SIZE - len, "%02x:", var[i]); \ seq_printf(m, "%d.", var[i]); \
} \ seq_printf(m, "%d\n", var[i])
len += snprintf(page+len, PAGE_SIZE - len, "%02x\n", var[i])
#define PUTD_TO_PAGE(len,page,message,size,var) \
len += snprintf(page+len, PAGE_SIZE - len, message); \
for (i = 0; i < (size - 1); i++) {\
len += snprintf(page+len, PAGE_SIZE - len, "%d.", var[i]); \
} \
len += snprintf(page+len, PAGE_SIZE - len, "%d\n", var[i])
#define FTNET_PROC init_net.proc_net #define FTNET_PROC init_net.proc_net
...@@ -55,19 +51,9 @@ int ft1000_read_dpram16 (struct ft1000_usb *ft1000dev, u16 indx, ...@@ -55,19 +51,9 @@ int ft1000_read_dpram16 (struct ft1000_usb *ft1000dev, u16 indx,
u8 *buffer, u8 highlow); u8 *buffer, u8 highlow);
static int static int ft1000ReadProc(struct seq_file *m, void *v)
ft1000ReadProc(char *page, char **start, off_t off, int count, int *eof,
void *data)
{ {
struct net_device *dev; static const char *status[] = {
int len;
int i;
unsigned short ledStat;
unsigned short conStat;
struct ft1000_info *info;
char *status[] = {
"Idle (Disconnect)", "Idle (Disconnect)",
"Searching", "Searching",
"Active (Connected)", "Active (Connected)",
...@@ -77,22 +63,18 @@ ft1000ReadProc(char *page, char **start, off_t off, int count, int *eof, ...@@ -77,22 +63,18 @@ ft1000ReadProc(char *page, char **start, off_t off, int count, int *eof,
"", "",
"", "",
}; };
static const char *signal[] = { "", "*", "**", "***", "****" };
char *signal[] = { "", "*", "**", "***", "****" }; struct net_device *dev = m->private;
struct ft1000_info *info = netdev_priv(dev);
int i;
unsigned short ledStat;
unsigned short conStat;
int strength; int strength;
int quality; int quality;
struct timeval tv; struct timeval tv;
time_t delta; time_t delta;
dev = (struct net_device *) data;
info = netdev_priv(dev);
if (off > 0) {
*eof = 1;
return 0;
}
if (info->ProgConStat != 0xFF) { if (info->ProgConStat != 0xFF) {
ft1000_read_dpram16(info->priv, FT1000_MAG_DSP_LED, ft1000_read_dpram16(info->priv, FT1000_MAG_DSP_LED,
(u8 *)&ledStat, FT1000_MAG_DSP_LED_INDX); (u8 *)&ledStat, FT1000_MAG_DSP_LED_INDX);
...@@ -144,36 +126,43 @@ ft1000ReadProc(char *page, char **start, off_t off, int count, int *eof, ...@@ -144,36 +126,43 @@ ft1000ReadProc(char *page, char **start, off_t off, int count, int *eof,
quality = 0; quality = 0;
} }
len = 0; seq_printf(m, "Connection Time: %02ld:%02ld:%02ld\n",
PUTM_TO_PAGE(len, page, "Connection Time: %02ld:%02ld:%02ld\n",
((delta / 3600) % 24), ((delta / 60) % 60), (delta % 60)); ((delta / 3600) % 24), ((delta / 60) % 60), (delta % 60));
PUTM_TO_PAGE(len, page, "Connection Time[s]: %ld\n", delta); seq_printf(m, "Connection Time[s]: %ld\n", delta);
PUTM_TO_PAGE(len, page, "Asic ID: %s\n", seq_printf(m, "Asic ID: %s\n",
(info->AsicID) == (info->AsicID) == ELECTRABUZZ_ID ? "ELECTRABUZZ ASIC" : "MAGNEMITE ASIC");
ELECTRABUZZ_ID ? "ELECTRABUZZ ASIC" : "MAGNEMITE ASIC"); seq_putx(m, "SKU: ", SKUSZ, info->Sku);
PUTX_TO_PAGE(len, page, "SKU: ", SKUSZ, info->Sku); seq_putx(m, "EUI64: ", EUISZ, info->eui64);
PUTX_TO_PAGE(len, page, "EUI64: ", EUISZ, info->eui64); seq_putd(m, "DSP version number: ", DSPVERSZ, info->DspVer);
PUTD_TO_PAGE(len, page, "DSP version number: ", DSPVERSZ, info->DspVer); seq_putx(m, "Hardware Serial Number: ", HWSERNUMSZ, info->HwSerNum);
PUTX_TO_PAGE(len, page, "Hardware Serial Number: ", HWSERNUMSZ, seq_putx(m, "Caliberation Version: ", CALVERSZ, info->RfCalVer);
info->HwSerNum); seq_putd(m, "Caliberation Date: ", CALDATESZ, info->RfCalDate);
PUTX_TO_PAGE(len, page, "Caliberation Version: ", CALVERSZ, seq_printf(m, "Media State: %s\n", (info->mediastate) ? "link" : "no link");
info->RfCalVer); seq_printf(m, "Connection Status: %s\n", status[info->ConStat & 0x7]);
PUTD_TO_PAGE(len, page, "Caliberation Date: ", CALDATESZ, seq_printf(m, "RX packets: %ld\n", info->stats.rx_packets);
info->RfCalDate); seq_printf(m, "TX packets: %ld\n", info->stats.tx_packets);
PUTM_TO_PAGE(len, page, "Media State: %s\n", seq_printf(m, "RX bytes: %ld\n", info->stats.rx_bytes);
(info->mediastate) ? "link" : "no link"); seq_printf(m, "TX bytes: %ld\n", info->stats.tx_bytes);
PUTM_TO_PAGE(len, page, "Connection Status: %s\n", seq_printf(m, "Signal Strength: %s\n", signal[strength]);
status[((info->ConStat) & 0x7)]); seq_printf(m, "Signal Quality: %s\n", signal[quality]);
PUTM_TO_PAGE(len, page, "RX packets: %ld\n", info->stats.rx_packets); return 0;
PUTM_TO_PAGE(len, page, "TX packets: %ld\n", info->stats.tx_packets);
PUTM_TO_PAGE(len, page, "RX bytes: %ld\n", info->stats.rx_bytes);
PUTM_TO_PAGE(len, page, "TX bytes: %ld\n", info->stats.tx_bytes);
PUTM_TO_PAGE(len, page, "Signal Strength: %s\n", signal[strength]);
PUTM_TO_PAGE(len, page, "Signal Quality: %s\n", signal[quality]);
return len;
} }
/*
* seq_file wrappers for procfile show routines.
*/
static int ft1000_proc_open(struct inode *inode, struct file *file)
{
return single_open(file, ft1000ReadProc, PDE_DATA(inode));
}
static const struct file_operations ft1000_proc_fops = {
.open = ft1000_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};
static int static int
ft1000NotifyProc(struct notifier_block *this, unsigned long event, void *ptr) ft1000NotifyProc(struct notifier_block *this, unsigned long event, void *ptr)
{ {
...@@ -186,9 +175,9 @@ ft1000NotifyProc(struct notifier_block *this, unsigned long event, void *ptr) ...@@ -186,9 +175,9 @@ ft1000NotifyProc(struct notifier_block *this, unsigned long event, void *ptr)
switch (event) { switch (event) {
case NETDEV_CHANGENAME: case NETDEV_CHANGENAME:
remove_proc_entry(info->netdevname, info->ft1000_proc_dir); remove_proc_entry(info->netdevname, info->ft1000_proc_dir);
ft1000_proc_file = create_proc_read_entry(dev->name, 0644, ft1000_proc_file =
info->ft1000_proc_dir, proc_create_data(dev->name, 0644, info->ft1000_proc_dir,
ft1000ReadProc, dev); &ft1000_proc_fops, dev);
snprintf(info->netdevname, IFNAMSIZ, "%s", dev->name); snprintf(info->netdevname, IFNAMSIZ, "%s", dev->name);
break; break;
} }
...@@ -217,10 +206,10 @@ int ft1000_init_proc(struct net_device *dev) ...@@ -217,10 +206,10 @@ int ft1000_init_proc(struct net_device *dev)
} }
ft1000_proc_file = ft1000_proc_file =
create_proc_read_entry(dev->name, 0644, proc_create_data(dev->name, 0644, info->ft1000_proc_dir,
info->ft1000_proc_dir, ft1000ReadProc, dev); &ft1000_proc_fops, dev);
if (ft1000_proc_file == NULL) { if (!ft1000_proc_file) {
printk(KERN_WARNING "Unable to create /proc entry.\n"); printk(KERN_WARNING "Unable to create /proc entry.\n");
goto fail_entry; goto fail_entry;
} }
......
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