diff options
author | David Howells <dhowells@redhat.com> | 2013-04-08 17:06:20 +0200 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-04-29 21:41:51 +0200 |
commit | 207e39099a90a7385900aca4868ed686f25300cb (patch) | |
tree | e098b6dd969acf8e3cd64b9438e614e454113bdc /drivers | |
parent | rtl8187se: Don't use create_proc_read_entry() (diff) | |
download | linux-207e39099a90a7385900aca4868ed686f25300cb.tar.xz linux-207e39099a90a7385900aca4868ed686f25300cb.zip |
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: David 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: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c | 130 | ||||
-rw-r--r-- | drivers/staging/ft1000/ft1000-usb/ft1000_proc.c | 129 |
2 files changed, 123 insertions, 136 deletions
diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c index 5337b415d450..21b369e0150f 100644 --- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c +++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c @@ -19,6 +19,7 @@ #include <linux/module.h> #include <linux/kernel.h> #include <linux/proc_fs.h> +#include <linux/seq_file.h> #include <linux/string.h> #include <linux/vmalloc.h> #include <linux/netdevice.h> @@ -29,70 +30,55 @@ #define FT1000_PROC "ft1000" #define MAX_FILE_LEN 255 -#define PUTM_TO_PAGE(len, page, args...) \ - len += snprintf(page+len, PAGE_SIZE - len, args) - -#define PUTX_TO_PAGE(len, page, message, size, var) \ - len += snprintf(page+len, PAGE_SIZE - len, message); \ +#define seq_putx(m, message, size, var) \ + seq_printf(m, message); \ 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) \ - len += snprintf(page+len, PAGE_SIZE - len, message); \ +#define seq_putd(m, message, size, var) \ + seq_printf(m, message); \ 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, - int count, int *eof, void *data) +static int ft1000ReadProc(struct seq_file *m, void *v) { - struct net_device *dev; - int len; - int i; - struct ft1000_info *info; - char *status[] = { + static const char *status[] = { "Idle (Disconnect)", "Searching", "Active (Connected)", "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 quality; struct timeval tv; 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->ProgConStat != 0xFF) { info->LedStat = ft1000_read_dpram(dev, FT1000_DSP_LED); info->ConStat = - ft1000_read_dpram(dev, - FT1000_DSP_CON_STATE); + ft1000_read_dpram(dev, FT1000_DSP_CON_STATE); } else { info->ConStat = 0xf; } } else { if (info->ProgConStat != 0xFF) { info->LedStat = - ntohs(ft1000_read_dpram_mag_16 - (dev, FT1000_MAG_DSP_LED, - FT1000_MAG_DSP_LED_INDX)); + ntohs(ft1000_read_dpram_mag_16( + dev, FT1000_MAG_DSP_LED, + FT1000_MAG_DSP_LED_INDX)); info->ConStat = - ntohs(ft1000_read_dpram_mag_16 - (dev, FT1000_MAG_DSP_CON_STATE, - FT1000_MAG_DSP_CON_STATE_INDX)); + ntohs(ft1000_read_dpram_mag_16( + dev, FT1000_MAG_DSP_CON_STATE, + FT1000_MAG_DSP_CON_STATE_INDX)); } else { info->ConStat = 0xf; } @@ -135,36 +121,46 @@ static int ft1000ReadProc(char *page, char **start, off_t off, } do_gettimeofday(&tv); - delta = (tv.tv_sec - info->ConTm); - len = 0; - PUTM_TO_PAGE(len, page, "Connection Time: %02ld:%02ld:%02ld\n", + delta = tv.tv_sec - info->ConTm; + seq_printf(m, "Connection Time: %02ld:%02ld:%02ld\n", ((delta / 3600) % 24), ((delta / 60) % 60), (delta % 60)); - PUTM_TO_PAGE(len, page, "Connection Time[s]: %ld\n", delta); - PUTM_TO_PAGE(len, page, "Asic ID: %s\n", - (info->AsicID) == + seq_printf(m, "Connection Time[s]: %ld\n", delta); + seq_printf(m, "Asic ID: %s\n", + info->AsicID == ELECTRABUZZ_ID ? "ELECTRABUZZ ASIC" : "MAGNEMITE ASIC"); - PUTX_TO_PAGE(len, page, "SKU: ", SKUSZ, info->Sku); - PUTX_TO_PAGE(len, page, "EUI64: ", EUISZ, info->eui64); - PUTD_TO_PAGE(len, page, "DSP version number: ", DSPVERSZ, info->DspVer); - PUTX_TO_PAGE(len, page, "Hardware Serial Number: ", HWSERNUMSZ, - info->HwSerNum); - PUTX_TO_PAGE(len, page, "Caliberation Version: ", CALVERSZ, - info->RfCalVer); - PUTD_TO_PAGE(len, page, "Caliberation Date: ", CALDATESZ, - info->RfCalDate); - PUTM_TO_PAGE(len, page, "Media State: %s\n", + seq_putx(m, "SKU: ", SKUSZ, info->Sku); + seq_putx(m, "EUI64: ", EUISZ, info->eui64); + seq_putd(m, "DSP version number: ", DSPVERSZ, info->DspVer); + seq_putx(m, "Hardware Serial Number: ", HWSERNUMSZ, info->HwSerNum); + seq_putx(m, "Caliberation Version: ", CALVERSZ, info->RfCalVer); + seq_putd(m, "Caliberation Date: ", CALDATESZ, info->RfCalDate); + seq_printf(m, "Media State: %s\n", (info->mediastate) ? "link" : "no link"); - PUTM_TO_PAGE(len, page, "Connection Status: %s\n", - status[((info->ConStat) & 0x7)]); - PUTM_TO_PAGE(len, page, "RX packets: %ld\n", info->stats.rx_packets); - 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_printf(m, "Connection Status: %s\n", status[info->ConStat & 0x7]); + seq_printf(m, "RX packets: %ld\n", info->stats.rx_packets); + seq_printf(m, "TX packets: %ld\n", info->stats.tx_packets); + seq_printf(m, "RX bytes: %ld\n", info->stats.rx_bytes); + seq_printf(m, "TX bytes: %ld\n", info->stats.tx_bytes); + seq_printf(m, "Signal Strength: %s\n", signal[strength]); + seq_printf(m, "Signal Quality: %s\n", signal[quality]); + return 0; +} + +/* + * 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, void *ptr) { @@ -176,8 +172,8 @@ static int ft1000NotifyProc(struct notifier_block *this, unsigned long event, switch (event) { case NETDEV_CHANGENAME: remove_proc_entry(info->netdevname, info->ft1000_proc_dir); - 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); break; } @@ -195,8 +191,10 @@ void ft1000InitProc(struct net_device *dev) info = netdev_priv(dev); 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); register_netdevice_notifier(&ft1000_netdev_notifier); } diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_proc.c b/drivers/staging/ft1000/ft1000-usb/ft1000_proc.c index b99640637fe0..d8294d6c9560 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_proc.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_proc.c @@ -22,6 +22,7 @@ #include <linux/module.h> #include <linux/kernel.h> #include <linux/proc_fs.h> +#include <linux/seq_file.h> #include <linux/netdevice.h> @@ -30,22 +31,17 @@ #define FT1000_PROC_DIR "ft1000" -#define PUTM_TO_PAGE(len,page,args...) \ - len += snprintf(page+len, PAGE_SIZE - len, args) +#define seq_putx(m, message, size, var) \ + 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) \ - len += snprintf(page+len, PAGE_SIZE - len, message); \ - for (i = 0; i < (size - 1); i++) {\ - len += snprintf(page+len, PAGE_SIZE - len, "%02x:", 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 seq_putd(m, message, size, var) \ + seq_printf(m, message); \ + for(i = 0; i < (size - 1); i++) \ + seq_printf(m, "%d.", var[i]); \ + seq_printf(m, "%d\n", var[i]) #define FTNET_PROC init_net.proc_net @@ -55,19 +51,9 @@ int ft1000_read_dpram16 (struct ft1000_usb *ft1000dev, u16 indx, u8 *buffer, u8 highlow); -static int -ft1000ReadProc(char *page, char **start, off_t off, int count, int *eof, - void *data) +static int ft1000ReadProc(struct seq_file *m, void *v) { - struct net_device *dev; - int len; - int i; - unsigned short ledStat; - unsigned short conStat; - - struct ft1000_info *info; - - char *status[] = { + static const char *status[] = { "Idle (Disconnect)", "Searching", "Active (Connected)", @@ -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 quality; struct timeval tv; time_t delta; - dev = (struct net_device *) data; - info = netdev_priv(dev); - - if (off > 0) { - *eof = 1; - return 0; - } - - if (info->ProgConStat != 0xFF) { ft1000_read_dpram16(info->priv, FT1000_MAG_DSP_LED, (u8 *)&ledStat, FT1000_MAG_DSP_LED_INDX); @@ -144,36 +126,43 @@ ft1000ReadProc(char *page, char **start, off_t off, int count, int *eof, quality = 0; } - len = 0; - PUTM_TO_PAGE(len, page, "Connection Time: %02ld:%02ld:%02ld\n", + seq_printf(m, "Connection Time: %02ld:%02ld:%02ld\n", ((delta / 3600) % 24), ((delta / 60) % 60), (delta % 60)); - PUTM_TO_PAGE(len, page, "Connection Time[s]: %ld\n", delta); - PUTM_TO_PAGE(len, page, "Asic ID: %s\n", - (info->AsicID) == - ELECTRABUZZ_ID ? "ELECTRABUZZ ASIC" : "MAGNEMITE ASIC"); - PUTX_TO_PAGE(len, page, "SKU: ", SKUSZ, info->Sku); - PUTX_TO_PAGE(len, page, "EUI64: ", EUISZ, info->eui64); - PUTD_TO_PAGE(len, page, "DSP version number: ", DSPVERSZ, info->DspVer); - PUTX_TO_PAGE(len, page, "Hardware Serial Number: ", HWSERNUMSZ, - info->HwSerNum); - PUTX_TO_PAGE(len, page, "Caliberation Version: ", CALVERSZ, - info->RfCalVer); - PUTD_TO_PAGE(len, page, "Caliberation Date: ", CALDATESZ, - info->RfCalDate); - PUTM_TO_PAGE(len, page, "Media State: %s\n", - (info->mediastate) ? "link" : "no link"); - PUTM_TO_PAGE(len, page, "Connection Status: %s\n", - status[((info->ConStat) & 0x7)]); - PUTM_TO_PAGE(len, page, "RX packets: %ld\n", info->stats.rx_packets); - 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_printf(m, "Connection Time[s]: %ld\n", delta); + seq_printf(m, "Asic ID: %s\n", + (info->AsicID) == ELECTRABUZZ_ID ? "ELECTRABUZZ ASIC" : "MAGNEMITE ASIC"); + seq_putx(m, "SKU: ", SKUSZ, info->Sku); + seq_putx(m, "EUI64: ", EUISZ, info->eui64); + seq_putd(m, "DSP version number: ", DSPVERSZ, info->DspVer); + seq_putx(m, "Hardware Serial Number: ", HWSERNUMSZ, info->HwSerNum); + seq_putx(m, "Caliberation Version: ", CALVERSZ, info->RfCalVer); + seq_putd(m, "Caliberation Date: ", CALDATESZ, info->RfCalDate); + seq_printf(m, "Media State: %s\n", (info->mediastate) ? "link" : "no link"); + seq_printf(m, "Connection Status: %s\n", status[info->ConStat & 0x7]); + seq_printf(m, "RX packets: %ld\n", info->stats.rx_packets); + seq_printf(m, "TX packets: %ld\n", info->stats.tx_packets); + seq_printf(m, "RX bytes: %ld\n", info->stats.rx_bytes); + seq_printf(m, "TX bytes: %ld\n", info->stats.tx_bytes); + seq_printf(m, "Signal Strength: %s\n", signal[strength]); + seq_printf(m, "Signal Quality: %s\n", signal[quality]); + return 0; +} + +/* + * 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, void *ptr) { @@ -186,9 +175,9 @@ ft1000NotifyProc(struct notifier_block *this, unsigned long event, void *ptr) switch (event) { case NETDEV_CHANGENAME: remove_proc_entry(info->netdevname, info->ft1000_proc_dir); - ft1000_proc_file = create_proc_read_entry(dev->name, 0644, - info->ft1000_proc_dir, - ft1000ReadProc, dev); + ft1000_proc_file = + proc_create_data(dev->name, 0644, info->ft1000_proc_dir, + &ft1000_proc_fops, dev); snprintf(info->netdevname, IFNAMSIZ, "%s", dev->name); break; } @@ -217,10 +206,10 @@ int ft1000_init_proc(struct net_device *dev) } ft1000_proc_file = - 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); - if (ft1000_proc_file == NULL) { + if (!ft1000_proc_file) { printk(KERN_WARNING "Unable to create /proc entry.\n"); goto fail_entry; } |