diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-05-01 17:51:54 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-05-01 17:51:54 -0700 |
commit | 20b4fb485227404329e41ad15588afad3df23050 (patch) | |
tree | f3e099f0ab3da8a93b447203e294d2bb22f6dc05 /drivers/staging | |
parent | b9394d8a657cd3c064fa432aa0905c1b58b38fe9 (diff) | |
parent | ac3e3c5b1164397656df81b9e9ab4991184d3236 (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull VFS updates from Al Viro,
Misc cleanups all over the place, mainly wrt /proc interfaces (switch
create_proc_entry to proc_create(), get rid of the deprecated
create_proc_read_entry() in favor of using proc_create_data() and
seq_file etc).
7kloc removed.
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (204 commits)
don't bother with deferred freeing of fdtables
proc: Move non-public stuff from linux/proc_fs.h to fs/proc/internal.h
proc: Make the PROC_I() and PDE() macros internal to procfs
proc: Supply a function to remove a proc entry by PDE
take cgroup_open() and cpuset_open() to fs/proc/base.c
ppc: Clean up scanlog
ppc: Clean up rtas_flash driver somewhat
hostap: proc: Use remove_proc_subtree()
drm: proc: Use remove_proc_subtree()
drm: proc: Use minor->index to label things, not PDE->name
drm: Constify drm_proc_list[]
zoran: Don't print proc_dir_entry data in debug
reiserfs: Don't access the proc_dir_entry in r_open(), r_start() r_show()
proc: Supply an accessor for getting the data from a PDE's parent
airo: Use remove_proc_subtree()
rtl8192u: Don't need to save device proc dir PDE
rtl8187se: Use a dir under /proc/net/r8180/
proc: Add proc_mkdir_data()
proc: Move some bits from linux/proc_fs.h to linux/{of.h,signal.h,tty.h}
proc: Move PDE_NET() to fs/proc/proc_net.c
...
Diffstat (limited to 'drivers/staging')
41 files changed, 1600 insertions, 5702 deletions
diff --git a/drivers/staging/comedi/proc.c b/drivers/staging/comedi/proc.c index 362c214bcc0..db790f9fc9d 100644 --- a/drivers/staging/comedi/proc.c +++ b/drivers/staging/comedi/proc.c @@ -31,17 +31,15 @@ #include "comedidev.h" #include "comedi_internal.h" #include <linux/proc_fs.h> -#include <linux/string.h> +#include <linux/seq_file.h> -static int comedi_read(char *buf, char **start, off_t offset, int len, - int *eof, void *data) +static int comedi_read(struct seq_file *m, void *v) { int i; int devices_q = 0; - int l = 0; struct comedi_driver *driv; - l += sprintf(buf + l, + seq_printf(m, "comedi version " COMEDI_RELEASE "\n" "format string: %s\n", "\"%2d: %-20s %-20s %4d\", i, " @@ -49,42 +47,51 @@ static int comedi_read(char *buf, char **start, off_t offset, int len, for (i = 0; i < COMEDI_NUM_BOARD_MINORS; i++) { struct comedi_device *dev = comedi_dev_from_minor(i); - if (!dev) continue; if (dev->attached) { devices_q = 1; - l += sprintf(buf + l, "%2d: %-20s %-20s %4d\n", - i, - dev->driver->driver_name, - dev->board_name, dev->n_subdevices); + seq_printf(m, "%2d: %-20s %-20s %4d\n", + i, dev->driver->driver_name, + dev->board_name, dev->n_subdevices); } } if (!devices_q) - l += sprintf(buf + l, "no devices\n"); + seq_puts(m, "no devices\n"); for (driv = comedi_drivers; driv; driv = driv->next) { - l += sprintf(buf + l, "%s:\n", driv->driver_name); - for (i = 0; i < driv->num_names; i++) { - l += sprintf(buf + l, " %s\n", - *(char **)((char *)driv->board_name + - i * driv->offset)); - } + seq_printf(m, "%s:\n", driv->driver_name); + for (i = 0; i < driv->num_names; i++) + seq_printf(m, " %s\n", + *(char **)((char *)driv->board_name + + i * driv->offset)); + if (!driv->num_names) - l += sprintf(buf + l, " %s\n", driv->driver_name); + seq_printf(m, " %s\n", driv->driver_name); } - return l; + return 0; } -void comedi_proc_init(void) +/* + * seq_file wrappers for procfile show routines. + */ +static int comedi_proc_open(struct inode *inode, struct file *file) { - struct proc_dir_entry *comedi_proc; + return single_open(file, comedi_read, NULL); +} + +static const struct file_operations comedi_proc_fops = { + .open = comedi_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; - comedi_proc = create_proc_entry("comedi", S_IFREG | S_IRUGO, NULL); - if (comedi_proc) - comedi_proc->read_proc = comedi_read; +void comedi_proc_init(void) +{ + proc_create("comedi", 0644, NULL, &comedi_proc_fops); } void comedi_proc_cleanup(void) diff --git a/drivers/staging/csr/csr_wifi_hip_udi.c b/drivers/staging/csr/csr_wifi_hip_udi.c index a65b822db69..a6b006b0e98 100644 --- a/drivers/staging/csr/csr_wifi_hip_udi.c +++ b/drivers/staging/csr/csr_wifi_hip_udi.c @@ -24,10 +24,50 @@ * * --------------------------------------------------------------------------- */ +#include <linux/seq_file.h> #include "csr_wifi_hip_unifi.h" #include "csr_wifi_hip_card.h" +static void unifi_print_unsafe_sdio_status(card_t *card, struct seq_file *m) +{ +#ifdef CSR_UNSAFE_SDIO_ACCESS + s32 iostate; + CsrResult r; + static const char *const states[] = { + "AWAKE", "DROWSY", "TORPID" + }; +#define SHARED_READ_RETRY_LIMIT 10 + u8 b; + + seq_printf(m, "Host State: %s\n", states[card->host_state]); + + r = unifi_check_io_status(card, &iostate); + if (iostate == 1) { + seq_puts(m, remaining, "I/O Check: F1 disabled\n"); + } else { + if (iostate == 1) { + seq_puts(m, "I/O Check: pending interrupt\n"); + + seq_printf(m, "BH reason interrupt = %d\n", card->bh_reason_unifi); + seq_printf(m, "BH reason host = %d\n", card->bh_reason_host); + + for (i = 0; i < SHARED_READ_RETRY_LIMIT; i++) { + r = unifi_read_8_or_16(card, card->sdio_ctrl_addr + 2, &b); + if (r == CSR_RESULT_SUCCESS && !(b & 0x80)) { + seq_printf(m, "fhsr: %u (driver thinks is %u)\n", + b, card->from_host_signals_r); + break; + } + } + + iostate = unifi_read_shared_count(card, card->sdio_ctrl_addr + 4); + seq_printf(m, "thsw: %u (driver thinks is %u)\n", + iostate, card->to_host_signals_w); + } +#endif +} + /* * --------------------------------------------------------------------------- * unifi_print_status @@ -41,228 +81,93 @@ * None. * --------------------------------------------------------------------------- */ -s32 unifi_print_status(card_t *card, char *str, s32 *remain) +s32 unifi_print_status(card_t *card, struct seq_file *m) { - char *p = str; - sdio_config_data_t *cfg; - u16 i, n; - s32 remaining = *remain; - s32 written; -#ifdef CSR_UNSAFE_SDIO_ACCESS - s32 iostate; - CsrResult r; - static const char *const states[] = { - "AWAKE", "DROWSY", "TORPID" - }; - #define SHARED_READ_RETRY_LIMIT 10 - u8 b; -#endif - - if (remaining <= 0) - { - return 0; - } - - i = n = 0; - written = scnprintf(p, remaining, "Chip ID %u\n", - (u16)card->chip_id); - UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "Chip Version %04X\n", - card->chip_version); - UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "HIP v%u.%u\n", - (card->config_data.version >> 8) & 0xFF, - card->config_data.version & 0xFF); - UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "Build %u: %s\n", - card->build_id, card->build_id_string); - UNIFI_SNPRINTF_RET(p, remaining, written); - - cfg = &card->config_data; - - written = scnprintf(p, remaining, "sdio ctrl offset %u\n", - cfg->sdio_ctrl_offset); - UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "fromhost sigbuf handle %u\n", - cfg->fromhost_sigbuf_handle); - UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "tohost_sigbuf_handle %u\n", - cfg->tohost_sigbuf_handle); - UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "num_fromhost_sig_frags %u\n", - cfg->num_fromhost_sig_frags); - UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "num_tohost_sig_frags %u\n", - cfg->num_tohost_sig_frags); - UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "num_fromhost_data_slots %u\n", - cfg->num_fromhost_data_slots); - UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "num_tohost_data_slots %u\n", - cfg->num_tohost_data_slots); - UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "data_slot_size %u\n", - cfg->data_slot_size); - UNIFI_SNPRINTF_RET(p, remaining, written); - - /* Added by protocol version 0x0001 */ - written = scnprintf(p, remaining, "overlay_size %u\n", - (u16)cfg->overlay_size); - UNIFI_SNPRINTF_RET(p, remaining, written); - - /* Added by protocol version 0x0300 */ - written = scnprintf(p, remaining, "data_slot_round %u\n", - cfg->data_slot_round); - UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "sig_frag_size %u\n", - cfg->sig_frag_size); - UNIFI_SNPRINTF_RET(p, remaining, written); - - /* Added by protocol version 0x0300 */ - written = scnprintf(p, remaining, "tohost_sig_pad %u\n", - cfg->tohost_signal_padding); - UNIFI_SNPRINTF_RET(p, remaining, written); - - written = scnprintf(p, remaining, "\nInternal state:\n"); - UNIFI_SNPRINTF_RET(p, remaining, written); - - written = scnprintf(p, remaining, "Last PHY PANIC: %04x:%04x\n", - card->last_phy_panic_code, card->last_phy_panic_arg); - UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "Last MAC PANIC: %04x:%04x\n", - card->last_mac_panic_code, card->last_mac_panic_arg); - UNIFI_SNPRINTF_RET(p, remaining, written); - - written = scnprintf(p, remaining, "fhsr: %u\n", - (u16)card->from_host_signals_r); - UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "fhsw: %u\n", - (u16)card->from_host_signals_w); - UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "thsr: %u\n", - (u16)card->to_host_signals_r); - UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "thsw: %u\n", - (u16)card->to_host_signals_w); - UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, - "fh buffer contains: %d signals, %td bytes\n", - card->fh_buffer.count, - card->fh_buffer.ptr - card->fh_buffer.buf); - UNIFI_SNPRINTF_RET(p, remaining, written); - - written = scnprintf(p, remaining, "paused: "); - UNIFI_SNPRINTF_RET(p, remaining, written); - for (i = 0; i < sizeof(card->tx_q_paused_flag) / sizeof(card->tx_q_paused_flag[0]); i++) - { - written = scnprintf(p, remaining, card->tx_q_paused_flag[i]?"1" : "0"); - UNIFI_SNPRINTF_RET(p, remaining, written); - } - written = scnprintf(p, remaining, "\n"); - UNIFI_SNPRINTF_RET(p, remaining, written); - - written = scnprintf(p, remaining, - "fh command q: %u waiting, %u free of %u:\n", - CSR_WIFI_HIP_Q_SLOTS_USED(&card->fh_command_queue), - CSR_WIFI_HIP_Q_SLOTS_FREE(&card->fh_command_queue), - UNIFI_SOFT_COMMAND_Q_LENGTH); - UNIFI_SNPRINTF_RET(p, remaining, written); - for (i = 0; i < UNIFI_NO_OF_TX_QS; i++) - { - written = scnprintf(p, remaining, - "fh traffic q[%u]: %u waiting, %u free of %u:\n", - i, - CSR_WIFI_HIP_Q_SLOTS_USED(&card->fh_traffic_queue[i]), - CSR_WIFI_HIP_Q_SLOTS_FREE(&card->fh_traffic_queue[i]), - UNIFI_SOFT_TRAFFIC_Q_LENGTH); - UNIFI_SNPRINTF_RET(p, remaining, written); - } - - written = scnprintf(p, remaining, "fh data slots free: %u\n", - card->from_host_data?CardGetFreeFromHostDataSlots(card) : 0); - UNIFI_SNPRINTF_RET(p, remaining, written); - - - written = scnprintf(p, remaining, "From host data slots:"); - UNIFI_SNPRINTF_RET(p, remaining, written); - n = card->config_data.num_fromhost_data_slots; - for (i = 0; i < n && card->from_host_data; i++) - { - written = scnprintf(p, remaining, " %u", - (u16)card->from_host_data[i].bd.data_length); - UNIFI_SNPRINTF_RET(p, remaining, written); - } - written = scnprintf(p, remaining, "\n"); - UNIFI_SNPRINTF_RET(p, remaining, written); - - written = scnprintf(p, remaining, "To host data slots:"); - UNIFI_SNPRINTF_RET(p, remaining, written); - n = card->config_data.num_tohost_data_slots; - for (i = 0; i < n && card->to_host_data; i++) - { - written = scnprintf(p, remaining, " %u", - (u16)card->to_host_data[i].data_length); - UNIFI_SNPRINTF_RET(p, remaining, written); - } - - written = scnprintf(p, remaining, "\n"); - UNIFI_SNPRINTF_RET(p, remaining, written); - -#ifdef CSR_UNSAFE_SDIO_ACCESS - written = scnprintf(p, remaining, "Host State: %s\n", states[card->host_state]); - UNIFI_SNPRINTF_RET(p, remaining, written); - - r = unifi_check_io_status(card, &iostate); - if (iostate == 1) - { - written = scnprintf(p, remaining, "I/O Check: F1 disabled\n"); - UNIFI_SNPRINTF_RET(p, remaining, written); - } - else - { - if (iostate == 1) - { - written = scnprintf(p, remaining, "I/O Check: pending interrupt\n"); - UNIFI_SNPRINTF_RET(p, remaining, written); - } - - written = scnprintf(p, remaining, "BH reason interrupt = %d\n", - card->bh_reason_unifi); - UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "BH reason host = %d\n", - card->bh_reason_host); - UNIFI_SNPRINTF_RET(p, remaining, written); - - for (i = 0; i < SHARED_READ_RETRY_LIMIT; i++) - { - r = unifi_read_8_or_16(card, card->sdio_ctrl_addr + 2, &b); - if ((r == CSR_RESULT_SUCCESS) && (!(b & 0x80))) - { - written = scnprintf(p, remaining, "fhsr: %u (driver thinks is %u)\n", - b, card->from_host_signals_r); - UNIFI_SNPRINTF_RET(p, remaining, written); - break; - } - } - iostate = unifi_read_shared_count(card, card->sdio_ctrl_addr + 4); - written = scnprintf(p, remaining, "thsw: %u (driver thinks is %u)\n", - iostate, card->to_host_signals_w); - UNIFI_SNPRINTF_RET(p, remaining, written); - } -#endif - - written = scnprintf(p, remaining, "\nStats:\n"); - UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "Total SDIO bytes: R=%u W=%u\n", - card->sdio_bytes_read, card->sdio_bytes_written); - - UNIFI_SNPRINTF_RET(p, remaining, written); - written = scnprintf(p, remaining, "Interrupts generated on card: %u\n", - card->unifi_interrupt_seq); - UNIFI_SNPRINTF_RET(p, remaining, written); - - *remain = remaining; - return (p - str); -} /* unifi_print_status() */ - - + sdio_config_data_t *cfg; + u16 i, n; + + i = n = 0; + seq_printf(m, "Chip ID %u\n", card->chip_id); + seq_printf(m, "Chip Version %04X\n", card->chip_version); + seq_printf(m, "HIP v%u.%u\n", + (card->config_data.version >> 8) & 0xFF, + card->config_data.version & 0xFF); + seq_printf(m, "Build %u: %s\n", card->build_id, card->build_id_string); + + cfg = &card->config_data; + + seq_printf(m, "sdio ctrl offset %u\n", cfg->sdio_ctrl_offset); + seq_printf(m, "fromhost sigbuf handle %u\n", cfg->fromhost_sigbuf_handle); + seq_printf(m, "tohost_sigbuf_handle %u\n", cfg->tohost_sigbuf_handle); + seq_printf(m, "num_fromhost_sig_frags %u\n", cfg->num_fromhost_sig_frags); + seq_printf(m, "num_tohost_sig_frags %u\n", cfg->num_tohost_sig_frags); + seq_printf(m, "num_fromhost_data_slots %u\n", cfg->num_fromhost_data_slots); + seq_printf(m, "num_tohost_data_slots %u\n", cfg->num_tohost_data_slots); + seq_printf(m, "data_slot_size %u\n", cfg->data_slot_size); + + /* Added by protocol version 0x0001 */ + seq_printf(m, "overlay_size %u\n", cfg->overlay_size); + + /* Added by protocol version 0x0300 */ + seq_printf(m, "data_slot_round %u\n", cfg->data_slot_round); + seq_printf(m, "sig_frag_size %u\n", cfg->sig_frag_size); + + /* Added by protocol version 0x0300 */ + seq_printf(m, "tohost_sig_pad %u\n", cfg->tohost_signal_padding); + + seq_puts(m, "\nInternal state:\n"); + + seq_printf(m, "Last PHY PANIC: %04x:%04x\n", + card->last_phy_panic_code, card->last_phy_panic_arg); + seq_printf(m, "Last MAC PANIC: %04x:%04x\n", + card->last_mac_panic_code, card->last_mac_panic_arg); + + seq_printf(m, "fhsr: %hu\n", (u16)card->from_host_signals_r); + seq_printf(m, "fhsw: %hu\n", (u16)card->from_host_signals_w); + seq_printf(m, "thsr: %hu\n", (u16)card->to_host_signals_r); + seq_printf(m, "thsw: %hu\n", (u16)card->to_host_signals_w); + seq_printf(m, "fh buffer contains: %d signals, %td bytes\n", + card->fh_buffer.count, + card->fh_buffer.ptr - card->fh_buffer.buf); + + seq_puts(m, "paused: "); + for (i = 0; i < ARRAY_SIZE(card->tx_q_paused_flag); i++) + seq_printf(m, card->tx_q_paused_flag[i] ? "1" : "0"); + seq_putc(m, '\n'); + + seq_printf(m, "fh command q: %u waiting, %u free of %u:\n", + CSR_WIFI_HIP_Q_SLOTS_USED(&card->fh_command_queue), + CSR_WIFI_HIP_Q_SLOTS_FREE(&card->fh_command_queue), + UNIFI_SOFT_COMMAND_Q_LENGTH); + + for (i = 0; i < UNIFI_NO_OF_TX_QS; i++) + seq_printf(m, "fh traffic q[%u]: %u waiting, %u free of %u:\n", + i, + CSR_WIFI_HIP_Q_SLOTS_USED(&card->fh_traffic_queue[i]), + CSR_WIFI_HIP_Q_SLOTS_FREE(&card->fh_traffic_queue[i]), + UNIFI_SOFT_TRAFFIC_Q_LENGTH); + + seq_printf(m, "fh data slots free: %u\n", + card->from_host_data ? CardGetFreeFromHostDataSlots(card) : 0); + + seq_puts(m, "From host data slots:"); + n = card->config_data.num_fromhost_data_slots; + for (i = 0; i < n && card->from_host_data; i++) + seq_printf(m, " %hu", (u16)card->from_host_data[i].bd.data_length); + seq_putc(m, '\n'); + + seq_puts(m, "To host data slots:"); + n = card->config_data.num_tohost_data_slots; + for (i = 0; i < n && card->to_host_data; i++) + seq_printf(m, " %hu", (u16)card->to_host_data[i].data_length); + seq_putc(m, '\n'); + + unifi_print_unsafe_sdio_status(card, m); + + seq_puts(m, "\nStats:\n"); + seq_printf(m, "Total SDIO bytes: R=%u W=%u\n", + card->sdio_bytes_read, card->sdio_bytes_written); + + seq_printf(m, "Interrupts generated on card: %u\n", card->unifi_interrupt_seq); + return 0; +} diff --git a/drivers/staging/csr/csr_wifi_hip_unifi_udi.h b/drivers/staging/csr/csr_wifi_hip_unifi_udi.h index 9d85cfd5761..4126e85bfe9 100644 --- a/drivers/staging/csr/csr_wifi_hip_unifi_udi.h +++ b/drivers/staging/csr/csr_wifi_hip_unifi_udi.h @@ -47,21 +47,6 @@ CsrResult unifi_remove_udi_hook(card_t *card, udi_func_t udi_fn); * This is used in the linux /proc interface and might be useful * in other systems. */ -s32 unifi_print_status(card_t *card, char *str, s32 *remain); - -#define UNIFI_SNPRINTF_RET(buf_p, remain, written) \ - do { \ - if (written >= remain) { \ - if (remain >= 2) { \ - buf_p[remain - 2] = '\n'; \ - buf_p[remain - 1] = 0; \ - } \ - buf_p += remain; \ - remain = 0; \ - } else if (written > 0) { \ - buf_p += written; \ - remain -= written; \ - } \ - } while (0) +s32 unifi_print_status(card_t *card, struct seq_file *m); #endif /* __CSR_WIFI_HIP_UNIFI_UDI_H__ */ diff --git a/drivers/staging/csr/drv.c b/drivers/staging/csr/drv.c index 5520d6539f7..bdc25236ab0 100644 --- a/drivers/staging/csr/drv.c +++ b/drivers/staging/csr/drv.c @@ -1941,7 +1941,7 @@ uf_sme_queue_message(unifi_priv_t *priv, u8 *buffer, int length) * **************************************************************************** */ -static struct file_operations unifi_fops = { +static const struct file_operations unifi_fops = { .owner = THIS_MODULE, .open = unifi_open, .release = unifi_release, @@ -2041,7 +2041,7 @@ void uf_destroy_device_nodes(unifi_priv_t *priv) * ---------------------------------------------------------------- */ static int -uf_create_debug_device(struct file_operations *fops) +uf_create_debug_device(const struct file_operations *fops) { int ret; diff --git a/drivers/staging/csr/io.c b/drivers/staging/csr/io.c index af9c28f073b..f9b5c22c00b 100644 --- a/drivers/staging/csr/io.c +++ b/drivers/staging/csr/io.c @@ -31,6 +31,7 @@ * --------------------------------------------------------------------------- */ #include <linux/proc_fs.h> +#include <linux/seq_file.h> #include "csr_wifi_hip_unifi.h" #include "csr_wifi_hip_unifiversion.h" @@ -76,9 +77,28 @@ DEFINE_SEMAPHORE(Unifi_instance_mutex); */ DECLARE_WAIT_QUEUE_HEAD(Unifi_cleanup_wq); +#ifdef CONFIG_PROC_FS +/* + * seq_file wrappers for procfile show routines. + */ +static int uf_proc_show(struct seq_file *m, void *v); + +#define UNIFI_DEBUG_TXT_BUFFER (8 * 1024) + +static int uf_proc_open(struct inode *inode, struct file *file) +{ + return single_open_size(file, uf_proc_show, PDE_DATA(inode), + UNIFI_DEBUG_TXT_BUFFER); +} + +static const struct file_operations uf_proc_fops = { + .open = uf_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; -static int uf_read_proc(char *page, char **start, off_t offset, int count, - int *eof, void *data); +#endif /* CONFIG_PROC_FS */ #ifdef CSR_WIFI_RX_PATH_SPLIT @@ -327,8 +347,8 @@ register_unifi_sdio(CsrSdioFunction *sdio_dev, int bus_id, struct device *dev) * The following complex casting is in place in order to eliminate 64-bit compilation warning * "cast to/from pointer from/to integer of different size" */ - if (!create_proc_read_entry(priv->proc_entry_name, 0, 0, - uf_read_proc, (void *)(long)priv->instance)) + if (!proc_create_data(priv->proc_entry_name, 0, NULL, + &uf_proc_fops, (void *)(long)priv->instance)) { unifi_error(priv, "unifi: can't create /proc/driver/unifi\n"); } @@ -827,7 +847,7 @@ uf_put_instance(int inst) /* * --------------------------------------------------------------------------- - * uf_read_proc + * uf_proc_show * * Read method for driver node in /proc/driver/unifi0 * @@ -844,107 +864,54 @@ uf_put_instance(int inst) * --------------------------------------------------------------------------- */ #ifdef CONFIG_PROC_FS -static int -uf_read_proc(char *page, char **start, off_t offset, int count, - int *eof, void *data) +static int uf_proc_show(struct seq_file *m, void *v) { -#define UNIFI_DEBUG_TXT_BUFFER 8*1024 - unifi_priv_t *priv; - int actual_amount_to_copy; - char *p, *orig_p; - s32 remain = UNIFI_DEBUG_TXT_BUFFER; - s32 written; - int i; - - /* - * The following complex casting is in place in order to eliminate 64-bit compilation warning - * "cast to/from pointer from/to integer of different size" - */ - priv = uf_find_instance((int)(long)data); - if (!priv) { - return 0; - } - - p = kmalloc( UNIFI_DEBUG_TXT_BUFFER, GFP_KERNEL ); - - orig_p = p; - - written = scnprintf(p, remain, "UniFi SDIO Driver: %s %s %s\n", - CSR_WIFI_VERSION, __DATE__, __TIME__); - UNIFI_SNPRINTF_RET(p, remain, written); + unifi_priv_t *priv; + int i; + + /* + * The following complex casting is in place in order to eliminate + * 64-bit compilation warning "cast to/from pointer from/to integer of + * different size" + */ + priv = uf_find_instance((long)m->private); + if (!priv) + return 0; + + seq_printf(m, "UniFi SDIO Driver: %s %s %s\n", + CSR_WIFI_VERSION, __DATE__, __TIME__); #ifdef CSR_SME_USERSPACE - written = scnprintf(p, remain, "SME: CSR userspace "); - UNIFI_SNPRINTF_RET(p, remain, written); + seq_puts(m, "SME: CSR userspace "); #ifdef CSR_SUPPORT_WEXT - written = scnprintf(p, remain, "with WEXT support\n"); + seq_puts(m, "with WEXT support\n"); #else - written = scnprintf(p, remain, "\n"); + seq_putc(m, '\n'); #endif /* CSR_SUPPORT_WEXT */ - UNIFI_SNPRINTF_RET(p, remain, written); #endif /* CSR_SME_USERSPACE */ #ifdef CSR_NATIVE_LINUX - written = scnprintf(p, remain, "SME: native\n"); - UNIFI_SNPRINTF_RET(p, remain, written); + seq_puts(m, "SME: native\n"); #endif #ifdef CSR_SUPPORT_SME - written = scnprintf(p, remain, - "Firmware (ROM) build:%u, Patch:%u\n", - priv->card_info.fw_build, - priv->sme_versions.firmwarePatch); - UNIFI_SNPRINTF_RET(p, remain, written); + seq_printf(m, "Firmware (ROM) build:%u, Patch:%u\n", + priv->card_info.fw_build, + priv->sme_versions.firmwarePatch); #endif - p += unifi_print_status(priv->card, p, &remain); - - written = scnprintf(p, remain, "Last dbg str: %s\n", - priv->last_debug_string); - UNIFI_SNPRINTF_RET(p, remain, written); - - written = scnprintf(p, remain, "Last dbg16:"); - UNIFI_SNPRINTF_RET(p, remain, written); - for (i = 0; i < 8; i++) { - written = scnprintf(p, remain, " %04X", - priv->last_debug_word16[i]); - UNIFI_SNPRINTF_RET(p, remain, written); - } - written = scnprintf(p, remain, "\n"); - UNIFI_SNPRINTF_RET(p, remain, written); - written = scnprintf(p, remain, " "); - UNIFI_SNPRINTF_RET(p, remain, written); - for (; i < 16; i++) { - written = scnprintf(p, remain, " %04X", - priv->last_debug_word16[i]); - UNIFI_SNPRINTF_RET(p, remain, written); - } - written = scnprintf(p, remain, "\n"); - UNIFI_SNPRINTF_RET(p, remain, written); - *start = page; - - written = UNIFI_DEBUG_TXT_BUFFER - remain; - - if( offset >= written ) - { - *eof = 1; - kfree( orig_p ); - return(0); - } - - if( offset + count > written ) - { - actual_amount_to_copy = written - offset; - *eof = 1; - } - else - { - actual_amount_to_copy = count; - } - memcpy( page, &(orig_p[offset]), actual_amount_to_copy ); + unifi_print_status(priv->card, m); - kfree( orig_p ); + seq_printf(m, "Last dbg str: %s\n", priv->last_debug_string); - return( actual_amount_to_copy ); -} /* uf_read_proc() */ + seq_puts(m, "Last dbg16:"); + for (i = 0; i < 8; i++) + seq_printf(m, " %04X", priv->last_debug_word16[i]); + seq_putc(m, '\n'); + seq_puts(m, " "); + for (; i < 16; i++) + seq_printf(m, " %04X", priv->last_debug_word16[i]); + seq_putc(m, '\n'); + return 0; +} #endif diff --git a/drivers/staging/cxt1e1/Makefile b/drivers/staging/cxt1e1/Makefile index e99b8231182..b9ccb765025 100644 --- a/drivers/staging/cxt1e1/Makefile +++ b/drivers/staging/cxt1e1/Makefile @@ -12,8 +12,9 @@ cxt1e1-y := \ linux.o \ functions.o \ hwprobe.o \ - sbeproc.o \ pmc93x6_eeprom.o \ sbecrc.o \ comet_tables.o \ sbeid.o + +cxt1e1-$(CONFIG_PROC_FS) += sbeproc.o diff --git a/drivers/staging/cxt1e1/sbeproc.c b/drivers/staging/cxt1e1/sbeproc.c index f42531c3d8d..49f10f0b7d2 100644 --- a/drivers/staging/cxt1e1/sbeproc.c +++ b/drivers/staging/cxt1e1/sbeproc.c @@ -19,6 +19,7 @@ #include <linux/kernel.h> #include <linux/init.h> #include <linux/proc_fs.h> +#include <linux/seq_file.h> #include <linux/sched.h> #include <asm/uaccess.h> #include "pmcc4_sysdep.h" @@ -26,332 +27,193 @@ #include "pmcc4_private.h" #include "sbeproc.h" -/* forwards */ -void sbecom_get_brdinfo (ci_t *, struct sbe_brd_info *, u_int8_t *); +extern void sbecom_get_brdinfo(ci_t *, struct sbe_brd_info *, u_int8_t *); extern struct s_hdw_info hdw_info[MAX_BOARDS]; -#ifdef CONFIG_PROC_FS - -/********************************************************************/ -/* procfs stuff */ -/********************************************************************/ - - -void -sbecom_proc_brd_cleanup (ci_t * ci) +void sbecom_proc_brd_cleanup(ci_t *ci) { - if (ci->dir_dev) - { - char dir[7 + SBE_IFACETMPL_SIZE + 1]; - snprintf(dir, sizeof(dir), "driver/%s", ci->devname); - remove_proc_entry("info", ci->dir_dev); - remove_proc_entry(dir, NULL); - ci->dir_dev = NULL; - } + if (ci->dir_dev) { + char dir[7 + SBE_IFACETMPL_SIZE + 1]; + snprintf(dir, sizeof(dir), "driver/%s", ci->devname); + remove_proc_entry("info", ci->dir_dev); + remove_proc_entry(dir, NULL); + ci->dir_dev = NULL; + } } - -static int -sbecom_proc_get_sbe_info (char *buffer, char **start, off_t offset, - int length, int *eof, void *priv) +static void sbecom_proc_get_brdinfo(ci_t *ci, struct sbe_brd_info *bip) { - ci_t *ci = (ci_t *) priv; - int len = 0; - char *spd; - struct sbe_brd_info *bip; - - if (!(bip = OS_kmalloc (sizeof (struct sbe_brd_info)))) - { - return -ENOMEM; - } -#if 0 - /** RLD DEBUG **/ - pr_info(">> sbecom_proc_get_sbe_info: entered, offset %d. length %d.\n", - (int) offset, (int) length); -#endif - - { - hdw_info_t *hi = &hdw_info[ci->brdno]; - - u_int8_t *bsn = 0; - - switch (hi->promfmt) - { - case PROM_FORMAT_TYPE1: - bsn = (u_int8_t *) hi->mfg_info.pft1.Serial; - break; - case PROM_FORMAT_TYPE2: - bsn = (u_int8_t *) hi->mfg_info.pft2.Serial; - break; - } - - sbecom_get_brdinfo (ci, bip, bsn); - } - -#if 0 - /** RLD DEBUG **/ - pr_info(">> sbecom_get_brdinfo: returned, first_if %p <%s> last_if %p <%s>\n", - (char *) &bip->first_iname, (char *) &bip->first_iname, - (char *) &bip->last_iname, (char *) &bip->last_iname); -#endif - len += sprintf (buffer + len, "Board Type: "); - switch (bip->brd_id) - { - case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C1T3): - len += sprintf (buffer + len, "wanPMC-C1T3"); - break; - case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPTMC_256T3_E1): - len += sprintf (buffer + len, "wanPTMC-256T3 <E1>"); - break; - case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPTMC_256T3_T1): - len += sprintf (buffer + len, "wanPTMC-256T3 <T1>"); - break; - case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPTMC_C24TE1): - len += sprintf (buffer + len, "wanPTMC-C24TE1"); - break; - - case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C4T1E1): - case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C4T1E1_L): - len += sprintf (buffer + len, "wanPMC-C4T1E1"); - break; - case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C2T1E1): - case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C2T1E1_L): - len += sprintf (buffer + len, "wanPMC-C2T1E1"); - break; - case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C1T1E1): - case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C1T1E1_L): - len += sprintf (buffer + len, "wanPMC-C1T1E1"); - break; - - case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPCI_C4T1E1): - len += sprintf (buffer + len, "wanPCI-C4T1E1"); - break; - case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPCI_C2T1E1): - len += sprintf (buffer + len, "wanPCI-C2T1E1"); - break; - case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPCI_C1T1E1): - len += sprintf (buffer + len, "wanPCI-C1T1E1"); - break; - - default: - len += sprintf (buffer + len, "unknown"); - break; - } - len += sprintf (buffer + len, " [%08X]\n", bip->brd_id); + hdw_info_t *hi = &hdw_info[ci->brdno]; + u_int8_t *bsn = 0; + + switch (hi->promfmt) + { + case PROM_FORMAT_TYPE1: + bsn = (u_int8_t *) hi->mfg_info.pft1.Serial; + break; + case PROM_FORMAT_TYPE2: + bsn = (u_int8_t *) hi->mfg_info.pft2.Serial; + break; + } + + sbecom_get_brdinfo (ci, bip, bsn); + + pr_devel(">> sbecom_get_brdinfo: returned, first_if %p <%s> last_if %p <%s>\n", + bip->first_iname, bip->first_iname, + bip->last_iname, bip->last_iname); +} - len += sprintf (buffer + len, "Board Number: %d\n", bip->brdno); - len += sprintf (buffer + len, "Hardware ID: 0x%02X\n", ci->hdw_bid); - len += sprintf (buffer + len, "Board SN: %06X\n", bip->brd_sn); - len += sprintf(buffer + len, "Board MAC: %pMF\n", - bip->brd_mac_addr); - len += sprintf (buffer + len, "Ports: %d\n", ci->max_port); - len += sprintf (buffer + len, "Channels: %d\n", bip->brd_chan_cnt); +/* + * Describe the driver state through /proc + */ +static int sbecom_proc_get_sbe_info(struct seq_file *m, void *v) +{ + ci_t *ci = m->private; + char *spd; + struct sbe_brd_info *bip; + + if (!(bip = OS_kmalloc(sizeof(struct sbe_brd_info)))) + return -ENOMEM; + + pr_devel(">> sbecom_proc_get_sbe_info: entered\n"); + + sbecom_proc_get_brdinfo(ci, bip); + + seq_puts(m, "Board Type: "); + switch (bip->brd_id) { + case SBE_BOARD_ID(PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C1T3): + seq_puts(m, "wanPMC-C1T3"); + break; + case SBE_BOARD_ID(PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPTMC_256T3_E1): + seq_puts(m, "wanPTMC-256T3 <E1>"); + break; + case SBE_BOARD_ID(PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPTMC_256T3_T1): + seq_puts(m, "wanPTMC-256T3 <T1>"); + break; + case SBE_BOARD_ID(PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPTMC_C24TE1): + seq_puts(m, "wanPTMC-C24TE1"); + break; + + case SBE_BOARD_ID(PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C4T1E1): + case SBE_BOARD_ID(PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C4T1E1_L): + seq_puts(m, "wanPMC-C4T1E1"); + break; + case SBE_BOARD_ID(PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C2T1E1): + case SBE_BOARD_ID(PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C2T1E1_L): + seq_puts(m, "wanPMC-C2T1E1"); + break; + case SBE_BOARD_ID(PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C1T1E1): + case SBE_BOARD_ID(PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C1T1E1_L): + seq_puts(m, "wanPMC-C1T1E1"); + break; + + case SBE_BOARD_ID(PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPCI_C4T1E1): + seq_puts(m, "wanPCI-C4T1E1"); + break; + case SBE_BOARD_ID(PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPCI_C2T1E1): + seq_puts(m, "wanPCI-C2T1E1"); + break; + case SBE_BOARD_ID(PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPCI_C1T1E1): + seq_puts(m, "wanPCI-C1T1E1"); + break; + + default: + seq_puts(m, "unknown"); + break; + } + + seq_printf(m, " [%08X]\n", bip->brd_id); + + seq_printf(m, "Board Number: %d\n", bip->brdno); + seq_printf(m, "Hardware ID: 0x%02X\n", ci->hdw_bid); + seq_printf(m, "Board SN: %06X\n", bip->brd_sn); + seq_printf(m, "Board MAC: %pMF\n", bip->brd_mac_addr); + seq_printf(m, "Ports: %d\n", ci->max_port); + seq_printf(m, "Channels: %d\n", bip->brd_chan_cnt); #if 1 - len += sprintf (buffer + len, "Interface: %s -> %s\n", - (char *) &bip->first_iname, (char *) &bip->last_iname); + seq_printf(m, "Interface: %s -> %s\n", + bip->first_iname, bip->last_iname); #else - len += sprintf (buffer + len, "Interface: <not available> 1st %p lst %p\n", - (char *) &bip->first_iname, (char *) &bip->last_iname); + seq_printf(m, "Interface: <not available> 1st %p lst %p\n", + bip->first_iname, bip->last_iname); #endif - switch (bip->brd_pci_speed) - { - case BINFO_PCI_SPEED_33: - spd = "33Mhz"; - break; - case BINFO_PCI_SPEED_66: - spd = "66Mhz"; - break; - default: - spd = "<not available>"; - break; - } - len += sprintf (buffer + len, "PCI Bus Speed: %s\n", spd); - len += sprintf (buffer + len, "Release: %s\n", ci->release); + switch (bip->brd_pci_speed) { + case BINFO_PCI_SPEED_33: + spd = "33Mhz"; + break; + case BINFO_PCI_SPEED_66: + spd = "66Mhz"; + break; + default: + spd = "<not available>"; + break; + } + seq_printf(m, "PCI Bus Speed: %s\n", spd); + seq_printf(m, "Release: %s\n", ci->release); #ifdef SBE_PMCC4_ENABLE - { - extern int cxt1e1_max_mru; -#if 0 - extern int max_chans_used; - extern int cxt1e1_max_mtu; -#endif - extern int max_rxdesc_used, max_txdesc_used; - - len += sprintf (buffer + len, "\ncxt1e1_max_mru: %d\n", cxt1e1_max_mru); + { + extern int cxt1e1_max_mru; #if 0 - len += sprintf (buffer + len, "\nmax_chans_used: %d\n", max_chans_used); - len += sprintf (buffer + len, "cxt1e1_max_mtu: %d\n", cxt1e1_max_mtu); -#endif - len += sprintf (buffer + len, "max_rxdesc_used: %d\n", max_rxdesc_used); - len += sprintf (buffer + len, "max_txdesc_used: %d\n", max_txdesc_used); - } -#endif - - OS_kfree (bip); /* cleanup */ - - /*** - * How to be a proc read function - * ------------------------------ - * Prototype: - * int f(char *buffer, char **start, off_t offset, - * int count, int *peof, void *dat) - * - * Assume that the buffer is "count" bytes in size. - * - * If you know you have supplied all the data you - * have, set *peof. - * - * You have three ways to return data: - * 0) Leave *start = NULL. (This is the default.) - * Put the data of the requested offset at that - * offset within the buffer. Return the number (n) - * of bytes there are from the beginning of the - * buffer up to the last byte of data. If the - * number of supplied bytes (= n - offset) is - * greater than zero and you didn't signal eof - * and the reader is prepared to take more data - * you will be called again with the requested - * offset advanced by the number of bytes - * absorbed. This interface is useful for files - * no larger than the buffer. - * 1) Set *start = an unsigned long value less than - * the buffer address but greater than zero. - * Put the data of the requested offset at the - * beginning of the buffer. Return the number of - * bytes of data placed there. If this number is - * greater than zero and you didn't signal eof - * and the reader is prepared to take more data - * you will be called again with the requested - * offset advanced by *start. This interface is - * useful when you have a large file consisting - * of a series of blocks which you want to count - * and return as wholes. - * (Hack by Paul.Russell@rustcorp.com.au) - * 2) Set *start = an address within the buffer. - * Put the data of the requested offset at *start. - * Return the number of bytes of data placed there. - * If this number is greater than zero and you - * didn't signal eof and the reader is prepared to - * take more data you will be called again with the - * requested offset advanced by the number of bytes - * absorbed. - */ - -#if 1 - /* #4 - interpretation of above = set EOF, return len */ - *eof = 1; + extern int max_chans_used; + extern int cxt1e1_max_mtu; #endif + extern int max_rxdesc_used, max_txdesc_used; + seq_printf(m, "\ncxt1e1_max_mru: %d\n", cxt1e1_max_mru); #if 0 - /* - * #1 - from net/wireless/atmel.c RLD NOTE -there's something wrong with - * this plagarized code which results in this routine being called TWICE. - * The second call returns ZERO, resulting in hidden failure, but at - * least only a single message set is being displayed. - */ - if (len <= offset + length) - *eof = 1; - *start = buffer + offset; - len -= offset; - if (len > length) - len = length; - if (len < 0) - len = 0; -#endif - -#if 0 /* #2 from net/tokenring/olympic.c + - * lanstreamer.c */ - { - off_t begin = 0; - int size = 0; - off_t pos = 0; - - size = len; - pos = begin + size; - if (pos < offset) - { - len = 0; - begin = pos; - } - *start = buffer + (offset - begin); /* Start of wanted data */ - len -= (offset - begin); /* Start slop */ - if (len > length) - len = length; /* Ending slop */ - } + seq_printf(m, "\nmax_chans_used: %d\n", max_chans_used); + seq_printf(m, "cxt1e1_max_mtu: %d\n", cxt1e1_max_mtu); #endif - -#if 0 /* #3 from - * char/ftape/lowlevel/ftape-proc.c */ - len = strlen (buffer); - *start = NULL; - if (offset + length >= len) - *eof = 1; - else - *eof = 0; -#endif - -#if 0 - pr_info(">> proc_fs: returned len = %d., start %p\n", len, start); /* RLD DEBUG */ + seq_printf(m, "max_rxdesc_used: %d\n", max_rxdesc_used); + seq_printf(m, "max_txdesc_used: %d\n", max_txdesc_used); + } #endif -/*** - using NONE: returns = 314.314.314. - using #1 : returns = 314, 0. - using #2 : returns = 314, 0, 0. - using #3 : returns = 314, 314. - using #4 : returns = 314, 314. -***/ + kfree(bip); - return len; + pr_devel(">> proc_fs: finished\n"); + return 0; } -/* initialize the /proc subsystem for the specific SBE driver */ - -int __init -sbecom_proc_brd_init (ci_t * ci) +/* + * seq_file wrappers for procfile show routines. + */ +static int sbecom_proc_open(struct inode *inode, struct file *file) { - struct proc_dir_entry *e; - char dir[7 + SBE_IFACETMPL_SIZE + 1]; - - /* create a directory in the root procfs */ - snprintf(dir, sizeof(dir), "driver/%s", ci->devname); - ci->dir_dev = proc_mkdir(dir, NULL); - if (!ci->dir_dev) - { - pr_err("Unable to create directory /proc/driver/%s\n", ci->devname); - goto fail; - } - e = create_proc_read_entry ("info", S_IFREG | S_IRUGO, - ci->dir_dev, sbecom_proc_get_sbe_info, ci); - if (!e) - { - pr_err("Unable to create entry /proc/driver/%s/info\n", ci->devname); - goto fail; - } - return 0; - -fail: - sbecom_proc_brd_cleanup (ci); - return 1; + return single_open(file, sbecom_proc_get_sbe_info, PDE_DATA(inode)); } -#else /*** ! CONFIG_PROC_FS ***/ +static const struct file_operations sbecom_proc_fops = { + .open = sbecom_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; -/* stubbed off dummy routines */ - -void -sbecom_proc_brd_cleanup (ci_t * ci) -{ -} - -int __init -sbecom_proc_brd_init (ci_t * ci) +/* + * Initialize the /proc subsystem for the specific SBE driver + */ +int __init sbecom_proc_brd_init(ci_t *ci) { - return 0; -} - -#endif /*** CONFIG_PROC_FS ***/ + char dir[7 + SBE_IFACETMPL_SIZE + 1]; + snprintf(dir, sizeof(dir), "driver/%s", ci->devname); + ci->dir_dev = proc_mkdir(dir, NULL); + if (!ci->dir_dev) { + pr_err("Unable to create directory /proc/driver/%s\n", ci->devname); + goto fail; + } + + if (!proc_create_data("info", S_IFREG | S_IRUGO, ci->dir_dev, + &sbecom_proc_fops, ci)) { + pr_err("Unable to create entry /proc/driver/%s/info\n", ci->devname); + goto fail; + } + return 0; -/*** End-of-File ***/ +fail: + sbecom_proc_brd_cleanup(ci); + return 1; +} diff --git a/drivers/staging/cxt1e1/sbeproc.h b/drivers/staging/cxt1e1/sbeproc.h index e82be6afd1e..e5c072cf195 100644 --- a/drivers/staging/cxt1e1/sbeproc.h +++ b/drivers/staging/cxt1e1/sbeproc.h @@ -23,10 +23,20 @@ #ifdef CONFIG_PROC_FS -#ifdef __KERNEL__ void sbecom_proc_brd_cleanup (ci_t *); int __init sbecom_proc_brd_init (ci_t *); -#endif /*** __KERNEL__ ***/ +#else + +static inline void sbecom_proc_brd_cleanup(ci_t * ci) +{ +} + +static inline int __init sbecom_proc_brd_init(ci_t * ci) +{ + return 0; +} + #endif /*** CONFIG_PROC_FS ***/ + #endif /*** _INC_SBEPROC_H_ ***/ diff --git a/drivers/staging/dgrp/dgrp_common.c b/drivers/staging/dgrp/dgrp_common.c index 3553998b72b..9a9b45624ba 100644 --- a/drivers/staging/dgrp/dgrp_common.c +++ b/drivers/staging/dgrp/dgrp_common.c @@ -167,34 +167,3 @@ void dgrp_carrier(struct ch_struct *ch) ch->ch_flag &= ~CH_PHYS_CD; } - -/** - * dgrp_chk_perm() -- check permissions for net device - * @inode: pointer to inode structure for the net communication device - * @op: operation to be tested - * - * The file permissions and ownerships are tested to determine whether - * the operation "op" is permitted on the file pointed to by the inode. - * Returns 0 if the operation is permitted, -EACCESS otherwise - */ -int dgrp_chk_perm(int mode, int op) -{ - if (!uid_eq(GLOBAL_ROOT_UID, current_euid())) - mode >>= 6; - else if (in_egroup_p(GLOBAL_ROOT_GID)) - mode >>= 3; - - if ((mode & op & 0007) == op) - return 0; - - if (capable(CAP_SYS_ADMIN)) - return 0; - - return -EACCES; -} - -/* dgrp_chk_perm wrapper for permission call in struct inode_operations */ -int dgrp_inode_permission(struct inode *inode, int op) -{ - return dgrp_chk_perm(inode->i_mode, op); -} diff --git a/drivers/staging/dgrp/dgrp_common.h b/drivers/staging/dgrp/dgrp_common.h index 2832b8e26c4..23aba6c4d22 100644 --- a/drivers/staging/dgrp/dgrp_common.h +++ b/drivers/staging/dgrp/dgrp_common.h @@ -49,20 +49,20 @@ extern struct dgrp_poll_data dgrp_poll_data; extern void dgrp_poll_handler(unsigned long arg); /* from dgrp_mon_ops.c */ -extern void dgrp_register_mon_hook(struct proc_dir_entry *de); +extern const struct file_operations dgrp_mon_ops; /* from dgrp_tty.c */ extern int dgrp_tty_init(struct nd_struct *nd); extern void dgrp_tty_uninit(struct nd_struct *nd); /* from dgrp_ports_ops.c */ -extern void dgrp_register_ports_hook(struct proc_dir_entry *de); +extern const struct file_operations dgrp_ports_ops; /* from dgrp_net_ops.c */ -extern void dgrp_register_net_hook(struct proc_dir_entry *de); +extern const struct file_operations dgrp_net_ops; /* from dgrp_dpa_ops.c */ -extern void dgrp_register_dpa_hook(struct proc_dir_entry *de); +extern const struct file_operations dgrp_dpa_ops; extern void dgrp_dpa_data(struct nd_struct *, int, u8 *, int); /* from dgrp_sysfs.c */ @@ -76,61 +76,6 @@ extern void dgrp_create_tty_sysfs(struct un_struct *un, struct device *c); extern void dgrp_remove_tty_sysfs(struct device *c); /* from dgrp_specproc.c */ -/* - * The list of DGRP entries with r/w capabilities. These - * magic numbers are used for identification purposes. - */ -enum { - DGRP_CONFIG = 1, /* Configure portservers */ - DGRP_NETDIR = 2, /* Directory for "net" devices */ - DGRP_MONDIR = 3, /* Directory for "mon" devices */ - DGRP_PORTSDIR = 4, /* Directory for "ports" devices */ - DGRP_INFO = 5, /* Get info. about the running module */ - DGRP_NODEINFO = 6, /* Get info. about the configured nodes */ - DGRP_DPADIR = 7, /* Directory for the "dpa" devices */ -}; - -/* - * Directions for proc handlers - */ -enum { - INBOUND = 1, /* Data being written to kernel */ - OUTBOUND = 2, /* Data being read from the kernel */ -}; - -/** - * dgrp_proc_entry: structure for dgrp proc dirs - * @id: ID number associated with this particular entry. Should be - * unique across all of DGRP. - * @name: text name associated with the /proc entry - * @mode: file access permisssions for the /proc entry - * @child: pointer to table describing a subdirectory for this entry - * @de: pointer to directory entry for this object once registered. Used - * to grab the handle of the object for unregistration - * @excl_sem: semaphore to provide exclusive to struct - * @excl_cnt: counter of current accesses - * - * Each entry in a DGRP proc directory is described with a - * dgrp_proc_entry structure. A collection of these - * entries (in an array) represents the members associated - * with a particular /proc directory, and is referred to - * as a table. All tables are terminated by an entry with - * zeros for every member. - */ -struct dgrp_proc_entry { - int id; /* Integer identifier */ - const char *name; /* ASCII identifier */ - mode_t mode; /* File access permissions */ - struct dgrp_proc_entry *child; /* Child pointer */ - - /* file ops to use, pass NULL to use default */ - struct file_operations *proc_file_ops; - - struct proc_dir_entry *de; /* proc entry pointer */ - struct semaphore excl_sem; /* Protects exclusive access var */ - int excl_cnt; /* Counts number of curr accesses */ -}; - extern void dgrp_unregister_proc(void); extern void dgrp_register_proc(void); @@ -144,8 +89,6 @@ extern void dgrp_register_proc(void); *-----------------------------------------------------------------------*/ void dgrp_carrier(struct ch_struct *ch); -extern int dgrp_inode_permission(struct inode *inode, int op); -extern int dgrp_chk_perm(int mode, int op); /* diff --git a/drivers/staging/dgrp/dgrp_dpa_ops.c b/drivers/staging/dgrp/dgrp_dpa_ops.c index ca10a3362e2..114799cddd8 100644 --- a/drivers/staging/dgrp/dgrp_dpa_ops.c +++ b/drivers/staging/dgrp/dgrp_dpa_ops.c @@ -40,6 +40,7 @@ #include <linux/cred.h> #include <linux/sched.h> #include <linux/ratelimit.h> +#include <linux/slab.h> #include <asm/unaligned.h> #include "dgrp_common.h" @@ -52,7 +53,7 @@ static long dgrp_dpa_ioctl(struct file *file, unsigned int cmd, unsigned long arg); static unsigned int dgrp_dpa_select(struct file *, struct poll_table_struct *); -static const struct file_operations dpa_ops = { +const struct file_operations dgrp_dpa_ops = { .owner = THIS_MODULE, .read = dgrp_dpa_read, .poll = dgrp_dpa_select, @@ -61,12 +62,6 @@ static const struct file_operations dpa_ops = { .release = dgrp_dpa_release, }; -static struct inode_operations dpa_inode_ops = { - .permission = dgrp_inode_permission -}; - - - struct digi_node { uint nd_state; /* Node state: 1 = up, 0 = down. */ uint nd_chan_count; /* Number of channels found */ @@ -111,17 +106,6 @@ struct digi_debug { #define DIGI_SETDEBUG (('d'<<8) | 247) /* set debug info */ -void dgrp_register_dpa_hook(struct proc_dir_entry *de) -{ - struct nd_struct *node = de->data; - - de->proc_iops = &dpa_inode_ops; - rcu_assign_pointer(de->proc_fops, &dpa_ops); - - node->nd_dpa_de = de; - spin_lock_init(&node->nd_dpa_lock); -} - /* * dgrp_dpa_open -- open the DPA device for a particular PortServer */ @@ -130,8 +114,6 @@ static int dgrp_dpa_open(struct inode *inode, struct file *file) struct nd_struct *nd; int rtn = 0; - struct proc_dir_entry *de; - rtn = try_module_get(THIS_MODULE); if (!rtn) return -ENXIO; @@ -154,12 +136,7 @@ static int dgrp_dpa_open(struct inode *inode, struct file *file) /* * Get the node pointer, and fail if it doesn't exist. */ - de = PDE(inode); - if (!de) { - rtn = -ENXIO; - goto done; - } - nd = (struct nd_struct *)de->data; + nd = PDE_DATA(inode); if (!nd) { rtn = -ENXIO; goto done; diff --git a/drivers/staging/dgrp/dgrp_mon_ops.c b/drivers/staging/dgrp/dgrp_mon_ops.c index b484fccb494..d18be4180e3 100644 --- a/drivers/staging/dgrp/dgrp_mon_ops.c +++ b/drivers/staging/dgrp/dgrp_mon_ops.c @@ -37,6 +37,7 @@ #include <linux/tty.h> #include <linux/sched.h> #include <asm/unaligned.h> +#include <linux/slab.h> #include <linux/proc_fs.h> #include <linux/uaccess.h> @@ -49,7 +50,7 @@ static ssize_t dgrp_mon_read(struct file *, char __user *, size_t, loff_t *); static long dgrp_mon_ioctl(struct file *file, unsigned int cmd, unsigned long arg); -static const struct file_operations mon_ops = { +const struct file_operations dgrp_mon_ops = { .owner = THIS_MODULE, .read = dgrp_mon_read, .unlocked_ioctl = dgrp_mon_ioctl, @@ -57,20 +58,6 @@ static const struct file_operations mon_ops = { .release = dgrp_mon_release, }; -static struct inode_operations mon_inode_ops = { - .permission = dgrp_inode_permission -}; - -void dgrp_register_mon_hook(struct proc_dir_entry *de) -{ - struct nd_struct *node = de->data; - - de->proc_iops = &mon_inode_ops; - rcu_assign_pointer(de->proc_fops, &mon_ops); - node->nd_mon_de = de; - sema_init(&node->nd_mon_semaphore, 1); -} - /** * dgrp_mon_open() -- open /proc/dgrp/ports device for a PortServer * @inode: struct inode * @@ -81,7 +68,6 @@ void dgrp_register_mon_hook(struct proc_dir_entry *de) static int dgrp_mon_open(struct inode *inode, struct file *file) { struct nd_struct *nd; - struct proc_dir_entry *de; struct timeval tv; uint32_t time; u8 *buf; @@ -109,13 +95,7 @@ static int dgrp_mon_open(struct inode *inode, struct file *file) /* * Get the node pointer, and fail if it doesn't exist. */ - de = PDE(inode); - if (!de) { - rtn = -ENXIO; - goto done; - } - - nd = (struct nd_struct *)de->data; + nd = PDE_DATA(inode); if (!nd) { rtn = -ENXIO; goto done; diff --git a/drivers/staging/dgrp/dgrp_net_ops.c b/drivers/staging/dgrp/dgrp_net_ops.c index 64f48ffb9d4..5b7833f593f 100644 --- a/drivers/staging/dgrp/dgrp_net_ops.c +++ b/drivers/staging/dgrp/dgrp_net_ops.c @@ -35,7 +35,7 @@ #include <linux/module.h> #include <linux/proc_fs.h> -#include <linux/types.h> +#include <linux/slab.h> #include <linux/string.h> #include <linux/device.h> #include <linux/tty.h> @@ -72,7 +72,7 @@ static long dgrp_net_ioctl(struct file *file, unsigned int cmd, static unsigned int dgrp_net_select(struct file *file, struct poll_table_struct *table); -static const struct file_operations net_ops = { +const struct file_operations dgrp_net_ops = { .owner = THIS_MODULE, .read = dgrp_net_read, .write = dgrp_net_write, @@ -82,23 +82,6 @@ static const struct file_operations net_ops = { .release = dgrp_net_release, }; -static struct inode_operations net_inode_ops = { - .permission = dgrp_inode_permission -}; - -void dgrp_register_net_hook(struct proc_dir_entry *de) -{ - struct nd_struct *node = de->data; - - de->proc_iops = &net_inode_ops; - rcu_assign_pointer(de->proc_fops, &net_ops); - node->nd_net_de = de; - sema_init(&node->nd_net_semaphore, 1); - node->nd_state = NS_CLOSED; - dgrp_create_node_class_sysfs_files(node); -} - - /** * dgrp_dump() -- prints memory for debugging purposes. * @mem: Memory location which should be printed to the console @@ -801,7 +784,6 @@ out_err: static int dgrp_net_open(struct inode *inode, struct file *file) { struct nd_struct *nd; - struct proc_dir_entry *de; ulong lock_flags; int rtn; @@ -825,13 +807,7 @@ static int dgrp_net_open(struct inode *inode, struct file *file) /* * Get the node pointer, and fail if it doesn't exist. */ - de = PDE(inode); - if (!de) { - rtn = -ENXIO; - goto done; - } - - nd = (struct nd_struct *) de->data; + nd = PDE_DATA(inode); if (!nd) { rtn = -ENXIO; goto done; diff --git a/drivers/staging/dgrp/dgrp_ports_ops.c b/drivers/staging/dgrp/dgrp_ports_ops.c index f93dc1f262f..4ce030815f2 100644 --- a/drivers/staging/dgrp/dgrp_ports_ops.c +++ b/drivers/staging/dgrp/dgrp_ports_ops.c @@ -47,7 +47,7 @@ /* File operation declarations */ static int dgrp_ports_open(struct inode *, struct file *); -static const struct file_operations ports_ops = { +const struct file_operations dgrp_ports_ops = { .owner = THIS_MODULE, .open = dgrp_ports_open, .read = seq_read, @@ -55,20 +55,6 @@ static const struct file_operations ports_ops = { .release = seq_release }; -static struct inode_operations ports_inode_ops = { - .permission = dgrp_inode_permission -}; - - -void dgrp_register_ports_hook(struct proc_dir_entry *de) -{ - struct nd_struct *node = de->data; - - de->proc_iops = &ports_inode_ops; - rcu_assign_pointer(de->proc_fops, &ports_ops); - node->nd_ports_de = de; -} - static void *dgrp_ports_seq_start(struct seq_file *seq, loff_t *pos) { if (*pos == 0) @@ -163,7 +149,7 @@ static int dgrp_ports_open(struct inode *inode, struct file *file) rtn = seq_open(file, &ports_seq_ops); if (!rtn) { seq = file->private_data; - seq->private = PDE(inode)->data; + seq->private = PDE_DATA(inode); } return rtn; diff --git a/drivers/staging/dgrp/dgrp_specproc.c b/drivers/staging/dgrp/dgrp_specproc.c index d66712c8aa9..205d80ef445 100644 --- a/drivers/staging/dgrp/dgrp_specproc.c +++ b/drivers/staging/dgrp/dgrp_specproc.c @@ -37,6 +37,7 @@ #include <linux/sched.h> #include <linux/cred.h> #include <linux/proc_fs.h> +#include <linux/slab.h> #include <linux/ctype.h> #include <linux/seq_file.h> #include <linux/uaccess.h> @@ -44,43 +45,17 @@ #include "dgrp_common.h" -static struct dgrp_proc_entry dgrp_table[]; static struct proc_dir_entry *dgrp_proc_dir_entry; static int dgrp_add_id(long id); static int dgrp_remove_nd(struct nd_struct *nd); -static void unregister_dgrp_device(struct proc_dir_entry *de); -static void register_dgrp_device(struct nd_struct *node, +static struct proc_dir_entry *add_proc_file(struct nd_struct *node, struct proc_dir_entry *root, - void (*register_hook)(struct proc_dir_entry *de)); + const struct file_operations *fops); /* File operation declarations */ -static int dgrp_gen_proc_open(struct inode *, struct file *); -static int dgrp_gen_proc_close(struct inode *, struct file *); static int parse_write_config(char *); - -static const struct file_operations dgrp_proc_file_ops = { - .owner = THIS_MODULE, - .open = dgrp_gen_proc_open, - .release = dgrp_gen_proc_close, -}; - -static struct inode_operations proc_inode_ops = { - .permission = dgrp_inode_permission -}; - - -static void register_proc_table(struct dgrp_proc_entry *, - struct proc_dir_entry *); -static void unregister_proc_table(struct dgrp_proc_entry *, - struct proc_dir_entry *); - -static struct dgrp_proc_entry dgrp_net_table[]; -static struct dgrp_proc_entry dgrp_mon_table[]; -static struct dgrp_proc_entry dgrp_ports_table[]; -static struct dgrp_proc_entry dgrp_dpa_table[]; - static ssize_t dgrp_config_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos); @@ -89,7 +64,7 @@ static int dgrp_nodeinfo_proc_open(struct inode *inode, struct file *file); static int dgrp_info_proc_open(struct inode *inode, struct file *file); static int dgrp_config_proc_open(struct inode *inode, struct file *file); -static struct file_operations config_proc_file_ops = { +static const struct file_operations config_proc_file_ops = { .owner = THIS_MODULE, .open = dgrp_config_proc_open, .read = seq_read, @@ -98,7 +73,7 @@ static struct file_operations config_proc_file_ops = { .write = dgrp_config_proc_write, }; -static struct file_operations info_proc_file_ops = { +static const struct file_operations info_proc_file_ops = { .owner = THIS_MODULE, .open = dgrp_info_proc_open, .read = seq_read, @@ -106,7 +81,7 @@ static struct file_operations info_proc_file_ops = { .release = single_release, }; -static struct file_operations nodeinfo_proc_file_ops = { +static const struct file_operations nodeinfo_proc_file_ops = { .owner = THIS_MODULE, .open = dgrp_nodeinfo_proc_open, .read = seq_read, @@ -114,71 +89,25 @@ static struct file_operations nodeinfo_proc_file_ops = { .release = seq_release, }; -static struct dgrp_proc_entry dgrp_table[] = { - { - .id = DGRP_CONFIG, - .name = "config", - .mode = 0644, - .proc_file_ops = &config_proc_file_ops, - }, - { - .id = DGRP_INFO, - .name = "info", - .mode = 0644, - .proc_file_ops = &info_proc_file_ops, - }, - { - .id = DGRP_NODEINFO, - .name = "nodeinfo", - .mode = 0644, - .proc_file_ops = &nodeinfo_proc_file_ops, - }, - { - .id = DGRP_NETDIR, - .name = "net", - .mode = 0500, - .child = dgrp_net_table - }, - { - .id = DGRP_MONDIR, - .name = "mon", - .mode = 0500, - .child = dgrp_mon_table - }, - { - .id = DGRP_PORTSDIR, - .name = "ports", - .mode = 0500, - .child = dgrp_ports_table - }, - { - .id = DGRP_DPADIR, - .name = "dpa", - .mode = 0500, - .child = dgrp_dpa_table - } -}; - static struct proc_dir_entry *net_entry_pointer; static struct proc_dir_entry *mon_entry_pointer; static struct proc_dir_entry *dpa_entry_pointer; static struct proc_dir_entry *ports_entry_pointer; -static struct dgrp_proc_entry dgrp_net_table[] = { - {0} -}; - -static struct dgrp_proc_entry dgrp_mon_table[] = { - {0} -}; - -static struct dgrp_proc_entry dgrp_ports_table[] = { - {0} -}; - -static struct dgrp_proc_entry dgrp_dpa_table[] = { - {0} -}; +static void remove_files(struct nd_struct *nd) +{ + char buf[3]; + ID_TO_CHAR(nd->nd_ID, buf); + dgrp_remove_node_class_sysfs_files(nd); + if (nd->nd_net_de) + remove_proc_entry(buf, net_entry_pointer); + if (nd->nd_mon_de) + remove_proc_entry(buf, mon_entry_pointer); + if (nd->nd_dpa_de) + remove_proc_entry(buf, dpa_entry_pointer); + if (nd->nd_ports_de) + remove_proc_entry(buf, ports_entry_pointer); +} void dgrp_unregister_proc(void) { @@ -188,12 +117,19 @@ void dgrp_unregister_proc(void) ports_entry_pointer = NULL; if (dgrp_proc_dir_entry) { - unregister_proc_table(dgrp_table, dgrp_proc_dir_entry); - remove_proc_entry(dgrp_proc_dir_entry->name, - dgrp_proc_dir_entry->parent); + struct nd_struct *nd; + list_for_each_entry(nd, &nd_struct_list, list) + remove_files(nd); + remove_proc_entry("dgrp/config", NULL); + remove_proc_entry("dgrp/info", NULL); + remove_proc_entry("dgrp/nodeinfo", NULL); + remove_proc_entry("dgrp/net", NULL); + remove_proc_entry("dgrp/mon", NULL); + remove_proc_entry("dgrp/dpa", NULL); + remove_proc_entry("dgrp/ports", NULL); + remove_proc_entry("dgrp", NULL); dgrp_proc_dir_entry = NULL; } - } void dgrp_register_proc(void) @@ -201,211 +137,16 @@ void dgrp_register_proc(void) /* * Register /proc/dgrp */ - dgrp_proc_dir_entry = proc_create("dgrp", S_IFDIR, NULL, - &dgrp_proc_file_ops); - register_proc_table(dgrp_table, dgrp_proc_dir_entry); -} - -/* - * /proc/sys support - */ -static int dgrp_proc_match(int len, const char *name, struct proc_dir_entry *de) -{ - if (!de || !de->low_ino) - return 0; - if (de->namelen != len) - return 0; - return !memcmp(name, de->name, len); -} - - -/* - * Scan the entries in table and add them all to /proc at the position - * referred to by "root" - */ -static void register_proc_table(struct dgrp_proc_entry *table, - struct proc_dir_entry *root) -{ - struct proc_dir_entry *de; - int len; - mode_t mode; - - if (table == NULL) + dgrp_proc_dir_entry = proc_mkdir("dgrp", NULL); + if (!dgrp_proc_dir_entry) return; - if (root == NULL) - return; - - for (; table->id; table++) { - /* Can't do anything without a proc name. */ - if (!table->name) - continue; - - /* Maybe we can't do anything with it... */ - if (!table->proc_file_ops && - !table->child) { - pr_warn("dgrp: Can't register %s\n", - table->name); - continue; - } - - len = strlen(table->name); - mode = table->mode; - - de = NULL; - if (!table->child) - mode |= S_IFREG; - else { - mode |= S_IFDIR; - for (de = root->subdir; de; de = de->next) { - if (dgrp_proc_match(len, table->name, de)) - break; - } - /* If the subdir exists already, de is non-NULL */ - } - - if (!de) { - de = create_proc_entry(table->name, mode, root); - if (!de) - continue; - de->data = (void *) table; - if (!table->child) { - de->proc_iops = &proc_inode_ops; - if (table->proc_file_ops) - rcu_assign_pointer(de->proc_fops, - table->proc_file_ops); - else - rcu_assign_pointer(de->proc_fops, - &dgrp_proc_file_ops); - } - } - table->de = de; - if (de->mode & S_IFDIR) - register_proc_table(table->child, de); - - if (table->id == DGRP_NETDIR) - net_entry_pointer = de; - - if (table->id == DGRP_MONDIR) - mon_entry_pointer = de; - - if (table->id == DGRP_DPADIR) - dpa_entry_pointer = de; - - if (table->id == DGRP_PORTSDIR) - ports_entry_pointer = de; - } -} - -/* - * Unregister a /proc sysctl table and any subdirectories. - */ -static void unregister_proc_table(struct dgrp_proc_entry *table, - struct proc_dir_entry *root) -{ - struct proc_dir_entry *de; - struct nd_struct *tmp; - - if (table == NULL) - return; - - list_for_each_entry(tmp, &nd_struct_list, list) { - if ((table == dgrp_net_table) && (tmp->nd_net_de)) { - unregister_dgrp_device(tmp->nd_net_de); - dgrp_remove_node_class_sysfs_files(tmp); - } - - if ((table == dgrp_mon_table) && (tmp->nd_mon_de)) - unregister_dgrp_device(tmp->nd_mon_de); - - if ((table == dgrp_dpa_table) && (tmp->nd_dpa_de)) - unregister_dgrp_device(tmp->nd_dpa_de); - - if ((table == dgrp_ports_table) && (tmp->nd_ports_de)) - unregister_dgrp_device(tmp->nd_ports_de); - } - - for (; table->id; table++) { - de = table->de; - - if (!de) - continue; - if (de->mode & S_IFDIR) { - if (!table->child) { - pr_alert("dgrp: malformed sysctl tree on free\n"); - continue; - } - unregister_proc_table(table->child, de); - - /* Don't unregister directories which still have entries */ - if (de->subdir) - continue; - } - - /* Don't unregister proc entries that are still being used.. */ - if ((atomic_read(&de->count)) != 1) { - pr_alert("proc entry %s in use, not removing\n", - de->name); - continue; - } - - remove_proc_entry(de->name, de->parent); - table->de = NULL; - } -} - -static int dgrp_gen_proc_open(struct inode *inode, struct file *file) -{ - struct proc_dir_entry *de; - struct dgrp_proc_entry *entry; - int ret = 0; - - de = (struct proc_dir_entry *) PDE(file_inode(file)); - if (!de || !de->data) { - ret = -ENXIO; - goto done; - } - - entry = (struct dgrp_proc_entry *) de->data; - if (!entry) { - ret = -ENXIO; - goto done; - } - - down(&entry->excl_sem); - - if (entry->excl_cnt) - ret = -EBUSY; - else - entry->excl_cnt++; - - up(&entry->excl_sem); - -done: - return ret; -} - -static int dgrp_gen_proc_close(struct inode *inode, struct file *file) -{ - struct proc_dir_entry *de; - struct dgrp_proc_entry *entry; - - de = (struct proc_dir_entry *) PDE(file_inode(file)); - if (!de || !de->data) - goto done; - - entry = (struct dgrp_proc_entry *) de->data; - if (!entry) - goto done; - - down(&entry->excl_sem); - - if (entry->excl_cnt) - entry->excl_cnt = 0; - - up(&entry->excl_sem); - -done: - return 0; + proc_create("dgrp/config", 0644, NULL, &config_proc_file_ops); + proc_create("dgrp/info", 0644, NULL, &info_proc_file_ops); + proc_create("dgrp/nodeinfo", 0644, NULL, &nodeinfo_proc_file_ops); + net_entry_pointer = proc_mkdir_mode("dgrp/net", 0500, NULL); + mon_entry_pointer = proc_mkdir_mode("dgrp/mon", 0500, NULL); + dpa_entry_pointer = proc_mkdir_mode("dgrp/dpa", 0500, NULL); + ports_entry_pointer = proc_mkdir_mode("dgrp/ports", 0500, NULL); } static void *dgrp_config_proc_start(struct seq_file *m, loff_t *pos) @@ -736,6 +477,10 @@ static int dgrp_add_id(long id) init_waitqueue_head(&nd->nd_tx_waitq); init_waitqueue_head(&nd->nd_mon_wqueue); init_waitqueue_head(&nd->nd_dpa_wqueue); + sema_init(&nd->nd_mon_semaphore, 1); + sema_init(&nd->nd_net_semaphore, 1); + spin_lock_init(&nd->nd_dpa_lock); + nd->nd_state = NS_CLOSED; for (i = 0; i < SEQ_MAX; i++) init_waitqueue_head(&nd->nd_seq_wque[i]); @@ -750,12 +495,12 @@ static int dgrp_add_id(long id) if (ret) goto error_out; - register_dgrp_device(nd, net_entry_pointer, dgrp_register_net_hook); - register_dgrp_device(nd, mon_entry_pointer, dgrp_register_mon_hook); - register_dgrp_device(nd, dpa_entry_pointer, dgrp_register_dpa_hook); - register_dgrp_device(nd, ports_entry_pointer, - dgrp_register_ports_hook); - + dgrp_create_node_class_sysfs_files(nd); + nd->nd_net_de = add_proc_file(nd, net_entry_pointer, &dgrp_net_ops); + nd->nd_mon_de = add_proc_file(nd, mon_entry_pointer, &dgrp_mon_ops); + nd->nd_dpa_de = add_proc_file(nd, dpa_entry_pointer, &dgrp_dpa_ops); + nd->nd_ports_de = add_proc_file(nd, ports_entry_pointer, + &dgrp_ports_ops); return 0; /* FIXME this guy should free the tty driver stored in nd and destroy @@ -774,16 +519,7 @@ static int dgrp_remove_nd(struct nd_struct *nd) if (nd->nd_tty_ref_cnt) return -EBUSY; - if (nd->nd_net_de) { - unregister_dgrp_device(nd->nd_net_de); - dgrp_remove_node_class_sysfs_files(nd); - } - - unregister_dgrp_device(nd->nd_mon_de); - - unregister_dgrp_device(nd->nd_ports_de); - - unregister_dgrp_device(nd->nd_dpa_de); + remove_files(nd); dgrp_tty_uninit(nd); @@ -795,38 +531,11 @@ static int dgrp_remove_nd(struct nd_struct *nd) return 0; } -static void register_dgrp_device(struct nd_struct *node, +static struct proc_dir_entry *add_proc_file(struct nd_struct *node, struct proc_dir_entry *root, - void (*register_hook)(struct proc_dir_entry *de)) + const struct file_operations *fops) { char buf[3]; - struct proc_dir_entry *de; - ID_TO_CHAR(node->nd_ID, buf); - - de = create_proc_entry(buf, 0600 | S_IFREG, root); - if (!de) - return; - - de->data = (void *) node; - - if (register_hook) - register_hook(de); - -} - -static void unregister_dgrp_device(struct proc_dir_entry *de) -{ - if (!de) - return; - - /* Don't unregister proc entries that are still being used.. */ - if ((atomic_read(&de->count)) != 1) { - pr_alert("%s - proc entry %s in use. Not removing.\n", - __func__, de->name); - return; - } - - remove_proc_entry(de->name, de->parent); - de = NULL; + return proc_create_data(buf, 0600, root, fops, node); } diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c index 5337b415d45..21b369e0150 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_debug.c b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c index 297389e8c60..3251d2e073b 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c @@ -55,7 +55,7 @@ int numofmsgbuf = 0; // // Table of entry-point routines for char device // -static struct file_operations ft1000fops = +static const struct file_operations ft1000fops = { .unlocked_ioctl = ft1000_ioctl, .poll = ft1000_poll_dev, diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_proc.c b/drivers/staging/ft1000/ft1000-usb/ft1000_proc.c index b99640637fe..d8294d6c956 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; } diff --git a/drivers/staging/keucr/scsiglue.c b/drivers/staging/keucr/scsiglue.c index 083b20e6253..48e1005349d 100644 --- a/drivers/staging/keucr/scsiglue.c +++ b/drivers/staging/keucr/scsiglue.c @@ -229,26 +229,18 @@ void usb_stor_report_bus_reset(struct us_data *us) /* we use this macro to help us write into the buffer */ #undef SPRINTF -#define SPRINTF(args...) \ - do { \ - if (pos < buffer+length) \ - pos += sprintf(pos, ## args); \ - } while (0) +#define SPRINTF(args...) seq_printf(m, ##args) -/* - * proc_info() - */ -static int proc_info(struct Scsi_Host *host, char *buffer, char **start, - off_t offset, int length, int inout) +static int write_info(struct Scsi_Host *host, char *buffer, int length) +{ + return length; +} + +static int show_info(struct seq_file *m, struct Scsi_Host *host) { struct us_data *us = host_to_us(host); - char *pos = buffer; const char *string; - /* pr_info("scsiglue --- proc_info\n"); */ - if (inout) - return length; - /* print the controller name */ SPRINTF(" Host scsi%d: usb-storage\n", host->host_no); @@ -278,29 +270,17 @@ static int proc_info(struct Scsi_Host *host, char *buffer, char **start, SPRINTF(" Transport: %s\n", us->transport_name); /* show the device flags */ - if (pos < buffer + length) { - pos += sprintf(pos, " Quirks:"); + SPRINTF(" Quirks:"); #define US_FLAG(name, value) \ do { \ if (us->fflags & value) \ - pos += sprintf(pos, " " #name); \ + SPRINTF(" " #name); \ } while (0); US_DO_ALL_FLAGS #undef US_FLAG - - *(pos++) = '\n'; - } - - /* Calculate start of next buffer, and return value. */ - *start = buffer + offset; - - if ((pos - buffer) < offset) - return 0; - else if ((pos - buffer - offset) < length) - return pos - buffer - offset; - else - return length; + seq_putc(m, '\n'); + return 0; } /*********************************************************************** @@ -351,7 +331,8 @@ struct scsi_host_template usb_stor_host_template = { /* basic userland interface stuff */ .name = "eucr-storage", .proc_name = "eucr-storage", - .proc_info = proc_info, + .write_info = write_info, + .show_info = show_info, .info = host_info, /* command interface -- queued only */ diff --git a/drivers/staging/rtl8187se/r8180.h b/drivers/staging/rtl8187se/r8180.h index 70ea4145b4c..edacc800164 100644 --- a/drivers/staging/rtl8187se/r8180.h +++ b/drivers/staging/rtl8187se/r8180.h @@ -372,7 +372,6 @@ typedef struct r8180_priv struct Stats stats; struct _link_detect_t link_detect; //YJ,add,080828 struct iw_statistics wstats; - struct proc_dir_entry *dir_dev; /*RX stuff*/ u32 *rxring; diff --git a/drivers/staging/rtl8187se/r8180_core.c b/drivers/staging/rtl8187se/r8180_core.c index d10d75e8a33..f7c1d9905ec 100644 --- a/drivers/staging/rtl8187se/r8180_core.c +++ b/drivers/staging/rtl8187se/r8180_core.c @@ -36,6 +36,8 @@ #include <linux/syscalls.h> #include <linux/eeprom_93cx6.h> #include <linux/interrupt.h> +#include <linux/proc_fs.h> +#include <linux/seq_file.h> #include "r8180_hw.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 int proc_get_registers(char *page, char **start, - off_t offset, int count, - int *eof, void *data) +static int proc_get_registers(struct seq_file *m, void *v) { - struct net_device *dev = data; - int len = 0; - int i, n; - int max = 0xff; + struct net_device *dev = m->private; + int i, n, max = 0xff; /* This dump the current register page */ 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++) - len += snprintf(page + len, count - len, "%2x ", - read_nic_byte(dev, n)); + seq_printf(m, "%2x ", read_nic_byte(dev, n)); } - len += snprintf(page + len, count - len, "\n"); - - *eof = 1; - return len; + seq_putc(m, '\n'); + return 0; } int get_curr_tx_free_desc(struct net_device *dev, int priority); -static int proc_get_stats_hw(char *page, char **start, - off_t offset, int count, - int *eof, void *data) +static int proc_get_stats_hw(struct seq_file *m, void *v) { - int len = 0; - - *eof = 1; - return len; + return 0; } -static int proc_get_stats_rx(char *page, char **start, - off_t offset, int count, - int *eof, void *data) +static int proc_get_stats_rx(struct seq_file *m, void *v) { - struct net_device *dev = data; + struct net_device *dev = m->private; struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - int len = 0; - - len += snprintf(page + len, count - len, + seq_printf(m, "RX OK: %lu\n" "RX Retry: %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 ); - *eof = 1; - return len; + return 0; } -static int proc_get_stats_tx(char *page, char **start, - off_t offset, int count, - int *eof, void *data) +static int proc_get_stats_tx(struct seq_file *m, void *v) { - struct net_device *dev = data; + struct net_device *dev = m->private; struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - - int len = 0; unsigned long totalOK; totalOK = priv->stats.txnpokint+priv->stats.txhpokint+priv->stats.txlpokint; - len += snprintf(page + len, count - len, + seq_printf(m, "TX OK: %lu\n" "TX Error: %lu\n" "TX Retry: %lu\n" @@ -291,8 +272,7 @@ static int proc_get_stats_tx(char *page, char **start, priv->stats.txbeaconerr ); - *eof = 1; - return len; + return 0; } void rtl8180_proc_module_init(void) @@ -308,59 +288,61 @@ void rtl8180_proc_module_remove(void) void rtl8180_proc_remove_one(struct net_device *dev) { - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - if (priv->dir_dev) { - remove_proc_entry("stats-hw", priv->dir_dev); - remove_proc_entry("stats-tx", priv->dir_dev); - remove_proc_entry("stats-rx", priv->dir_dev); - remove_proc_entry("registers", priv->dir_dev); - priv->dir_dev = NULL; - } + remove_proc_subtree(dev->name, rtl8180_proc); } -void rtl8180_proc_init_one(struct net_device *dev) +/* + * seq_file wrappers for procfile show routines. + */ +static int rtl8180_proc_open(struct inode *inode, struct file *file) { - struct proc_dir_entry *e; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct net_device *dev = proc_get_parent_data(inode); + int (*show)(struct seq_file *, void *) = PDE_DATA(inode); - priv->dir_dev = rtl8180_proc; - if (!priv->dir_dev) { - DMESGE("Unable to initialize /proc/net/r8180/%s\n", - dev->name); - return; - } + return single_open(file, show, dev); +} - e = create_proc_read_entry("stats-hw", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_stats_hw, dev); - if (!e) { - DMESGE("Unable to initialize " - "/proc/net/r8180/%s/stats-hw\n", - dev->name); - } +static const struct file_operations rtl8180_proc_fops = { + .open = rtl8180_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; - 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); - } +/* + * 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) +{ + const struct rtl8180_proc_file *f; + struct proc_dir_entry *dir; - 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); + dir = proc_mkdir_data(dev->name, 0, rtl8180_proc, dev); + if (!dir) { + DMESGE("Unable to initialize /proc/net/r8180/%s\n", dev->name); + return; } - 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); + for (f = rtl8180_proc_files; f->name[0]; f++) { + if (!proc_create_data(f->name, S_IFREG | S_IRUGO, dir, + &rtl8180_proc_fops, f->show)) { + DMESGE("Unable to initialize /proc/net/r8180/%s/%s\n", + dev->name, f->name); + return; + } } } diff --git a/drivers/staging/rtl8192e/rtl8192e/Makefile b/drivers/staging/rtl8192e/rtl8192e/Makefile index 313a92ec683..a2c4fb4ba1a 100644 --- a/drivers/staging/rtl8192e/rtl8192e/Makefile +++ b/drivers/staging/rtl8192e/rtl8192e/Makefile @@ -7,7 +7,6 @@ r8192e_pci-objs := \ r8190P_rtl8256.o \ rtl_cam.o \ rtl_core.o \ - rtl_debug.o \ rtl_dm.o \ rtl_eeprom.o \ rtl_ethtool.o \ diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index 4ebf99b3097..2b6c61c5d3d 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -2966,8 +2966,6 @@ static int rtl8192_pci_probe(struct pci_dev *pdev, goto err_free_irq; RT_TRACE(COMP_INIT, "dev name: %s\n", dev->name); - rtl8192_proc_init_one(dev); - if (priv->polling_timer_on == 0) check_rfctrl_gpio_timer((unsigned long)dev); @@ -3003,7 +3001,6 @@ static void rtl8192_pci_disconnect(struct pci_dev *pdev) del_timer_sync(&priv->gpio_polling_timer); cancel_delayed_work(&priv->gpio_change_rf_wq); priv->polling_timer_on = 0; - rtl8192_proc_remove_one(dev); rtl8192_down(dev, true); deinit_hal_dm(dev); if (priv->pFirmware) { @@ -3093,7 +3090,6 @@ static int __init rtl8192_pci_module_init(void) printk(KERN_INFO "\nLinux kernel driver for RTL8192E WLAN cards\n"); printk(KERN_INFO "Copyright (c) 2007-2008, Realsil Wlan Driver\n"); - rtl8192_proc_module_init(); if (0 != pci_register_driver(&rtl8192_pci_driver)) { DMESG("No device found"); /*pci_unregister_driver (&rtl8192_pci_driver);*/ @@ -3107,7 +3103,6 @@ static void __exit rtl8192_pci_module_exit(void) pci_unregister_driver(&rtl8192_pci_driver); RT_TRACE(COMP_DOWN, "Exiting"); - rtl8192_proc_module_remove(); } void check_rfctrl_gpio_timer(unsigned long data) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h index 320d5fc026b..87d4d349c89 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h @@ -1085,10 +1085,4 @@ void ActUpdateChannelAccessSetting(struct net_device *dev, enum wireless_mode WirelessMode, struct channel_access_setting *ChnlAccessSetting); -/* proc stuff from rtl_debug.c */ -void rtl8192_proc_init_one(struct net_device *dev); -void rtl8192_proc_remove_one(struct net_device *dev); -void rtl8192_proc_module_init(void); -void rtl8192_proc_module_remove(void); - #endif diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_debug.c b/drivers/staging/rtl8192e/rtl8192e/rtl_debug.c deleted file mode 100644 index c19b14cd6f7..00000000000 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_debug.c +++ /dev/null @@ -1,1029 +0,0 @@ -/****************************************************************************** - * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. - * - * Based on the r8180 driver, which is: - * Copyright 2004-2005 Andrea Merello <andreamrl@tiscali.it>, et al. - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * wlanfae <wlanfae@realtek.com> -******************************************************************************/ -#include "rtl_core.h" -#include "r8192E_phy.h" -#include "r8192E_phyreg.h" -#include "r8190P_rtl8256.h" /* RTL8225 Radio frontend */ -#include "r8192E_cmdpkt.h" - -/**************************************************************************** - -----------------------------PROCFS STUFF------------------------- -*****************************************************************************/ -/*This part is related to PROC, which will record some statistics. */ -static struct proc_dir_entry *rtl8192_proc; - -static int proc_get_stats_ap(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - struct rtllib_device *ieee = priv->rtllib; - struct rtllib_network *target; - int len = 0; - - list_for_each_entry(target, &ieee->network_list, list) { - - len += snprintf(page + len, count - len, - "%s ", target->ssid); - - if (target->wpa_ie_len > 0 || target->rsn_ie_len > 0) - len += snprintf(page + len, count - len, - "WPA\n"); - else - len += snprintf(page + len, count - len, - "non_WPA\n"); - - } - - *eof = 1; - return len; -} - -static int proc_get_registers_0(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - - int len = 0; - int i, n, page0; - - int max = 0xff; - page0 = 0x000; - - len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", - (page0>>8)); - len += snprintf(page + len, count - len, - "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B " - "0C 0D 0E 0F"); - for (n = 0; n <= max;) { - len += snprintf(page + len, count - len, "\nD: %2x > ", n); - for (i = 0; i < 16 && n <= max; n++, i++) - len += snprintf(page + len, count - len, - "%2.2x ", read_nic_byte(dev, - (page0 | n))); - } - len += snprintf(page + len, count - len, "\n"); - *eof = 1; - return len; - -} -static int proc_get_registers_1(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - - int len = 0; - int i, n, page0; - - int max = 0xff; - page0 = 0x100; - - /* This dump the current register page */ - len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", - (page0>>8)); - len += snprintf(page + len, count - len, - "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B " - "0C 0D 0E 0F"); - for (n = 0; n <= max;) { - len += snprintf(page + len, count - len, - "\nD: %2x > ", n); - for (i = 0; i < 16 && n <= max; i++, n++) - len += snprintf(page + len, count - len, - "%2.2x ", read_nic_byte(dev, - (page0 | n))); - } - len += snprintf(page + len, count - len, "\n"); - *eof = 1; - return len; - -} -static int proc_get_registers_2(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - - int len = 0; - int i, n, page0; - - int max = 0xff; - page0 = 0x200; - - /* This dump the current register page */ - len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", - (page0 >> 8)); - len += snprintf(page + len, count - len, - "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C " - "0D 0E 0F"); - for (n = 0; n <= max;) { - len += snprintf(page + len, count - len, - "\nD: %2x > ", n); - for (i = 0; i < 16 && n <= max; i++, n++) - len += snprintf(page + len, count - len, - "%2.2x ", read_nic_byte(dev, - (page0 | n))); - } - len += snprintf(page + len, count - len, "\n"); - *eof = 1; - return len; - -} -static int proc_get_registers_3(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - - int len = 0; - int i, n, page0; - - int max = 0xff; - page0 = 0x300; - - /* This dump the current register page */ - len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", - (page0>>8)); - len += snprintf(page + len, count - len, - "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B " - "0C 0D 0E 0F"); - for (n = 0; n <= max;) { - len += snprintf(page + len, count - len, - "\nD: %2x > ", n); - for (i = 0; i < 16 && n <= max; i++, n++) - len += snprintf(page + len, count - len, - "%2.2x ", read_nic_byte(dev, - (page0 | n))); - } - len += snprintf(page + len, count - len, "\n"); - *eof = 1; - return len; - -} -static int proc_get_registers_4(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - - int len = 0; - int i, n, page0; - - int max = 0xff; - page0 = 0x400; - - /* This dump the current register page */ - len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", - (page0>>8)); - len += snprintf(page + len, count - len, - "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B " - "0C 0D 0E 0F"); - for (n = 0; n <= max;) { - len += snprintf(page + len, count - len, - "\nD: %2x > ", n); - for (i = 0; i < 16 && n <= max; i++, n++) - len += snprintf(page + len, count - len, - "%2.2x ", read_nic_byte(dev, - (page0 | n))); - } - len += snprintf(page + len, count - len, "\n"); - *eof = 1; - return len; - -} -static int proc_get_registers_5(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - - int len = 0; - int i, n, page0; - - int max = 0xff; - page0 = 0x500; - - /* This dump the current register page */ - len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", - (page0 >> 8)); - len += snprintf(page + len, count - len, - "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B " - "0C 0D 0E 0F"); - for (n = 0; n <= max;) { - len += snprintf(page + len, count - len, - "\nD: %2x > ", n); - for (i = 0; i < 16 && n <= max; i++, n++) - len += snprintf(page + len, count - len, - "%2.2x ", read_nic_byte(dev, - (page0 | n))); - } - len += snprintf(page + len, count - len, "\n"); - *eof = 1; - return len; - -} -static int proc_get_registers_6(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - - int len = 0; - int i, n, page0; - - int max = 0xff; - page0 = 0x600; - - /* This dump the current register page */ - len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", - (page0>>8)); - len += snprintf(page + len, count - len, - "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B " - "0C 0D 0E 0F"); - for (n = 0; n <= max;) { - len += snprintf(page + len, count - len, - "\nD: %2x > ", n); - for (i = 0; i < 16 && n <= max; i++, n++) - len += snprintf(page + len, count - len, - "%2.2x ", read_nic_byte(dev, - (page0 | n))); - } - len += snprintf(page + len, count - len, "\n"); - *eof = 1; - return len; - -} -static int proc_get_registers_7(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - - int len = 0; - int i, n, page0; - - int max = 0xff; - page0 = 0x700; - - /* This dump the current register page */ - len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", - (page0 >> 8)); - len += snprintf(page + len, count - len, - "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C " - "0D 0E 0F"); - for (n = 0; n <= max;) { - len += snprintf(page + len, count - len, - "\nD: %2x > ", n); - for (i = 0; i < 16 && n <= max; i++, n++) - len += snprintf(page + len, count - len, - "%2.2x ", read_nic_byte(dev, - (page0 | n))); - } - len += snprintf(page + len, count - len, "\n"); - *eof = 1; - return len; - -} -static int proc_get_registers_8(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - - int len = 0; - int i, n, page0; - - int max = 0xff; - page0 = 0x800; - - /* This dump the current register page */ - len += snprintf(page + len, count - len, - "\n####################page %x##################\n", - (page0 >> 8)); - for (n = 0; n <= max;) { - len += snprintf(page + len, count - len, "\nD: %2x > ", n); - for (i = 0; i < 4 && n <= max; n += 4, i++) - len += snprintf(page + len, count - len, - "%8.8x ", rtl8192_QueryBBReg(dev, - (page0 | n), bMaskDWord)); - } - len += snprintf(page + len, count - len, "\n"); - *eof = 1; - return len; - -} -static int proc_get_registers_9(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - - int len = 0; - int i, n, page0; - - int max = 0xff; - page0 = 0x900; - - /* This dump the current register page */ - len += snprintf(page + len, count - len, - "\n####################page %x##################\n", - (page0>>8)); - for (n = 0; n <= max;) { - len += snprintf(page + len, count - len, "\nD: %2x > ", n); - for (i = 0; i < 4 && n <= max; n += 4, i++) - len += snprintf(page + len, count - len, - "%8.8x ", rtl8192_QueryBBReg(dev, - (page0 | n), bMaskDWord)); - } - len += snprintf(page + len, count - len, "\n"); - *eof = 1; - return len; -} -static int proc_get_registers_a(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - - int len = 0; - int i, n, page0; - - int max = 0xff; - page0 = 0xa00; - - /* This dump the current register page */ - len += snprintf(page + len, count - len, - "\n####################page %x##################\n", - (page0>>8)); - for (n = 0; n <= max;) { - len += snprintf(page + len, count - len, "\nD: %2x > ", n); - for (i = 0; i < 4 && n <= max; n += 4, i++) - len += snprintf(page + len, count - len, - "%8.8x ", rtl8192_QueryBBReg(dev, - (page0 | n), bMaskDWord)); - } - len += snprintf(page + len, count - len, "\n"); - *eof = 1; - return len; -} -static int proc_get_registers_b(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - - int len = 0; - int i, n, page0; - - int max = 0xff; - page0 = 0xb00; - - /* This dump the current register page */ - len += snprintf(page + len, count - len, - "\n####################page %x##################\n", - (page0 >> 8)); - for (n = 0; n <= max;) { - len += snprintf(page + len, count - len, "\nD: %2x > ", n); - for (i = 0; i < 4 && n <= max; n += 4, i++) - len += snprintf(page + len, count - len, - "%8.8x ", rtl8192_QueryBBReg(dev, - (page0 | n), bMaskDWord)); - } - len += snprintf(page + len, count - len, "\n"); - *eof = 1; - return len; -} -static int proc_get_registers_c(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - - int len = 0; - int i, n, page0; - - int max = 0xff; - page0 = 0xc00; - - /* This dump the current register page */ - len += snprintf(page + len, count - len, - "\n####################page %x##################\n", - (page0>>8)); - for (n = 0; n <= max;) { - len += snprintf(page + len, count - len, "\nD: %2x > ", n); - for (i = 0; i < 4 && n <= max; n += 4, i++) - len += snprintf(page + len, count - len, - "%8.8x ", rtl8192_QueryBBReg(dev, - (page0 | n), bMaskDWord)); - } - len += snprintf(page + len, count - len, "\n"); - *eof = 1; - return len; -} -static int proc_get_registers_d(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - - int len = 0; - int i, n, page0; - - int max = 0xff; - page0 = 0xd00; - - /* This dump the current register page */ - len += snprintf(page + len, count - len, - "\n####################page %x##################\n", - (page0>>8)); - for (n = 0; n <= max;) { - len += snprintf(page + len, count - len, "\nD: %2x > ", n); - for (i = 0; i < 4 && n <= max; n += 4, i++) - len += snprintf(page + len, count - len, - "%8.8x ", rtl8192_QueryBBReg(dev, - (page0 | n), bMaskDWord)); - } - len += snprintf(page + len, count - len, "\n"); - *eof = 1; - return len; -} -static int proc_get_registers_e(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - - int len = 0; - int i, n, page0; - - int max = 0xff; - page0 = 0xe00; - - /* This dump the current register page */ - len += snprintf(page + len, count - len, - "\n####################page %x##################\n", - (page0>>8)); - for (n = 0; n <= max;) { - len += snprintf(page + len, count - len, "\nD: %2x > ", n); - for (i = 0; i < 4 && n <= max; n += 4, i++) - len += snprintf(page + len, count - len, - "%8.8x ", rtl8192_QueryBBReg(dev, - (page0 | n), bMaskDWord)); - } - len += snprintf(page + len, count - len, "\n"); - *eof = 1; - return len; -} - -static int proc_get_reg_rf_a(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - - int len = 0; - int i, n; - - int max = 0xff; - - /* This dump the current register page */ - len += snprintf(page + len, count - len, - "\n#################### RF-A ##################\n "); - for (n = 0; n <= max;) { - len += snprintf(page + len, count - len, "\nD: %2x > ", n); - for (i = 0; i < 4 && n <= max; n += 4, i++) - len += snprintf(page + len, count - len, - "%8.8x ", rtl8192_phy_QueryRFReg(dev, - (enum rf90_radio_path)RF90_PATH_A, n, - bMaskDWord)); - } - len += snprintf(page + len, count - len, "\n"); - *eof = 1; - return len; -} - -static int proc_get_reg_rf_b(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - - int len = 0; - int i, n; - - int max = 0xff; - - /* This dump the current register page */ - len += snprintf(page + len, count - len, - "\n#################### RF-B ##################\n "); - for (n = 0; n <= max;) { - len += snprintf(page + len, count - len, "\nD: %2x > ", n); - for (i = 0; i < 4 && n <= max; n += 4, i++) - len += snprintf(page + len, count - len, - "%8.8x ", rtl8192_phy_QueryRFReg(dev, - (enum rf90_radio_path)RF90_PATH_B, n, - bMaskDWord)); - } - len += snprintf(page + len, count - len, "\n"); - *eof = 1; - return len; -} - -static int proc_get_reg_rf_c(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - - int len = 0; - int i, n; - - int max = 0xff; - - /* This dump the current register page */ - len += snprintf(page + len, count - len, - "\n#################### RF-C ##################\n"); - for (n = 0; n <= max;) { - len += snprintf(page + len, count - len, "\nD: %2x > ", n); - for (i = 0; i < 4 && n <= max; n += 4, i++) - len += snprintf(page + len, count - len, - "%8.8x ", rtl8192_phy_QueryRFReg(dev, - (enum rf90_radio_path)RF90_PATH_C, n, - bMaskDWord)); - } - len += snprintf(page + len, count - len, "\n"); - *eof = 1; - return len; -} - -static int proc_get_reg_rf_d(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - - int len = 0; - int i, n; - - int max = 0xff; - - /* This dump the current register page */ - len += snprintf(page + len, count - len, - "\n#################### RF-D ##################\n "); - for (n = 0; n <= max;) { - len += snprintf(page + len, count - len, "\nD: %2x > ", n); - for (i = 0; i < 4 && n <= max; n += 4, i++) - len += snprintf(page + len, count - len, - "%8.8x ", rtl8192_phy_QueryRFReg(dev, - (enum rf90_radio_path)RF90_PATH_D, n, - bMaskDWord)); - } - len += snprintf(page + len, count - len, "\n"); - *eof = 1; - return len; -} - -static int proc_get_cam_register_1(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - u32 target_command = 0; - u32 target_content = 0; - u8 entry_i = 0; - u32 ulStatus; - int len = 0; - int i = 100, j = 0; - - /* This dump the current register page */ - len += snprintf(page + len, count - len, - "\n#################### SECURITY CAM (0-10) ######" - "############\n "); - for (j = 0; j < 11; j++) { - len += snprintf(page + len, count - len, "\nD: %2x > ", j); - for (entry_i = 0; entry_i < CAM_CONTENT_COUNT; entry_i++) { - target_command = entry_i+CAM_CONTENT_COUNT*j; - target_command = target_command | BIT31; - - while ((i--) >= 0) { - ulStatus = read_nic_dword(dev, RWCAM); - if (ulStatus & BIT31) - continue; - else - break; - } - write_nic_dword(dev, RWCAM, target_command); - target_content = read_nic_dword(dev, RCAMO); - len += snprintf(page + len, count - len, "%8.8x ", - target_content); - } - } - - len += snprintf(page + len, count - len, "\n"); - *eof = 1; - return len; -} - -static int proc_get_cam_register_2(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - u32 target_command = 0; - u32 target_content = 0; - u8 entry_i = 0; - u32 ulStatus; - int len = 0; - int i = 100, j = 0; - - /* This dump the current register page */ - len += snprintf(page + len, count - len, - "\n#################### SECURITY CAM (11-21) " - "##################\n "); - for (j = 11; j < 22; j++) { - len += snprintf(page + len, count - len, "\nD: %2x > ", j); - for (entry_i = 0; entry_i < CAM_CONTENT_COUNT; entry_i++) { - target_command = entry_i + CAM_CONTENT_COUNT * j; - target_command = target_command | BIT31; - - while ((i--) >= 0) { - ulStatus = read_nic_dword(dev, RWCAM); - if (ulStatus & BIT31) - continue; - else - break; - } - write_nic_dword(dev, RWCAM, target_command); - target_content = read_nic_dword(dev, RCAMO); - len += snprintf(page + len, count - len, "%8.8x ", - target_content); - } - } - - len += snprintf(page + len, count - len, "\n"); - *eof = 1; - return len; -} - -static int proc_get_cam_register_3(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - u32 target_command = 0; - u32 target_content = 0; - u8 entry_i = 0; - u32 ulStatus; - int len = 0; - int i = 100, j = 0; - - /* This dump the current register page */ - len += snprintf(page + len, count - len, - "\n#################### SECURITY CAM (22-31) ######" - "############\n "); - for (j = 22; j < TOTAL_CAM_ENTRY; j++) { - len += snprintf(page + len, count - len, "\nD: %2x > ", j); - for (entry_i = 0; entry_i < CAM_CONTENT_COUNT; entry_i++) { - target_command = entry_i + CAM_CONTENT_COUNT * j; - target_command = target_command | BIT31; - - while ((i--) >= 0) { - ulStatus = read_nic_dword(dev, RWCAM); - if (ulStatus & BIT31) - continue; - else - break; - } - write_nic_dword(dev, RWCAM, target_command); - target_content = read_nic_dword(dev, RCAMO); - len += snprintf(page + len, count - len, "%8.8x ", - target_content); - } - } - - len += snprintf(page + len, count - len, "\n"); - *eof = 1; - return len; -} -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 r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - - int len = 0; - - len += snprintf(page + len, count - len, - "TX VI priority ok int: %lu\n" - "TX VO priority ok int: %lu\n" - "TX BE priority ok int: %lu\n" - "TX BK priority ok int: %lu\n" - "TX MANAGE priority ok int: %lu\n" - "TX BEACON priority ok int: %lu\n" - "TX BEACON priority error int: %lu\n" - "TX CMDPKT priority ok int: %lu\n" - "TX queue stopped?: %d\n" - "TX fifo overflow: %lu\n" - "TX total data packets %lu\n" - "TX total data bytes :%lu\n", - priv->stats.txviokint, - priv->stats.txvookint, - priv->stats.txbeokint, - priv->stats.txbkokint, - priv->stats.txmanageokint, - priv->stats.txbeaconokint, - priv->stats.txbeaconerr, - priv->stats.txcmdpktokint, - netif_queue_stopped(dev), - priv->stats.txoverflow, - priv->rtllib->stats.tx_packets, - priv->rtllib->stats.tx_bytes - - - ); - - *eof = 1; - return len; -} - - - -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 r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - - int len = 0; - - len += snprintf(page + len, count - len, - "RX packets: %lu\n" - "RX data crc err: %lu\n" - "RX mgmt crc err: %lu\n" - "RX desc err: %lu\n" - "RX rx overflow error: %lu\n", - priv->stats.rxint, - priv->stats.rxdatacrcerr, - priv->stats.rxmgmtcrcerr, - priv->stats.rxrdu, - priv->stats.rxoverflow); - - *eof = 1; - return len; -} - -void rtl8192_proc_module_init(void) -{ - RT_TRACE(COMP_INIT, "Initializing proc filesystem"); - rtl8192_proc = create_proc_entry(DRV_NAME, S_IFDIR, init_net.proc_net); -} - - -void rtl8192_proc_module_remove(void) -{ - remove_proc_entry(DRV_NAME, init_net.proc_net); -} - - -void rtl8192_proc_remove_one(struct net_device *dev) -{ - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - - printk(KERN_INFO "dev name %s\n", dev->name); - - if (priv->dir_dev) { - remove_proc_entry("stats-tx", priv->dir_dev); - remove_proc_entry("stats-rx", priv->dir_dev); - remove_proc_entry("stats-ap", priv->dir_dev); - remove_proc_entry("registers-0", priv->dir_dev); - remove_proc_entry("registers-1", priv->dir_dev); - remove_proc_entry("registers-2", priv->dir_dev); - remove_proc_entry("registers-3", priv->dir_dev); - remove_proc_entry("registers-4", priv->dir_dev); - remove_proc_entry("registers-5", priv->dir_dev); - remove_proc_entry("registers-6", priv->dir_dev); - remove_proc_entry("registers-7", priv->dir_dev); - remove_proc_entry("registers-8", priv->dir_dev); - remove_proc_entry("registers-9", priv->dir_dev); - remove_proc_entry("registers-a", priv->dir_dev); - remove_proc_entry("registers-b", priv->dir_dev); - remove_proc_entry("registers-c", priv->dir_dev); - remove_proc_entry("registers-d", priv->dir_dev); - remove_proc_entry("registers-e", priv->dir_dev); - remove_proc_entry("RF-A", priv->dir_dev); - remove_proc_entry("RF-B", priv->dir_dev); - remove_proc_entry("RF-C", priv->dir_dev); - remove_proc_entry("RF-D", priv->dir_dev); - remove_proc_entry("SEC-CAM-1", priv->dir_dev); - remove_proc_entry("SEC-CAM-2", priv->dir_dev); - remove_proc_entry("SEC-CAM-3", priv->dir_dev); - remove_proc_entry("wlan0", rtl8192_proc); - 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 *)rtllib_priv(dev); - - priv->dir_dev = create_proc_entry(dev->name, - S_IFDIR | S_IRUGO | S_IXUGO, - 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-0", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_registers_0, dev); - if (!e) - RT_TRACE(COMP_ERR, "Unable to initialize " - "/proc/net/rtl8192/%s/registers-0\n", - dev->name); - e = create_proc_read_entry("registers-1", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_registers_1, dev); - if (!e) - RT_TRACE(COMP_ERR, "Unable to initialize " - "/proc/net/rtl8192/%s/registers-1\n", - dev->name); - e = create_proc_read_entry("registers-2", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_registers_2, dev); - if (!e) - RT_TRACE(COMP_ERR, "Unable to initialize " - "/proc/net/rtl8192/%s/registers-2\n", - dev->name); - e = create_proc_read_entry("registers-3", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_registers_3, dev); - if (!e) - RT_TRACE(COMP_ERR, "Unable to initialize " - "/proc/net/rtl8192/%s/registers-3\n", - dev->name); - e = create_proc_read_entry("registers-4", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_registers_4, dev); - if (!e) - RT_TRACE(COMP_ERR, "Unable to initialize " - "/proc/net/rtl8192/%s/registers-4\n", - dev->name); - e = create_proc_read_entry("registers-5", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_registers_5, dev); - if (!e) - RT_TRACE(COMP_ERR, "Unable to initialize " - "/proc/net/rtl8192/%s/registers-5\n", - dev->name); - e = create_proc_read_entry("registers-6", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_registers_6, dev); - if (!e) - RT_TRACE(COMP_ERR, "Unable to initialize " - "/proc/net/rtl8192/%s/registers-6\n", - dev->name); - e = create_proc_read_entry("registers-7", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_registers_7, dev); - if (!e) - RT_TRACE(COMP_ERR, "Unable to initialize " - "/proc/net/rtl8192/%s/registers-7\n", - dev->name); - e = create_proc_read_entry("registers-8", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_registers_8, dev); - if (!e) - RT_TRACE(COMP_ERR, "Unable to initialize " - "/proc/net/rtl8192/%s/registers-8\n", - dev->name); - e = create_proc_read_entry("registers-9", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_registers_9, dev); - if (!e) - RT_TRACE(COMP_ERR, "Unable to initialize " - "/proc/net/rtl8192/%s/registers-9\n", - dev->name); - e = create_proc_read_entry("registers-a", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_registers_a, dev); - if (!e) - RT_TRACE(COMP_ERR, "Unable to initialize " - "/proc/net/rtl8192/%s/registers-a\n", - dev->name); - e = create_proc_read_entry("registers-b", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_registers_b, dev); - if (!e) - RT_TRACE(COMP_ERR, "Unable to initialize " - "/proc/net/rtl8192/%s/registers-b\n", - dev->name); - e = create_proc_read_entry("registers-c", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_registers_c, dev); - if (!e) - RT_TRACE(COMP_ERR, "Unable to initialize " - "/proc/net/rtl8192/%s/registers-c\n", - dev->name); - e = create_proc_read_entry("registers-d", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_registers_d, dev); - if (!e) - RT_TRACE(COMP_ERR, "Unable to initialize " - "/proc/net/rtl8192/%s/registers-d\n", - dev->name); - e = create_proc_read_entry("registers-e", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_registers_e, dev); - if (!e) - RT_TRACE(COMP_ERR, "Unable to initialize " - "/proc/net/rtl8192/%s/registers-e\n", - dev->name); - e = create_proc_read_entry("RF-A", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_reg_rf_a, dev); - if (!e) - RT_TRACE(COMP_ERR, "Unable to initialize " - "/proc/net/rtl8192/%s/RF-A\n", - dev->name); - e = create_proc_read_entry("RF-B", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_reg_rf_b, dev); - if (!e) - RT_TRACE(COMP_ERR, "Unable to initialize " - "/proc/net/rtl8192/%s/RF-B\n", - dev->name); - e = create_proc_read_entry("RF-C", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_reg_rf_c, dev); - if (!e) - RT_TRACE(COMP_ERR, "Unable to initialize " - "/proc/net/rtl8192/%s/RF-C\n", - dev->name); - e = create_proc_read_entry("RF-D", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_reg_rf_d, dev); - if (!e) - RT_TRACE(COMP_ERR, "Unable to initialize " - "/proc/net/rtl8192/%s/RF-D\n", - dev->name); - e = create_proc_read_entry("SEC-CAM-1", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_cam_register_1, dev); - if (!e) - RT_TRACE(COMP_ERR, "Unable to initialize " - "/proc/net/rtl8192/%s/SEC-CAM-1\n", - dev->name); - e = create_proc_read_entry("SEC-CAM-2", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_cam_register_2, dev); - if (!e) - RT_TRACE(COMP_ERR, "Unable to initialize " - "/proc/net/rtl8192/%s/SEC-CAM-2\n", - dev->name); - e = create_proc_read_entry("SEC-CAM-3", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_cam_register_3, dev); - if (!e) - RT_TRACE(COMP_ERR, "Unable to initialize " - "/proc/net/rtl8192/%s/SEC-CAM-3\n", - dev->name); -} diff --git a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c index 4217b88e6fc..e51cb49ce10 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c @@ -412,19 +412,18 @@ static int rtllib_ccmp_get_key(void *key, int len, u8 *seq, void *priv) } -static char *rtllib_ccmp_print_stats(char *p, void *priv) +static void rtllib_ccmp_print_stats(struct seq_file *m, void *priv) { struct rtllib_ccmp_data *ccmp = priv; - p += sprintf(p, "key[%d] alg=CCMP key_set=%d " - "tx_pn=%pM rx_pn=%pM " - "format_errors=%d replays=%d decrypt_errors=%d\n", - ccmp->key_idx, ccmp->key_set, - ccmp->tx_pn, ccmp->rx_pn, - ccmp->dot11RSNAStatsCCMPFormatErrors, - ccmp->dot11RSNAStatsCCMPReplays, - ccmp->dot11RSNAStatsCCMPDecryptErrors); - - return p; + seq_printf(m, + "key[%d] alg=CCMP key_set=%d " + "tx_pn=%pM rx_pn=%pM " + "format_errors=%d replays=%d decrypt_errors=%d\n", + ccmp->key_idx, ccmp->key_set, + ccmp->tx_pn, ccmp->rx_pn, + ccmp->dot11RSNAStatsCCMPFormatErrors, + ccmp->dot11RSNAStatsCCMPReplays, + ccmp->dot11RSNAStatsCCMPDecryptErrors); } static struct lib80211_crypto_ops rtllib_crypt_ccmp = { diff --git a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c index 800925053fb..5cfd73baf1c 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c @@ -708,30 +708,30 @@ static int rtllib_tkip_get_key(void *key, int len, u8 *seq, void *priv) } -static char *rtllib_tkip_print_stats(char *p, void *priv) +static void rtllib_tkip_print_stats(struct seq_file *m, void *priv) { struct rtllib_tkip_data *tkip = priv; - p += sprintf(p, "key[%d] alg=TKIP key_set=%d " - "tx_pn=%02x%02x%02x%02x%02x%02x " - "rx_pn=%02x%02x%02x%02x%02x%02x " - "replays=%d icv_errors=%d local_mic_failures=%d\n", - tkip->key_idx, tkip->key_set, - (tkip->tx_iv32 >> 24) & 0xff, - (tkip->tx_iv32 >> 16) & 0xff, - (tkip->tx_iv32 >> 8) & 0xff, - tkip->tx_iv32 & 0xff, - (tkip->tx_iv16 >> 8) & 0xff, - tkip->tx_iv16 & 0xff, - (tkip->rx_iv32 >> 24) & 0xff, - (tkip->rx_iv32 >> 16) & 0xff, - (tkip->rx_iv32 >> 8) & 0xff, - tkip->rx_iv32 & 0xff, - (tkip->rx_iv16 >> 8) & 0xff, - tkip->rx_iv16 & 0xff, - tkip->dot11RSNAStatsTKIPReplays, - tkip->dot11RSNAStatsTKIPICVErrors, - tkip->dot11RSNAStatsTKIPLocalMICFailures); - return p; + seq_printf(m, + "key[%d] alg=TKIP key_set=%d " + "tx_pn=%02x%02x%02x%02x%02x%02x " + "rx_pn=%02x%02x%02x%02x%02x%02x " + "replays=%d icv_errors=%d local_mic_failures=%d\n", + tkip->key_idx, tkip->key_set, + (tkip->tx_iv32 >> 24) & 0xff, + (tkip->tx_iv32 >> 16) & 0xff, + (tkip->tx_iv32 >> 8) & 0xff, + tkip->tx_iv32 & 0xff, + (tkip->tx_iv16 >> 8) & 0xff, + tkip->tx_iv16 & 0xff, + (tkip->rx_iv32 >> 24) & 0xff, + (tkip->rx_iv32 >> 16) & 0xff, + (tkip->rx_iv32 >> 8) & 0xff, + tkip->rx_iv32 & 0xff, + (tkip->rx_iv16 >> 8) & 0xff, + tkip->rx_iv16 & 0xff, + tkip->dot11RSNAStatsTKIPReplays, + tkip->dot11RSNAStatsTKIPICVErrors, + tkip->dot11RSNAStatsTKIPLocalMICFailures); } static struct lib80211_crypto_ops rtllib_crypt_tkip = { diff --git a/drivers/staging/rtl8192e/rtllib_crypt_wep.c b/drivers/staging/rtl8192e/rtllib_crypt_wep.c index 8cdf38913a3..c4df6e01ef7 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_wep.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_wep.c @@ -247,12 +247,10 @@ static int prism2_wep_get_key(void *key, int len, u8 *seq, void *priv) } -static char *prism2_wep_print_stats(char *p, void *priv) +static void prism2_wep_print_stats(struct seq_file *m, void *priv) { struct prism2_wep_data *wep = priv; - p += sprintf(p, "key[%d] alg=WEP len=%d\n", - wep->key_idx, wep->key_len); - return p; + seq_printf(m, "key[%d] alg=WEP len=%d\n", wep->key_idx, wep->key_len); } static struct lib80211_crypto_ops rtllib_crypt_wep = { diff --git a/drivers/staging/rtl8192e/rtllib_module.c b/drivers/staging/rtl8192e/rtllib_module.c index f9dae958a5d..84ea721d5d8 100644 --- a/drivers/staging/rtl8192e/rtllib_module.c +++ b/drivers/staging/rtl8192e/rtllib_module.c @@ -208,61 +208,51 @@ static int debug = \ ; static struct proc_dir_entry *rtllib_proc; -static int show_debug_level(char *page, char **start, off_t offset, - int count, int *eof, void *data) +static int show_debug_level(struct seq_file *m, void *v) { - return snprintf(page, count, "0x%08X\n", rtllib_debug_level); + return seq_printf(m, "0x%08X\n", rtllib_debug_level); } -static int store_debug_level(struct file *file, const char __user *buffer, - unsigned long count, void *data) +static ssize_t write_debug_level(struct file *file, const char __user *buffer, + size_t count, loff_t *ppos) { - char buf[] = "0x00000000"; - unsigned long len = min((unsigned long)sizeof(buf) - 1, count); - char *p = (char *)buf; unsigned long val; + int err = kstrtoul_from_user(buffer, count, 0, &val); + if (err) + return err; + rtllib_debug_level = val; + return count; +} - if (copy_from_user(buf, buffer, len)) - return count; - buf[len] = 0; - if (p[1] == 'x' || p[1] == 'X' || p[0] == 'x' || p[0] == 'X') { - p++; - if (p[0] == 'x' || p[0] == 'X') - p++; - val = simple_strtoul(p, &p, 16); - } else - val = simple_strtoul(p, &p, 10); - if (p == buf) - printk(KERN_INFO DRV_NAME - ": %s is not in hex or decimal form.\n", buf); - else - rtllib_debug_level = val; - - return strnlen(buf, count); +static int open_debug_level(struct inode *inode, struct file *file) +{ + return single_open(file, show_debug_level, NULL); } +static const struct file_operations fops = { + .open = open_debug_level, + .read = seq_read, + .llseek = seq_lseek, + .write = write_debug_level +}; + int __init rtllib_init(void) { struct proc_dir_entry *e; rtllib_debug_level = debug; - rtllib_proc = create_proc_entry(DRV_NAME, S_IFDIR, init_net.proc_net); + rtllib_proc = proc_mkdir(DRV_NAME, init_net.proc_net); if (rtllib_proc == NULL) { RTLLIB_ERROR("Unable to create " DRV_NAME " proc directory\n"); return -EIO; } - e = create_proc_entry("debug_level", S_IFREG | S_IRUGO | S_IWUSR, - rtllib_proc); + e = proc_create("debug_level", S_IRUGO | S_IWUSR, rtllib_proc, &fops); if (!e) { remove_proc_entry(DRV_NAME, init_net.proc_net); rtllib_proc = NULL; return -EIO; } - e->read_proc = show_debug_level; - e->write_proc = store_debug_level; - e->data = NULL; - return 0; } diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c index 76c56e5aed7..e0870c05a5e 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c @@ -243,39 +243,34 @@ static int debug = \ ; struct proc_dir_entry *ieee80211_proc; -static int show_debug_level(char *page, char **start, off_t offset, - int count, int *eof, void *data) +static int show_debug_level(struct seq_file *m, void *v) { - return snprintf(page, count, "0x%08X\n", ieee80211_debug_level); + return seq_printf(m, "0x%08X\n", ieee80211_debug_level); } -static int store_debug_level(struct file *file, const char *buffer, - unsigned long count, void *data) +static ssize_t write_debug_level(struct file *file, const char __user *buffer, + size_t count, loff_t *ppos) { - char buf[] = "0x00000000"; - unsigned long len = min_t(unsigned long, sizeof(buf) - 1, count); - char *p = (char *)buf; unsigned long val; + int err = kstrtoul_from_user(buffer, count, 0, &val); + if (err) + return err; + ieee80211_debug_level = val; + return count; +} - if (copy_from_user(buf, buffer, len)) - return count; - buf[len] = 0; - if (p[1] == 'x' || p[1] == 'X' || p[0] == 'x' || p[0] == 'X') { - p++; - if (p[0] == 'x' || p[0] == 'X') - p++; - val = simple_strtoul(p, &p, 16); - } else - val = simple_strtoul(p, &p, 10); - if (p == buf) - printk(KERN_INFO DRV_NAME - ": %s is not in hex or decimal form.\n", buf); - else - ieee80211_debug_level = val; - - return strnlen(buf, count); +static int open_debug_level(struct inode *inode, struct file *file) +{ + return single_open(file, show_debug_level, NULL); } +static const struct file_operations fops = { + .open = open_debug_level, + .read = seq_read, + .llseek = seq_lseek, + .write = write_debug_level +}; + int __init ieee80211_debug_init(void) { struct proc_dir_entry *e; @@ -288,17 +283,13 @@ int __init ieee80211_debug_init(void) " proc directory\n"); return -EIO; } - e = create_proc_entry("debug_level", S_IFREG | S_IRUGO | S_IWUSR, - ieee80211_proc); + e = proc_create("debug_level", S_IRUGO | S_IWUSR, + ieee80211_proc, &fops); if (!e) { remove_proc_entry(DRV_NAME, init_net.proc_net); ieee80211_proc = NULL; return -EIO; } - e->read_proc = show_debug_level; - e->write_proc = store_debug_level; - e->data = NULL; - return 0; } diff --git a/drivers/staging/rtl8192u/ieee80211/proc.c b/drivers/staging/rtl8192u/ieee80211/proc.c index 6eda928e409..c426dfdd9fd 100644 --- a/drivers/staging/rtl8192u/ieee80211/proc.c +++ b/drivers/staging/rtl8192u/ieee80211/proc.c @@ -99,7 +99,7 @@ static int crypto_info_open(struct inode *inode, struct file *file) return seq_open(file, &crypto_seq_ops); } -static struct file_operations proc_crypto_ops = { +static const struct file_operations proc_crypto_ops = { .open = crypto_info_open, .read = seq_read, .llseek = seq_lseek, @@ -108,9 +108,5 @@ static struct file_operations proc_crypto_ops = { void __init crypto_init_proc(void) { - struct proc_dir_entry *proc; - - proc = create_proc_entry("crypto", 0, NULL); - if (proc) - proc->proc_fops = &proc_crypto_ops; + proc_create("crypto", 0, NULL, &proc_crypto_ops); } diff --git a/drivers/staging/rtl8192u/r8192U.h b/drivers/staging/rtl8192u/r8192U.h index e538e026b51..bedeb330ad4 100644 --- a/drivers/staging/rtl8192u/r8192U.h +++ b/drivers/staging/rtl8192u/r8192U.h @@ -946,7 +946,6 @@ typedef struct r8192_priv { /*stats*/ struct Stats stats; struct iw_statistics wstats; - struct proc_dir_entry *dir_dev; /*RX stuff*/ // u32 *rxring; diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index f7de2f6d49a..14592339755 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -71,6 +71,8 @@ double __extendsfdf2(float a) {return a;} //#include "r8192xU_phyreg.h" #include <linux/usb.h> #include <linux/slab.h> +#include <linux/proc_fs.h> +#include <linux/seq_file.h> // FIXME: check if 2.6.7 is ok #ifdef CONFIG_RTL8192_PM @@ -472,103 +474,73 @@ void watch_dog_timer_callback(unsigned long data); static struct proc_dir_entry *rtl8192_proc; -static int proc_get_stats_ap(char *page, char **start, off_t offset, int count, - int *eof, void *data) +static int proc_get_stats_ap(struct seq_file *m, void *v) { - struct net_device *dev = data; + struct net_device *dev = m->private; struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); struct ieee80211_device *ieee = priv->ieee80211; struct ieee80211_network *target; - int len = 0; - list_for_each_entry(target, &ieee->network_list, list) { - - len += snprintf(page + len, count - len, "%s ", target->ssid); - + const char *wpa = "non_WPA"; if (target->wpa_ie_len > 0 || target->rsn_ie_len > 0) - len += snprintf(page + len, count - len, "WPA\n"); - else - len += snprintf(page + len, count - len, "non_WPA\n"); + wpa = "WPA"; + + seq_printf(m, "%s %s\n", target->ssid, wpa); } - *eof = 1; - return len; + return 0; } -static int proc_get_registers(char *page, char **start, - off_t offset, int count, - int *eof, void *data) +static int proc_get_registers(struct seq_file *m, void *v) { - struct net_device *dev = data; -// struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); + struct net_device *dev = m->private; + int i,n, max = 0xff; - int len = 0; - int i,n; - - int max=0xff; - - /* This dump the current register page */ - len += snprintf(page + len, count - len, - "\n####################page 0##################\n "); + seq_puts(m, "\n####################page 0##################\n "); for (n=0;n<=max;) { //printk( "\nD: %2x> ", n); - len += snprintf(page + len, count - len, - "\nD: %2x > ",n); + seq_printf(m, "\nD: %2x > ",n); for (i=0;i<16 && n<=max;i++,n++) - len += snprintf(page + len, count - len, - "%2x ",read_nic_byte(dev,0x000|n)); + seq_printf(m, "%2x ",read_nic_byte(dev,0x000|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;) { //printk( "\nD: %2x> ", n); - len += snprintf(page + len, count - len, - "\nD: %2x > ",n); + seq_printf(m, "\nD: %2x > ",n); for (i=0;i<16 && n<=max;i++,n++) - len += snprintf(page + len, count - len, - "%2x ",read_nic_byte(dev,0x100|n)); + seq_printf(m, "%2x ",read_nic_byte(dev,0x100|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;) { //printk( "\nD: %2x> ", n); - len += snprintf(page + len, count - len, - "\nD: %2x > ",n); + seq_printf(m, "\nD: %2x > ",n); for(i=0;i<16 && n<=max;i++,n++) - len += snprintf(page + len, count - len, - "%2x ",read_nic_byte(dev,0x300|n)); + seq_printf(m, "%2x ",read_nic_byte(dev,0x300|n)); // printk("%2x ",read_nic_byte(dev,n)); } - len += snprintf(page + len, count - len,"\n"); - *eof = 1; - return len; + seq_putc(m, '\n'); + return 0; } - - - - -static int proc_get_stats_tx(char *page, char **start, - off_t offset, int count, - int *eof, void *data) +static int proc_get_stats_tx(struct seq_file *m, void *v) { - struct net_device *dev = data; + struct net_device *dev = m->private; struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); - int len = 0; - - len += snprintf(page + len, count - len, + seq_printf(m, "TX VI priority ok int: %lu\n" "TX VI priority error 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 ); - *eof = 1; - return len; + return 0; } - - -static int proc_get_stats_rx(char *page, char **start, - off_t offset, int count, - int *eof, void *data) +static int proc_get_stats_rx(struct seq_file *m, void *v) { - struct net_device *dev = data; + struct net_device *dev = m->private; struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); - int len = 0; - - len += snprintf(page + len, count - len, + seq_printf(m, "RX packets: %lu\n" "RX urb status 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.rxurberr); - *eof = 1; - return len; + return 0; } + void rtl8192_proc_module_init(void) { RT_TRACE(COMP_INIT, "Initializing proc filesystem"); @@ -667,74 +632,70 @@ void rtl8192_proc_module_remove(void) remove_proc_entry(RTL819xU_MODULE_NAME, init_net.proc_net); } - -void rtl8192_proc_remove_one(struct net_device *dev) +/* + * seq_file wrappers for procfile show routines. + */ +static int rtl8192_proc_open(struct inode *inode, struct file *file) { - struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); + struct net_device *dev = proc_get_parent_data(inode); + int (*show)(struct seq_file *, void *) = PDE_DATA(inode); - - if (priv->dir_dev) { - // remove_proc_entry("stats-hw", priv->dir_dev); - 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; - } + 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, +}; -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); - } - +/* + * Table of proc files we need to create. + */ +struct rtl8192_proc_file { + char name[12]; + int (*show)(struct seq_file *, void *); +}; - e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_stats_tx, dev); +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 }, + { "" } +}; - if (!e) { - RT_TRACE(COMP_ERR, "Unable to initialize " - "/proc/net/rtl8192/%s/stats-tx\n", - dev->name); - } +void rtl8192_proc_init_one(struct net_device *dev) +{ + const struct rtl8192_proc_file *f; + struct proc_dir_entry *dir; - e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_stats_ap, dev); + 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); + return; + } - if (!e) { - RT_TRACE(COMP_ERR, "Unable to initialize " - "/proc/net/rtl8192/%s/stats-ap\n", - dev->name); + 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); + return; + } + } } +} - 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); - } +void rtl8192_proc_remove_one(struct net_device *dev) +{ + remove_proc_subtree(dev->name, rtl8192_proc); } + /**************************************************************************** -----------------------------MISC STUFF------------------------- *****************************************************************************/ diff --git a/drivers/staging/rts5139/rts51x_scsi.c b/drivers/staging/rts5139/rts51x_scsi.c index b58f1dfe006..61087054640 100644 --- a/drivers/staging/rts5139/rts51x_scsi.c +++ b/drivers/staging/rts5139/rts51x_scsi.c @@ -1968,18 +1968,16 @@ int slave_configure(struct scsi_device *sdev) /* we use this macro to help us write into the buffer */ #undef SPRINTF -#define SPRINTF(args...) \ - do { if (pos < buffer+length) pos += sprintf(pos, ## args); } while (0) +#define SPRINTF(args...) seq_printf(m, ##args) -int proc_info(struct Scsi_Host *host, char *buffer, - char **start, off_t offset, int length, int inout) +static int write_info(struct Scsi_Host *host, char *buffer, int length) { - char *pos = buffer; - /* if someone is sending us data, just throw it away */ - if (inout) - return length; + return length; +} +static int show_info(struct seq_file *m, struct Scsi_Host *host) +{ /* print the controller name */ SPRINTF(" Host scsi%d: %s\n", host->host_no, RTS51X_NAME); @@ -1988,18 +1986,7 @@ int proc_info(struct Scsi_Host *host, char *buffer, SPRINTF(" Product: RTS51xx USB Card Reader\n"); SPRINTF(" Version: %s\n", DRIVER_VERSION); SPRINTF(" Build: %s\n", __TIME__); - - /* - * Calculate start of next buffer, and return value. - */ - *start = buffer + offset; - - if ((pos - buffer) < offset) - return 0; - else if ((pos - buffer - offset) < length) - return pos - buffer - offset; - else - return length; + return 0; } /* queue a command */ @@ -2100,7 +2087,8 @@ struct scsi_host_template rts51x_host_template = { /* basic userland interface stuff */ .name = RTS51X_NAME, .proc_name = RTS51X_NAME, - .proc_info = proc_info, + .show_info = show_info, + .write_info = write_info, .info = rts5139_info, /* command interface -- queued only */ diff --git a/drivers/staging/rts5139/rts51x_scsi.h b/drivers/staging/rts5139/rts51x_scsi.h index 3a5213611d2..1a0d7056618 100644 --- a/drivers/staging/rts5139/rts51x_scsi.h +++ b/drivers/staging/rts5139/rts51x_scsi.h @@ -147,8 +147,6 @@ struct scsi_cmnd; int slave_alloc(struct scsi_device *sdev); int slave_configure(struct scsi_device *sdev); -int proc_info(struct Scsi_Host *host, char *buffer, - char **start, off_t offset, int length, int inout); int queuecommand(struct Scsi_Host *, struct scsi_cmnd *); int command_abort(struct scsi_cmnd *srb); int bus_reset(struct scsi_cmnd *srb); diff --git a/drivers/staging/silicom/Makefile b/drivers/staging/silicom/Makefile index 80e6d12d156..ca8359481c4 100644 --- a/drivers/staging/silicom/Makefile +++ b/drivers/staging/silicom/Makefile @@ -4,6 +4,3 @@ obj-$(CONFIG_BPCTL) += bpctl_mod.o obj-$(CONFIG_SBYPASS) += bypasslib/ - - -bpctl_mod-objs := bp_mod.o bp_proc.o diff --git a/drivers/staging/silicom/bp_proc.c b/drivers/staging/silicom/bp_proc.c deleted file mode 100644 index a01ca97b766..00000000000 --- a/drivers/staging/silicom/bp_proc.c +++ /dev/null @@ -1,1327 +0,0 @@ -/******************************************************************************/ -/* */ -/* Copyright (c) 2004-2006 Silicom, Ltd */ -/* All rights reserved. */ -/* */ -/* This program is free software; you can redistribute it and/or modify */ -/* it under the terms of the GNU General Public License as published by */ -/* the Free Software Foundation, located in the file LICENSE. */ -/* */ -/* */ -/******************************************************************************/ - -#if defined(CONFIG_SMP) && !defined(__SMP__) -#define __SMP__ -#endif - -#include <linux/proc_fs.h> -#include <linux/netdevice.h> -#include <asm/uaccess.h> -/* #include <linux/smp_lock.h> */ -#include "bp_mod.h" - -#define BP_PROC_DIR "bypass" -/* #define BYPASS_SUPPORT "bypass" */ - -#ifdef BYPASS_SUPPORT - -#define GPIO6_SET_ENTRY_SD "gpio6_set" -#define GPIO6_CLEAR_ENTRY_SD "gpio6_clear" - -#define GPIO7_SET_ENTRY_SD "gpio7_set" -#define GPIO7_CLEAR_ENTRY_SD "gpio7_clear" - -#define PULSE_SET_ENTRY_SD "pulse_set" -#define ZERO_SET_ENTRY_SD "zero_set" -#define PULSE_GET1_ENTRY_SD "pulse_get1" -#define PULSE_GET2_ENTRY_SD "pulse_get2" - -#define CMND_ON_ENTRY_SD "cmnd_on" -#define CMND_OFF_ENTRY_SD "cmnd_off" -#define RESET_CONT_ENTRY_SD "reset_cont" - - /*COMMANDS*/ -#define BYPASS_INFO_ENTRY_SD "bypass_info" -#define BYPASS_SLAVE_ENTRY_SD "bypass_slave" -#define BYPASS_CAPS_ENTRY_SD "bypass_caps" -#define WD_SET_CAPS_ENTRY_SD "wd_set_caps" -#define BYPASS_ENTRY_SD "bypass" -#define BYPASS_CHANGE_ENTRY_SD "bypass_change" -#define BYPASS_WD_ENTRY_SD "bypass_wd" -#define WD_EXPIRE_TIME_ENTRY_SD "wd_expire_time" -#define RESET_BYPASS_WD_ENTRY_SD "reset_bypass_wd" -#define DIS_BYPASS_ENTRY_SD "dis_bypass" -#define BYPASS_PWUP_ENTRY_SD "bypass_pwup" -#define BYPASS_PWOFF_ENTRY_SD "bypass_pwoff" -#define STD_NIC_ENTRY_SD "std_nic" -#define STD_NIC_ENTRY_SD "std_nic" -#define TAP_ENTRY_SD "tap" -#define TAP_CHANGE_ENTRY_SD "tap_change" -#define DIS_TAP_ENTRY_SD "dis_tap" -#define TAP_PWUP_ENTRY_SD "tap_pwup" -#define TWO_PORT_LINK_ENTRY_SD "two_port_link" -#define WD_EXP_MODE_ENTRY_SD "wd_exp_mode" -#define WD_AUTORESET_ENTRY_SD "wd_autoreset" -#define TPL_ENTRY_SD "tpl" -#define WAIT_AT_PWUP_ENTRY_SD "wait_at_pwup" -#define HW_RESET_ENTRY_SD "hw_reset" -#define DISC_ENTRY_SD "disc" -#define DISC_CHANGE_ENTRY_SD "disc_change" -#define DIS_DISC_ENTRY_SD "dis_disc" -#define DISC_PWUP_ENTRY_SD "disc_pwup" - -static struct proc_dir_entry *bp_procfs_dir; - -static struct proc_dir_entry *proc_getdir(char *name, - struct proc_dir_entry *proc_dir) -{ - struct proc_dir_entry *pde = proc_dir; - for (pde = pde->subdir; pde; pde = pde->next) { - if (pde->namelen && (strcmp(name, pde->name) == 0)) { - /* directory exists */ - break; - } - } - if (pde == (struct proc_dir_entry *)0) { - /* create the directory */ - pde = create_proc_entry(name, S_IFDIR, proc_dir); - if (pde == (struct proc_dir_entry *)0) - return pde; - } - return pde; -} - -int -bypass_proc_create_entry_sd(struct pfs_unit *pfs_unit_curr, - char *proc_name, - write_proc_t *write_proc, - read_proc_t *read_proc, - struct proc_dir_entry *parent_pfs, void *data) -{ - strcpy(pfs_unit_curr->proc_name, proc_name); - pfs_unit_curr->proc_entry = create_proc_entry(pfs_unit_curr->proc_name, - S_IFREG | S_IRUSR | - S_IWUSR | S_IRGRP | - S_IROTH, parent_pfs); - if (pfs_unit_curr->proc_entry == 0) - return -1; - - pfs_unit_curr->proc_entry->read_proc = read_proc; - pfs_unit_curr->proc_entry->write_proc = write_proc; - pfs_unit_curr->proc_entry->data = data; - - return 0; - -} - -int -get_bypass_info_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) -{ - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - int len = 0; - - len += sprintf(page, "Name\t\t\t%s\n", pbp_device_block->bp_name); - len += - sprintf(page + len, "Firmware version\t0x%x\n", - pbp_device_block->bp_fw_ver); - - *eof = 1; - return len; -} - -int -get_bypass_slave_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) -{ - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - struct pci_dev *pci_slave_dev = pbp_device_block->bp_slave; - struct net_device *net_slave_dev; - int len = 0; - - if (is_bypass_fn(pbp_device_block)) { - net_slave_dev = pci_get_drvdata(pci_slave_dev); - if (net_slave_dev) - len = sprintf(page, "%s\n", net_slave_dev->name); - else - len = sprintf(page, "fail\n"); - } else - len = sprintf(page, "fail\n"); - - *eof = 1; - return len; -} - -int -get_bypass_caps_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) -{ - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; - - ret = get_bypass_caps_fn(pbp_device_block); - if (ret == BP_NOT_CAP) - len = sprintf(page, "-1\n"); - else - len = sprintf(page, "0x%x\n", ret); - *eof = 1; - return len; - -} - -int -get_wd_set_caps_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) -{ - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; - - ret = get_wd_set_caps_fn(pbp_device_block); - if (ret == BP_NOT_CAP) - len = sprintf(page, "-1\n"); - else - len = sprintf(page, "0x%x\n", ret); - *eof = 1; - return len; -} - -int -set_bypass_pfs(struct file *file, const char *buffer, - unsigned long count, void *data) -{ - - char kbuf[256]; - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int bypass_param = 0, length = 0; - - if (count > (sizeof(kbuf) - 1)) - return -1; - - if (copy_from_user(&kbuf, buffer, count)) - return -1; - - kbuf[count] = '\0'; - length = strlen(kbuf); - if (kbuf[length - 1] == '\n') - kbuf[--length] = '\0'; - - if (strcmp(kbuf, "on") == 0) - bypass_param = 1; - else if (strcmp(kbuf, "off") == 0) - bypass_param = 0; - - set_bypass_fn(pbp_device_block, bypass_param); - - return count; -} - -int -set_tap_pfs(struct file *file, const char *buffer, - unsigned long count, void *data) -{ - - char kbuf[256]; - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int tap_param = 0, length = 0; - - if (count > (sizeof(kbuf) - 1)) - return -1; - - if (copy_from_user(&kbuf, buffer, count)) - return -1; - - kbuf[count] = '\0'; - length = strlen(kbuf); - if (kbuf[length - 1] == '\n') - kbuf[--length] = '\0'; - - if (strcmp(kbuf, "on") == 0) - tap_param = 1; - else if (strcmp(kbuf, "off") == 0) - tap_param = 0; - - set_tap_fn(pbp_device_block, tap_param); - - return count; -} - -int -set_disc_pfs(struct file *file, const char *buffer, - unsigned long count, void *data) -{ - - char kbuf[256]; - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int tap_param = 0, length = 0; - - if (count > (sizeof(kbuf) - 1)) - return -1; - - if (copy_from_user(&kbuf, buffer, count)) - return -1; - - kbuf[count] = '\0'; - length = strlen(kbuf); - if (kbuf[length - 1] == '\n') - kbuf[--length] = '\0'; - - if (strcmp(kbuf, "on") == 0) - tap_param = 1; - else if (strcmp(kbuf, "off") == 0) - tap_param = 0; - - set_disc_fn(pbp_device_block, tap_param); - - return count; -} - -int -get_bypass_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) -{ - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; - - ret = get_bypass_fn(pbp_device_block); - if (ret == BP_NOT_CAP) - len = sprintf(page, "fail\n"); - else if (ret == 1) - len = sprintf(page, "on\n"); - else if (ret == 0) - len = sprintf(page, "off\n"); - - *eof = 1; - return len; -} - -int -get_tap_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) -{ - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; - - ret = get_tap_fn(pbp_device_block); - if (ret == BP_NOT_CAP) - len = sprintf(page, "fail\n"); - else if (ret == 1) - len = sprintf(page, "on\n"); - else if (ret == 0) - len = sprintf(page, "off\n"); - - *eof = 1; - return len; -} - -int -get_disc_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) -{ - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; - - ret = get_disc_fn(pbp_device_block); - if (ret == BP_NOT_CAP) - len = sprintf(page, "fail\n"); - else if (ret == 1) - len = sprintf(page, "on\n"); - else if (ret == 0) - len = sprintf(page, "off\n"); - - *eof = 1; - return len; -} - -int -get_bypass_change_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) -{ - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; - - ret = get_bypass_change_fn(pbp_device_block); - if (ret == 1) - len = sprintf(page, "on\n"); - else if (ret == 0) - len = sprintf(page, "off\n"); - else - len = sprintf(page, "fail\n"); - - *eof = 1; - return len; -} - -int -get_tap_change_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) -{ - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; - - ret = get_tap_change_fn(pbp_device_block); - if (ret == 1) - len = sprintf(page, "on\n"); - else if (ret == 0) - len = sprintf(page, "off\n"); - else - len = sprintf(page, "fail\n"); - - *eof = 1; - return len; -} - -int -get_disc_change_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) -{ - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; - - ret = get_disc_change_fn(pbp_device_block); - if (ret == 1) - len = sprintf(page, "on\n"); - else if (ret == 0) - len = sprintf(page, "off\n"); - else - len = sprintf(page, "fail\n"); - - *eof = 1; - return len; -} - -int -set_bypass_wd_pfs(struct file *file, const char *buffer, - unsigned long count, void *data) -{ - - char kbuf[256]; - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - unsigned int timeout = 0; - char *timeout_ptr = kbuf; - - if (copy_from_user(&kbuf, buffer, count)) - return -1; - - timeout_ptr = kbuf; - timeout = atoi(&timeout_ptr); - - set_bypass_wd_fn(pbp_device_block, timeout); - - return count; -} - -int -get_bypass_wd_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) -{ - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0, timeout = 0; - - ret = get_bypass_wd_fn(pbp_device_block, &timeout); - if (ret == BP_NOT_CAP) - len = sprintf(page, "fail\n"); - else if (timeout == -1) - len = sprintf(page, "unknown\n"); - else if (timeout == 0) - len = sprintf(page, "disable\n"); - else - len = sprintf(page, "%d\n", timeout); - - *eof = 1; - return len; -} - -int -get_wd_expire_time_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) -{ - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0, timeout = 0; - - ret = get_wd_expire_time_fn(pbp_device_block, &timeout); - if (ret == BP_NOT_CAP) - len = sprintf(page, "fail\n"); - else if (timeout == -1) - len = sprintf(page, "expire\n"); - else if (timeout == 0) - len = sprintf(page, "disable\n"); - - else - len = sprintf(page, "%d\n", timeout); - *eof = 1; - return len; -} - -int -get_tpl_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) -{ - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; - - ret = get_tpl_fn(pbp_device_block); - if (ret == BP_NOT_CAP) - len = sprintf(page, "fail\n"); - else if (ret == 1) - len = sprintf(page, "on\n"); - else if (ret == 0) - len = sprintf(page, "off\n"); - - *eof = 1; - return len; -} - -#ifdef PMC_FIX_FLAG -int -get_wait_at_pwup_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) -{ - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; - - ret = get_bp_wait_at_pwup_fn(pbp_device_block); - if (ret == BP_NOT_CAP) - len = sprintf(page, "fail\n"); - else if (ret == 1) - len = sprintf(page, "on\n"); - else if (ret == 0) - len = sprintf(page, "off\n"); - - *eof = 1; - return len; -} - -int -get_hw_reset_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) -{ - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; - - ret = get_bp_hw_reset_fn(pbp_device_block); - if (ret == BP_NOT_CAP) - len = sprintf(page, "fail\n"); - else if (ret == 1) - len = sprintf(page, "on\n"); - else if (ret == 0) - len = sprintf(page, "off\n"); - - *eof = 1; - return len; -} - -#endif /*PMC_WAIT_FLAG */ - -int -reset_bypass_wd_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) -{ - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; - - ret = reset_bypass_wd_timer_fn(pbp_device_block); - if (ret == BP_NOT_CAP) - len = sprintf(page, "fail\n"); - else if (ret == 0) - len = sprintf(page, "disable\n"); - else if (ret == 1) - len = sprintf(page, "success\n"); - - *eof = 1; - return len; -} - -int -set_dis_bypass_pfs(struct file *file, const char *buffer, - unsigned long count, void *data) -{ - - char kbuf[256]; - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int bypass_param = 0, length = 0; - - if (copy_from_user(&kbuf, buffer, count)) - return -1; - - kbuf[count] = '\0'; - length = strlen(kbuf); - if (kbuf[length - 1] == '\n') - kbuf[--length] = '\0'; - - if (strcmp(kbuf, "on") == 0) - bypass_param = 1; - else if (strcmp(kbuf, "off") == 0) - bypass_param = 0; - - set_dis_bypass_fn(pbp_device_block, bypass_param); - - return count; -} - -int -set_dis_tap_pfs(struct file *file, const char *buffer, - unsigned long count, void *data) -{ - - char kbuf[256]; - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int tap_param = 0, length = 0; - - if (copy_from_user(&kbuf, buffer, count)) - return -1; - - kbuf[count] = '\0'; - length = strlen(kbuf); - if (kbuf[length - 1] == '\n') - kbuf[--length] = '\0'; - - if (strcmp(kbuf, "on") == 0) - tap_param = 1; - else if (strcmp(kbuf, "off") == 0) - tap_param = 0; - - set_dis_tap_fn(pbp_device_block, tap_param); - - return count; -} - -int -set_dis_disc_pfs(struct file *file, const char *buffer, - unsigned long count, void *data) -{ - - char kbuf[256]; - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int tap_param = 0, length = 0; - - if (copy_from_user(&kbuf, buffer, count)) - return -1; - - kbuf[count] = '\0'; - length = strlen(kbuf); - if (kbuf[length - 1] == '\n') - kbuf[--length] = '\0'; - - if (strcmp(kbuf, "on") == 0) - tap_param = 1; - else if (strcmp(kbuf, "off") == 0) - tap_param = 0; - - set_dis_disc_fn(pbp_device_block, tap_param); - - return count; -} - -int -get_dis_bypass_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) -{ - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; - - ret = get_dis_bypass_fn(pbp_device_block); - if (ret == BP_NOT_CAP) - len = sprintf(page, "fail\n"); - else if (ret == 0) - len = sprintf(page, "off\n"); - else - len = sprintf(page, "on\n"); - - *eof = 1; - return len; -} - -int -get_dis_tap_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) -{ - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; - - ret = get_dis_tap_fn(pbp_device_block); - if (ret == BP_NOT_CAP) - len = sprintf(page, "fail\n"); - else if (ret == 0) - len = sprintf(page, "off\n"); - else - len = sprintf(page, "on\n"); - - *eof = 1; - return len; -} - -int -get_dis_disc_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) -{ - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; - - ret = get_dis_disc_fn(pbp_device_block); - if (ret == BP_NOT_CAP) - len = sprintf(page, "fail\n"); - else if (ret == 0) - len = sprintf(page, "off\n"); - else - len = sprintf(page, "on\n"); - - *eof = 1; - return len; -} - -int -set_bypass_pwup_pfs(struct file *file, const char *buffer, - unsigned long count, void *data) -{ - - char kbuf[256]; - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int bypass_param = 0, length = 0; - - if (copy_from_user(&kbuf, buffer, count)) - return -1; - - kbuf[count] = '\0'; - length = strlen(kbuf); - if (kbuf[length - 1] == '\n') - kbuf[--length] = '\0'; - - if (strcmp(kbuf, "on") == 0) - bypass_param = 1; - else if (strcmp(kbuf, "off") == 0) - bypass_param = 0; - - set_bypass_pwup_fn(pbp_device_block, bypass_param); - - return count; -} - -int -set_bypass_pwoff_pfs(struct file *file, const char *buffer, - unsigned long count, void *data) -{ - - char kbuf[256]; - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int bypass_param = 0, length = 0; - - if (copy_from_user(&kbuf, buffer, count)) - return -1; - - kbuf[count] = '\0'; - length = strlen(kbuf); - if (kbuf[length - 1] == '\n') - kbuf[--length] = '\0'; - - if (strcmp(kbuf, "on") == 0) - bypass_param = 1; - else if (strcmp(kbuf, "off") == 0) - bypass_param = 0; - - set_bypass_pwoff_fn(pbp_device_block, bypass_param); - - return count; -} - -int -set_tap_pwup_pfs(struct file *file, const char *buffer, - unsigned long count, void *data) -{ - - char kbuf[256]; - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int tap_param = 0, length = 0; - - if (copy_from_user(&kbuf, buffer, count)) - return -1; - - kbuf[count] = '\0'; - length = strlen(kbuf); - if (kbuf[length - 1] == '\n') - kbuf[--length] = '\0'; - - if (strcmp(kbuf, "on") == 0) - tap_param = 1; - else if (strcmp(kbuf, "off") == 0) - tap_param = 0; - - set_tap_pwup_fn(pbp_device_block, tap_param); - - return count; -} - -int -set_disc_pwup_pfs(struct file *file, const char *buffer, - unsigned long count, void *data) -{ - - char kbuf[256]; - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int tap_param = 0, length = 0; - - if (copy_from_user(&kbuf, buffer, count)) - return -1; - - kbuf[count] = '\0'; - length = strlen(kbuf); - if (kbuf[length - 1] == '\n') - kbuf[--length] = '\0'; - - if (strcmp(kbuf, "on") == 0) - tap_param = 1; - else if (strcmp(kbuf, "off") == 0) - tap_param = 0; - - set_disc_pwup_fn(pbp_device_block, tap_param); - - return count; -} - -int -get_bypass_pwup_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) -{ - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; - - ret = get_bypass_pwup_fn(pbp_device_block); - if (ret == BP_NOT_CAP) - len = sprintf(page, "fail\n"); - else if (ret == 0) - len = sprintf(page, "off\n"); - else - len = sprintf(page, "on\n"); - - *eof = 1; - return len; -} - -int -get_bypass_pwoff_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) -{ - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; - - ret = get_bypass_pwoff_fn(pbp_device_block); - if (ret == BP_NOT_CAP) - len = sprintf(page, "fail\n"); - else if (ret == 0) - len = sprintf(page, "off\n"); - else - len = sprintf(page, "on\n"); - - *eof = 1; - return len; -} - -int -get_tap_pwup_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) -{ - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; - - ret = get_tap_pwup_fn(pbp_device_block); - if (ret == BP_NOT_CAP) - len = sprintf(page, "fail\n"); - else if (ret == 0) - len = sprintf(page, "off\n"); - else - len = sprintf(page, "on\n"); - - *eof = 1; - return len; -} - -int -get_disc_pwup_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) -{ - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; - - ret = get_disc_pwup_fn(pbp_device_block); - if (ret == BP_NOT_CAP) - len = sprintf(page, "fail\n"); - else if (ret == 0) - len = sprintf(page, "off\n"); - else - len = sprintf(page, "on\n"); - - *eof = 1; - return len; -} - -int -set_std_nic_pfs(struct file *file, const char *buffer, - unsigned long count, void *data) -{ - - char kbuf[256]; - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int bypass_param = 0, length = 0; - - if (copy_from_user(&kbuf, buffer, count)) - return -1; - - kbuf[count] = '\0'; - length = strlen(kbuf); - if (kbuf[length - 1] == '\n') - kbuf[--length] = '\0'; - - if (strcmp(kbuf, "on") == 0) - bypass_param = 1; - else if (strcmp(kbuf, "off") == 0) - bypass_param = 0; - - set_std_nic_fn(pbp_device_block, bypass_param); - - return count; -} - -int -get_std_nic_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) -{ - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; - - ret = get_std_nic_fn(pbp_device_block); - if (ret == BP_NOT_CAP) - len = sprintf(page, "fail\n"); - else if (ret == 0) - len = sprintf(page, "off\n"); - else - len = sprintf(page, "on\n"); - - *eof = 1; - return len; -} - -int -get_wd_exp_mode_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) -{ - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; - - ret = get_wd_exp_mode_fn(pbp_device_block); - if (ret == 1) - len = sprintf(page, "tap\n"); - else if (ret == 0) - len = sprintf(page, "bypass\n"); - else if (ret == 2) - len = sprintf(page, "disc\n"); - - else - len = sprintf(page, "fail\n"); - - *eof = 1; - return len; -} - -int -set_wd_exp_mode_pfs(struct file *file, const char *buffer, - unsigned long count, void *data) -{ - - char kbuf[256]; - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int bypass_param = 0, length = 0; - - if (count > (sizeof(kbuf) - 1)) - return -1; - - if (copy_from_user(&kbuf, buffer, count)) - return -1; - - kbuf[count] = '\0'; - length = strlen(kbuf); - if (kbuf[length - 1] == '\n') - kbuf[--length] = '\0'; - - if (strcmp(kbuf, "tap") == 0) - bypass_param = 1; - else if (strcmp(kbuf, "bypass") == 0) - bypass_param = 0; - else if (strcmp(kbuf, "disc") == 0) - bypass_param = 2; - - set_wd_exp_mode_fn(pbp_device_block, bypass_param); - - return count; -} - -int -get_wd_autoreset_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) -{ - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; - - ret = get_wd_autoreset_fn(pbp_device_block); - if (ret >= 0) - len = sprintf(page, "%d\n", ret); - else - len = sprintf(page, "fail\n"); - - *eof = 1; - return len; -} - -int -set_wd_autoreset_pfs(struct file *file, const char *buffer, - unsigned long count, void *data) -{ - char kbuf[256]; - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - u32 timeout = 0; - char *timeout_ptr = kbuf; - - if (copy_from_user(&kbuf, buffer, count)) - return -1; - - timeout_ptr = kbuf; - timeout = atoi(&timeout_ptr); - - set_wd_autoreset_fn(pbp_device_block, timeout); - - return count; -} - -int -set_tpl_pfs(struct file *file, const char *buffer, - unsigned long count, void *data) -{ - - char kbuf[256]; - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int tpl_param = 0, length = 0; - - if (count > (sizeof(kbuf) - 1)) - return -1; - - if (copy_from_user(&kbuf, buffer, count)) - return -1; - - kbuf[count] = '\0'; - length = strlen(kbuf); - if (kbuf[length - 1] == '\n') - kbuf[--length] = '\0'; - - if (strcmp(kbuf, "on") == 0) - tpl_param = 1; - else if (strcmp(kbuf, "off") == 0) - tpl_param = 0; - - set_tpl_fn(pbp_device_block, tpl_param); - - return count; -} - -#ifdef PMC_FIX_FLAG -int -set_wait_at_pwup_pfs(struct file *file, const char *buffer, - unsigned long count, void *data) -{ - - char kbuf[256]; - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int tpl_param = 0, length = 0; - - if (count > (sizeof(kbuf) - 1)) - return -1; - - if (copy_from_user(&kbuf, buffer, count)) - return -1; - - kbuf[count] = '\0'; - length = strlen(kbuf); - if (kbuf[length - 1] == '\n') - kbuf[--length] = '\0'; - - if (strcmp(kbuf, "on") == 0) - tpl_param = 1; - else if (strcmp(kbuf, "off") == 0) - tpl_param = 0; - - set_bp_wait_at_pwup_fn(pbp_device_block, tpl_param); - - return count; -} - -int -set_hw_reset_pfs(struct file *file, const char *buffer, - unsigned long count, void *data) -{ - - char kbuf[256]; - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int tpl_param = 0, length = 0; - - if (count > (sizeof(kbuf) - 1)) - return -1; - - if (copy_from_user(&kbuf, buffer, count)) - return -1; - - kbuf[count] = '\0'; - length = strlen(kbuf); - if (kbuf[length - 1] == '\n') - kbuf[--length] = '\0'; - - if (strcmp(kbuf, "on") == 0) - tpl_param = 1; - else if (strcmp(kbuf, "off") == 0) - tpl_param = 0; - - set_bp_hw_reset_fn(pbp_device_block, tpl_param); - - return count; -} - -#endif /*PMC_FIX_FLAG */ - -int bypass_proc_create_dev_sd(bpctl_dev_t *pbp_device_block) -{ - struct bypass_pfs_sd *current_pfs = &(pbp_device_block->bypass_pfs_set); - static struct proc_dir_entry *procfs_dir; - int ret = 0; - - sprintf(current_pfs->dir_name, "bypass_%s", dev->name); - - if (!bp_procfs_dir) - return -1; - - /* create device proc dir */ - procfs_dir = proc_getdir(current_pfs->dir_name, bp_procfs_dir); - if (procfs_dir == 0) { - printk(KERN_DEBUG "Could not create procfs directory %s\n", - current_pfs->dir_name); - return -1; - } - current_pfs->bypass_entry = procfs_dir; - - if (bypass_proc_create_entry(&(current_pfs->bypass_info), BYPASS_INFO_ENTRY_SD, NULL, /* write */ - get_bypass_info_pfs, /* read */ - procfs_dir, pbp_device_block)) - ret = -1; - - if (pbp_device_block->bp_caps & SW_CTL_CAP) { - - /* Create set param proc's */ - if (bypass_proc_create_entry_sd(&(current_pfs->bypass_slave), BYPASS_SLAVE_ENTRY_SD, NULL, /* write */ - get_bypass_slave_pfs, /* read */ - procfs_dir, pbp_device_block)) - ret = -1; - - if (bypass_proc_create_entry_sd(&(current_pfs->bypass_caps), BYPASS_CAPS_ENTRY_SD, NULL, /* write */ - get_bypass_caps_pfs, /* read */ - procfs_dir, pbp_device_block)) - ret = -1; - - if (bypass_proc_create_entry_sd(&(current_pfs->wd_set_caps), WD_SET_CAPS_ENTRY_SD, NULL, /* write */ - get_wd_set_caps_pfs, /* read */ - procfs_dir, pbp_device_block)) - ret = -1; - if (bypass_proc_create_entry_sd(&(current_pfs->bypass_wd), BYPASS_WD_ENTRY_SD, set_bypass_wd_pfs, /* write */ - get_bypass_wd_pfs, /* read */ - procfs_dir, pbp_device_block)) - ret = -1; - - if (bypass_proc_create_entry_sd(&(current_pfs->wd_expire_time), WD_EXPIRE_TIME_ENTRY_SD, NULL, /* write */ - get_wd_expire_time_pfs, /* read */ - procfs_dir, pbp_device_block)) - ret = -1; - - if (bypass_proc_create_entry_sd(&(current_pfs->reset_bypass_wd), RESET_BYPASS_WD_ENTRY_SD, NULL, /* write */ - reset_bypass_wd_pfs, /* read */ - procfs_dir, pbp_device_block)) - ret = -1; - - if (bypass_proc_create_entry_sd(&(current_pfs->std_nic), STD_NIC_ENTRY_SD, set_std_nic_pfs, /* write */ - get_std_nic_pfs, /* read */ - procfs_dir, pbp_device_block)) - ret = -1; - - if (pbp_device_block->bp_caps & BP_CAP) { - if (bypass_proc_create_entry_sd(&(current_pfs->bypass), BYPASS_ENTRY_SD, set_bypass_pfs, /* write */ - get_bypass_pfs, /* read */ - procfs_dir, - pbp_device_block)) - ret = -1; - - if (bypass_proc_create_entry_sd(&(current_pfs->dis_bypass), DIS_BYPASS_ENTRY_SD, set_dis_bypass_pfs, /* write */ - get_dis_bypass_pfs, /* read */ - procfs_dir, - pbp_device_block)) - ret = -1; - - if (bypass_proc_create_entry_sd(&(current_pfs->bypass_pwup), BYPASS_PWUP_ENTRY_SD, set_bypass_pwup_pfs, /* write */ - get_bypass_pwup_pfs, /* read */ - procfs_dir, - pbp_device_block)) - ret = -1; - if (bypass_proc_create_entry_sd(&(current_pfs->bypass_pwoff), BYPASS_PWOFF_ENTRY_SD, set_bypass_pwoff_pfs, /* write */ - get_bypass_pwoff_pfs, /* read */ - procfs_dir, - pbp_device_block)) - ret = -1; - - if (bypass_proc_create_entry_sd(&(current_pfs->bypass_change), BYPASS_CHANGE_ENTRY_SD, NULL, /* write */ - get_bypass_change_pfs, /* read */ - procfs_dir, - pbp_device_block)) - ret = -1; - } - - if (pbp_device_block->bp_caps & TAP_CAP) { - - if (bypass_proc_create_entry_sd(&(current_pfs->tap), TAP_ENTRY_SD, set_tap_pfs, /* write */ - get_tap_pfs, /* read */ - procfs_dir, - pbp_device_block)) - ret = -1; - - if (bypass_proc_create_entry_sd(&(current_pfs->dis_tap), DIS_TAP_ENTRY_SD, set_dis_tap_pfs, /* write */ - get_dis_tap_pfs, /* read */ - procfs_dir, - pbp_device_block)) - ret = -1; - - if (bypass_proc_create_entry_sd(&(current_pfs->tap_pwup), TAP_PWUP_ENTRY_SD, set_tap_pwup_pfs, /* write */ - get_tap_pwup_pfs, /* read */ - procfs_dir, - pbp_device_block)) - ret = -1; - - if (bypass_proc_create_entry_sd(&(current_pfs->tap_change), TAP_CHANGE_ENTRY_SD, NULL, /* write */ - get_tap_change_pfs, /* read */ - procfs_dir, - pbp_device_block)) - ret = -1; - } - if (pbp_device_block->bp_caps & DISC_CAP) { - - if (bypass_proc_create_entry_sd(&(current_pfs->tap), DISC_ENTRY_SD, set_disc_pfs, /* write */ - get_disc_pfs, /* read */ - procfs_dir, - pbp_device_block)) - ret = -1; -#if 1 - - if (bypass_proc_create_entry_sd(&(current_pfs->dis_tap), DIS_DISC_ENTRY_SD, set_dis_disc_pfs, /* write */ - get_dis_disc_pfs, /* read */ - procfs_dir, - pbp_device_block)) - ret = -1; -#endif - - if (bypass_proc_create_entry_sd(&(current_pfs->tap_pwup), DISC_PWUP_ENTRY_SD, set_disc_pwup_pfs, /* write */ - get_disc_pwup_pfs, /* read */ - procfs_dir, - pbp_device_block)) - ret = -1; - - if (bypass_proc_create_entry_sd(&(current_pfs->tap_change), DISC_CHANGE_ENTRY_SD, NULL, /* write */ - get_disc_change_pfs, /* read */ - procfs_dir, - pbp_device_block)) - ret = -1; - } - - if (bypass_proc_create_entry_sd(&(current_pfs->wd_exp_mode), WD_EXP_MODE_ENTRY_SD, set_wd_exp_mode_pfs, /* write */ - get_wd_exp_mode_pfs, /* read */ - procfs_dir, pbp_device_block)) - ret = -1; - - if (bypass_proc_create_entry_sd(&(current_pfs->wd_autoreset), WD_AUTORESET_ENTRY_SD, set_wd_autoreset_pfs, /* write */ - get_wd_autoreset_pfs, /* read */ - procfs_dir, pbp_device_block)) - ret = -1; - if (bypass_proc_create_entry_sd(&(current_pfs->tpl), TPL_ENTRY_SD, set_tpl_pfs, /* write */ - get_tpl_pfs, /* read */ - procfs_dir, pbp_device_block)) - ret = -1; -#ifdef PMC_FIX_FLAG - if (bypass_proc_create_entry_sd(&(current_pfs->tpl), WAIT_AT_PWUP_ENTRY_SD, set_wait_at_pwup_pfs, /* write */ - get_wait_at_pwup_pfs, /* read */ - procfs_dir, pbp_device_block)) - ret = -1; - if (bypass_proc_create_entry_sd(&(current_pfs->tpl), HW_RESET_ENTRY_SD, set_hw_reset_pfs, /* write */ - get_hw_reset_pfs, /* read */ - procfs_dir, pbp_device_block)) - ret = -1; - -#endif - - } - if (ret < 0) - printk(KERN_DEBUG "Create proc entry failed\n"); - - return ret; -} - -int bypass_proc_remove_dev_sd(bpctl_dev_t *pbp_device_block) -{ - - struct bypass_pfs_sd *current_pfs = &pbp_device_block->bypass_pfs_set; - struct proc_dir_entry *pde = current_pfs->bypass_entry, *pde_curr = - NULL; - char name[256]; - - for (pde = pde->subdir; pde;) { - strcpy(name, pde->name); - pde_curr = pde; - pde = pde->next; - remove_proc_entry(name, current_pfs->bypass_entry); - } - if (!pde) - remove_proc_entry(current_pfs->dir_name, bp_procfs_dir); - - return 0; -} - -#endif /* BYPASS_SUPPORT */ diff --git a/drivers/staging/silicom/bp_mod.c b/drivers/staging/silicom/bpctl_mod.c index 45a22272320..b7e570ccb75 100644 --- a/drivers/staging/silicom/bp_mod.c +++ b/drivers/staging/silicom/bpctl_mod.c @@ -35,7 +35,6 @@ #define BP_MOD_DESCR "Silicom Bypass-SD Control driver" #define BP_SYNC_FLAG 1 -static int Device_Open = 0; static int major_num = 0; MODULE_AUTHOR("Anna Lukin, annal@silicom.co.il"); @@ -60,35 +59,9 @@ typedef enum { bp_none, } bp_media_type; -struct pfs_unit_sd { - struct proc_dir_entry *proc_entry; - char proc_name[32]; -}; - struct bypass_pfs_sd { char dir_name[32]; struct proc_dir_entry *bypass_entry; - struct pfs_unit_sd bypass_info; - struct pfs_unit_sd bypass_slave; - struct pfs_unit_sd bypass_caps; - struct pfs_unit_sd wd_set_caps; - struct pfs_unit_sd bypass; - struct pfs_unit_sd bypass_change; - struct pfs_unit_sd bypass_wd; - struct pfs_unit_sd wd_expire_time; - struct pfs_unit_sd reset_bypass_wd; - struct pfs_unit_sd dis_bypass; - struct pfs_unit_sd bypass_pwup; - struct pfs_unit_sd bypass_pwoff; - struct pfs_unit_sd std_nic; - struct pfs_unit_sd tap; - struct pfs_unit_sd dis_tap; - struct pfs_unit_sd tap_pwup; - struct pfs_unit_sd tap_change; - struct pfs_unit_sd wd_exp_mode; - struct pfs_unit_sd wd_autoreset; - struct pfs_unit_sd tpl; - }; typedef struct _bpctl_dev { @@ -315,27 +288,6 @@ static struct notifier_block bp_notifier_block = { .notifier_call = bp_device_event, }; -static int device_open(struct inode *inode, struct file *file) -{ -#ifdef DEBUG - printk("device_open(%p)\n", file); -#endif - Device_Open++; -/* -* Initialize the message -*/ - return SUCCESS; -} - -static int device_release(struct inode *inode, struct file *file) -{ -#ifdef DEBUG - printk("device_release(%p,%p)\n", inode, file); -#endif - Device_Open--; - return SUCCESS; -} - int is_bypass_fn(bpctl_dev_t *pbpctl_dev); int wdt_time_left(bpctl_dev_t *pbpctl_dev); @@ -1728,62 +1680,33 @@ int gpio6_clear_fn(bpctl_dev_t *pbpctl_dev) } #endif /*BYPASS_DEBUG */ -static bpctl_dev_t *get_status_port_fn(bpctl_dev_t *pbpctl_dev) +static bpctl_dev_t *lookup_port(bpctl_dev_t *dev) { - int idx_dev = 0; - - if (pbpctl_dev == NULL) - return NULL; - - if ((pbpctl_dev->func == 0) || (pbpctl_dev->func == 2)) { - for (idx_dev = 0; - ((bpctl_dev_arr[idx_dev].pdev != NULL) - && (idx_dev < device_num)); idx_dev++) { - if ((bpctl_dev_arr[idx_dev].bus == pbpctl_dev->bus) - && (bpctl_dev_arr[idx_dev].slot == pbpctl_dev->slot) - && ((bpctl_dev_arr[idx_dev].func == 1) - && (pbpctl_dev->func == 0))) { - - return &(bpctl_dev_arr[idx_dev]); - } - if ((bpctl_dev_arr[idx_dev].bus == pbpctl_dev->bus) && - (bpctl_dev_arr[idx_dev].slot == pbpctl_dev->slot) && - ((bpctl_dev_arr[idx_dev].func == 3) - && (pbpctl_dev->func == 2))) { + bpctl_dev_t *p; + int n; + for (n = 0, p = bpctl_dev_arr; n < device_num && p->pdev; n++) { + if (p->bus == dev->bus + && p->slot == dev->slot + && p->func == (dev->func ^ 1)) + return p; + } + return NULL; +} - return &(bpctl_dev_arr[idx_dev]); - } - } +static bpctl_dev_t *get_status_port_fn(bpctl_dev_t *pbpctl_dev) +{ + if (pbpctl_dev) { + if (pbpctl_dev->func == 0 || pbpctl_dev->func == 2) + return lookup_port(pbpctl_dev); } return NULL; } static bpctl_dev_t *get_master_port_fn(bpctl_dev_t *pbpctl_dev) { - int idx_dev = 0; - - if (pbpctl_dev == NULL) - return NULL; - - if ((pbpctl_dev->func == 1) || (pbpctl_dev->func == 3)) { - for (idx_dev = 0; - ((bpctl_dev_arr[idx_dev].pdev != NULL) - && (idx_dev < device_num)); idx_dev++) { - if ((bpctl_dev_arr[idx_dev].bus == pbpctl_dev->bus) - && (bpctl_dev_arr[idx_dev].slot == pbpctl_dev->slot) - && ((bpctl_dev_arr[idx_dev].func == 0) - && (pbpctl_dev->func == 1))) { - - return &(bpctl_dev_arr[idx_dev]); - } - if ((bpctl_dev_arr[idx_dev].bus == pbpctl_dev->bus) && - (bpctl_dev_arr[idx_dev].slot == pbpctl_dev->slot) && - ((bpctl_dev_arr[idx_dev].func == 2) - && (pbpctl_dev->func == 3))) { - - return &(bpctl_dev_arr[idx_dev]); - } - } + if (pbpctl_dev) { + if (pbpctl_dev->func == 1 || pbpctl_dev->func == 3) + return lookup_port(pbpctl_dev); } return NULL; } @@ -5858,11 +5781,9 @@ static long device_ioctl(struct file *file, /* see include/linux/fs.h */ return ret; } -struct file_operations Fops = { +static const struct file_operations Fops = { .owner = THIS_MODULE, .unlocked_ioctl = device_ioctl, - .open = device_open, - .release = device_release, /* a.k.a. close */ }; #ifndef PCI_DEVICE @@ -6686,6 +6607,118 @@ static bpmod_info_t tx_ctl_pci_tbl[] = { {0,} }; +static void find_fw(bpctl_dev_t *dev) +{ + unsigned long mmio_start, mmio_len; + struct pci_dev *pdev1 = dev->pdev; + + if ((OLD_IF_SERIES(dev->subdevice)) || + (INTEL_IF_SERIES(dev->subdevice))) + dev->bp_fw_ver = 0xff; + else + dev->bp_fw_ver = bypass_fw_ver(dev); + + if (dev->bp_10gb == 1 && dev->bp_fw_ver == 0xff) { + int cnt = 100; + while (cnt--) { + iounmap((void *)dev->mem_map); + mmio_start = pci_resource_start(pdev1, 0); + mmio_len = pci_resource_len(pdev1, 0); + + dev->mem_map = (unsigned long) + ioremap(mmio_start, mmio_len); + + dev->bp_fw_ver = bypass_fw_ver(dev); + if (dev-> bp_fw_ver == 0xa8) + break; + } + } + /* dev->bp_fw_ver=0xa8; */ + printk("firmware version: 0x%x\n", dev->bp_fw_ver); +} + +static int init_one(bpctl_dev_t *dev, bpmod_info_t *info, struct pci_dev *pdev1) +{ + unsigned long mmio_start, mmio_len; + + dev->pdev = pdev1; + mmio_start = pci_resource_start(pdev1, 0); + mmio_len = pci_resource_len(pdev1, 0); + + dev->desc = dev_desc[info->index].name; + dev->name = info->bp_name; + dev->device = info->device; + dev->vendor = info->vendor; + dev->subdevice = info->subdevice; + dev->subvendor = info->subvendor; + dev->func = PCI_FUNC(pdev1->devfn); + dev->slot = PCI_SLOT(pdev1->devfn); + dev->bus = pdev1->bus->number; + dev->mem_map = (unsigned long)ioremap(mmio_start, mmio_len); +#ifdef BP_SYNC_FLAG + spin_lock_init(&dev->bypass_wr_lock); +#endif + if (BP10G9_IF_SERIES(dev->subdevice)) + dev->bp_10g9 = 1; + if (BP10G_IF_SERIES(dev->subdevice)) + dev->bp_10g = 1; + if (PEG540_IF_SERIES(dev->subdevice)) + dev->bp_540 = 1; + if (PEGF5_IF_SERIES(dev->subdevice)) + dev->bp_fiber5 = 1; + if (PEG80_IF_SERIES(dev->subdevice)) + dev->bp_i80 = 1; + if (PEGF80_IF_SERIES(dev->subdevice)) + dev->bp_i80 = 1; + if ((dev->subdevice & 0xa00) == 0xa00) + dev->bp_i80 = 1; + if (BP10GB_IF_SERIES(dev->subdevice)) { + if (dev->ifindex == 0) { + unregister_chrdev(major_num, DEVICE_NAME); + printk("Please load network driver for %s adapter!\n", + dev->name); + return -1; + } + + if (dev->ndev && !(dev->ndev->flags & IFF_UP)) { + unregister_chrdev(major_num, DEVICE_NAME); + printk("Please bring up network interfaces for %s adapter!\n", + dev->name); + return -1; + } + dev->bp_10gb = 1; + } + + if (!dev->bp_10g9) { + if (is_bypass_fn(dev)) { + printk(KERN_INFO "%s found, ", + dev->name); + find_fw(dev); + } + dev->wdt_status = WDT_STATUS_UNKNOWN; + dev->reset_time = 0; + atomic_set(&dev->wdt_busy, 0); + dev->bp_status_un = 1; + + bypass_caps_init(dev); + + init_bypass_wd_auto(dev); + init_bypass_tpl_auto(dev); + if (NOKIA_SERIES(dev->subdevice)) + reset_cont(dev); + } +#ifdef BP_SELF_TEST + if ((dev->bp_tx_data = kzalloc(BPTEST_DATA_LEN, GFP_KERNEL))) { + memset(dev->bp_tx_data, 0xff, 6); + memset(dev->bp_tx_data + 6, 0x0, 1); + memset(dev->bp_tx_data + 7, 0xaa, 5); + *(__be16 *)(dev->bp_tx_data + 12) = htons(ETH_P_BPTEST); + } else + printk("bp_ctl: Memory allocation error!\n"); +#endif + return 0; +} + /* * Initialize the module - Register the character device */ @@ -6694,7 +6727,7 @@ static int __init bypass_init_module(void) { int ret_val, idx, idx_dev = 0; struct pci_dev *pdev1 = NULL; - unsigned long mmio_start, mmio_len; + bpctl_dev_t *dev; printk(BP_MOD_DESCR " v" BP_MOD_VER "\n"); ret_val = register_chrdev(major_num, DEVICE_NAME, &Fops); @@ -6729,181 +6762,16 @@ static int __init bypass_init_module(void) memset(bpctl_dev_arr, 0, ((device_num) * sizeof(bpctl_dev_t))); pdev1 = NULL; + dev = bpctl_dev_arr; for (idx = 0; tx_ctl_pci_tbl[idx].vendor; idx++) { while ((pdev1 = pci_get_subsys(tx_ctl_pci_tbl[idx].vendor, tx_ctl_pci_tbl[idx].device, tx_ctl_pci_tbl[idx].subvendor, tx_ctl_pci_tbl[idx].subdevice, pdev1))) { - bpctl_dev_arr[idx_dev].pdev = pdev1; - - mmio_start = pci_resource_start(pdev1, 0); - mmio_len = pci_resource_len(pdev1, 0); - - bpctl_dev_arr[idx_dev].desc = - dev_desc[tx_ctl_pci_tbl[idx].index].name; - bpctl_dev_arr[idx_dev].name = - tx_ctl_pci_tbl[idx].bp_name; - bpctl_dev_arr[idx_dev].device = - tx_ctl_pci_tbl[idx].device; - bpctl_dev_arr[idx_dev].vendor = - tx_ctl_pci_tbl[idx].vendor; - bpctl_dev_arr[idx_dev].subdevice = - tx_ctl_pci_tbl[idx].subdevice; - bpctl_dev_arr[idx_dev].subvendor = - tx_ctl_pci_tbl[idx].subvendor; - /* bpctl_dev_arr[idx_dev].pdev=pdev1; */ - bpctl_dev_arr[idx_dev].func = PCI_FUNC(pdev1->devfn); - bpctl_dev_arr[idx_dev].slot = PCI_SLOT(pdev1->devfn); - bpctl_dev_arr[idx_dev].bus = pdev1->bus->number; - bpctl_dev_arr[idx_dev].mem_map = - (unsigned long)ioremap(mmio_start, mmio_len); -#ifdef BP_SYNC_FLAG - spin_lock_init(&bpctl_dev_arr[idx_dev].bypass_wr_lock); -#endif - if (BP10G9_IF_SERIES(bpctl_dev_arr[idx_dev].subdevice)) - bpctl_dev_arr[idx_dev].bp_10g9 = 1; - if (BP10G_IF_SERIES(bpctl_dev_arr[idx_dev].subdevice)) - bpctl_dev_arr[idx_dev].bp_10g = 1; - if (PEG540_IF_SERIES(bpctl_dev_arr[idx_dev].subdevice)) { - - bpctl_dev_arr[idx_dev].bp_540 = 1; - } - if (PEGF5_IF_SERIES(bpctl_dev_arr[idx_dev].subdevice)) - bpctl_dev_arr[idx_dev].bp_fiber5 = 1; - if (PEG80_IF_SERIES(bpctl_dev_arr[idx_dev].subdevice)) - bpctl_dev_arr[idx_dev].bp_i80 = 1; - if (PEGF80_IF_SERIES(bpctl_dev_arr[idx_dev].subdevice)) - bpctl_dev_arr[idx_dev].bp_i80 = 1; - if ((bpctl_dev_arr[idx_dev].subdevice & 0xa00) == 0xa00) - bpctl_dev_arr[idx_dev].bp_i80 = 1; - if (BP10GB_IF_SERIES(bpctl_dev_arr[idx_dev].subdevice)) { - if (bpctl_dev_arr[idx_dev].ifindex == 0) { - unregister_chrdev(major_num, - DEVICE_NAME); - printk - ("Please load network driver for %s adapter!\n", - bpctl_dev_arr[idx_dev].name); - return -1; - } - - if (bpctl_dev_arr[idx_dev].ndev) { - if (! - (bpctl_dev_arr[idx_dev].ndev-> - flags & IFF_UP)) { - if (! - (bpctl_dev_arr[idx_dev]. - ndev->flags & IFF_UP)) { - unregister_chrdev - (major_num, - DEVICE_NAME); - printk - ("Please bring up network interfaces for %s adapter!\n", - bpctl_dev_arr - [idx_dev].name); - return -1; - } - - } - } - bpctl_dev_arr[idx_dev].bp_10gb = 1; - } - - if (!bpctl_dev_arr[idx_dev].bp_10g9) { - - if (is_bypass_fn(&bpctl_dev_arr[idx_dev])) { - printk(KERN_INFO "%s found, ", - bpctl_dev_arr[idx_dev].name); - if ((OLD_IF_SERIES - (bpctl_dev_arr[idx_dev].subdevice)) - || - (INTEL_IF_SERIES - (bpctl_dev_arr[idx_dev]. - subdevice))) - bpctl_dev_arr[idx_dev]. - bp_fw_ver = 0xff; - else - bpctl_dev_arr[idx_dev]. - bp_fw_ver = - bypass_fw_ver(&bpctl_dev_arr - [idx_dev]); - if ((bpctl_dev_arr[idx_dev].bp_10gb == - 1) - && (bpctl_dev_arr[idx_dev]. - bp_fw_ver == 0xff)) { - int cnt = 100; - while (cnt--) { - iounmap((void - *) - (bpctl_dev_arr - [idx_dev]. - mem_map)); - mmio_start = - pci_resource_start - (pdev1, 0); - mmio_len = - pci_resource_len - (pdev1, 0); - - bpctl_dev_arr[idx_dev]. - mem_map = - (unsigned long) - ioremap(mmio_start, - mmio_len); - - bpctl_dev_arr[idx_dev]. - bp_fw_ver = - bypass_fw_ver - (&bpctl_dev_arr - [idx_dev]); - if (bpctl_dev_arr - [idx_dev]. - bp_fw_ver == 0xa8) - break; - - } - } - /* bpctl_dev_arr[idx_dev].bp_fw_ver=0xa8; */ - printk("firmware version: 0x%x\n", - bpctl_dev_arr[idx_dev]. - bp_fw_ver); - } - bpctl_dev_arr[idx_dev].wdt_status = - WDT_STATUS_UNKNOWN; - bpctl_dev_arr[idx_dev].reset_time = 0; - atomic_set(&bpctl_dev_arr[idx_dev].wdt_busy, 0); - bpctl_dev_arr[idx_dev].bp_status_un = 1; - - bypass_caps_init(&bpctl_dev_arr[idx_dev]); - - init_bypass_wd_auto(&bpctl_dev_arr[idx_dev]); - init_bypass_tpl_auto(&bpctl_dev_arr[idx_dev]); - if (NOKIA_SERIES - (bpctl_dev_arr[idx_dev].subdevice)) - reset_cont(&bpctl_dev_arr[idx_dev]); - } -#ifdef BP_SELF_TEST - if ((bpctl_dev_arr[idx_dev].bp_tx_data = - kmalloc(BPTEST_DATA_LEN, GFP_KERNEL))) { - - memset(bpctl_dev_arr[idx_dev].bp_tx_data, 0x0, - BPTEST_DATA_LEN); - - memset(bpctl_dev_arr[idx_dev].bp_tx_data, 0xff, - 6); - memset(bpctl_dev_arr[idx_dev].bp_tx_data + 6, - 0x0, 1); - memset(bpctl_dev_arr[idx_dev].bp_tx_data + 7, - 0xaa, 5); - - *(__be16 *) (bpctl_dev_arr[idx_dev].bp_tx_data + - 12) = htons(ETH_P_BPTEST); - - } else - printk("bp_ctl: Memory allocation error!\n"); -#endif - idx_dev++; - + if (init_one(dev, &tx_ctl_pci_tbl[idx], pdev1) < 0) + return -1; + dev++; } } if_scan_init(); @@ -6913,33 +6781,27 @@ static int __init bypass_init_module(void) { bpctl_dev_t *pbpctl_dev_c = NULL; - for (idx_dev = 0; - ((bpctl_dev_arr[idx_dev].pdev != NULL) - && (idx_dev < device_num)); idx_dev++) { - if (bpctl_dev_arr[idx_dev].bp_10g9) { - pbpctl_dev_c = - get_status_port_fn(&bpctl_dev_arr[idx_dev]); - if (is_bypass_fn(&bpctl_dev_arr[idx_dev])) { + for (idx_dev = 0, dev = bpctl_dev_arr; + idx_dev < device_num && dev->pdev; + idx_dev++, dev++) { + if (dev->bp_10g9) { + pbpctl_dev_c = get_status_port_fn(dev); + if (is_bypass_fn(dev)) { printk(KERN_INFO "%s found, ", - bpctl_dev_arr[idx_dev].name); - bpctl_dev_arr[idx_dev].bp_fw_ver = - bypass_fw_ver(&bpctl_dev_arr - [idx_dev]); + dev->name); + dev->bp_fw_ver = bypass_fw_ver(dev); printk("firmware version: 0x%x\n", - bpctl_dev_arr[idx_dev]. - bp_fw_ver); - + dev->bp_fw_ver); } - bpctl_dev_arr[idx_dev].wdt_status = - WDT_STATUS_UNKNOWN; - bpctl_dev_arr[idx_dev].reset_time = 0; - atomic_set(&bpctl_dev_arr[idx_dev].wdt_busy, 0); - bpctl_dev_arr[idx_dev].bp_status_un = 1; + dev->wdt_status = WDT_STATUS_UNKNOWN; + dev->reset_time = 0; + atomic_set(&dev->wdt_busy, 0); + dev->bp_status_un = 1; - bypass_caps_init(&bpctl_dev_arr[idx_dev]); + bypass_caps_init(dev); - init_bypass_wd_auto(&bpctl_dev_arr[idx_dev]); - init_bypass_tpl_auto(&bpctl_dev_arr[idx_dev]); + init_bypass_wd_auto(dev); + init_bypass_tpl_auto(dev); } @@ -7336,78 +7198,11 @@ EXPORT_SYMBOL_NOVERS(bp_if_scan_sd); #define BP_PROC_DIR "bypass" -#define GPIO6_SET_ENTRY_SD "gpio6_set" -#define GPIO6_CLEAR_ENTRY_SD "gpio6_clear" - -#define GPIO7_SET_ENTRY_SD "gpio7_set" -#define GPIO7_CLEAR_ENTRY_SD "gpio7_clear" - -#define PULSE_SET_ENTRY_SD "pulse_set" -#define ZERO_SET_ENTRY_SD "zero_set" -#define PULSE_GET1_ENTRY_SD "pulse_get1" -#define PULSE_GET2_ENTRY_SD "pulse_get2" - -#define CMND_ON_ENTRY_SD "cmnd_on" -#define CMND_OFF_ENTRY_SD "cmnd_off" -#define RESET_CONT_ENTRY_SD "reset_cont" - - /*COMMANDS*/ -#define BYPASS_INFO_ENTRY_SD "bypass_info" -#define BYPASS_SLAVE_ENTRY_SD "bypass_slave" -#define BYPASS_CAPS_ENTRY_SD "bypass_caps" -#define WD_SET_CAPS_ENTRY_SD "wd_set_caps" -#define BYPASS_ENTRY_SD "bypass" -#define BYPASS_CHANGE_ENTRY_SD "bypass_change" -#define BYPASS_WD_ENTRY_SD "bypass_wd" -#define WD_EXPIRE_TIME_ENTRY_SD "wd_expire_time" -#define RESET_BYPASS_WD_ENTRY_SD "reset_bypass_wd" -#define DIS_BYPASS_ENTRY_SD "dis_bypass" -#define BYPASS_PWUP_ENTRY_SD "bypass_pwup" -#define BYPASS_PWOFF_ENTRY_SD "bypass_pwoff" -#define STD_NIC_ENTRY_SD "std_nic" -#define STD_NIC_ENTRY_SD "std_nic" -#define TAP_ENTRY_SD "tap" -#define TAP_CHANGE_ENTRY_SD "tap_change" -#define DIS_TAP_ENTRY_SD "dis_tap" -#define TAP_PWUP_ENTRY_SD "tap_pwup" -#define TWO_PORT_LINK_ENTRY_SD "two_port_link" -#define WD_EXP_MODE_ENTRY_SD "wd_exp_mode" -#define WD_AUTORESET_ENTRY_SD "wd_autoreset" -#define TPL_ENTRY_SD "tpl" -#define WAIT_AT_PWUP_ENTRY_SD "wait_at_pwup" -#define HW_RESET_ENTRY_SD "hw_reset" -#define DISC_ENTRY_SD "disc" -#define DISC_CHANGE_ENTRY_SD "disc_change" -#define DIS_DISC_ENTRY_SD "dis_disc" -#define DISC_PWUP_ENTRY_SD "disc_pwup" static struct proc_dir_entry *bp_procfs_dir; -static struct proc_dir_entry *proc_getdir(char *name, - struct proc_dir_entry *proc_dir) -{ - struct proc_dir_entry *pde = proc_dir; - - for (pde = pde->subdir; pde; pde = pde->next) { - if (pde->namelen && (strcmp(name, pde->name) == 0)) { - /* directory exists */ - break; - } - } - if (pde == (struct proc_dir_entry *)0) { - /* create the directory */ - pde = proc_mkdir(name, proc_dir); - if (pde == (struct proc_dir_entry *)0) { - - return pde; - } - } - - return pde; -} - int bp_proc_create(void) { - bp_procfs_dir = proc_getdir(BP_PROC_DIR, init_net.proc_net); + bp_procfs_dir = proc_mkdir(BP_PROC_DIR, init_net.proc_net); if (bp_procfs_dir == (struct proc_dir_entry *)0) { printk(KERN_DEBUG "Could not create procfs nicinfo directory %s\n", @@ -7417,144 +7212,99 @@ int bp_proc_create(void) return 0; } -int -bypass_proc_create_entry_sd(struct pfs_unit_sd *pfs_unit_curr, - char *proc_name, - write_proc_t *write_proc, - read_proc_t *read_proc, - struct proc_dir_entry *parent_pfs, void *data) +static int procfs_add(char *proc_name, const struct file_operations *fops, + bpctl_dev_t *dev) { - strcpy(pfs_unit_curr->proc_name, proc_name); - pfs_unit_curr->proc_entry = create_proc_entry(pfs_unit_curr->proc_name, - S_IFREG | S_IRUSR | - S_IWUSR | S_IRGRP | - S_IROTH, parent_pfs); - if (pfs_unit_curr->proc_entry == NULL) + struct bypass_pfs_sd *pfs = &dev->bypass_pfs_set; + if (!proc_create_data(proc_name, 0644, pfs->bypass_entry, fops, dev)) return -1; - - pfs_unit_curr->proc_entry->read_proc = read_proc; - pfs_unit_curr->proc_entry->write_proc = write_proc; - pfs_unit_curr->proc_entry->data = data; - return 0; - } -int -get_bypass_info_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) -{ - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - int len = 0; - - len += sprintf(page, "Name\t\t\t%s\n", pbp_device_block->name); - len += - sprintf(page + len, "Firmware version\t0x%x\n", - pbp_device_block->bp_fw_ver); +#define RO_FOPS(name) \ +static int name##_open(struct inode *inode, struct file *file) \ +{ \ + return single_open(file, show_##name, PDE_DATA(inode));\ +} \ +static const struct file_operations name##_ops = { \ + .open = name##_open, \ + .read = seq_read, \ + .llseek = seq_lseek, \ + .release = single_release, \ +}; - *eof = 1; - return len; -} +#define RW_FOPS(name) \ +static int name##_open(struct inode *inode, struct file *file) \ +{ \ + return single_open(file, show_##name, PDE_DATA(inode));\ +} \ +static const struct file_operations name##_ops = { \ + .open = name##_open, \ + .read = seq_read, \ + .write = name##_write, \ + .llseek = seq_lseek, \ + .release = single_release, \ +}; -int -get_bypass_slave_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) +static int show_bypass_info(struct seq_file *m, void *v) { - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; + bpctl_dev_t *dev = m->private; - int len = 0; - bpctl_dev_t *pbp_device_block_slave = NULL; - int idx_dev = 0; - struct net_device *net_slave_dev = NULL; - - if ((pbp_device_block->func == 0) || (pbp_device_block->func == 2)) { - for (idx_dev = 0; - ((bpctl_dev_arr[idx_dev].pdev != NULL) - && (idx_dev < device_num)); idx_dev++) { - if ((bpctl_dev_arr[idx_dev].bus == - pbp_device_block->bus) - && (bpctl_dev_arr[idx_dev].slot == - pbp_device_block->slot)) { - if ((pbp_device_block->func == 0) - && (bpctl_dev_arr[idx_dev].func == 1)) { - pbp_device_block_slave = - &bpctl_dev_arr[idx_dev]; - break; - } - if ((pbp_device_block->func == 2) && - (bpctl_dev_arr[idx_dev].func == 3)) { - pbp_device_block_slave = - &bpctl_dev_arr[idx_dev]; - break; - } - } - } - } else - pbp_device_block_slave = pbp_device_block; - if (!pbp_device_block_slave) { - len = sprintf(page, "fail\n"); - *eof = 1; - return len; - } - net_slave_dev = pbp_device_block_slave->ndev; - if (net_slave_dev) - len = sprintf(page, "%s\n", net_slave_dev->name); - - *eof = 1; - return len; + seq_printf(m, "Name\t\t\t%s\n", dev->name); + seq_printf(m, "Firmware version\t0x%x\n", dev->bp_fw_ver); + return 0; } +RO_FOPS(bypass_info) -int -get_bypass_caps_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) +static int show_bypass_slave(struct seq_file *m, void *v) { - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; + bpctl_dev_t *dev = m->private; + bpctl_dev_t *slave = get_status_port_fn(dev); + if (!slave) + slave = dev; + if (!slave) + seq_printf(m, "fail\n"); + else if (slave->ndev) + seq_printf(m, "%s\n", slave->ndev->name); + return 0; +} +RO_FOPS(bypass_slave) - ret = get_bypass_caps_fn(pbp_device_block); +static int show_bypass_caps(struct seq_file *m, void *v) +{ + bpctl_dev_t *dev = m->private; + int ret = get_bypass_caps_fn(dev); if (ret == BP_NOT_CAP) - len = sprintf(page, "-1\n"); + seq_printf(m, "-1\n"); else - len = sprintf(page, "0x%x\n", ret); - *eof = 1; - return len; - + seq_printf(m, "0x%x\n", ret); + return 0; } +RO_FOPS(bypass_caps) -int -get_wd_set_caps_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) +static int show_wd_set_caps(struct seq_file *m, void *v) { - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; - - ret = get_wd_set_caps_fn(pbp_device_block); + bpctl_dev_t *dev = m->private; + int ret = get_wd_set_caps_fn(dev); if (ret == BP_NOT_CAP) - len = sprintf(page, "-1\n"); + seq_printf(m, "-1\n"); else - len = sprintf(page, "0x%x\n", ret); - *eof = 1; - return len; + seq_printf(m, "0x%x\n", ret); + return 0; } +RO_FOPS(wd_set_caps) -int -set_bypass_pfs(struct file *file, const char *buffer, - unsigned long count, void *data) +static int user_on_off(const void __user *buffer, size_t count) { char kbuf[256]; - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int bypass_param = 0, length = 0; + int length = 0; if (count > (sizeof(kbuf) - 1)) return -1; - if (copy_from_user(&kbuf, buffer, count)) { + if (copy_from_user(&kbuf, buffer, count)) return -1; - } kbuf[count] = '\0'; length = strlen(kbuf); @@ -7562,806 +7312,467 @@ set_bypass_pfs(struct file *file, const char *buffer, kbuf[--length] = '\0'; if (strcmp(kbuf, "on") == 0) - bypass_param = 1; - else if (strcmp(kbuf, "off") == 0) - bypass_param = 0; - - set_bypass_fn(pbp_device_block, bypass_param); - - return count; + return 1; + if (strcmp(kbuf, "off") == 0) + return 0; + return 0; } -int -set_tap_pfs(struct file *file, const char *buffer, - unsigned long count, void *data) +static ssize_t bypass_write(struct file *file, const char __user *buffer, + size_t count, loff_t *pos) { - - char kbuf[256]; - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int tap_param = 0, length = 0; - - if (count > (sizeof(kbuf) - 1)) + int bypass_param = user_on_off(buffer, count); + if (bypass_param < 0) return -1; - if (copy_from_user(&kbuf, buffer, count)) { - return -1; - } - - kbuf[count] = '\0'; - length = strlen(kbuf); - if (kbuf[length - 1] == '\n') - kbuf[--length] = '\0'; - - if (strcmp(kbuf, "on") == 0) - tap_param = 1; - else if (strcmp(kbuf, "off") == 0) - tap_param = 0; - - set_tap_fn(pbp_device_block, tap_param); - + set_bypass_fn(PDE_DATA(file_inode(file)), bypass_param); return count; } - -int -set_disc_pfs(struct file *file, const char *buffer, - unsigned long count, void *data) +static int show_bypass(struct seq_file *m, void *v) { + bpctl_dev_t *dev = m->private; + int ret = get_bypass_fn(dev); + if (ret == BP_NOT_CAP) + seq_printf(m, "fail\n"); + else if (ret == 1) + seq_printf(m, "on\n"); + else if (ret == 0) + seq_printf(m, "off\n"); + return 0; +} +RW_FOPS(bypass) - char kbuf[256]; - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int tap_param = 0, length = 0; - - if (count > (sizeof(kbuf) - 1)) - return -1; - - if (copy_from_user(&kbuf, buffer, count)) { +static ssize_t tap_write(struct file *file, const char __user *buffer, + size_t count, loff_t *pos) +{ + int tap_param = user_on_off(buffer, count); + if (tap_param < 0) return -1; - } - - kbuf[count] = '\0'; - length = strlen(kbuf); - if (kbuf[length - 1] == '\n') - kbuf[--length] = '\0'; - - if (strcmp(kbuf, "on") == 0) - tap_param = 1; - else if (strcmp(kbuf, "off") == 0) - tap_param = 0; - - set_disc_fn(pbp_device_block, tap_param); + set_tap_fn(PDE_DATA(file_inode(file)), tap_param); return count; } - -int -get_bypass_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) +static int show_tap(struct seq_file *m, void *v) { - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; - - ret = get_bypass_fn(pbp_device_block); + bpctl_dev_t *dev = m->private; + int ret = get_tap_fn(dev); if (ret == BP_NOT_CAP) - len = sprintf(page, "fail\n"); + seq_printf(m, "fail\n"); else if (ret == 1) - len = sprintf(page, "on\n"); + seq_printf(m, "on\n"); else if (ret == 0) - len = sprintf(page, "off\n"); - - *eof = 1; - return len; + seq_printf(m, "off\n"); + return 0; } +RW_FOPS(tap) -int -get_tap_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) +static ssize_t disc_write(struct file *file, const char __user *buffer, + size_t count, loff_t *pos) { - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; - - ret = get_tap_fn(pbp_device_block); - if (ret == BP_NOT_CAP) - len = sprintf(page, "fail\n"); - else if (ret == 1) - len = sprintf(page, "on\n"); - else if (ret == 0) - len = sprintf(page, "off\n"); + int tap_param = user_on_off(buffer, count); + if (tap_param < 0) + return -1; - *eof = 1; - return len; + set_disc_fn(PDE_DATA(file_inode(file)), tap_param); + return count; } - -int -get_disc_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) +static int show_disc(struct seq_file *m, void *v) { - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; - - ret = get_disc_fn(pbp_device_block); + bpctl_dev_t *dev = m->private; + int ret = get_disc_fn(dev); if (ret == BP_NOT_CAP) - len = sprintf(page, "fail\n"); + seq_printf(m, "fail\n"); else if (ret == 1) - len = sprintf(page, "on\n"); + seq_printf(m, "on\n"); else if (ret == 0) - len = sprintf(page, "off\n"); - - *eof = 1; - return len; + seq_printf(m, "off\n"); + return 0; } +RW_FOPS(disc) -int -get_bypass_change_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) +static int show_bypass_change(struct seq_file *m, void *v) { - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; - - ret = get_bypass_change_fn(pbp_device_block); + bpctl_dev_t *dev = m->private; + int ret = get_bypass_change_fn(dev); if (ret == 1) - len = sprintf(page, "on\n"); + seq_printf(m, "on\n"); else if (ret == 0) - len = sprintf(page, "off\n"); + seq_printf(m, "off\n"); else - len = sprintf(page, "fail\n"); - - *eof = 1; - return len; + seq_printf(m, "fail\n"); + return 0; } +RO_FOPS(bypass_change) -int -get_tap_change_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) +static int show_tap_change(struct seq_file *m, void *v) { - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; - - ret = get_tap_change_fn(pbp_device_block); + bpctl_dev_t *dev = m->private; + int ret = get_tap_change_fn(dev); if (ret == 1) - len = sprintf(page, "on\n"); + seq_printf(m, "on\n"); else if (ret == 0) - len = sprintf(page, "off\n"); + seq_printf(m, "off\n"); else - len = sprintf(page, "fail\n"); - - *eof = 1; - return len; + seq_printf(m, "fail\n"); + return 0; } +RO_FOPS(tap_change) -int -get_disc_change_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) +static int show_disc_change(struct seq_file *m, void *v) { - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; - - ret = get_disc_change_fn(pbp_device_block); + bpctl_dev_t *dev = m->private; + int ret = get_disc_change_fn(dev); if (ret == 1) - len = sprintf(page, "on\n"); + seq_printf(m, "on\n"); else if (ret == 0) - len = sprintf(page, "off\n"); + seq_printf(m, "off\n"); else - len = sprintf(page, "fail\n"); - - *eof = 1; - return len; -} - -#define isdigit(c) (c >= '0' && c <= '9') -__inline static int atoi(char **s) -{ - int i = 0; - while (isdigit(**s)) - i = i * 10 + *((*s)++) - '0'; - return i; + seq_printf(m, "fail\n"); + return 0; } +RO_FOPS(disc_change) -int -set_bypass_wd_pfs(struct file *file, const char *buffer, - unsigned long count, void *data) +static ssize_t bypass_wd_write(struct file *file, const char __user *buffer, + size_t count, loff_t *pos) { - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; + bpctl_dev_t *dev = PDE_DATA(file_inode(file)); int timeout; - int ret; - - ret = kstrtoint_from_user(buffer, count, 10, &timeout); + int ret = kstrtoint_from_user(buffer, count, 10, &timeout); if (ret) return ret; - set_bypass_wd_fn(pbp_device_block, timeout); - + set_bypass_wd_fn(dev, timeout); return count; } - -int -get_bypass_wd_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) +static int show_bypass_wd(struct seq_file *m, void *v) { - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; + bpctl_dev_t *dev = m->private; + int ret = 0, timeout = 0; - int len = 0, ret = 0, timeout = 0; - - ret = get_bypass_wd_fn(pbp_device_block, &timeout); + ret = get_bypass_wd_fn(dev, &timeout); if (ret == BP_NOT_CAP) - len = sprintf(page, "fail\n"); + seq_printf(m, "fail\n"); else if (timeout == -1) - len = sprintf(page, "unknown\n"); + seq_printf(m, "unknown\n"); else if (timeout == 0) - len = sprintf(page, "disable\n"); + seq_printf(m, "disable\n"); else - len = sprintf(page, "%d\n", timeout); - - *eof = 1; - return len; + seq_printf(m, "%d\n", timeout); + return 0; } +RW_FOPS(bypass_wd) -int -get_wd_expire_time_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) +static int show_wd_expire_time(struct seq_file *m, void *v) { - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0, timeout = 0; - - ret = get_wd_expire_time_fn(pbp_device_block, &timeout); + bpctl_dev_t *dev = m->private; + int ret = 0, timeout = 0; + ret = get_wd_expire_time_fn(dev, &timeout); if (ret == BP_NOT_CAP) - len = sprintf(page, "fail\n"); + seq_printf(m, "fail\n"); else if (timeout == -1) - len = sprintf(page, "expire\n"); + seq_printf(m, "expire\n"); else if (timeout == 0) - len = sprintf(page, "disable\n"); - + seq_printf(m, "disable\n"); else - len = sprintf(page, "%d\n", timeout); - *eof = 1; - return len; + seq_printf(m, "%d\n", timeout); + return 0; } +RO_FOPS(wd_expire_time) -int -get_tpl_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) +static ssize_t tpl_write(struct file *file, const char __user *buffer, + size_t count, loff_t *pos) { - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; + bpctl_dev_t *dev = PDE_DATA(file_inode(file)); + int tpl_param = user_on_off(buffer, count); + if (tpl_param < 0) + return -1; - ret = get_tpl_fn(pbp_device_block); + set_tpl_fn(dev, tpl_param); + return count; +} +static int show_tpl(struct seq_file *m, void *v) +{ + bpctl_dev_t *dev = m->private; + int ret = get_tpl_fn(dev); if (ret == BP_NOT_CAP) - len = sprintf(page, "fail\n"); + seq_printf(m, "fail\n"); else if (ret == 1) - len = sprintf(page, "on\n"); + seq_printf(m, "on\n"); else if (ret == 0) - len = sprintf(page, "off\n"); - - *eof = 1; - return len; + seq_printf(m, "off\n"); + return 0; } +RW_FOPS(tpl) #ifdef PMC_FIX_FLAG -int -get_wait_at_pwup_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) +static ssize_t wait_at_pwup_write(struct file *file, const char __user *buffer, + size_t count, loff_t *pos) { - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; + bpctl_dev_t *dev = PDE_DATA(file_inode(file)); + int tpl_param = user_on_off(buffer, count); + if (tpl_param < 0) + return -1; - ret = get_bp_wait_at_pwup_fn(pbp_device_block); + set_bp_wait_at_pwup_fn(dev, tpl_param); + return count; +} +static int show_wait_at_pwup(struct seq_file *m, void *v) +{ + bpctl_dev_t *dev = m->private; + int ret = get_bp_wait_at_pwup_fn(dev); if (ret == BP_NOT_CAP) - len = sprintf(page, "fail\n"); + seq_printf(m, "fail\n"); else if (ret == 1) - len = sprintf(page, "on\n"); + seq_printf(m, "on\n"); else if (ret == 0) - len = sprintf(page, "off\n"); - - *eof = 1; - return len; + seq_printf(m, "off\n"); + return 0; } +RW_FOPS(wait_at_pwup) -int -get_hw_reset_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) +static ssize_t hw_reset_write(struct file *file, const char __user *buffer, + size_t count, loff_t *pos) { - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; + bpctl_dev_t *dev = PDE_DATA(file_inode(file)); + int tpl_param = user_on_off(buffer, count); + if (tpl_param < 0) + return -1; - ret = get_bp_hw_reset_fn(pbp_device_block); + set_bp_hw_reset_fn(dev, tpl_param); + return count; +} +static int show_hw_reset(struct seq_file *m, void *v) +{ + bpctl_dev_t *dev = m->private; + int ret = get_bp_hw_reset_fn(dev); if (ret == BP_NOT_CAP) - len = sprintf(page, "fail\n"); + seq_printf(m, "fail\n"); else if (ret == 1) - len = sprintf(page, "on\n"); + seq_printf(m, "on\n"); else if (ret == 0) - len = sprintf(page, "off\n"); - - *eof = 1; - return len; + seq_printf(m, "off\n"); + return 0; } +RW_FOPS(hw_reset) #endif /*PMC_WAIT_FLAG */ -int -reset_bypass_wd_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) +static int show_reset_bypass_wd(struct seq_file *m, void *v) { - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; - - ret = reset_bypass_wd_timer_fn(pbp_device_block); + bpctl_dev_t *dev = m->private; + int ret = reset_bypass_wd_timer_fn(dev); if (ret == BP_NOT_CAP) - len = sprintf(page, "fail\n"); + seq_printf(m, "fail\n"); else if (ret == 0) - len = sprintf(page, "disable\n"); + seq_printf(m, "disable\n"); else if (ret == 1) - len = sprintf(page, "success\n"); - - *eof = 1; - return len; + seq_printf(m, "success\n"); + return 0; } +RO_FOPS(reset_bypass_wd) -int -set_dis_bypass_pfs(struct file *file, const char *buffer, - unsigned long count, void *data) +static ssize_t dis_bypass_write(struct file *file, const char __user *buffer, + size_t count, loff_t *pos) { - - char kbuf[256]; - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int bypass_param = 0, length = 0; - - if (count >= sizeof(kbuf)) + int bypass_param = user_on_off(buffer, count); + if (bypass_param < 0) return -EINVAL; - if (copy_from_user(&kbuf, buffer, count)) { - return -1; - } - - kbuf[count] = '\0'; - length = strlen(kbuf); - if (kbuf[length - 1] == '\n') - kbuf[--length] = '\0'; - - if (strcmp(kbuf, "on") == 0) - bypass_param = 1; - else if (strcmp(kbuf, "off") == 0) - bypass_param = 0; - - set_dis_bypass_fn(pbp_device_block, bypass_param); - + set_dis_bypass_fn(PDE_DATA(file_inode(file)), bypass_param); return count; } - -int -set_dis_tap_pfs(struct file *file, const char *buffer, - unsigned long count, void *data) +static int show_dis_bypass(struct seq_file *m, void *v) { - - char kbuf[256]; - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int tap_param = 0, length = 0; - - if (count >= sizeof(kbuf)) - return -EINVAL; - - if (copy_from_user(&kbuf, buffer, count)) { - return -1; - } - - kbuf[count] = '\0'; - length = strlen(kbuf); - if (kbuf[length - 1] == '\n') - kbuf[--length] = '\0'; - - if (strcmp(kbuf, "on") == 0) - tap_param = 1; - else if (strcmp(kbuf, "off") == 0) - tap_param = 0; - - set_dis_tap_fn(pbp_device_block, tap_param); - - return count; + bpctl_dev_t *dev = m->private; + int ret = get_dis_bypass_fn(dev); + if (ret == BP_NOT_CAP) + seq_printf(m, "fail\n"); + else if (ret == 0) + seq_printf(m, "off\n"); + else + seq_printf(m, "on\n"); + return 0; } +RW_FOPS(dis_bypass) -int -set_dis_disc_pfs(struct file *file, const char *buffer, - unsigned long count, void *data) +static ssize_t dis_tap_write(struct file *file, const char __user *buffer, + size_t count, loff_t *pos) { - - char kbuf[256]; - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int tap_param = 0, length = 0; - - if (count >= sizeof(kbuf)) + int tap_param = user_on_off(buffer, count); + if (tap_param < 0) return -EINVAL; - if (copy_from_user(&kbuf, buffer, count)) { - return -1; - } - - kbuf[count] = '\0'; - length = strlen(kbuf); - if (kbuf[length - 1] == '\n') - kbuf[--length] = '\0'; - - if (strcmp(kbuf, "on") == 0) - tap_param = 1; - else if (strcmp(kbuf, "off") == 0) - tap_param = 0; - - set_dis_disc_fn(pbp_device_block, tap_param); - + set_dis_tap_fn(PDE_DATA(file_inode(file)), tap_param); return count; } - -int -get_dis_bypass_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) +static int show_dis_tap(struct seq_file *m, void *v) { - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; - - ret = get_dis_bypass_fn(pbp_device_block); + bpctl_dev_t *dev = m->private; + int ret = get_dis_tap_fn(dev); if (ret == BP_NOT_CAP) - len = sprintf(page, "fail\n"); + seq_printf(m, "fail\n"); else if (ret == 0) - len = sprintf(page, "off\n"); + seq_printf(m, "off\n"); else - len = sprintf(page, "on\n"); - - *eof = 1; - return len; + seq_printf(m, "on\n"); + return 0; } +RW_FOPS(dis_tap) -int -get_dis_tap_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) +static ssize_t dis_disc_write(struct file *file, const char __user *buffer, + size_t count, loff_t *pos) { - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; - - ret = get_dis_tap_fn(pbp_device_block); - if (ret == BP_NOT_CAP) - len = sprintf(page, "fail\n"); - else if (ret == 0) - len = sprintf(page, "off\n"); - else - len = sprintf(page, "on\n"); + int tap_param = user_on_off(buffer, count); + if (tap_param < 0) + return -EINVAL; - *eof = 1; - return len; + set_dis_disc_fn(PDE_DATA(file_inode(file)), tap_param); + return count; } - -int -get_dis_disc_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) +static int show_dis_disc(struct seq_file *m, void *v) { - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; - - ret = get_dis_disc_fn(pbp_device_block); + bpctl_dev_t *dev = m->private; + int ret = get_dis_disc_fn(dev); if (ret == BP_NOT_CAP) - len = sprintf(page, "fail\n"); + seq_printf(m, "fail\n"); else if (ret == 0) - len = sprintf(page, "off\n"); + seq_printf(m, "off\n"); else - len = sprintf(page, "on\n"); - - *eof = 1; - return len; -} - -int -set_bypass_pwup_pfs(struct file *file, const char *buffer, - unsigned long count, void *data) -{ - - char kbuf[256]; - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int bypass_param = 0, length = 0; - - if (count >= sizeof(kbuf)) - return -EINVAL; - - if (copy_from_user(&kbuf, buffer, count)) { - return -1; - } - - kbuf[count] = '\0'; - length = strlen(kbuf); - if (kbuf[length - 1] == '\n') - kbuf[--length] = '\0'; - - if (strcmp(kbuf, "on") == 0) - bypass_param = 1; - else if (strcmp(kbuf, "off") == 0) - bypass_param = 0; - - set_bypass_pwup_fn(pbp_device_block, bypass_param); - - return count; + seq_printf(m, "on\n"); + return 0; } +RW_FOPS(dis_disc) -int -set_bypass_pwoff_pfs(struct file *file, const char *buffer, - unsigned long count, void *data) +static ssize_t bypass_pwup_write(struct file *file, const char __user *buffer, + size_t count, loff_t *pos) { - - char kbuf[256]; - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int bypass_param = 0, length = 0; - - if (count >= sizeof(kbuf)) + int bypass_param = user_on_off(buffer, count); + if (bypass_param < 0) return -EINVAL; - if (copy_from_user(&kbuf, buffer, count)) { - return -1; - } - - kbuf[count] = '\0'; - length = strlen(kbuf); - if (kbuf[length - 1] == '\n') - kbuf[--length] = '\0'; - - if (strcmp(kbuf, "on") == 0) - bypass_param = 1; - else if (strcmp(kbuf, "off") == 0) - bypass_param = 0; - - set_bypass_pwoff_fn(pbp_device_block, bypass_param); - + set_bypass_pwup_fn(PDE_DATA(file_inode(file)), bypass_param); return count; } - -int -set_tap_pwup_pfs(struct file *file, const char *buffer, - unsigned long count, void *data) +static int show_bypass_pwup(struct seq_file *m, void *v) { - - char kbuf[256]; - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int tap_param = 0, length = 0; - - if (count >= sizeof(kbuf)) - return -EINVAL; - - if (copy_from_user(&kbuf, buffer, count)) { - return -1; - } - - kbuf[count] = '\0'; - length = strlen(kbuf); - if (kbuf[length - 1] == '\n') - kbuf[--length] = '\0'; - - if (strcmp(kbuf, "on") == 0) - tap_param = 1; - else if (strcmp(kbuf, "off") == 0) - tap_param = 0; - - set_tap_pwup_fn(pbp_device_block, tap_param); - - return count; + bpctl_dev_t *dev = m->private; + int ret = get_bypass_pwup_fn(dev); + if (ret == BP_NOT_CAP) + seq_printf(m, "fail\n"); + else if (ret == 0) + seq_printf(m, "off\n"); + else + seq_printf(m, "on\n"); + return 0; } +RW_FOPS(bypass_pwup) -int -set_disc_pwup_pfs(struct file *file, const char *buffer, - unsigned long count, void *data) +static ssize_t bypass_pwoff_write(struct file *file, const char __user *buffer, + size_t count, loff_t *pos) { - - char kbuf[256]; - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int tap_param = 0, length = 0; - - if (count >= sizeof(kbuf)) + int bypass_param = user_on_off(buffer, count); + if (bypass_param < 0) return -EINVAL; - if (copy_from_user(&kbuf, buffer, count)) { - return -1; - } - - kbuf[count] = '\0'; - length = strlen(kbuf); - if (kbuf[length - 1] == '\n') - kbuf[--length] = '\0'; - - if (strcmp(kbuf, "on") == 0) - tap_param = 1; - else if (strcmp(kbuf, "off") == 0) - tap_param = 0; - - set_disc_pwup_fn(pbp_device_block, tap_param); - + set_bypass_pwoff_fn(PDE_DATA(file_inode(file)), bypass_param); return count; } - -int -get_bypass_pwup_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) +static int show_bypass_pwoff(struct seq_file *m, void *v) { - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; - - ret = get_bypass_pwup_fn(pbp_device_block); + bpctl_dev_t *dev = m->private; + int ret = get_bypass_pwoff_fn(dev); if (ret == BP_NOT_CAP) - len = sprintf(page, "fail\n"); + seq_printf(m, "fail\n"); else if (ret == 0) - len = sprintf(page, "off\n"); + seq_printf(m, "off\n"); else - len = sprintf(page, "on\n"); - - *eof = 1; - return len; + seq_printf(m, "on\n"); + return 0; } +RW_FOPS(bypass_pwoff) -int -get_bypass_pwoff_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) +static ssize_t tap_pwup_write(struct file *file, const char __user *buffer, + size_t count, loff_t *pos) { - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; - - ret = get_bypass_pwoff_fn(pbp_device_block); - if (ret == BP_NOT_CAP) - len = sprintf(page, "fail\n"); - else if (ret == 0) - len = sprintf(page, "off\n"); - else - len = sprintf(page, "on\n"); + int tap_param = user_on_off(buffer, count); + if (tap_param < 0) + return -EINVAL; - *eof = 1; - return len; + set_tap_pwup_fn(PDE_DATA(file_inode(file)), tap_param); + return count; } - -int -get_tap_pwup_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) +static int show_tap_pwup(struct seq_file *m, void *v) { - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; - - ret = get_tap_pwup_fn(pbp_device_block); + bpctl_dev_t *dev = m->private; + int ret = get_tap_pwup_fn(dev); if (ret == BP_NOT_CAP) - len = sprintf(page, "fail\n"); + seq_printf(m, "fail\n"); else if (ret == 0) - len = sprintf(page, "off\n"); + seq_printf(m, "off\n"); else - len = sprintf(page, "on\n"); - - *eof = 1; - return len; + seq_printf(m, "on\n"); + return 0; } +RW_FOPS(tap_pwup) -int -get_disc_pwup_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) +static ssize_t disc_pwup_write(struct file *file, const char __user *buffer, + size_t count, loff_t *pos) { - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; + int tap_param = user_on_off(buffer, count); + if (tap_param < 0) + return -EINVAL; - ret = get_disc_pwup_fn(pbp_device_block); + set_disc_pwup_fn(PDE_DATA(file_inode(file)), tap_param); + return count; +} +static int show_disc_pwup(struct seq_file *m, void *v) +{ + bpctl_dev_t *dev = m->private; + int ret = get_disc_pwup_fn(dev); if (ret == BP_NOT_CAP) - len = sprintf(page, "fail\n"); + seq_printf(m, "fail\n"); else if (ret == 0) - len = sprintf(page, "off\n"); + seq_printf(m, "off\n"); else - len = sprintf(page, "on\n"); - - *eof = 1; - return len; + seq_printf(m, "on\n"); + return 0; } +RW_FOPS(disc_pwup) -int -set_std_nic_pfs(struct file *file, const char *buffer, - unsigned long count, void *data) +static ssize_t std_nic_write(struct file *file, const char __user *buffer, + size_t count, loff_t *pos) { - - char kbuf[256]; - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int bypass_param = 0, length = 0; - - if (count >= sizeof(kbuf)) + int bypass_param = user_on_off(buffer, count); + if (bypass_param < 0) return -EINVAL; - if (copy_from_user(&kbuf, buffer, count)) { - return -1; - } - - kbuf[count] = '\0'; - length = strlen(kbuf); - if (kbuf[length - 1] == '\n') - kbuf[--length] = '\0'; - - if (strcmp(kbuf, "on") == 0) - bypass_param = 1; - else if (strcmp(kbuf, "off") == 0) - bypass_param = 0; - - set_std_nic_fn(pbp_device_block, bypass_param); - + set_std_nic_fn(PDE_DATA(file_inode(file)), bypass_param); return count; } - -int -get_std_nic_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) +static int show_std_nic(struct seq_file *m, void *v) { - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; - - ret = get_std_nic_fn(pbp_device_block); + bpctl_dev_t *dev = m->private; + int ret = get_std_nic_fn(dev); if (ret == BP_NOT_CAP) - len = sprintf(page, "fail\n"); + seq_printf(m, "fail\n"); else if (ret == 0) - len = sprintf(page, "off\n"); + seq_printf(m, "off\n"); else - len = sprintf(page, "on\n"); - - *eof = 1; - return len; -} - -int -get_wd_exp_mode_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) -{ - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; - - ret = get_wd_exp_mode_fn(pbp_device_block); - if (ret == 1) - len = sprintf(page, "tap\n"); - else if (ret == 0) - len = sprintf(page, "bypass\n"); - else if (ret == 2) - len = sprintf(page, "disc\n"); - - else - len = sprintf(page, "fail\n"); - - *eof = 1; - return len; + seq_printf(m, "on\n"); + return 0; } +RW_FOPS(std_nic) -int -set_wd_exp_mode_pfs(struct file *file, const char *buffer, - unsigned long count, void *data) +static ssize_t wd_exp_mode_write(struct file *file, const char __user *buffer, + size_t count, loff_t *pos) { - char kbuf[256]; - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - int bypass_param = 0, length = 0; if (count > (sizeof(kbuf) - 1)) return -1; - if (copy_from_user(&kbuf, buffer, count)) { + if (copy_from_user(&kbuf, buffer, count)) return -1; - } kbuf[count] = '\0'; length = strlen(kbuf); @@ -8375,143 +7786,47 @@ set_wd_exp_mode_pfs(struct file *file, const char *buffer, else if (strcmp(kbuf, "disc") == 0) bypass_param = 2; - set_wd_exp_mode_fn(pbp_device_block, bypass_param); + set_wd_exp_mode_fn(PDE_DATA(file_inode(file)), bypass_param); return count; } - -int -get_wd_autoreset_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) +static int show_wd_exp_mode(struct seq_file *m, void *v) { - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; - - ret = get_wd_autoreset_fn(pbp_device_block); - if (ret >= 0) - len = sprintf(page, "%d\n", ret); + bpctl_dev_t *dev = m->private; + int ret = get_wd_exp_mode_fn(dev); + if (ret == 1) + seq_printf(m, "tap\n"); + else if (ret == 0) + seq_printf(m, "bypass\n"); + else if (ret == 2) + seq_printf(m, "disc\n"); else - len = sprintf(page, "fail\n"); - - *eof = 1; - return len; + seq_printf(m, "fail\n"); + return 0; } +RW_FOPS(wd_exp_mode) -int -set_wd_autoreset_pfs(struct file *file, const char *buffer, - unsigned long count, void *data) +static ssize_t wd_autoreset_write(struct file *file, const char __user *buffer, + size_t count, loff_t *pos) { - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; int timeout; - int ret; - - ret = kstrtoint_from_user(buffer, count, 10, &timeout); + int ret = kstrtoint_from_user(buffer, count, 10, &timeout); if (ret) return ret; - set_wd_autoreset_fn(pbp_device_block, timeout); - - return count; -} - -int -set_tpl_pfs(struct file *file, const char *buffer, - unsigned long count, void *data) -{ - - char kbuf[256]; - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int tpl_param = 0, length = 0; - - if (count > (sizeof(kbuf) - 1)) - return -1; - - if (copy_from_user(&kbuf, buffer, count)) { - return -1; - } - - kbuf[count] = '\0'; - length = strlen(kbuf); - if (kbuf[length - 1] == '\n') - kbuf[--length] = '\0'; - - if (strcmp(kbuf, "on") == 0) - tpl_param = 1; - else if (strcmp(kbuf, "off") == 0) - tpl_param = 0; - - set_tpl_fn(pbp_device_block, tpl_param); - + set_wd_autoreset_fn(PDE_DATA(file_inode(file)), timeout); return count; } - -#ifdef PMC_FIX_FLAG -int -set_wait_at_pwup_pfs(struct file *file, const char *buffer, - unsigned long count, void *data) -{ - - char kbuf[256]; - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int tpl_param = 0, length = 0; - - if (count > (sizeof(kbuf) - 1)) - return -1; - - if (copy_from_user(&kbuf, buffer, count)) { - return -1; - } - - kbuf[count] = '\0'; - length = strlen(kbuf); - if (kbuf[length - 1] == '\n') - kbuf[--length] = '\0'; - - if (strcmp(kbuf, "on") == 0) - tpl_param = 1; - else if (strcmp(kbuf, "off") == 0) - tpl_param = 0; - - set_bp_wait_at_pwup_fn(pbp_device_block, tpl_param); - - return count; -} - -int -set_hw_reset_pfs(struct file *file, const char *buffer, - unsigned long count, void *data) +static int show_wd_autoreset(struct seq_file *m, void *v) { - - char kbuf[256]; - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int tpl_param = 0, length = 0; - - if (count > (sizeof(kbuf) - 1)) - return -1; - - if (copy_from_user(&kbuf, buffer, count)) { - return -1; - } - - kbuf[count] = '\0'; - length = strlen(kbuf); - if (kbuf[length - 1] == '\n') - kbuf[--length] = '\0'; - - if (strcmp(kbuf, "on") == 0) - tpl_param = 1; - else if (strcmp(kbuf, "off") == 0) - tpl_param = 0; - - set_bp_hw_reset_fn(pbp_device_block, tpl_param); - - return count; + bpctl_dev_t *dev = m->private; + int ret = get_wd_autoreset_fn(dev); + if (ret >= 0) + seq_printf(m, "%d\n", ret); + else + seq_printf(m, "fail\n"); + return 0; } - -#endif /*PMC_FIX_FLAG */ +RW_FOPS(wd_autoreset) int bypass_proc_create_dev_sd(bpctl_dev_t *pbp_device_block) { @@ -8528,168 +7843,54 @@ int bypass_proc_create_dev_sd(bpctl_dev_t *pbp_device_block) return -1; /* create device proc dir */ - procfs_dir = proc_getdir(current_pfs->dir_name, bp_procfs_dir); - if (procfs_dir == 0) { + procfs_dir = proc_mkdir(current_pfs->dir_name, bp_procfs_dir); + if (!procfs_dir) { printk(KERN_DEBUG "Could not create procfs directory %s\n", current_pfs->dir_name); return -1; } current_pfs->bypass_entry = procfs_dir; - if (bypass_proc_create_entry_sd(&(current_pfs->bypass_info), BYPASS_INFO_ENTRY_SD, NULL, /* write */ - get_bypass_info_pfs, /* read */ - procfs_dir, pbp_device_block)) - ret = -1; - +#define ENTRY(x) ret |= procfs_add(#x, &x##_ops, pbp_device_block) + ENTRY(bypass_info); if (pbp_device_block->bp_caps & SW_CTL_CAP) { - /* Create set param proc's */ - if (bypass_proc_create_entry_sd(&(current_pfs->bypass_slave), BYPASS_SLAVE_ENTRY_SD, NULL, /* write */ - get_bypass_slave_pfs, /* read */ - procfs_dir, pbp_device_block)) - ret = -1; - - if (bypass_proc_create_entry_sd(&(current_pfs->bypass_caps), BYPASS_CAPS_ENTRY_SD, NULL, /* write */ - get_bypass_caps_pfs, /* read */ - procfs_dir, pbp_device_block)) - ret = -1; - - if (bypass_proc_create_entry_sd(&(current_pfs->wd_set_caps), WD_SET_CAPS_ENTRY_SD, NULL, /* write */ - get_wd_set_caps_pfs, /* read */ - procfs_dir, pbp_device_block)) - ret = -1; - if (bypass_proc_create_entry_sd(&(current_pfs->bypass_wd), BYPASS_WD_ENTRY_SD, set_bypass_wd_pfs, /* write */ - get_bypass_wd_pfs, /* read */ - procfs_dir, pbp_device_block)) - ret = -1; - - if (bypass_proc_create_entry_sd(&(current_pfs->wd_expire_time), WD_EXPIRE_TIME_ENTRY_SD, NULL, /* write */ - get_wd_expire_time_pfs, /* read */ - procfs_dir, pbp_device_block)) - ret = -1; - - if (bypass_proc_create_entry_sd(&(current_pfs->reset_bypass_wd), RESET_BYPASS_WD_ENTRY_SD, NULL, /* write */ - reset_bypass_wd_pfs, /* read */ - procfs_dir, pbp_device_block)) - ret = -1; - - if (bypass_proc_create_entry_sd(&(current_pfs->std_nic), STD_NIC_ENTRY_SD, set_std_nic_pfs, /* write */ - get_std_nic_pfs, /* read */ - procfs_dir, pbp_device_block)) - ret = -1; - + ENTRY(bypass_slave); + ENTRY(bypass_caps); + ENTRY(wd_set_caps); + ENTRY(bypass_wd); + ENTRY(wd_expire_time); + ENTRY(reset_bypass_wd); + ENTRY(std_nic); if (pbp_device_block->bp_caps & BP_CAP) { - if (bypass_proc_create_entry_sd(&(current_pfs->bypass), BYPASS_ENTRY_SD, set_bypass_pfs, /* write */ - get_bypass_pfs, /* read */ - procfs_dir, - pbp_device_block)) - ret = -1; - - if (bypass_proc_create_entry_sd(&(current_pfs->dis_bypass), DIS_BYPASS_ENTRY_SD, set_dis_bypass_pfs, /* write */ - get_dis_bypass_pfs, /* read */ - procfs_dir, - pbp_device_block)) - ret = -1; - - if (bypass_proc_create_entry_sd(&(current_pfs->bypass_pwup), BYPASS_PWUP_ENTRY_SD, set_bypass_pwup_pfs, /* write */ - get_bypass_pwup_pfs, /* read */ - procfs_dir, - pbp_device_block)) - ret = -1; - if (bypass_proc_create_entry_sd(&(current_pfs->bypass_pwoff), BYPASS_PWOFF_ENTRY_SD, set_bypass_pwoff_pfs, /* write */ - get_bypass_pwoff_pfs, /* read */ - procfs_dir, - pbp_device_block)) - ret = -1; - - if (bypass_proc_create_entry_sd(&(current_pfs->bypass_change), BYPASS_CHANGE_ENTRY_SD, NULL, /* write */ - get_bypass_change_pfs, /* read */ - procfs_dir, - pbp_device_block)) - ret = -1; + ENTRY(bypass); + ENTRY(dis_bypass); + ENTRY(bypass_pwup); + ENTRY(bypass_pwoff); + ENTRY(bypass_change); } - if (pbp_device_block->bp_caps & TAP_CAP) { - - if (bypass_proc_create_entry_sd(&(current_pfs->tap), TAP_ENTRY_SD, set_tap_pfs, /* write */ - get_tap_pfs, /* read */ - procfs_dir, - pbp_device_block)) - ret = -1; - - if (bypass_proc_create_entry_sd(&(current_pfs->dis_tap), DIS_TAP_ENTRY_SD, set_dis_tap_pfs, /* write */ - get_dis_tap_pfs, /* read */ - procfs_dir, - pbp_device_block)) - ret = -1; - - if (bypass_proc_create_entry_sd(&(current_pfs->tap_pwup), TAP_PWUP_ENTRY_SD, set_tap_pwup_pfs, /* write */ - get_tap_pwup_pfs, /* read */ - procfs_dir, - pbp_device_block)) - ret = -1; - - if (bypass_proc_create_entry_sd(&(current_pfs->tap_change), TAP_CHANGE_ENTRY_SD, NULL, /* write */ - get_tap_change_pfs, /* read */ - procfs_dir, - pbp_device_block)) - ret = -1; + ENTRY(tap); + ENTRY(dis_tap); + ENTRY(tap_pwup); + ENTRY(tap_change); } if (pbp_device_block->bp_caps & DISC_CAP) { - - if (bypass_proc_create_entry_sd(&(current_pfs->tap), DISC_ENTRY_SD, set_disc_pfs, /* write */ - get_disc_pfs, /* read */ - procfs_dir, - pbp_device_block)) - ret = -1; -#if 1 - - if (bypass_proc_create_entry_sd(&(current_pfs->dis_tap), DIS_DISC_ENTRY_SD, set_dis_disc_pfs, /* write */ - get_dis_disc_pfs, /* read */ - procfs_dir, - pbp_device_block)) - ret = -1; -#endif - - if (bypass_proc_create_entry_sd(&(current_pfs->tap_pwup), DISC_PWUP_ENTRY_SD, set_disc_pwup_pfs, /* write */ - get_disc_pwup_pfs, /* read */ - procfs_dir, - pbp_device_block)) - ret = -1; - - if (bypass_proc_create_entry_sd(&(current_pfs->tap_change), DISC_CHANGE_ENTRY_SD, NULL, /* write */ - get_disc_change_pfs, /* read */ - procfs_dir, - pbp_device_block)) - ret = -1; + ENTRY(disc); + ENTRY(dis_disc); + ENTRY(disc_pwup); + ENTRY(disc_change); } - if (bypass_proc_create_entry_sd(&(current_pfs->wd_exp_mode), WD_EXP_MODE_ENTRY_SD, set_wd_exp_mode_pfs, /* write */ - get_wd_exp_mode_pfs, /* read */ - procfs_dir, pbp_device_block)) - ret = -1; - - if (bypass_proc_create_entry_sd(&(current_pfs->wd_autoreset), WD_AUTORESET_ENTRY_SD, set_wd_autoreset_pfs, /* write */ - get_wd_autoreset_pfs, /* read */ - procfs_dir, pbp_device_block)) - ret = -1; - if (bypass_proc_create_entry_sd(&(current_pfs->tpl), TPL_ENTRY_SD, set_tpl_pfs, /* write */ - get_tpl_pfs, /* read */ - procfs_dir, pbp_device_block)) - ret = -1; + ENTRY(wd_exp_mode); + ENTRY(wd_autoreset); + ENTRY(tpl); #ifdef PMC_FIX_FLAG - if (bypass_proc_create_entry_sd(&(current_pfs->tpl), WAIT_AT_PWUP_ENTRY_SD, set_wait_at_pwup_pfs, /* write */ - get_wait_at_pwup_pfs, /* read */ - procfs_dir, pbp_device_block)) - ret = -1; - if (bypass_proc_create_entry_sd(&(current_pfs->tpl), HW_RESET_ENTRY_SD, set_hw_reset_pfs, /* write */ - get_hw_reset_pfs, /* read */ - procfs_dir, pbp_device_block)) - ret = -1; - + ENTRY(wait_at_pwup); + ENTRY(hw_reset); #endif - } +#undef ENTRY if (ret < 0) printk(KERN_DEBUG "Create proc entry failed\n"); @@ -8700,21 +7901,7 @@ int bypass_proc_remove_dev_sd(bpctl_dev_t *pbp_device_block) { struct bypass_pfs_sd *current_pfs = &pbp_device_block->bypass_pfs_set; - struct proc_dir_entry *pde = current_pfs->bypass_entry, *pde_curr = - NULL; - char name[256]; - - if (!pde) - return 0; - for (pde = pde->subdir; pde;) { - strcpy(name, pde->name); - pde_curr = pde; - pde = pde->next; - remove_proc_entry(name, current_pfs->bypass_entry); - } - if (!pde) - remove_proc_entry(current_pfs->dir_name, bp_procfs_dir); + remove_proc_subtree(current_pfs->dir_name, bp_procfs_dir); current_pfs->bypass_entry = NULL; - return 0; } diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index be4f6c2ca3f..08b250f01da 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -60,6 +60,7 @@ */ #undef __NO_VERSION__ +#include <linux/file.h> #include "device.h" #include "card.h" #include "channel.h" @@ -2737,83 +2738,50 @@ static int Config_FileGetParameter(unsigned char *string, return true; } -int Config_FileOperation(PSDevice pDevice, bool fwrite, unsigned char *Parameter) { - unsigned char *config_path = CONFIG_PATH; - unsigned char *buffer = NULL; +int Config_FileOperation(PSDevice pDevice,bool fwrite,unsigned char *Parameter) +{ + unsigned char *buffer = kmalloc(1024, GFP_KERNEL); unsigned char tmpbuffer[20]; - struct file *filp = NULL; - mm_segment_t old_fs = get_fs(); - //int oldfsuid=0,oldfsgid=0; - int result = 0; - - set_fs(KERNEL_DS); - - /* Can't do this anymore, so we rely on correct filesystem permissions: - //Make sure a caller can read or write power as root - oldfsuid=current->cred->fsuid; - oldfsgid=current->cred->fsgid; - current->cred->fsuid = 0; - current->cred->fsgid = 0; - */ - - //open file - filp = filp_open(config_path, O_RDWR, 0); - if (IS_ERR(filp)) { - printk("Config_FileOperation:open file fail?\n"); - result = -1; - goto error2; - } + struct file *file; + int result=0; - if (!(filp->f_op) || !(filp->f_op->read) || !(filp->f_op->write)) { - printk("file %s cann't readable or writable?\n", config_path); - result = -1; - goto error1; - } - - buffer = kmalloc(1024, GFP_KERNEL); - if (buffer == NULL) { + if (!buffer) { printk("allocate mem for file fail?\n"); - result = -1; - goto error1; + return -1; + } + file = filp_open(CONFIG_PATH, O_RDONLY, 0); + if (IS_ERR(file)) { + kfree(buffer); + printk("Config_FileOperation:open file fail?\n"); + return -1; } - if (filp->f_op->read(filp, buffer, 1024, &filp->f_pos) < 0) { + if (kernel_read(file, 0, buffer, 1024) < 0) { printk("read file error?\n"); result = -1; goto error1; } - if (Config_FileGetParameter("ZONETYPE", tmpbuffer, buffer) != true) { + if (Config_FileGetParameter("ZONETYPE",tmpbuffer,buffer)!=true) { printk("get parameter error?\n"); result = -1; goto error1; } - if (memcmp(tmpbuffer, "USA", 3) == 0) { + if (memcmp(tmpbuffer,"USA",3)==0) { result = ZoneType_USA; - } else if (memcmp(tmpbuffer, "JAPAN", 5) == 0) { + } else if(memcmp(tmpbuffer,"JAPAN",5)==0) { result = ZoneType_Japan; - } else if (memcmp(tmpbuffer, "EUROPE", 5) == 0) { + } else if(memcmp(tmpbuffer,"EUROPE",5)==0) { result = ZoneType_Europe; } else { result = -1; - printk("Unknown Zonetype[%s]?\n", tmpbuffer); + printk("Unknown Zonetype[%s]?\n",tmpbuffer); } error1: kfree(buffer); - - if (filp_close(filp, NULL)) - printk("Config_FileOperation:close file fail\n"); - -error2: - set_fs(old_fs); - - /* - current->cred->fsuid=oldfsuid; - current->cred->fsgid=oldfsgid; - */ - + fput(file); return result; } diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index 2161af83eaa..3a3fdc58b6d 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -46,6 +46,7 @@ */ #undef __NO_VERSION__ +#include <linux/file.h> #include "device.h" #include "card.h" #include "baseband.h" @@ -1273,53 +1274,29 @@ static int Config_FileGetParameter(unsigned char *string, /* if read fails, return NULL, or return data pointer */ static unsigned char *Config_FileOperation(struct vnt_private *pDevice) { - unsigned char *config_path = CONFIG_PATH; - unsigned char *buffer = NULL; - struct file *filp=NULL; - mm_segment_t old_fs = get_fs(); + unsigned char *buffer = kmalloc(1024, GFP_KERNEL); + struct file *file; - int result = 0; - - set_fs (KERNEL_DS); - - /* open file */ - filp = filp_open(config_path, O_RDWR, 0); - if (IS_ERR(filp)) { - printk("Config_FileOperation file Not exist\n"); - result=-1; - goto error2; - } - - if(!(filp->f_op) || !(filp->f_op->read) ||!(filp->f_op->write)) { - printk("file %s is not read or writeable?\n",config_path); - result = -1; - goto error1; - } - - buffer = kmalloc(1024, GFP_KERNEL); - if(buffer==NULL) { - printk("allocate mem for file fail?\n"); - result = -1; - goto error1; - } - - if(filp->f_op->read(filp, buffer, 1024, &filp->f_pos)<0) { - printk("read file error?\n"); - result = -1; - } + if (!buffer) { + printk("allocate mem for file fail?\n"); + return NULL; + } -error1: - if(filp_close(filp,NULL)) - printk("Config_FileOperation:close file fail\n"); + file = filp_open(CONFIG_PATH, O_RDONLY, 0); + if (IS_ERR(file)) { + kfree(buffer); + printk("Config_FileOperation file Not exist\n"); + return NULL; + } -error2: - set_fs (old_fs); + if (kernel_read(file, 0, buffer, 1024) < 0) { + printk("read file error?\n"); + kfree(buffer); + buffer = NULL; + } -if(result!=0) { - kfree(buffer); - buffer=NULL; -} - return buffer; + fput(file); + return buffer; } /* return --->-1:fail; >=0:successful */ diff --git a/drivers/staging/wlags49_h2/wl_main.c b/drivers/staging/wlags49_h2/wl_main.c index f5f120a6246..c4264e8c877 100644 --- a/drivers/staging/wlags49_h2/wl_main.c +++ b/drivers/staging/wlags49_h2/wl_main.c @@ -73,6 +73,7 @@ #include <linux/module.h> #include <linux/proc_fs.h> +#include <linux/seq_file.h> #include <linux/types.h> #include <linux/kernel.h> // #include <linux/sched.h> @@ -144,10 +145,23 @@ void wl_isr_handler( unsigned long p ); #if 0 //SCULL_USE_PROC /* don't waste space if unused */ -//int scull_read_procmem(char *buf, char **start, off_t offset, int len, int unused); -int scull_read_procmem(char *buf, char **start, off_t offset, int len, int *eof, void *data ); +static int scull_read_procmem(struct seq_file *m, void *v); static int write_int(struct file *file, const char *buffer, unsigned long count, void *data); -static void proc_write(const char *name, write_proc_t *w, void *data); + +/* + * seq_file wrappers for procfile show routines. + */ +static int scull_read_procmem_open(struct inode *inode, struct file *file) +{ + return single_open(file, scull_read_procmem, PDE_DATA(inode)); +} + +static const struct file_operations scull_read_procmem_fops = { + .open = scull_read_procmem_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; #endif /* SCULL_USE_PROC */ @@ -908,9 +922,8 @@ int wl_insert( struct net_device *dev ) } #if 0 //SCULL_USE_PROC /* don't waste space if unused */ - create_proc_read_entry( "wlags", 0, NULL, scull_read_procmem, dev ); + proc_create_data( "wlags", 0, NULL, &scull_read_procmem_fops, dev ); proc_mkdir("driver/wlags49", 0); - proc_write("driver/wlags49/wlags49_type", write_int, &lp->wlags49_type); #endif /* SCULL_USE_PROC */ DBG_LEAVE( DbgInfo ); @@ -2097,7 +2110,7 @@ static void __exit wl_module_exit( void ) wl_adapter_cleanup_module( ); #if 0 //SCULL_USE_PROC /* don't waste space if unused */ - remove_proc_entry( "wlags", NULL ); //;?why so a-symmetric compared to location of create_proc_read_entry + remove_proc_entry( "wlags", NULL ); //;?why so a-symmetric compared to location of proc_create_data #endif DBG_LEAVE( DbgInfo ); @@ -3531,229 +3544,215 @@ void wl_wds_netdev_deregister( struct wl_private *lp ) /* * The proc filesystem: function to read and entry */ -int printf_hcf_16( char *s, char *buf, hcf_16* p, int n ); -int printf_hcf_16( char *s, char *buf, hcf_16* p, int n ) { +static void printf_hcf_16(struct seq_file *m, const char *s, hcf_16 *p, int n) +{ + int i, len; -int i, len; + seq_printf(m, "%-20.20s: ", s); + len = 22; - len = sprintf(buf, "%s", s ); - while ( len < 20 ) len += sprintf(buf+len, " " ); - len += sprintf(buf+len,": " ); - for ( i = 0; i < n; i++ ) { - if ( len % 80 > 75 ) { - len += sprintf(buf+len,"\n" ); - } - len += sprintf(buf+len,"%04X ", p[i] ); + for (i = 0; i < n; i++) { + if (len % 80 > 75) + seq_putc(m, '\n'); + seq_printf(m, "%04X ", p[i]); } - len += sprintf(buf+len,"\n" ); - return len; -} // printf_hcf_16 + seq_putc(m, '\n'); +} -int printf_hcf_8( char *s, char *buf, hcf_8* p, int n ); -int printf_hcf_8( char *s, char *buf, hcf_8* p, int n ) { +static void printf_hcf_8(struct seq_file *m, const char *s, hcf_8 *p, int n) +{ + int i, len; -int i, len; + seq_printf(m, "%-20.20s: ", s); + len = 22; - len = sprintf(buf, "%s", s ); - while ( len < 20 ) len += sprintf(buf+len, " " ); - len += sprintf(buf+len,": " ); - for ( i = 0; i <= n; i++ ) { - if ( len % 80 > 77 ) { - len += sprintf(buf+len,"\n" ); - } - len += sprintf(buf+len,"%02X ", p[i] ); + for (i = 0; i <= n; i++) { + if (len % 80 > 77) + seq_putc(m, '\n'); + seq_printf(m, "%02X ", p[i]); } - len += sprintf(buf+len,"\n" ); - return len; -} // printf_hcf8 + seq_putc(m, '\n'); +} -int printf_strct( char *s, char *buf, hcf_16* p ); -int printf_strct( char *s, char *buf, hcf_16* p ) { +static void printf_strct(struct seq_file *m, const char *s, hcf_16 *p) +{ + int i, len; -int i, len; + seq_printf(m, "%-20.20s: ", s); + len = 22; - len = sprintf(buf, "%s", s ); - while ( len < 20 ) len += sprintf(buf+len, " " ); - len += sprintf(buf+len,": " ); for ( i = 0; i <= *p; i++ ) { - if ( len % 80 > 75 ) { - len += sprintf(buf+len,"\n" ); - } - len += sprintf(buf+len,"%04X ", p[i] ); + if (len % 80 > 75) + seq_putc(m, '\n'); + seq_printf(m,"%04X ", p[i]); } - len += sprintf(buf+len,"\n" ); - return len; -} // printf_strct + seq_putc(m, '\n'); +} -int scull_read_procmem(char *buf, char **start, off_t offset, int len, int *eof, void *data ) +int scull_read_procmem(struct seq_file *m, void *v) { - struct wl_private *lp = NULL; + struct wl_private *lp = m->private; IFBP ifbp; CFG_HERMES_TALLIES_STRCT *p; - #define LIMIT (PAGE_SIZE-80) /* don't print any more after this size */ - - len=0; - - lp = ((struct net_device *)data)->priv; if (lp == NULL) { - len += sprintf(buf+len,"No wl_private in scull_read_procmem\n" ); + seq_puts(m, "No wl_private in scull_read_procmem\n" ); } else if ( lp->wlags49_type == 0 ){ - ifbp = &lp->hcfCtx; - len += sprintf(buf+len,"Magic: 0x%04X\n", ifbp->IFB_Magic ); - len += sprintf(buf+len,"IOBase: 0x%04X\n", ifbp->IFB_IOBase ); - len += sprintf(buf+len,"LinkStat: 0x%04X\n", ifbp->IFB_LinkStat ); - len += sprintf(buf+len,"DSLinkStat: 0x%04X\n", ifbp->IFB_DSLinkStat ); - len += sprintf(buf+len,"TickIni: 0x%08lX\n", ifbp->IFB_TickIni ); - len += sprintf(buf+len,"TickCnt: 0x%04X\n", ifbp->IFB_TickCnt ); - len += sprintf(buf+len,"IntOffCnt: 0x%04X\n", ifbp->IFB_IntOffCnt ); - len += printf_hcf_16( "IFB_FWIdentity", &buf[len], - &ifbp->IFB_FWIdentity.len, ifbp->IFB_FWIdentity.len + 1 ); + ifbp = &lp->hcfCtx; + seq_printf(m, "Magic: 0x%04X\n", ifbp->IFB_Magic ); + seq_printf(m, "IOBase: 0x%04X\n", ifbp->IFB_IOBase ); + seq_printf(m, "LinkStat: 0x%04X\n", ifbp->IFB_LinkStat ); + seq_printf(m, "DSLinkStat: 0x%04X\n", ifbp->IFB_DSLinkStat ); + seq_printf(m, "TickIni: 0x%08lX\n", ifbp->IFB_TickIni ); + seq_printf(m, "TickCnt: 0x%04X\n", ifbp->IFB_TickCnt ); + seq_printf(m, "IntOffCnt: 0x%04X\n", ifbp->IFB_IntOffCnt ); + printf_hcf_16(m, "IFB_FWIdentity", + &ifbp->IFB_FWIdentity.len, ifbp->IFB_FWIdentity.len + 1 ); } else if ( lp->wlags49_type == 1 ) { - len += sprintf(buf+len,"Channel: 0x%04X\n", lp->Channel ); -/****** len += sprintf(buf+len,"slock: %d\n", lp->slock ); */ + seq_printf(m, "Channel: 0x%04X\n", lp->Channel ); +/****** seq_printf(m, "slock: %d\n", lp->slock ); */ //x struct tq_struct "task: 0x%04X\n", lp->task ); //x struct net_device_stats "stats: 0x%04X\n", lp->stats ); #ifdef WIRELESS_EXT //x struct iw_statistics "wstats: 0x%04X\n", lp->wstats ); -//x len += sprintf(buf+len,"spy_number: 0x%04X\n", lp->spy_number ); +//x seq_printf(m, "spy_number: 0x%04X\n", lp->spy_number ); //x u_char spy_address[IW_MAX_SPY][ETH_ALEN]; //x struct iw_quality spy_stat[IW_MAX_SPY]; #endif // WIRELESS_EXT - len += sprintf(buf+len,"IFB: 0x%p\n", &lp->hcfCtx ); - len += sprintf(buf+len,"flags: %#.8lX\n", lp->flags ); //;?use this format from now on - len += sprintf(buf+len,"DebugFlag(wl_private) 0x%04X\n", lp->DebugFlag ); + seq_printf(m, "IFB: 0x%p\n", &lp->hcfCtx ); + seq_printf(m, "flags: %#.8lX\n", lp->flags ); //;?use this format from now on + seq_printf(m, "DebugFlag(wl_private) 0x%04X\n", lp->DebugFlag ); #if DBG - len += sprintf(buf+len,"DebugFlag (DbgInfo): 0x%08lX\n", DbgInfo->DebugFlag ); + seq_printf(m, "DebugFlag (DbgInfo): 0x%08lX\n", DbgInfo->DebugFlag ); #endif // DBG - len += sprintf(buf+len,"is_registered: 0x%04X\n", lp->is_registered ); + seq_printf(m, "is_registered: 0x%04X\n", lp->is_registered ); //x CFG_DRV_INFO_STRCT "driverInfo: 0x%04X\n", lp->driverInfo ); - len += printf_strct( "driverInfo", &buf[len], (hcf_16*)&lp->driverInfo ); + printf_strct( m, "driverInfo", (hcf_16*)&lp->driverInfo ); //x CFG_IDENTITY_STRCT "driverIdentity: 0x%04X\n", lp->driverIdentity ); - len += printf_strct( "driverIdentity", &buf[len], (hcf_16*)&lp->driverIdentity ); + printf_strct( m, "driverIdentity", (hcf_16*)&lp->driverIdentity ); //x CFG_FW_IDENTITY_STRCT "StationIdentity: 0x%04X\n", lp->StationIdentity ); - len += printf_strct( "StationIdentity", &buf[len], (hcf_16*)&lp->StationIdentity ); + printf_strct( m, "StationIdentity", (hcf_16*)&lp->StationIdentity ); //x CFG_PRI_IDENTITY_STRCT "PrimaryIdentity: 0x%04X\n", lp->PrimaryIdentity ); - len += printf_strct( "PrimaryIdentity", &buf[len], (hcf_16*)&lp->hcfCtx.IFB_PRIIdentity ); - len += printf_strct( "PrimarySupplier", &buf[len], (hcf_16*)&lp->hcfCtx.IFB_PRISup ); + printf_strct( m, "PrimaryIdentity", (hcf_16*)&lp->hcfCtx.IFB_PRIIdentity ); + printf_strct( m, "PrimarySupplier", (hcf_16*)&lp->hcfCtx.IFB_PRISup ); //x CFG_PRI_IDENTITY_STRCT "NICIdentity: 0x%04X\n", lp->NICIdentity ); - len += printf_strct( "NICIdentity", &buf[len], (hcf_16*)&lp->NICIdentity ); + printf_strct( m, "NICIdentity", (hcf_16*)&lp->NICIdentity ); //x ltv_t "ltvRecord: 0x%04X\n", lp->ltvRecord ); - len += sprintf(buf+len,"txBytes: 0x%08lX\n", lp->txBytes ); - len += sprintf(buf+len,"maxPort: 0x%04X\n", lp->maxPort ); /* 0 for STA, 6 for AP */ - /* Elements used for async notification from hardware */ + seq_printf(m, "txBytes: 0x%08lX\n", lp->txBytes ); + seq_printf(m, "maxPort: 0x%04X\n", lp->maxPort ); /* 0 for STA, 6 for AP */ + /* Elements used for async notification from hardware */ //x RID_LOG_STRCT RidList[10]; //x ltv_t "updatedRecord: 0x%04X\n", lp->updatedRecord ); //x PROBE_RESP "ProbeResp: 0x%04X\n", lp->ProbeResp ); //x ASSOC_STATUS_STRCT "assoc_stat: 0x%04X\n", lp->assoc_stat ); //x SECURITY_STATUS_STRCT "sec_stat: 0x%04X\n", lp->sec_stat ); //x u_char lookAheadBuf[WVLAN_MAX_LOOKAHEAD]; - len += sprintf(buf+len,"PortType: 0x%04X\n", lp->PortType ); // 1 - 3 (1 [Normal] | 3 [AdHoc]) - len += sprintf(buf+len,"Channel: 0x%04X\n", lp->Channel ); // 0 - 14 (0) + seq_printf(m, "PortType: 0x%04X\n", lp->PortType ); // 1 - 3 (1 [Normal] | 3 [AdHoc]) + seq_printf(m, "Channel: 0x%04X\n", lp->Channel ); // 0 - 14 (0) //x hcf_16 TxRateControl[2]; - len += sprintf(buf+len,"TxRateControl[2]: 0x%04X 0x%04X\n", - lp->TxRateControl[0], lp->TxRateControl[1] ); - len += sprintf(buf+len,"DistanceBetweenAPs: 0x%04X\n", lp->DistanceBetweenAPs ); // 1 - 3 (1) - len += sprintf(buf+len,"RTSThreshold: 0x%04X\n", lp->RTSThreshold ); // 0 - 2347 (2347) - len += sprintf(buf+len,"PMEnabled: 0x%04X\n", lp->PMEnabled ); // 0 - 2, 8001 - 8002 (0) - len += sprintf(buf+len,"MicrowaveRobustness: 0x%04X\n", lp->MicrowaveRobustness );// 0 - 1 (0) - len += sprintf(buf+len,"CreateIBSS: 0x%04X\n", lp->CreateIBSS ); // 0 - 1 (0) - len += sprintf(buf+len,"MulticastReceive: 0x%04X\n", lp->MulticastReceive ); // 0 - 1 (1) - len += sprintf(buf+len,"MaxSleepDuration: 0x%04X\n", lp->MaxSleepDuration ); // 0 - 65535 (100) + seq_printf(m, "TxRateControl[2]: 0x%04X 0x%04X\n", + lp->TxRateControl[0], lp->TxRateControl[1] ); + seq_printf(m, "DistanceBetweenAPs: 0x%04X\n", lp->DistanceBetweenAPs ); // 1 - 3 (1) + seq_printf(m, "RTSThreshold: 0x%04X\n", lp->RTSThreshold ); // 0 - 2347 (2347) + seq_printf(m, "PMEnabled: 0x%04X\n", lp->PMEnabled ); // 0 - 2, 8001 - 8002 (0) + seq_printf(m, "MicrowaveRobustness: 0x%04X\n", lp->MicrowaveRobustness );// 0 - 1 (0) + seq_printf(m, "CreateIBSS: 0x%04X\n", lp->CreateIBSS ); // 0 - 1 (0) + seq_printf(m, "MulticastReceive: 0x%04X\n", lp->MulticastReceive ); // 0 - 1 (1) + seq_printf(m, "MaxSleepDuration: 0x%04X\n", lp->MaxSleepDuration ); // 0 - 65535 (100) //x hcf_8 MACAddress[ETH_ALEN]; - len += printf_hcf_8( "MACAddress", &buf[len], lp->MACAddress, ETH_ALEN ); + printf_hcf_8(m, "MACAddress", lp->MACAddress, ETH_ALEN ); //x char NetworkName[HCF_MAX_NAME_LEN+1]; - len += sprintf(buf+len,"NetworkName: %.32s\n", lp->NetworkName ); + seq_printf(m, "NetworkName: %.32s\n", lp->NetworkName ); //x char StationName[HCF_MAX_NAME_LEN+1]; - len += sprintf(buf+len,"EnableEncryption: 0x%04X\n", lp->EnableEncryption ); // 0 - 1 (0) + seq_printf(m, "EnableEncryption: 0x%04X\n", lp->EnableEncryption ); // 0 - 1 (0) //x char Key1[MAX_KEY_LEN+1]; - len += printf_hcf_8( "Key1", &buf[len], lp->Key1, MAX_KEY_LEN ); + printf_hcf_8( m, "Key1", lp->Key1, MAX_KEY_LEN ); //x char Key2[MAX_KEY_LEN+1]; //x char Key3[MAX_KEY_LEN+1]; //x char Key4[MAX_KEY_LEN+1]; - len += sprintf(buf+len,"TransmitKeyID: 0x%04X\n", lp->TransmitKeyID ); // 1 - 4 (1) + seq_printf(m, "TransmitKeyID: 0x%04X\n", lp->TransmitKeyID ); // 1 - 4 (1) //x CFG_DEFAULT_KEYS_STRCT "DefaultKeys: 0x%04X\n", lp->DefaultKeys ); //x u_char mailbox[MB_SIZE]; //x char szEncryption[MAX_ENC_LEN]; - len += sprintf(buf+len,"driverEnable: 0x%04X\n", lp->driverEnable ); - len += sprintf(buf+len,"wolasEnable: 0x%04X\n", lp->wolasEnable ); - len += sprintf(buf+len,"atimWindow: 0x%04X\n", lp->atimWindow ); - len += sprintf(buf+len,"holdoverDuration: 0x%04X\n", lp->holdoverDuration ); + seq_printf(m, "driverEnable: 0x%04X\n", lp->driverEnable ); + seq_printf(m, "wolasEnable: 0x%04X\n", lp->wolasEnable ); + seq_printf(m, "atimWindow: 0x%04X\n", lp->atimWindow ); + seq_printf(m, "holdoverDuration: 0x%04X\n", lp->holdoverDuration ); //x hcf_16 MulticastRate[2]; - len += sprintf(buf+len,"authentication: 0x%04X\n", lp->authentication ); // is this AP specific? - len += sprintf(buf+len,"promiscuousMode: 0x%04X\n", lp->promiscuousMode ); - len += sprintf(buf+len,"DownloadFirmware: 0x%04X\n", lp->DownloadFirmware ); // 0 - 2 (0 [None] | 1 [STA] | 2 [AP]) - len += sprintf(buf+len,"AuthKeyMgmtSuite: 0x%04X\n", lp->AuthKeyMgmtSuite ); - len += sprintf(buf+len,"loadBalancing: 0x%04X\n", lp->loadBalancing ); - len += sprintf(buf+len,"mediumDistribution: 0x%04X\n", lp->mediumDistribution ); - len += sprintf(buf+len,"txPowLevel: 0x%04X\n", lp->txPowLevel ); -// len += sprintf(buf+len,"shortRetryLimit: 0x%04X\n", lp->shortRetryLimit ); -// len += sprintf(buf+len,"longRetryLimit: 0x%04X\n", lp->longRetryLimit ); + seq_printf(m, "authentication: 0x%04X\n", lp->authentication ); // is this AP specific? + seq_printf(m, "promiscuousMode: 0x%04X\n", lp->promiscuousMode ); + seq_printf(m, "DownloadFirmware: 0x%04X\n", lp->DownloadFirmware ); // 0 - 2 (0 [None] | 1 [STA] | 2 [AP]) + seq_printf(m, "AuthKeyMgmtSuite: 0x%04X\n", lp->AuthKeyMgmtSuite ); + seq_printf(m, "loadBalancing: 0x%04X\n", lp->loadBalancing ); + seq_printf(m, "mediumDistribution: 0x%04X\n", lp->mediumDistribution ); + seq_printf(m, "txPowLevel: 0x%04X\n", lp->txPowLevel ); +// seq_printf(m, "shortRetryLimit: 0x%04X\n", lp->shortRetryLimit ); +// seq_printf(m, "longRetryLimit: 0x%04X\n", lp->longRetryLimit ); //x hcf_16 srsc[2]; //x hcf_16 brsc[2]; - len += sprintf(buf+len,"connectionControl: 0x%04X\n", lp->connectionControl ); + seq_printf(m, "connectionControl: 0x%04X\n", lp->connectionControl ); //x //hcf_16 probeDataRates[2]; - len += sprintf(buf+len,"ownBeaconInterval: 0x%04X\n", lp->ownBeaconInterval ); - len += sprintf(buf+len,"coexistence: 0x%04X\n", lp->coexistence ); + seq_printf(m, "ownBeaconInterval: 0x%04X\n", lp->ownBeaconInterval ); + seq_printf(m, "coexistence: 0x%04X\n", lp->coexistence ); //x WVLAN_FRAME "txF: 0x%04X\n", lp->txF ); //x WVLAN_LFRAME txList[DEFAULT_NUM_TX_FRAMES]; //x struct list_head "txFree: 0x%04X\n", lp->txFree ); //x struct list_head txQ[WVLAN_MAX_TX_QUEUES]; - len += sprintf(buf+len,"netif_queue_on: 0x%04X\n", lp->netif_queue_on ); - len += sprintf(buf+len,"txQ_count: 0x%04X\n", lp->txQ_count ); + seq_printf(m, "netif_queue_on: 0x%04X\n", lp->netif_queue_on ); + seq_printf(m, "txQ_count: 0x%04X\n", lp->txQ_count ); //x DESC_STRCT "desc_rx: 0x%04X\n", lp->desc_rx ); //x DESC_STRCT "desc_tx: 0x%04X\n", lp->desc_tx ); //x WVLAN_PORT_STATE "portState: 0x%04X\n", lp->portState ); //x ScanResult "scan_results: 0x%04X\n", lp->scan_results ); //x ProbeResult "probe_results: 0x%04X\n", lp->probe_results ); - len += sprintf(buf+len,"probe_num_aps: 0x%04X\n", lp->probe_num_aps ); - len += sprintf(buf+len,"use_dma: 0x%04X\n", lp->use_dma ); + seq_printf(m, "probe_num_aps: 0x%04X\n", lp->probe_num_aps ); + seq_printf(m, "use_dma: 0x%04X\n", lp->use_dma ); //x DMA_STRCT "dma: 0x%04X\n", lp->dma ); #ifdef USE_RTS - len += sprintf(buf+len,"useRTS: 0x%04X\n", lp->useRTS ); + seq_printf(m, "useRTS: 0x%04X\n", lp->useRTS ); #endif // USE_RTS #if 1 //;? (HCF_TYPE) & HCF_TYPE_AP //;?should we restore this to allow smaller memory footprint //;?I guess not. This should be brought under Debug mode only - len += sprintf(buf+len,"DTIMPeriod: 0x%04X\n", lp->DTIMPeriod ); // 1 - 255 (1) - len += sprintf(buf+len,"multicastPMBuffering: 0x%04X\n", lp->multicastPMBuffering ); - len += sprintf(buf+len,"RejectAny: 0x%04X\n", lp->RejectAny ); // 0 - 1 (0) - len += sprintf(buf+len,"ExcludeUnencrypted: 0x%04X\n", lp->ExcludeUnencrypted ); // 0 - 1 (1) - len += sprintf(buf+len,"intraBSSRelay: 0x%04X\n", lp->intraBSSRelay ); - len += sprintf(buf+len,"wlags49_type: 0x%08lX\n", lp->wlags49_type ); + seq_printf(m, "DTIMPeriod: 0x%04X\n", lp->DTIMPeriod ); // 1 - 255 (1) + seq_printf(m, "multicastPMBuffering: 0x%04X\n", lp->multicastPMBuffering ); + seq_printf(m, "RejectAny: 0x%04X\n", lp->RejectAny ); // 0 - 1 (0) + seq_printf(m, "ExcludeUnencrypted: 0x%04X\n", lp->ExcludeUnencrypted ); // 0 - 1 (1) + seq_printf(m, "intraBSSRelay: 0x%04X\n", lp->intraBSSRelay ); + seq_printf(m, "wlags49_type: 0x%08lX\n", lp->wlags49_type ); #ifdef USE_WDS //x WVLAN_WDS_IF wds_port[NUM_WDS_PORTS]; #endif // USE_WDS #endif // HCF_AP } else if ( lp->wlags49_type == 2 ){ - len += sprintf(buf+len,"tallies to be added\n" ); + seq_printf(m, "tallies to be added\n" ); //Hermes Tallies (IFB substructure) { - p = &lp->hcfCtx.IFB_NIC_Tallies; - len += sprintf(buf+len,"TxUnicastFrames: %08lX\n", p->TxUnicastFrames ); - len += sprintf(buf+len,"TxMulticastFrames: %08lX\n", p->TxMulticastFrames ); - len += sprintf(buf+len,"TxFragments: %08lX\n", p->TxFragments ); - len += sprintf(buf+len,"TxUnicastOctets: %08lX\n", p->TxUnicastOctets ); - len += sprintf(buf+len,"TxMulticastOctets: %08lX\n", p->TxMulticastOctets ); - len += sprintf(buf+len,"TxDeferredTransmissions: %08lX\n", p->TxDeferredTransmissions ); - len += sprintf(buf+len,"TxSingleRetryFrames: %08lX\n", p->TxSingleRetryFrames ); - len += sprintf(buf+len,"TxMultipleRetryFrames: %08lX\n", p->TxMultipleRetryFrames ); - len += sprintf(buf+len,"TxRetryLimitExceeded: %08lX\n", p->TxRetryLimitExceeded ); - len += sprintf(buf+len,"TxDiscards: %08lX\n", p->TxDiscards ); - len += sprintf(buf+len,"RxUnicastFrames: %08lX\n", p->RxUnicastFrames ); - len += sprintf(buf+len,"RxMulticastFrames: %08lX\n", p->RxMulticastFrames ); - len += sprintf(buf+len,"RxFragments: %08lX\n", p->RxFragments ); - len += sprintf(buf+len,"RxUnicastOctets: %08lX\n", p->RxUnicastOctets ); - len += sprintf(buf+len,"RxMulticastOctets: %08lX\n", p->RxMulticastOctets ); - len += sprintf(buf+len,"RxFCSErrors: %08lX\n", p->RxFCSErrors ); - len += sprintf(buf+len,"RxDiscardsNoBuffer: %08lX\n", p->RxDiscardsNoBuffer ); - len += sprintf(buf+len,"TxDiscardsWrongSA: %08lX\n", p->TxDiscardsWrongSA ); - len += sprintf(buf+len,"RxWEPUndecryptable: %08lX\n", p->RxWEPUndecryptable ); - len += sprintf(buf+len,"RxMsgInMsgFragments: %08lX\n", p->RxMsgInMsgFragments ); - len += sprintf(buf+len,"RxMsgInBadMsgFragments: %08lX\n", p->RxMsgInBadMsgFragments ); - len += sprintf(buf+len,"RxDiscardsWEPICVError: %08lX\n", p->RxDiscardsWEPICVError ); - len += sprintf(buf+len,"RxDiscardsWEPExcluded: %08lX\n", p->RxDiscardsWEPExcluded ); + p = &lp->hcfCtx.IFB_NIC_Tallies; + seq_printf(m, "TxUnicastFrames: %08lX\n", p->TxUnicastFrames ); + seq_printf(m, "TxMulticastFrames: %08lX\n", p->TxMulticastFrames ); + seq_printf(m, "TxFragments: %08lX\n", p->TxFragments ); + seq_printf(m, "TxUnicastOctets: %08lX\n", p->TxUnicastOctets ); + seq_printf(m, "TxMulticastOctets: %08lX\n", p->TxMulticastOctets ); + seq_printf(m, "TxDeferredTransmissions: %08lX\n", p->TxDeferredTransmissions ); + seq_printf(m, "TxSingleRetryFrames: %08lX\n", p->TxSingleRetryFrames ); + seq_printf(m, "TxMultipleRetryFrames: %08lX\n", p->TxMultipleRetryFrames ); + seq_printf(m, "TxRetryLimitExceeded: %08lX\n", p->TxRetryLimitExceeded ); + seq_printf(m, "TxDiscards: %08lX\n", p->TxDiscards ); + seq_printf(m, "RxUnicastFrames: %08lX\n", p->RxUnicastFrames ); + seq_printf(m, "RxMulticastFrames: %08lX\n", p->RxMulticastFrames ); + seq_printf(m, "RxFragments: %08lX\n", p->RxFragments ); + seq_printf(m, "RxUnicastOctets: %08lX\n", p->RxUnicastOctets ); + seq_printf(m, "RxMulticastOctets: %08lX\n", p->RxMulticastOctets ); + seq_printf(m, "RxFCSErrors: %08lX\n", p->RxFCSErrors ); + seq_printf(m, "RxDiscardsNoBuffer: %08lX\n", p->RxDiscardsNoBuffer ); + seq_printf(m, "TxDiscardsWrongSA: %08lX\n", p->TxDiscardsWrongSA ); + seq_printf(m, "RxWEPUndecryptable: %08lX\n", p->RxWEPUndecryptable ); + seq_printf(m, "RxMsgInMsgFragments: %08lX\n", p->RxMsgInMsgFragments ); + seq_printf(m, "RxMsgInBadMsgFragments: %08lX\n", p->RxMsgInBadMsgFragments ); + seq_printf(m, "RxDiscardsWEPICVError: %08lX\n", p->RxDiscardsWEPICVError ); + seq_printf(m, "RxDiscardsWEPExcluded: %08lX\n", p->RxDiscardsWEPExcluded ); #if (HCF_EXT) & HCF_EXT_TALLIES_FW - //to be added ;? + //to be added ;? #endif // HCF_EXT_TALLIES_FW } else if ( lp->wlags49_type & 0x8000 ) { //;?kludgy but it is unclear to me were else to place this #if DBG @@ -3761,27 +3760,19 @@ int scull_read_procmem(char *buf, char **start, off_t offset, int len, int *eof, #endif // DBG lp->wlags49_type = 0; //default to IFB again ;? } else { - len += sprintf(buf+len,"unknown value for wlags49_type: 0x%08lX\n", lp->wlags49_type ); - len += sprintf(buf+len,"0x0000 - IFB\n" ); - len += sprintf(buf+len,"0x0001 - wl_private\n" ); - len += sprintf(buf+len,"0x0002 - Tallies\n" ); - len += sprintf(buf+len,"0x8xxx - Change debufflag\n" ); - len += sprintf(buf+len,"ERROR 0001\nWARNING 0002\nNOTICE 0004\nTRACE 0008\n" ); - len += sprintf(buf+len,"VERBOSE 0010\nPARAM 0020\nBREAK 0040\nRX 0100\n" ); - len += sprintf(buf+len,"TX 0200\nDS 0400\n" ); - } - return len; + seq_printf(m, "unknown value for wlags49_type: 0x%08lX\n", lp->wlags49_type ); + seq_puts(m, + "0x0000 - IFB\n" + "0x0001 - wl_private\n" + "0x0002 - Tallies\n" + "0x8xxx - Change debufflag\n" + "ERROR 0001\nWARNING 0002\nNOTICE 0004\nTRACE 0008\n" + "VERBOSE 0010\nPARAM 0020\nBREAK 0040\nRX 0100\n" + "TX 0200\nDS 0400\n"); + } + return 0; } // scull_read_procmem -static void proc_write(const char *name, write_proc_t *w, void *data) -{ - struct proc_dir_entry * entry = create_proc_entry(name, S_IFREG | S_IWUSR, NULL); - if (entry) { - entry->write_proc = w; - entry->data = data; - } -} // proc_write - static int write_int(struct file *file, const char *buffer, unsigned long count, void *data) { static char proc_number[11]; |