From 03d95eb2f2578083a3f6286262e1cb5d88a00c02 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Wed, 20 Mar 2013 13:04:20 -0400 Subject: lift sb_start_write() out of ->write() Signed-off-by: Al Viro --- drivers/block/loop.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers') diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 747bb2af69d..cd1e17460f0 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -230,9 +230,11 @@ static int __do_lo_send_write(struct file *file, ssize_t bw; mm_segment_t old_fs = get_fs(); + file_start_write(file); set_fs(get_ds()); bw = file->f_op->write(file, buf, len, &pos); set_fs(old_fs); + file_end_write(file); if (likely(bw == len)) return 0; printk(KERN_ERR "loop: Write error at byte offset %llu, length %i.\n", -- cgit v1.2.3 From c62c5a887766de7dc51f7722ff461aef8f388b71 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 28 Mar 2013 13:00:31 -0400 Subject: ccg: don't bother with fops->owner filesystem module as whole is pinned down by its superblock, no need to have opened files on it to add anything to that. Signed-off-by: Al Viro --- drivers/staging/ccg/f_fs.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/ccg/f_fs.c b/drivers/staging/ccg/f_fs.c index f6373dade7f..e82b1cdfd18 100644 --- a/drivers/staging/ccg/f_fs.c +++ b/drivers/staging/ccg/f_fs.c @@ -723,7 +723,6 @@ static long ffs_ep0_ioctl(struct file *file, unsigned code, unsigned long value) } static const struct file_operations ffs_ep0_operations = { - .owner = THIS_MODULE, .llseek = no_llseek, .open = ffs_ep0_open, @@ -943,7 +942,6 @@ static long ffs_epfile_ioctl(struct file *file, unsigned code, } static const struct file_operations ffs_epfile_operations = { - .owner = THIS_MODULE, .llseek = no_llseek, .open = ffs_epfile_open, -- cgit v1.2.3 From 3273097ee9c077512bcb017535b0781f1e1f7a6d Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 28 Mar 2013 13:12:32 -0400 Subject: gadgetfs: don't bother with fops->owner filesystem module as whole is pinned down by its superblock, no need to have opened files on it to add anything to that. Signed-off-by: Al Viro --- drivers/usb/gadget/f_fs.c | 2 -- drivers/usb/gadget/inode.c | 2 -- 2 files changed, 4 deletions(-) (limited to 'drivers') diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c index c377ff84bf2..f394f295d63 100644 --- a/drivers/usb/gadget/f_fs.c +++ b/drivers/usb/gadget/f_fs.c @@ -727,7 +727,6 @@ static long ffs_ep0_ioctl(struct file *file, unsigned code, unsigned long value) } static const struct file_operations ffs_ep0_operations = { - .owner = THIS_MODULE, .llseek = no_llseek, .open = ffs_ep0_open, @@ -947,7 +946,6 @@ static long ffs_epfile_ioctl(struct file *file, unsigned code, } static const struct file_operations ffs_epfile_operations = { - .owner = THIS_MODULE, .llseek = no_llseek, .open = ffs_epfile_open, diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c index e2b2e9cf254..dda0dc4a556 100644 --- a/drivers/usb/gadget/inode.c +++ b/drivers/usb/gadget/inode.c @@ -887,7 +887,6 @@ ep_open (struct inode *inode, struct file *fd) /* used before endpoint configuration */ static const struct file_operations ep_config_operations = { - .owner = THIS_MODULE, .llseek = no_llseek, .open = ep_open, @@ -1940,7 +1939,6 @@ dev_open (struct inode *inode, struct file *fd) } static const struct file_operations dev_init_operations = { - .owner = THIS_MODULE, .llseek = no_llseek, .open = dev_open, -- cgit v1.2.3 From 4d8e8d21de89ff9d86b83182f723129533aacaa9 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 28 Mar 2013 18:56:21 -0400 Subject: hysdn: stash pointer to card into proc_dir_entry->data no need to search later - we know the card when we are creating procfs entries Signed-off-by: Al Viro --- drivers/isdn/hysdn/hysdn_procconf.c | 32 +++-------------- drivers/isdn/hysdn/hysdn_proclog.c | 71 +++++++------------------------------ 2 files changed, 18 insertions(+), 85 deletions(-) (limited to 'drivers') diff --git a/drivers/isdn/hysdn/hysdn_procconf.c b/drivers/isdn/hysdn/hysdn_procconf.c index 8023d2510fb..dc88bcb2502 100644 --- a/drivers/isdn/hysdn/hysdn_procconf.c +++ b/drivers/isdn/hysdn/hysdn_procconf.c @@ -229,23 +229,12 @@ static int hysdn_conf_open(struct inode *ino, struct file *filep) { hysdn_card *card; - struct proc_dir_entry *pd; struct conf_writedata *cnf; char *cp, *tmp; /* now search the addressed card */ mutex_lock(&hysdn_conf_mutex); - card = card_root; - while (card) { - pd = card->procconf; - if (pd == PDE(ino)) - break; - card = card->next; /* search next entry */ - } - if (!card) { - mutex_unlock(&hysdn_conf_mutex); - return (-ENODEV); /* device is unknown/invalid */ - } + card = PDE(ino)->data; if (card->debug_flags & (LOG_PROC_OPEN | LOG_PROC_ALL)) hysdn_addlog(card, "config open for uid=%d gid=%d mode=0x%x", filep->f_cred->fsuid, filep->f_cred->fsgid, @@ -317,21 +306,9 @@ hysdn_conf_close(struct inode *ino, struct file *filep) hysdn_card *card; struct conf_writedata *cnf; int retval = 0; - struct proc_dir_entry *pd; mutex_lock(&hysdn_conf_mutex); - /* search the addressed card */ - card = card_root; - while (card) { - pd = card->procconf; - if (pd == PDE(ino)) - break; - card = card->next; /* search next entry */ - } - if (!card) { - mutex_unlock(&hysdn_conf_mutex); - return (-ENODEV); /* device is unknown/invalid */ - } + card = PDE(ino)->data; if (card->debug_flags & (LOG_PROC_OPEN | LOG_PROC_ALL)) hysdn_addlog(card, "config close for uid=%d gid=%d mode=0x%x", filep->f_cred->fsuid, filep->f_cred->fsgid, @@ -394,10 +371,11 @@ hysdn_procconf_init(void) while (card) { sprintf(conf_name, "%s%d", PROC_CONF_BASENAME, card->myid); - if ((card->procconf = (void *) proc_create(conf_name, + if ((card->procconf = (void *) proc_create_data(conf_name, S_IFREG | S_IRUGO | S_IWUSR, hysdn_proc_entry, - &conf_fops)) != NULL) { + &conf_fops, + card)) != NULL) { hysdn_proclog_init(card); /* init the log file entry */ } card = card->next; /* next entry */ diff --git a/drivers/isdn/hysdn/hysdn_proclog.c b/drivers/isdn/hysdn/hysdn_proclog.c index 9a3ce93665c..22f0e4ef1fb 100644 --- a/drivers/isdn/hysdn/hysdn_proclog.c +++ b/drivers/isdn/hysdn/hysdn_proclog.c @@ -173,27 +173,14 @@ hysdn_log_read(struct file *file, char __user *buf, size_t count, loff_t *off) { struct log_data *inf; int len; - struct proc_dir_entry *pde = PDE(file_inode(file)); - struct procdata *pd = NULL; - hysdn_card *card; + hysdn_card *card = PDE(file_inode(file))->data; if (!*((struct log_data **) file->private_data)) { + struct procdata *pd = card->proclog; if (file->f_flags & O_NONBLOCK) return (-EAGAIN); - /* sorry, but we need to search the card */ - card = card_root; - while (card) { - pd = card->proclog; - if (pd->log == pde) - break; - card = card->next; /* search next entry */ - } - if (card) - interruptible_sleep_on(&(pd->rd_queue)); - else - return (-EAGAIN); - + interruptible_sleep_on(&(pd->rd_queue)); } if (!(inf = *((struct log_data **) file->private_data))) return (0); @@ -215,27 +202,15 @@ hysdn_log_read(struct file *file, char __user *buf, size_t count, loff_t *off) static int hysdn_log_open(struct inode *ino, struct file *filep) { - hysdn_card *card; - struct procdata *pd = NULL; - unsigned long flags; + hysdn_card *card = PDE(ino)->data; mutex_lock(&hysdn_log_mutex); - card = card_root; - while (card) { - pd = card->proclog; - if (pd->log == PDE(ino)) - break; - card = card->next; /* search next entry */ - } - if (!card) { - mutex_unlock(&hysdn_log_mutex); - return (-ENODEV); /* device is unknown/invalid */ - } - filep->private_data = card; /* remember our own card */ - if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_WRITE) { /* write only access -> write log level only */ + filep->private_data = card; /* remember our own card */ } else if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) { + struct procdata *pd = card->proclog; + unsigned long flags; /* read access -> log/debug read */ spin_lock_irqsave(&card->hysdn_lock, flags); @@ -275,21 +250,13 @@ hysdn_log_close(struct inode *ino, struct file *filep) } else { /* read access -> log/debug read, mark one further file as closed */ - pd = NULL; inf = *((struct log_data **) filep->private_data); /* get first log entry */ if (inf) pd = (struct procdata *) inf->proc_ctrl; /* still entries there */ else { /* no info available -> search card */ - card = card_root; - while (card) { - pd = card->proclog; - if (pd->log == PDE(ino)) - break; - card = card->next; /* search next entry */ - } - if (card) - pd = card->proclog; /* pointer to procfs log */ + card = PDE(file_inode(filep))->data; + pd = card->proclog; /* pointer to procfs log */ } if (pd) pd->if_used--; /* decrement interface usage count by one */ @@ -319,24 +286,12 @@ static unsigned int hysdn_log_poll(struct file *file, poll_table *wait) { unsigned int mask = 0; - struct proc_dir_entry *pde = PDE(file_inode(file)); - hysdn_card *card; - struct procdata *pd = NULL; + hysdn_card *card = PDE(file_inode(file))->data; + struct procdata *pd = card->proclog; if ((file->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_WRITE) return (mask); /* no polling for write supported */ - /* we need to search the card */ - card = card_root; - while (card) { - pd = card->proclog; - if (pd->log == pde) - break; - card = card->next; /* search next entry */ - } - if (!card) - return (mask); /* card not found */ - poll_wait(file, &(pd->rd_queue), wait); if (*((struct log_data **) file->private_data)) @@ -373,9 +328,9 @@ hysdn_proclog_init(hysdn_card *card) if ((pd = kzalloc(sizeof(struct procdata), GFP_KERNEL)) != NULL) { sprintf(pd->log_name, "%s%d", PROC_LOG_BASENAME, card->myid); - pd->log = proc_create(pd->log_name, + pd->log = proc_create_data(pd->log_name, S_IFREG | S_IRUGO | S_IWUSR, hysdn_proc_entry, - &log_fops); + &log_fops, card); init_waitqueue_head(&(pd->rd_queue)); -- cgit v1.2.3 From 0ecc833bac594099505a090cbca6ccd5b83d5975 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 29 Mar 2013 12:23:28 -0400 Subject: mode_t, whack-a-mole at 11... Signed-off-by: Al Viro --- drivers/net/wireless/ath/wil6210/debugfs.c | 4 ++-- drivers/staging/dgrp/dgrp_common.h | 2 +- drivers/staging/dgrp/dgrp_specproc.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/net/wireless/ath/wil6210/debugfs.c b/drivers/net/wireless/ath/wil6210/debugfs.c index 65fc9683bfd..76c7694518d 100644 --- a/drivers/net/wireless/ath/wil6210/debugfs.c +++ b/drivers/net/wireless/ath/wil6210/debugfs.c @@ -216,7 +216,7 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_iomem_x32, wil_debugfs_iomem_x32_get, wil_debugfs_iomem_x32_set, "0x%08llx\n"); static struct dentry *wil_debugfs_create_iomem_x32(const char *name, - mode_t mode, + umode_t mode, struct dentry *parent, void __iomem *value) { @@ -367,7 +367,7 @@ static const struct file_operations fops_ioblob = { static struct dentry *wil_debugfs_create_ioblob(const char *name, - mode_t mode, + umode_t mode, struct dentry *parent, struct debugfs_blob_wrapper *blob) { diff --git a/drivers/staging/dgrp/dgrp_common.h b/drivers/staging/dgrp/dgrp_common.h index 0583fe9c7b0..fde116236e9 100644 --- a/drivers/staging/dgrp/dgrp_common.h +++ b/drivers/staging/dgrp/dgrp_common.h @@ -120,7 +120,7 @@ enum { struct dgrp_proc_entry { int id; /* Integer identifier */ const char *name; /* ASCII identifier */ - mode_t mode; /* File access permissions */ + umode_t mode; /* File access permissions */ struct dgrp_proc_entry *child; /* Child pointer */ /* file ops to use, pass NULL to use default */ diff --git a/drivers/staging/dgrp/dgrp_specproc.c b/drivers/staging/dgrp/dgrp_specproc.c index 73f287f9660..dddf8a2e396 100644 --- a/drivers/staging/dgrp/dgrp_specproc.c +++ b/drivers/staging/dgrp/dgrp_specproc.c @@ -228,7 +228,7 @@ static void register_proc_table(struct dgrp_proc_entry *table, { struct proc_dir_entry *de; int len; - mode_t mode; + umode_t mode; if (table == NULL) return; -- cgit v1.2.3 From e3e7b40c192b4e31eb7043867ea87f834076b1e2 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 29 Mar 2013 19:30:06 -0400 Subject: rtl8192e: don't use create_proc_entry() for directories proc_mkdir() is there for purpose... Signed-off-by: Al Viro --- drivers/staging/rtl8192e/rtllib_module.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/staging/rtl8192e/rtllib_module.c b/drivers/staging/rtl8192e/rtllib_module.c index f9dae958a5d..40b6d809e01 100644 --- a/drivers/staging/rtl8192e/rtllib_module.c +++ b/drivers/staging/rtl8192e/rtllib_module.c @@ -246,7 +246,7 @@ 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"); -- cgit v1.2.3 From c037773cc7f8d3fb72dabc3dc0a53f5376d1383c Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 15:02:51 -0400 Subject: rtl8192e: switch to proc_create() Signed-off-by: Al Viro --- drivers/staging/rtl8192e/rtllib_module.c | 52 +++++++++++++------------------- 1 file changed, 21 insertions(+), 31 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/rtl8192e/rtllib_module.c b/drivers/staging/rtl8192e/rtllib_module.c index 40b6d809e01..84ea721d5d8 100644 --- a/drivers/staging/rtl8192e/rtllib_module.c +++ b/drivers/staging/rtl8192e/rtllib_module.c @@ -208,39 +208,34 @@ 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; @@ -252,17 +247,12 @@ int __init rtllib_init(void) " 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; } -- cgit v1.2.3 From f56e2947be4585fd35627b4b778c582ca7fb5b03 Mon Sep 17 00:00:00 2001 From: Sean MacLennan Date: Mon, 8 Apr 2013 21:18:06 -0400 Subject: The rtl8192e procfs-based debug interface seems very broken The procfs debug code in rtl_debug.c is, ironically, very buggy: it lacks proper locking. Since the most useful part of the code (the stats) are available through more standard APIs, I think it is best to just delete the whole mess. Signed-off-by: Sean MacLennan Signed-off-by: Al Viro --- drivers/staging/rtl8192e/rtl8192e/Makefile | 1 - drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 5 - drivers/staging/rtl8192e/rtl8192e/rtl_core.h | 6 - drivers/staging/rtl8192e/rtl8192e/rtl_debug.c | 1029 ------------------------- 4 files changed, 1041 deletions(-) delete mode 100644 drivers/staging/rtl8192e/rtl8192e/rtl_debug.c (limited to 'drivers') 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 , 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 -******************************************************************************/ -#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); -} -- cgit v1.2.3 From aa66d7bba7c25ab2aefad9dad01c485b04dc4cbe Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 29 Mar 2013 20:39:17 -0400 Subject: dgrp procfs fixes, part 1 proc_create() has shat upon fops argument when mode is S_IFDIR. Good thing, too, since fops passed to it is completely useless for any directory. Just use proc_mkdir(), damnit. Signed-off-by: Al Viro --- drivers/staging/dgrp/dgrp_specproc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/dgrp/dgrp_specproc.c b/drivers/staging/dgrp/dgrp_specproc.c index dddf8a2e396..556cb3124da 100644 --- a/drivers/staging/dgrp/dgrp_specproc.c +++ b/drivers/staging/dgrp/dgrp_specproc.c @@ -201,8 +201,7 @@ void dgrp_register_proc(void) /* * Register /proc/dgrp */ - dgrp_proc_dir_entry = proc_create("dgrp", S_IFDIR, NULL, - &dgrp_proc_file_ops); + dgrp_proc_dir_entry = proc_mkdir("dgrp", NULL); register_proc_table(dgrp_table, dgrp_proc_dir_entry); } -- cgit v1.2.3 From 878c68c6c2a28e3c3a62f723e0eaa2fd02297594 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 29 Mar 2013 20:45:38 -0400 Subject: dgrp procfs fixes, part 2 All table entries either have non-NULL ->proc_file_fops or non-NULL child. Signed-off-by: Al Viro --- drivers/staging/dgrp/dgrp_specproc.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/dgrp/dgrp_specproc.c b/drivers/staging/dgrp/dgrp_specproc.c index 556cb3124da..23b10f365bc 100644 --- a/drivers/staging/dgrp/dgrp_specproc.c +++ b/drivers/staging/dgrp/dgrp_specproc.c @@ -269,10 +269,7 @@ static void register_proc_table(struct dgrp_proc_entry *table, de->data = (void *) table; if (!table->child) { de->proc_iops = &proc_inode_ops; - if (table->proc_file_ops) - de->proc_fops = table->proc_file_ops; - else - de->proc_fops = &dgrp_proc_file_ops; + de->proc_fops = table->proc_file_ops; } } table->de = de; -- cgit v1.2.3 From 772317b53b51e5895e953828c8ff4f06fecfad1c Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 29 Mar 2013 20:49:43 -0400 Subject: dgrp procfs fixes, part 3: kill dead code Signed-off-by: Al Viro --- drivers/staging/dgrp/dgrp_specproc.c | 63 ------------------------------------ 1 file changed, 63 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/dgrp/dgrp_specproc.c b/drivers/staging/dgrp/dgrp_specproc.c index 23b10f365bc..1ccf10ce85c 100644 --- a/drivers/staging/dgrp/dgrp_specproc.c +++ b/drivers/staging/dgrp/dgrp_specproc.c @@ -55,17 +55,9 @@ static void register_dgrp_device(struct nd_struct *node, void (*register_hook)(struct proc_dir_entry *de)); /* 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 }; @@ -347,61 +339,6 @@ static void unregister_proc_table(struct dgrp_proc_entry *table, } } -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; -} - static void *dgrp_config_proc_start(struct seq_file *m, loff_t *pos) { return seq_list_start_head(&nd_struct_list, *pos); -- cgit v1.2.3 From 08f3d07ddd53ca3bf322ddebc0f8992e3112520f Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 30 Mar 2013 00:36:23 -0400 Subject: dgrp procfs fixes, part 4: get rid of sysctl-like machinery racy and very overblown... Signed-off-by: Al Viro --- drivers/staging/dgrp/dgrp_common.h | 55 -------- drivers/staging/dgrp/dgrp_specproc.c | 257 ++++++----------------------------- 2 files changed, 42 insertions(+), 270 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/dgrp/dgrp_common.h b/drivers/staging/dgrp/dgrp_common.h index fde116236e9..99e231c3c60 100644 --- a/drivers/staging/dgrp/dgrp_common.h +++ b/drivers/staging/dgrp/dgrp_common.h @@ -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 */ - umode_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); diff --git a/drivers/staging/dgrp/dgrp_specproc.c b/drivers/staging/dgrp/dgrp_specproc.c index 1ccf10ce85c..caf4faccf42 100644 --- a/drivers/staging/dgrp/dgrp_specproc.c +++ b/drivers/staging/dgrp/dgrp_specproc.c @@ -44,7 +44,6 @@ #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); @@ -63,16 +62,6 @@ static struct inode_operations proc_inode_ops = { }; -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); @@ -106,72 +95,11 @@ 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} -}; - void dgrp_unregister_proc(void) { net_entry_pointer = NULL; @@ -180,163 +108,62 @@ 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) { + if (nd->nd_net_de) { + unregister_dgrp_device(nd->nd_net_de); + dgrp_remove_node_class_sysfs_files(nd); + } + + if (nd->nd_mon_de) + unregister_dgrp_device(nd->nd_mon_de); + + if (nd->nd_dpa_de) + unregister_dgrp_device(nd->nd_dpa_de); + + if (nd->nd_ports_de) + unregister_dgrp_device(nd->nd_ports_de); + } + 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) { + struct proc_dir_entry *de; /* * Register /proc/dgrp */ dgrp_proc_dir_entry = proc_mkdir("dgrp", NULL); - 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; - umode_t mode; - - if (table == 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; - de->proc_fops = table->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; + de = create_proc_entry("dgrp/config", 0644, NULL); + if (de) { + de->proc_fops = &config_proc_file_ops; + de->proc_iops = &proc_inode_ops; } -} - -/* - * 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); + de = create_proc_entry("dgrp/info", 0644, NULL); + if (de) { + de->proc_fops = &info_proc_file_ops; + de->proc_iops = &proc_inode_ops; } - - 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; + de = create_proc_entry("dgrp/nodeinfo", 0644, NULL); + if (de) { + de->proc_fops = &nodeinfo_proc_file_ops; + de->proc_iops = &proc_inode_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) -- cgit v1.2.3 From af064cdde64d58feb315dba268e1f8439fb935be Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 30 Mar 2013 01:03:53 -0400 Subject: dgrp procfs fixes, part 5: per-node files this "hooks" scheme is pointless - just make file_operations non-static and consolidate initialiazation bits. Signed-off-by: Al Viro --- drivers/staging/dgrp/dgrp_common.h | 8 +-- drivers/staging/dgrp/dgrp_dpa_ops.c | 19 +------ drivers/staging/dgrp/dgrp_mon_ops.c | 16 +----- drivers/staging/dgrp/dgrp_net_ops.c | 19 +------ drivers/staging/dgrp/dgrp_ports_ops.c | 16 +----- drivers/staging/dgrp/dgrp_specproc.c | 96 ++++++++++++++--------------------- 6 files changed, 45 insertions(+), 129 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/dgrp/dgrp_common.h b/drivers/staging/dgrp/dgrp_common.h index 99e231c3c60..81fc9ae155a 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 */ diff --git a/drivers/staging/dgrp/dgrp_dpa_ops.c b/drivers/staging/dgrp/dgrp_dpa_ops.c index 021cca498f2..cfa8e82404f 100644 --- a/drivers/staging/dgrp/dgrp_dpa_ops.c +++ b/drivers/staging/dgrp/dgrp_dpa_ops.c @@ -52,7 +52,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 +61,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 +105,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; - 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 */ diff --git a/drivers/staging/dgrp/dgrp_mon_ops.c b/drivers/staging/dgrp/dgrp_mon_ops.c index 4792d056a36..52493b5c167 100644 --- a/drivers/staging/dgrp/dgrp_mon_ops.c +++ b/drivers/staging/dgrp/dgrp_mon_ops.c @@ -49,7 +49,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 +57,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; - 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 * diff --git a/drivers/staging/dgrp/dgrp_net_ops.c b/drivers/staging/dgrp/dgrp_net_ops.c index e6018823b9d..dc826b2cf90 100644 --- a/drivers/staging/dgrp/dgrp_net_ops.c +++ b/drivers/staging/dgrp/dgrp_net_ops.c @@ -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; - 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 diff --git a/drivers/staging/dgrp/dgrp_ports_ops.c b/drivers/staging/dgrp/dgrp_ports_ops.c index cd1fc208862..48e9079c635 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; - 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) diff --git a/drivers/staging/dgrp/dgrp_specproc.c b/drivers/staging/dgrp/dgrp_specproc.c index caf4faccf42..22c5d0bfe10 100644 --- a/drivers/staging/dgrp/dgrp_specproc.c +++ b/drivers/staging/dgrp/dgrp_specproc.c @@ -48,10 +48,9 @@ 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 parse_write_config(char *); @@ -100,6 +99,21 @@ 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 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) { net_entry_pointer = NULL; @@ -109,21 +123,8 @@ void dgrp_unregister_proc(void) if (dgrp_proc_dir_entry) { struct nd_struct *nd; - list_for_each_entry(nd, &nd_struct_list, list) { - if (nd->nd_net_de) { - unregister_dgrp_device(nd->nd_net_de); - dgrp_remove_node_class_sysfs_files(nd); - } - - if (nd->nd_mon_de) - unregister_dgrp_device(nd->nd_mon_de); - - if (nd->nd_dpa_de) - unregister_dgrp_device(nd->nd_dpa_de); - - if (nd->nd_ports_de) - unregister_dgrp_device(nd->nd_ports_de); - } + 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); @@ -494,6 +495,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]); @@ -508,12 +513,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 @@ -532,16 +537,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); @@ -553,9 +549,9 @@ 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; @@ -563,28 +559,10 @@ static void register_dgrp_device(struct nd_struct *node, 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; + if (de) { + de->data = (void *) node; + de->proc_fops = fops; + de->proc_iops = &proc_inode_ops; } - - remove_proc_entry(de->name, de->parent); - de = NULL; + return de; } -- cgit v1.2.3 From 895b5599ba20cb663af9281050dc83cd7ae91843 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 30 Mar 2013 01:07:56 -0400 Subject: dgrp procfs fixes, part 6: just use proc_create{,_data} ->permission() of its own is a rudiment of sysctl imitation; normal procfs logics will do just fine here, no need to mess with ->proc_iops at all. Signed-off-by: Al Viro --- drivers/staging/dgrp/dgrp_common.c | 31 ------------------------------- drivers/staging/dgrp/dgrp_common.h | 2 -- drivers/staging/dgrp/dgrp_specproc.c | 36 ++++-------------------------------- 3 files changed, 4 insertions(+), 65 deletions(-) (limited to 'drivers') 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 81fc9ae155a..076dd6bc5ac 100644 --- a/drivers/staging/dgrp/dgrp_common.h +++ b/drivers/staging/dgrp/dgrp_common.h @@ -89,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_specproc.c b/drivers/staging/dgrp/dgrp_specproc.c index 22c5d0bfe10..99c993b1337 100644 --- a/drivers/staging/dgrp/dgrp_specproc.c +++ b/drivers/staging/dgrp/dgrp_specproc.c @@ -55,12 +55,6 @@ static struct proc_dir_entry *add_proc_file(struct nd_struct *node, /* File operation declarations */ static int parse_write_config(char *); - -static struct inode_operations proc_inode_ops = { - .permission = dgrp_inode_permission -}; - - static ssize_t dgrp_config_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos); @@ -139,28 +133,15 @@ void dgrp_unregister_proc(void) void dgrp_register_proc(void) { - struct proc_dir_entry *de; /* * Register /proc/dgrp */ dgrp_proc_dir_entry = proc_mkdir("dgrp", NULL); if (!dgrp_proc_dir_entry) return; - de = create_proc_entry("dgrp/config", 0644, NULL); - if (de) { - de->proc_fops = &config_proc_file_ops; - de->proc_iops = &proc_inode_ops; - } - de = create_proc_entry("dgrp/info", 0644, NULL); - if (de) { - de->proc_fops = &info_proc_file_ops; - de->proc_iops = &proc_inode_ops; - } - de = create_proc_entry("dgrp/nodeinfo", 0644, NULL); - if (de) { - de->proc_fops = &nodeinfo_proc_file_ops; - de->proc_iops = &proc_inode_ops; - } + 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); @@ -554,15 +535,6 @@ static struct proc_dir_entry *add_proc_file(struct nd_struct *node, 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) { - de->data = (void *) node; - de->proc_fops = fops; - de->proc_iops = &proc_inode_ops; - } - return de; + return proc_create_data(buf, 0600, root, fops, node); } -- cgit v1.2.3 From 5a787a682047fbf5d250b0c2aed572fb6b7104d6 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 30 Mar 2013 13:13:39 -0400 Subject: rtl8192u: don't play with reassigning ->proc_fops, just use proc_create() Signed-off-by: Al Viro --- drivers/staging/rtl8192u/ieee80211/proc.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/rtl8192u/ieee80211/proc.c b/drivers/staging/rtl8192u/ieee80211/proc.c index 6eda928e409..54026a412ca 100644 --- a/drivers/staging/rtl8192u/ieee80211/proc.c +++ b/drivers/staging/rtl8192u/ieee80211/proc.c @@ -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); } -- cgit v1.2.3 From 96e7d9158f5ae91accb9c81cca14bcd0c996c0cc Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 30 Mar 2013 13:15:27 -0400 Subject: isp1362-hcd: don't reimplement proc_create_data() ... especially in a racy way Signed-off-by: Al Viro --- drivers/usb/host/isp1362-hcd.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/usb/host/isp1362-hcd.c b/drivers/usb/host/isp1362-hcd.c index 974480c516f..9137caadb1c 100644 --- a/drivers/usb/host/isp1362-hcd.c +++ b/drivers/usb/host/isp1362-hcd.c @@ -2192,14 +2192,11 @@ static void create_debug_file(struct isp1362_hcd *isp1362_hcd) { struct proc_dir_entry *pde; - pde = create_proc_entry(proc_filename, 0, NULL); + pde = proc_create_data(proc_filename, 0, NULL, &proc_ops, isp1362_hcd); if (pde == NULL) { pr_warning("%s: Failed to create debug file '%s'\n", __func__, proc_filename); return; } - - pde->proc_fops = &proc_ops; - pde->data = isp1362_hcd; isp1362_hcd->pde = pde; } -- cgit v1.2.3 From e784788ddb7000dbea8bd2986a3f83c4d77f96ff Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 30 Mar 2013 13:26:37 -0400 Subject: get rid of a bunch of open-coded create_proc_read_entry() Signed-off-by: Al Viro --- drivers/char/ds1620.c | 7 +++---- drivers/staging/comedi/proc.c | 7 ++----- 2 files changed, 5 insertions(+), 9 deletions(-) (limited to 'drivers') diff --git a/drivers/char/ds1620.c b/drivers/char/ds1620.c index 24ffd8cec51..b599fae698d 100644 --- a/drivers/char/ds1620.c +++ b/drivers/char/ds1620.c @@ -397,10 +397,9 @@ static int __init ds1620_init(void) return ret; #ifdef THERM_USE_PROC - proc_therm_ds1620 = create_proc_entry("therm", 0, NULL); - if (proc_therm_ds1620) - proc_therm_ds1620->read_proc = proc_therm_ds1620_read; - else + proc_therm_ds1620 = create_proc_read_entry("therm", 0, NULL, + proc_therm_ds1620_read, NULL); + if (!proc_therm_ds1620) printk(KERN_ERR "therm: unable to register /proc/therm\n"); #endif diff --git a/drivers/staging/comedi/proc.c b/drivers/staging/comedi/proc.c index 362c214bcc0..f01e0cccac3 100644 --- a/drivers/staging/comedi/proc.c +++ b/drivers/staging/comedi/proc.c @@ -80,11 +80,8 @@ static int comedi_read(char *buf, char **start, off_t offset, int len, void comedi_proc_init(void) { - struct proc_dir_entry *comedi_proc; - - comedi_proc = create_proc_entry("comedi", S_IFREG | S_IRUGO, NULL); - if (comedi_proc) - comedi_proc->read_proc = comedi_read; + create_proc_read_entry("comedi", S_IFREG | S_IRUGO, NULL, + comedi_read, NULL); } void comedi_proc_cleanup(void) -- cgit v1.2.3 From 7e1be8a5011d6be1d16e44b2f7ff8c610263f4b3 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 30 Mar 2013 15:41:56 -0400 Subject: silicom: helper functions are often useful... Signed-off-by: Al Viro --- drivers/staging/silicom/bp_mod.c | 323 ++++++--------------------------------- 1 file changed, 43 insertions(+), 280 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/silicom/bp_mod.c b/drivers/staging/silicom/bp_mod.c index 58c5f5cf4ce..cae901858b3 100644 --- a/drivers/staging/silicom/bp_mod.c +++ b/drivers/staging/silicom/bp_mod.c @@ -7541,22 +7541,17 @@ get_wd_set_caps_pfs(char *page, char **start, off_t off, int count, return len; } -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); @@ -7564,12 +7559,22 @@ 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; + return 1; + if (strcmp(kbuf, "off") == 0) + return 0; + return 0; +} - set_bypass_fn(pbp_device_block, bypass_param); +int +set_bypass_pfs(struct file *file, const char *buffer, + unsigned long count, void *data) +{ + bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; + int bypass_param = user_on_off(buffer, count); + if (bypass_param < 0) + return -1; + set_bypass_fn(pbp_device_block, bypass_param); return count; } @@ -7578,30 +7583,12 @@ 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)) + int tap_param = user_on_off(buffer, count); + if (tap_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); - return count; } @@ -7610,30 +7597,12 @@ 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)) + int tap_param = user_on_off(buffer, count); + if (tap_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_disc_fn(pbp_device_block, tap_param); - return count; } @@ -7914,30 +7883,12 @@ 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 (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); - return count; } @@ -7946,30 +7897,12 @@ 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 (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_tap_fn(pbp_device_block, tap_param); - return count; } @@ -7978,30 +7911,12 @@ 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 (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); - return count; } @@ -8069,31 +7984,12 @@ 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)) + 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_pwup_fn(pbp_device_block, bypass_param); - return count; } @@ -8101,31 +7997,12 @@ 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 (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); - return count; } @@ -8133,31 +8010,12 @@ 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 (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_tap_pwup_fn(pbp_device_block, tap_param); - return count; } @@ -8165,31 +8023,12 @@ 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 (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_disc_pwup_fn(pbp_device_block, tap_param); - return count; } @@ -8277,31 +8116,12 @@ 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 (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); - return count; } @@ -8420,31 +8240,12 @@ 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)) { + int tpl_param = user_on_off(buffer, count); + if (tpl_param < 0) 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; } @@ -8453,31 +8254,12 @@ 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)) { + int tpl_param = user_on_off(buffer, count); + if (tpl_param < 0) 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; } @@ -8485,31 +8267,12 @@ 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)) { + int tpl_param = user_on_off(buffer, count); + if (tpl_param < 0) 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; } -- cgit v1.2.3 From fb8004d39bebfcc8b6b0a4263c712cee5b0f2a54 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 30 Mar 2013 16:07:02 -0400 Subject: silicom: unobfuscate get_{status,master}_port_fn() Signed-off-by: Al Viro --- drivers/staging/silicom/bp_mod.c | 67 ++++++++++++---------------------------- 1 file changed, 19 insertions(+), 48 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/silicom/bp_mod.c b/drivers/staging/silicom/bp_mod.c index cae901858b3..5392df316fb 100644 --- a/drivers/staging/silicom/bp_mod.c +++ b/drivers/staging/silicom/bp_mod.c @@ -1728,62 +1728,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; } -- cgit v1.2.3 From f1b68d4ba40ab327a2aeec1e1fd667d9b9f5d777 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 30 Mar 2013 16:44:11 -0400 Subject: silicom: get_bypass_slave_pfs() open-codes lookup_port() Signed-off-by: Al Viro --- drivers/staging/silicom/bp_mod.c | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/silicom/bp_mod.c b/drivers/staging/silicom/bp_mod.c index 5392df316fb..2c7334162c4 100644 --- a/drivers/staging/silicom/bp_mod.c +++ b/drivers/staging/silicom/bp_mod.c @@ -7436,33 +7436,10 @@ get_bypass_slave_pfs(char *page, char **start, off_t off, int count, bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; int len = 0; - bpctl_dev_t *pbp_device_block_slave = NULL; - int idx_dev = 0; + bpctl_dev_t *pbp_device_block_slave = get_status_port_fn(pbp_device_block); 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 + if (!pbp_device_block_slave) pbp_device_block_slave = pbp_device_block; if (!pbp_device_block_slave) { len = sprintf(page, "fail\n"); -- cgit v1.2.3 From bdcecec3242368688c44eebb6c7f5fd460990c40 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 30 Mar 2013 17:20:54 -0400 Subject: silicom: untangle module_init Helper functions are often useful. So are local variables... Signed-off-by: Al Viro --- drivers/staging/silicom/bp_mod.c | 325 ++++++++++++++++----------------------- 1 file changed, 133 insertions(+), 192 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/silicom/bp_mod.c b/drivers/staging/silicom/bp_mod.c index 2c7334162c4..e737939e4c4 100644 --- a/drivers/staging/silicom/bp_mod.c +++ b/drivers/staging/silicom/bp_mod.c @@ -6657,6 +6657,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 */ @@ -6665,7 +6777,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); @@ -6700,181 +6812,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(); @@ -6884,33 +6831,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); } -- cgit v1.2.3 From a01b0c576db9129f4a21c5e0a8815fc95468d169 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 30 Mar 2013 19:11:39 -0400 Subject: silicom: switch to create_proc_data(), clean procfs side of things up Signed-off-by: Al Viro --- drivers/staging/silicom/bp_mod.c | 1199 ++++++++++++-------------------------- 1 file changed, 379 insertions(+), 820 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/silicom/bp_mod.c b/drivers/staging/silicom/bp_mod.c index e737939e4c4..f64ee07c15a 100644 --- a/drivers/staging/silicom/bp_mod.c +++ b/drivers/staging/silicom/bp_mod.c @@ -60,35 +60,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 { @@ -7250,78 +7224,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", @@ -7331,104 +7238,87 @@ 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(inode)->data);\ +} \ +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(inode)->data);\ +} \ +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 = get_status_port_fn(pbp_device_block); - struct net_device *net_slave_dev = NULL; - - if (!pbp_device_block_slave) - 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) static int user_on_off(const void __user *buffer, size_t count) { @@ -7454,625 +7344,461 @@ static int user_on_off(const void __user *buffer, size_t count) return 0; } -int -set_bypass_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) { - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; int bypass_param = user_on_off(buffer, count); if (bypass_param < 0) return -1; - set_bypass_fn(pbp_device_block, bypass_param); + set_bypass_fn(PDE(file_inode(file))->data, bypass_param); return count; } - -int -set_tap_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 *pbp_device_block = (bpctl_dev_t *) data; - int tap_param = user_on_off(buffer, count); - if (tap_param < 0) - return -1; - - set_tap_fn(pbp_device_block, tap_param); - return count; + 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) -int -set_disc_pfs(struct file *file, const char *buffer, - unsigned long count, void *data) +static ssize_t tap_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 tap_param = user_on_off(buffer, count); if (tap_param < 0) return -1; - set_disc_fn(pbp_device_block, tap_param); + set_tap_fn(PDE(file_inode(file))->data, 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(file_inode(file))->data, 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(file_inode(file))->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_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; - - int len = 0, ret = 0, timeout = 0; + bpctl_dev_t *dev = m->private; + int 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(file_inode(file))->data; + 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(file_inode(file))->data; + 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(file_inode(file))->data; + 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) { - - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; int bypass_param = user_on_off(buffer, count); if (bypass_param < 0) return -EINVAL; - set_dis_bypass_fn(pbp_device_block, bypass_param); + set_dis_bypass_fn(PDE(file_inode(file))->data, 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) { - - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - int tap_param = user_on_off(buffer, count); - if (tap_param < 0) - return -EINVAL; - - 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) { - - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; int tap_param = user_on_off(buffer, count); if (tap_param < 0) return -EINVAL; - set_dis_disc_fn(pbp_device_block, tap_param); + set_dis_tap_fn(PDE(file_inode(file))->data, 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(file_inode(file))->data, 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; + seq_printf(m, "on\n"); + return 0; } +RW_FOPS(dis_disc) -int -set_bypass_pwup_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) { - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; int bypass_param = user_on_off(buffer, count); if (bypass_param < 0) return -EINVAL; - set_bypass_pwup_fn(pbp_device_block, bypass_param); + set_bypass_pwup_fn(PDE(file_inode(file))->data, bypass_param); return count; } +static int show_bypass_pwup(struct seq_file *m, void *v) +{ + 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_bypass_pwoff_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) { - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; int bypass_param = user_on_off(buffer, count); if (bypass_param < 0) return -EINVAL; - set_bypass_pwoff_fn(pbp_device_block, bypass_param); + set_bypass_pwoff_fn(PDE(file_inode(file))->data, bypass_param); return count; } - -int -set_tap_pwup_pfs(struct file *file, const char *buffer, - unsigned long count, void *data) +static int show_bypass_pwoff(struct seq_file *m, void *v) { - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - int tap_param = user_on_off(buffer, count); - if (tap_param < 0) - return -EINVAL; - - set_tap_pwup_fn(pbp_device_block, tap_param); - return count; + bpctl_dev_t *dev = m->private; + int ret = get_bypass_pwoff_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_pwoff) -int -set_disc_pwup_pfs(struct file *file, const char *buffer, - unsigned long count, 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 tap_param = user_on_off(buffer, count); if (tap_param < 0) return -EINVAL; - set_disc_pwup_fn(pbp_device_block, tap_param); + set_tap_pwup_fn(PDE(file_inode(file))->data, tap_param); return count; } - -int -get_bypass_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_bypass_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; -} - -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; + seq_printf(m, "on\n"); + return 0; } +RW_FOPS(tap_pwup) -int -get_tap_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; - - 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"); + int tap_param = user_on_off(buffer, count); + if (tap_param < 0) + return -EINVAL; - *eof = 1; - return len; + set_disc_pwup_fn(PDE(file_inode(file))->data, tap_param); + return count; } - -int -get_disc_pwup_pfs(char *page, char **start, off_t off, int count, - int *eof, void *data) +static int show_disc_pwup(struct seq_file *m, void *v) { - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - - int len = 0, ret = 0; - - ret = get_disc_pwup_fn(pbp_device_block); + 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) { - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; int bypass_param = user_on_off(buffer, count); if (bypass_param < 0) return -EINVAL; - set_std_nic_fn(pbp_device_block, bypass_param); + set_std_nic_fn(PDE(file_inode(file))->data, 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"); - 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"); + seq_printf(m, "fail\n"); else if (ret == 0) - len = sprintf(page, "bypass\n"); - else if (ret == 2) - len = sprintf(page, "disc\n"); - + seq_printf(m, "off\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); @@ -8086,86 +7812,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(file_inode(file))->data, 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); - + set_wd_autoreset_fn(PDE(file_inode(file))->data, timeout); return count; } - -int -set_tpl_pfs(struct file *file, const char *buffer, - unsigned long count, void *data) +static int show_wd_autoreset(struct seq_file *m, void *v) { - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - int tpl_param = user_on_off(buffer, count); - if (tpl_param < 0) - return -1; - - 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) -{ - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - int tpl_param = user_on_off(buffer, count); - if (tpl_param < 0) - return -1; - - 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) -{ - bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data; - int tpl_param = user_on_off(buffer, count); - if (tpl_param < 0) - return -1; - - 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) { @@ -8182,168 +7869,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"); @@ -8354,21 +7927,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; } -- cgit v1.2.3 From 685e55eb5192ac05085a8e486fcfa5849a0dd60c Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 5 Apr 2013 13:42:42 -0400 Subject: silicom: bury bp_proc.c It's a seriously rotten copy of parts of bp_mod.c; had been ifdefed out all along, lacks a bunch of declarations that would be needed if ifdef had been removed, all stuff in it is duplicated in bp_mod.c anyway... Signed-off-by: Al Viro --- drivers/staging/silicom/Makefile | 3 - drivers/staging/silicom/bp_mod.c | 7933 ----------------------------------- drivers/staging/silicom/bp_proc.c | 1327 ------ drivers/staging/silicom/bpctl_mod.c | 7933 +++++++++++++++++++++++++++++++++++ 4 files changed, 7933 insertions(+), 9263 deletions(-) delete mode 100644 drivers/staging/silicom/bp_mod.c delete mode 100644 drivers/staging/silicom/bp_proc.c create mode 100644 drivers/staging/silicom/bpctl_mod.c (limited to 'drivers') 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_mod.c b/drivers/staging/silicom/bp_mod.c deleted file mode 100644 index f64ee07c15a..00000000000 --- a/drivers/staging/silicom/bp_mod.c +++ /dev/null @@ -1,7933 +0,0 @@ -/******************************************************************************/ -/* */ -/* Bypass Control utility, Copyright (c) 2005-20011 Silicom */ -/* */ -/* 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. */ -/* Copyright(c) 2007 - 2009 Intel Corporation. All rights reserved. */ -/* */ -/* */ -/******************************************************************************/ - -#include /* We're doing kernel work */ -#include /* Specifically, a module */ -#include -#include -#include -#include -#include -#include -#include - -#include /* for get_user and put_user */ -#include -#include -#include - -#include "bp_ioctl.h" -#include "bp_mod.h" -#include "bypass.h" -#include "libbp_sd.h" - -#define SUCCESS 0 -#define BP_MOD_VER "9.0.4" -#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"); -MODULE_LICENSE("GPL"); -MODULE_DESCRIPTION(BP_MOD_DESCR); -MODULE_VERSION(BP_MOD_VER); -spinlock_t bpvm_lock; - -#define lock_bpctl() \ -if (down_interruptible(&bpctl_sema)) { \ - return -ERESTARTSYS; \ -} \ - -#define unlock_bpctl() \ - up(&bpctl_sema); - -/* Media Types */ -typedef enum { - bp_copper = 0, - bp_fiber, - bp_cx4, - bp_none, -} bp_media_type; - -struct bypass_pfs_sd { - char dir_name[32]; - struct proc_dir_entry *bypass_entry; -}; - -typedef struct _bpctl_dev { - char *name; - char *desc; - struct pci_dev *pdev; /* PCI device */ - struct net_device *ndev; /* net device */ - unsigned long mem_map; - uint8_t bus; - uint8_t slot; - uint8_t func; - u_int32_t device; - u_int32_t vendor; - u_int32_t subvendor; - u_int32_t subdevice; - int ifindex; - uint32_t bp_caps; - uint32_t bp_caps_ex; - uint8_t bp_fw_ver; - int bp_ext_ver; - int wdt_status; - unsigned long bypass_wdt_on_time; - uint32_t bypass_timer_interval; - struct timer_list bp_timer; - uint32_t reset_time; - uint8_t bp_status_un; - atomic_t wdt_busy; - bp_media_type media_type; - int bp_tpl_flag; - struct timer_list bp_tpl_timer; - spinlock_t bypass_wr_lock; - int bp_10g; - int bp_10gb; - int bp_fiber5; - int bp_10g9; - int bp_i80; - int bp_540; - int (*hard_start_xmit_save) (struct sk_buff *skb, - struct net_device *dev); - const struct net_device_ops *old_ops; - struct net_device_ops new_ops; - int bp_self_test_flag; - char *bp_tx_data; - struct bypass_pfs_sd bypass_pfs_set; - -} bpctl_dev_t; - -static bpctl_dev_t *bpctl_dev_arr; - -static struct semaphore bpctl_sema; -static int device_num = 0; - -static int get_dev_idx(int ifindex); -static bpctl_dev_t *get_master_port_fn(bpctl_dev_t *pbpctl_dev); -static int disc_status(bpctl_dev_t *pbpctl_dev); -static int bypass_status(bpctl_dev_t *pbpctl_dev); -static int wdt_timer(bpctl_dev_t *pbpctl_dev, int *time_left); -static bpctl_dev_t *get_status_port_fn(bpctl_dev_t *pbpctl_dev); -static void if_scan_init(void); - -int bypass_proc_create_dev_sd(bpctl_dev_t *pbp_device_block); -int bypass_proc_remove_dev_sd(bpctl_dev_t *pbp_device_block); -int bp_proc_create(void); - -int is_bypass_fn(bpctl_dev_t *pbpctl_dev); -int get_dev_idx_bsf(int bus, int slot, int func); - -static unsigned long str_to_hex(char *p); -static int bp_device_event(struct notifier_block *unused, - unsigned long event, void *ptr) -{ - struct net_device *dev = ptr; - static bpctl_dev_t *pbpctl_dev = NULL, *pbpctl_dev_m = NULL; - int dev_num = 0, ret = 0, ret_d = 0, time_left = 0; - /* printk("BP_PROC_SUPPORT event =%d %s %d\n", event,dev->name, dev->ifindex ); */ - /* return NOTIFY_DONE; */ - if (!dev) - return NOTIFY_DONE; - if (event == NETDEV_REGISTER) { - { - struct ethtool_drvinfo drvinfo; - char cbuf[32]; - char *buf = NULL; - char res[10]; - int i = 0, ifindex, idx_dev = 0; - int bus = 0, slot = 0, func = 0; - ifindex = dev->ifindex; - - memset(res, 0, 10); - memset(&drvinfo, 0, sizeof(struct ethtool_drvinfo)); - - if (dev->ethtool_ops && dev->ethtool_ops->get_drvinfo) { - memset(&drvinfo, 0, sizeof(drvinfo)); - dev->ethtool_ops->get_drvinfo(dev, &drvinfo); - } else - return NOTIFY_DONE; - if (!drvinfo.bus_info) - return NOTIFY_DONE; - if (!strcmp(drvinfo.bus_info, "N/A")) - return NOTIFY_DONE; - memcpy(&cbuf, drvinfo.bus_info, 32); - buf = &cbuf[0]; - - while (*buf++ != ':') ; - for (i = 0; i < 10; i++, buf++) { - if (*buf == ':') - break; - res[i] = *buf; - - } - buf++; - bus = str_to_hex(res); - memset(res, 0, 10); - - for (i = 0; i < 10; i++, buf++) { - if (*buf == '.') - break; - res[i] = *buf; - - } - buf++; - slot = str_to_hex(res); - func = str_to_hex(buf); - idx_dev = get_dev_idx_bsf(bus, slot, func); - - if (idx_dev != -1) { - - bpctl_dev_arr[idx_dev].ifindex = ifindex; - bpctl_dev_arr[idx_dev].ndev = dev; - - bypass_proc_remove_dev_sd(&bpctl_dev_arr - [idx_dev]); - bypass_proc_create_dev_sd(&bpctl_dev_arr - [idx_dev]); - - } - - } - return NOTIFY_DONE; - - } - if (event == NETDEV_UNREGISTER) { - int idx_dev = 0; - for (idx_dev = 0; - ((bpctl_dev_arr[idx_dev].pdev != NULL) - && (idx_dev < device_num)); idx_dev++) { - if (bpctl_dev_arr[idx_dev].ndev == dev) { - bypass_proc_remove_dev_sd(&bpctl_dev_arr - [idx_dev]); - bpctl_dev_arr[idx_dev].ndev = NULL; - - return NOTIFY_DONE; - - } - - } - return NOTIFY_DONE; - } - if (event == NETDEV_CHANGENAME) { - int idx_dev = 0; - for (idx_dev = 0; - ((bpctl_dev_arr[idx_dev].pdev != NULL) - && (idx_dev < device_num)); idx_dev++) { - if (bpctl_dev_arr[idx_dev].ndev == dev) { - bypass_proc_remove_dev_sd(&bpctl_dev_arr - [idx_dev]); - bypass_proc_create_dev_sd(&bpctl_dev_arr - [idx_dev]); - - return NOTIFY_DONE; - - } - - } - return NOTIFY_DONE; - - } - - switch (event) { - - case NETDEV_CHANGE:{ - if (netif_carrier_ok(dev)) - return NOTIFY_DONE; - - if (((dev_num = get_dev_idx(dev->ifindex)) == -1) || - (!(pbpctl_dev = &bpctl_dev_arr[dev_num]))) - return NOTIFY_DONE; - - if ((is_bypass_fn(pbpctl_dev)) == 1) - pbpctl_dev_m = pbpctl_dev; - else - pbpctl_dev_m = get_master_port_fn(pbpctl_dev); - if (!pbpctl_dev_m) - return NOTIFY_DONE; - ret = bypass_status(pbpctl_dev_m); - if (ret == 1) - printk("bpmod: %s is in the Bypass mode now", - dev->name); - ret_d = disc_status(pbpctl_dev_m); - if (ret_d == 1) - printk - ("bpmod: %s is in the Disconnect mode now", - dev->name); - if (ret || ret_d) { - wdt_timer(pbpctl_dev_m, &time_left); - if (time_left == -1) - printk("; WDT has expired"); - printk(".\n"); - - } - return NOTIFY_DONE; - - } - - default: - return NOTIFY_DONE; - - } - return NOTIFY_DONE; - -} - -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); - -static void write_pulse(bpctl_dev_t *pbpctl_dev, - unsigned int ctrl_ext, - unsigned char value, unsigned char len) -{ - unsigned char ctrl_val = 0; - unsigned int i = len; - unsigned int ctrl = 0; - bpctl_dev_t *pbpctl_dev_c = NULL; - - if (pbpctl_dev->bp_i80) - ctrl = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); - if (pbpctl_dev->bp_540) - ctrl = BP10G_READ_REG(pbpctl_dev, ESDP); - - if (pbpctl_dev->bp_10g9) { - if (!(pbpctl_dev_c = get_status_port_fn(pbpctl_dev))) - return; - ctrl = BP10G_READ_REG(pbpctl_dev_c, ESDP); - } - - while (i--) { - ctrl_val = (value >> i) & 0x1; - if (ctrl_val) { - if (pbpctl_dev->bp_10g9) { - - /* To start management : MCLK 1, MDIO 1, output */ - /* DATA 1 CLK 1 */ - /*BP10G_WRITE_REG(pbpctl_dev, I2CCTL, (ctrl_ext|BP10G_MCLK_DATA_OUT9|BP10G_MDIO_DATA_OUT9)); */ - BP10G_WRITE_REG(pbpctl_dev, I2CCTL, - ctrl_ext | - BP10G_MDIO_DATA_OUT9); - BP10G_WRITE_REG(pbpctl_dev_c, ESDP, - (ctrl | BP10G_MCLK_DATA_OUT9 | - BP10G_MCLK_DIR_OUT9)); - - } else if (pbpctl_dev->bp_fiber5) { - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, (ctrl_ext | - BPCTLI_CTRL_EXT_MCLK_DIR5 - | - BPCTLI_CTRL_EXT_MDIO_DIR5 - | - BPCTLI_CTRL_EXT_MDIO_DATA5 - | - BPCTLI_CTRL_EXT_MCLK_DATA5)); - - } else if (pbpctl_dev->bp_i80) { - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, (ctrl_ext | - BPCTLI_CTRL_EXT_MDIO_DIR80 - | - BPCTLI_CTRL_EXT_MDIO_DATA80)); - - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, (ctrl | - BPCTLI_CTRL_EXT_MCLK_DIR80 - | - BPCTLI_CTRL_EXT_MCLK_DATA80)); - - } else if (pbpctl_dev->bp_540) { - BP10G_WRITE_REG(pbpctl_dev, ESDP, (ctrl | - BP540_MDIO_DIR - | - BP540_MDIO_DATA - | - BP540_MCLK_DIR - | - BP540_MCLK_DATA)); - - } else if (pbpctl_dev->bp_10gb) { - BP10GB_WRITE_REG(pbpctl_dev, MISC_REG_SPIO, - (ctrl_ext | BP10GB_MDIO_SET | - BP10GB_MCLK_SET) & - ~(BP10GB_MCLK_DIR | - BP10GB_MDIO_DIR | - BP10GB_MDIO_CLR | - BP10GB_MCLK_CLR)); - - } else if (!pbpctl_dev->bp_10g) - /* To start management : MCLK 1, MDIO 1, output */ - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, - (ctrl_ext | - BPCTLI_CTRL_EXT_MCLK_DIR | - BPCTLI_CTRL_EXT_MDIO_DIR | - BPCTLI_CTRL_EXT_MDIO_DATA | - BPCTLI_CTRL_EXT_MCLK_DATA)); - else { - - /* To start management : MCLK 1, MDIO 1, output*/ - BP10G_WRITE_REG(pbpctl_dev, EODSDP, - (ctrl_ext | BP10G_MCLK_DATA_OUT - | BP10G_MDIO_DATA_OUT)); - - } - - usec_delay(PULSE_TIME); - if (pbpctl_dev->bp_10g9) { - - /*BP10G_WRITE_REG(pbpctl_dev, I2CCTL, ((ctrl_ext|BP10G_MDIO_DATA_OUT9)&~(BP10G_MCLK_DATA_OUT9))); */ - /* DATA 1 CLK 0 */ - BP10G_WRITE_REG(pbpctl_dev, I2CCTL, - ctrl_ext | - BP10G_MDIO_DATA_OUT9); - BP10G_WRITE_REG(pbpctl_dev_c, ESDP, - (ctrl | BP10G_MCLK_DIR_OUT9) & - ~BP10G_MCLK_DATA_OUT9); - - } else if (pbpctl_dev->bp_fiber5) { - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, - ((ctrl_ext | - BPCTLI_CTRL_EXT_MCLK_DIR5 | - BPCTLI_CTRL_EXT_MDIO_DIR5 | - BPCTLI_CTRL_EXT_MDIO_DATA5) - & - ~ - (BPCTLI_CTRL_EXT_MCLK_DATA5))); - - } else if (pbpctl_dev->bp_i80) { - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, (ctrl_ext | - BPCTLI_CTRL_EXT_MDIO_DIR80 - | - BPCTLI_CTRL_EXT_MDIO_DATA80)); - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, - ((ctrl | - BPCTLI_CTRL_EXT_MCLK_DIR80) - & - ~ - (BPCTLI_CTRL_EXT_MCLK_DATA80))); - - } else if (pbpctl_dev->bp_540) { - BP10G_WRITE_REG(pbpctl_dev, ESDP, - (ctrl | BP540_MDIO_DIR | - BP540_MDIO_DATA | - BP540_MCLK_DIR) & - ~(BP540_MCLK_DATA)); - - } else if (pbpctl_dev->bp_10gb) { - - BP10GB_WRITE_REG(pbpctl_dev, MISC_REG_SPIO, - (ctrl_ext | BP10GB_MDIO_SET | - BP10GB_MCLK_CLR) & - ~(BP10GB_MCLK_DIR | - BP10GB_MDIO_DIR | - BP10GB_MDIO_CLR | - BP10GB_MCLK_SET)); - - } else if (!pbpctl_dev->bp_10g) - - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, - ((ctrl_ext | - BPCTLI_CTRL_EXT_MCLK_DIR | - BPCTLI_CTRL_EXT_MDIO_DIR | - BPCTLI_CTRL_EXT_MDIO_DATA) - & - ~ - (BPCTLI_CTRL_EXT_MCLK_DATA))); - else { - - BP10G_WRITE_REG(pbpctl_dev, EODSDP, - ((ctrl_ext | - BP10G_MDIO_DATA_OUT) & - ~(BP10G_MCLK_DATA_OUT))); - } - - usec_delay(PULSE_TIME); - - } else { - if (pbpctl_dev->bp_10g9) { - /* DATA 0 CLK 1 */ - /*BP10G_WRITE_REG(pbpctl_dev, I2CCTL, ((ctrl_ext|BP10G_MCLK_DATA_OUT9)&~BP10G_MDIO_DATA_OUT9)); */ - BP10G_WRITE_REG(pbpctl_dev, I2CCTL, - (ctrl_ext & - ~BP10G_MDIO_DATA_OUT9)); - BP10G_WRITE_REG(pbpctl_dev_c, ESDP, - (ctrl | BP10G_MCLK_DATA_OUT9 | - BP10G_MCLK_DIR_OUT9)); - - } else if (pbpctl_dev->bp_fiber5) { - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, - ((ctrl_ext | - BPCTLI_CTRL_EXT_MCLK_DIR5 | - BPCTLI_CTRL_EXT_MDIO_DIR5 | - BPCTLI_CTRL_EXT_MCLK_DATA5) - & - ~ - (BPCTLI_CTRL_EXT_MDIO_DATA5))); - - } else if (pbpctl_dev->bp_i80) { - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, - ((ctrl_ext | - BPCTLI_CTRL_EXT_MDIO_DIR80) - & - ~ - (BPCTLI_CTRL_EXT_MDIO_DATA80))); - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, - (ctrl | - BPCTLI_CTRL_EXT_MCLK_DIR80 | - BPCTLI_CTRL_EXT_MCLK_DATA80)); - - } else if (pbpctl_dev->bp_540) { - BP10G_WRITE_REG(pbpctl_dev, ESDP, - ((ctrl | BP540_MCLK_DIR | - BP540_MCLK_DATA | - BP540_MDIO_DIR) & - ~(BP540_MDIO_DATA))); - - } else if (pbpctl_dev->bp_10gb) { - BP10GB_WRITE_REG(pbpctl_dev, MISC_REG_SPIO, - (ctrl_ext | BP10GB_MDIO_CLR | - BP10GB_MCLK_SET) & - ~(BP10GB_MCLK_DIR | - BP10GB_MDIO_DIR | - BP10GB_MDIO_SET | - BP10GB_MCLK_CLR)); - - } else if (!pbpctl_dev->bp_10g) - - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, - ((ctrl_ext | - BPCTLI_CTRL_EXT_MCLK_DIR | - BPCTLI_CTRL_EXT_MDIO_DIR | - BPCTLI_CTRL_EXT_MCLK_DATA) - & - ~ - (BPCTLI_CTRL_EXT_MDIO_DATA))); - else { - - BP10G_WRITE_REG(pbpctl_dev, EODSDP, - ((ctrl_ext | - BP10G_MCLK_DATA_OUT) & - ~BP10G_MDIO_DATA_OUT)); - - } - usec_delay(PULSE_TIME); - if (pbpctl_dev->bp_10g9) { - /* DATA 0 CLK 0 */ - /*BP10G_WRITE_REG(pbpctl_dev, I2CCTL, (ctrl_ext&~(BP10G_MCLK_DATA_OUT9|BP10G_MDIO_DATA_OUT9))); */ - BP10G_WRITE_REG(pbpctl_dev, I2CCTL, - (ctrl_ext & - ~BP10G_MDIO_DATA_OUT9)); - BP10G_WRITE_REG(pbpctl_dev_c, ESDP, - ((ctrl | BP10G_MCLK_DIR_OUT9) & - ~(BP10G_MCLK_DATA_OUT9))); - - } else if (pbpctl_dev->bp_fiber5) { - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, - ((ctrl_ext | - BPCTLI_CTRL_EXT_MCLK_DIR5 | - BPCTLI_CTRL_EXT_MDIO_DIR5) - & - ~(BPCTLI_CTRL_EXT_MCLK_DATA5 - | - BPCTLI_CTRL_EXT_MDIO_DATA5))); - - } else if (pbpctl_dev->bp_i80) { - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, - ((ctrl_ext | - BPCTLI_CTRL_EXT_MDIO_DIR80) - & - ~BPCTLI_CTRL_EXT_MDIO_DATA80)); - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, - ((ctrl | - BPCTLI_CTRL_EXT_MCLK_DIR80) - & - ~ - (BPCTLI_CTRL_EXT_MCLK_DATA80))); - - } else if (pbpctl_dev->bp_540) { - BP10G_WRITE_REG(pbpctl_dev, ESDP, - ((ctrl | BP540_MCLK_DIR | - BP540_MDIO_DIR) & - ~(BP540_MDIO_DATA | - BP540_MCLK_DATA))); - } else if (pbpctl_dev->bp_10gb) { - - BP10GB_WRITE_REG(pbpctl_dev, MISC_REG_SPIO, - (ctrl_ext | BP10GB_MDIO_CLR | - BP10GB_MCLK_CLR) & - ~(BP10GB_MCLK_DIR | - BP10GB_MDIO_DIR | - BP10GB_MDIO_SET | - BP10GB_MCLK_SET)); - - } else if (!pbpctl_dev->bp_10g) - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, - ((ctrl_ext | - BPCTLI_CTRL_EXT_MCLK_DIR | - BPCTLI_CTRL_EXT_MDIO_DIR) & - ~(BPCTLI_CTRL_EXT_MCLK_DATA - | - BPCTLI_CTRL_EXT_MDIO_DATA))); - else { - - BP10G_WRITE_REG(pbpctl_dev, EODSDP, - (ctrl_ext & - ~(BP10G_MCLK_DATA_OUT | - BP10G_MDIO_DATA_OUT))); - } - - usec_delay(PULSE_TIME); - } - - } -} - -static int read_pulse(bpctl_dev_t *pbpctl_dev, unsigned int ctrl_ext, - unsigned char len) -{ - unsigned char ctrl_val = 0; - unsigned int i = len; - unsigned int ctrl = 0; - bpctl_dev_t *pbpctl_dev_c = NULL; - - if (pbpctl_dev->bp_i80) - ctrl = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); - if (pbpctl_dev->bp_540) - ctrl = BP10G_READ_REG(pbpctl_dev, ESDP); - if (pbpctl_dev->bp_10g9) { - if (!(pbpctl_dev_c = get_status_port_fn(pbpctl_dev))) - return -1; - ctrl = BP10G_READ_REG(pbpctl_dev_c, ESDP); - } - - - while (i--) { - if (pbpctl_dev->bp_10g9) { - /*BP10G_WRITE_REG(pbpctl_dev, I2CCTL, ((ctrl_ext|BP10G_MDIO_DATA_OUT9)&~BP10G_MCLK_DATA_OUT9)); */ - /* DATA ? CLK 0 */ - BP10G_WRITE_REG(pbpctl_dev_c, ESDP, - ((ctrl | BP10G_MCLK_DIR_OUT9) & - ~(BP10G_MCLK_DATA_OUT9))); - - } else if (pbpctl_dev->bp_fiber5) { - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, ((ctrl_ext | - BPCTLI_CTRL_EXT_MCLK_DIR5) - & - ~ - (BPCTLI_CTRL_EXT_MDIO_DIR5 - | - BPCTLI_CTRL_EXT_MCLK_DATA5))); - - } else if (pbpctl_dev->bp_i80) { - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, - (ctrl_ext & - ~BPCTLI_CTRL_EXT_MDIO_DIR80)); - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, - ((ctrl | BPCTLI_CTRL_EXT_MCLK_DIR80) - & ~(BPCTLI_CTRL_EXT_MCLK_DATA80))); - - } else if (pbpctl_dev->bp_540) { - BP10G_WRITE_REG(pbpctl_dev, ESDP, - ((ctrl | BP540_MCLK_DIR) & - ~(BP540_MDIO_DIR | BP540_MCLK_DATA))); - - } else if (pbpctl_dev->bp_10gb) { - - BP10GB_WRITE_REG(pbpctl_dev, MISC_REG_SPIO, - (ctrl_ext | BP10GB_MDIO_DIR | - BP10GB_MCLK_CLR) & ~(BP10GB_MCLK_DIR | - BP10GB_MDIO_CLR | - BP10GB_MDIO_SET | - BP10GB_MCLK_SET)); - - } else if (!pbpctl_dev->bp_10g) - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ((ctrl_ext | - BPCTLI_CTRL_EXT_MCLK_DIR) - & - ~ - (BPCTLI_CTRL_EXT_MDIO_DIR - | - BPCTLI_CTRL_EXT_MCLK_DATA))); - else { - - BP10G_WRITE_REG(pbpctl_dev, EODSDP, ((ctrl_ext | BP10G_MDIO_DATA_OUT) & ~BP10G_MCLK_DATA_OUT)); /* ? */ - /* printk("0x28=0x%x\n",BP10G_READ_REG(pbpctl_dev,EODSDP);); */ - - } - - usec_delay(PULSE_TIME); - if (pbpctl_dev->bp_10g9) { - /*BP10G_WRITE_REG(pbpctl_dev, I2CCTL, (ctrl_ext|BP10G_MCLK_DATA_OUT9|BP10G_MDIO_DATA_OUT9)); */ - /* DATA ? CLK 1 */ - BP10G_WRITE_REG(pbpctl_dev_c, ESDP, - (ctrl | BP10G_MCLK_DATA_OUT9 | - BP10G_MCLK_DIR_OUT9)); - - } else if (pbpctl_dev->bp_fiber5) { - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, ((ctrl_ext | - BPCTLI_CTRL_EXT_MCLK_DIR5 - | - BPCTLI_CTRL_EXT_MCLK_DATA5) - & - ~ - (BPCTLI_CTRL_EXT_MDIO_DIR5))); - - } else if (pbpctl_dev->bp_i80) { - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, - (ctrl_ext & - ~(BPCTLI_CTRL_EXT_MDIO_DIR80))); - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, - (ctrl | BPCTLI_CTRL_EXT_MCLK_DIR80 | - BPCTLI_CTRL_EXT_MCLK_DATA80)); - - } else if (pbpctl_dev->bp_540) { - BP10G_WRITE_REG(pbpctl_dev, ESDP, - ((ctrl | BP540_MCLK_DIR | - BP540_MCLK_DATA) & - ~(BP540_MDIO_DIR))); - - } else if (pbpctl_dev->bp_10gb) { - BP10GB_WRITE_REG(pbpctl_dev, MISC_REG_SPIO, - (ctrl_ext | BP10GB_MDIO_DIR | - BP10GB_MCLK_SET) & ~(BP10GB_MCLK_DIR | - BP10GB_MDIO_CLR | - BP10GB_MDIO_SET | - BP10GB_MCLK_CLR)); - - } else if (!pbpctl_dev->bp_10g) - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ((ctrl_ext | - BPCTLI_CTRL_EXT_MCLK_DIR - | - BPCTLI_CTRL_EXT_MCLK_DATA) - & - ~ - (BPCTLI_CTRL_EXT_MDIO_DIR))); - else { - - BP10G_WRITE_REG(pbpctl_dev, EODSDP, - (ctrl_ext | BP10G_MCLK_DATA_OUT | - BP10G_MDIO_DATA_OUT)); - - } - if (pbpctl_dev->bp_10g9) { - ctrl_ext = BP10G_READ_REG(pbpctl_dev, I2CCTL); - - } else if ((pbpctl_dev->bp_fiber5) || (pbpctl_dev->bp_i80)) { - ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL); - } else if (pbpctl_dev->bp_540) { - ctrl_ext = BP10G_READ_REG(pbpctl_dev, ESDP); - } else if (pbpctl_dev->bp_10gb) - ctrl_ext = BP10GB_READ_REG(pbpctl_dev, MISC_REG_SPIO); - - else if (!pbpctl_dev->bp_10g) - ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); - else - ctrl_ext = BP10G_READ_REG(pbpctl_dev, EODSDP); - - usec_delay(PULSE_TIME); - if (pbpctl_dev->bp_10g9) { - if (ctrl_ext & BP10G_MDIO_DATA_IN9) - ctrl_val |= 1 << i; - - } else if (pbpctl_dev->bp_fiber5) { - if (ctrl_ext & BPCTLI_CTRL_EXT_MDIO_DATA5) - ctrl_val |= 1 << i; - } else if (pbpctl_dev->bp_i80) { - if (ctrl_ext & BPCTLI_CTRL_EXT_MDIO_DATA80) - ctrl_val |= 1 << i; - } else if (pbpctl_dev->bp_540) { - if (ctrl_ext & BP540_MDIO_DATA) - ctrl_val |= 1 << i; - } else if (pbpctl_dev->bp_10gb) { - if (ctrl_ext & BP10GB_MDIO_DATA) - ctrl_val |= 1 << i; - - } else if (!pbpctl_dev->bp_10g) { - - if (ctrl_ext & BPCTLI_CTRL_EXT_MDIO_DATA) - ctrl_val |= 1 << i; - } else { - - if (ctrl_ext & BP10G_MDIO_DATA_IN) - ctrl_val |= 1 << i; - } - - } - - return ctrl_val; -} - -static void write_reg(bpctl_dev_t *pbpctl_dev, unsigned char value, - unsigned char addr) -{ - uint32_t ctrl_ext = 0, ctrl = 0; - bpctl_dev_t *pbpctl_dev_c = NULL; - unsigned long flags; - if (pbpctl_dev->bp_10g9) { - if (!(pbpctl_dev_c = get_status_port_fn(pbpctl_dev))) - return; - } - if ((pbpctl_dev->wdt_status == WDT_STATUS_EN) && - (pbpctl_dev->bp_ext_ver < PXG4BPFI_VER)) - wdt_time_left(pbpctl_dev); - -#ifdef BP_SYNC_FLAG - spin_lock_irqsave(&pbpctl_dev->bypass_wr_lock, flags); -#else - atomic_set(&pbpctl_dev->wdt_busy, 1); -#endif - if (pbpctl_dev->bp_10g9) { - - ctrl_ext = BP10G_READ_REG(pbpctl_dev, I2CCTL); - ctrl = BP10G_READ_REG(pbpctl_dev_c, ESDP); - /* DATA 0 CLK 0 */ - /* BP10G_WRITE_REG(pbpctl_dev, I2CCTL, (ctrl_ext&~(BP10G_MCLK_DATA_OUT9|BP10G_MDIO_DATA_OUT9))); */ - BP10G_WRITE_REG(pbpctl_dev, I2CCTL, - (ctrl_ext & ~BP10G_MDIO_DATA_OUT9)); - BP10G_WRITE_REG(pbpctl_dev_c, ESDP, - ((ctrl | BP10G_MCLK_DIR_OUT9) & - ~(BP10G_MCLK_DATA_OUT9))); - - } else if (pbpctl_dev->bp_fiber5) { - ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL); - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, ((ctrl_ext | - BPCTLI_CTRL_EXT_MCLK_DIR5 - | - BPCTLI_CTRL_EXT_MDIO_DIR5) - & - ~ - (BPCTLI_CTRL_EXT_MDIO_DATA5 - | - BPCTLI_CTRL_EXT_MCLK_DATA5))); - } else if (pbpctl_dev->bp_i80) { - ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL); - ctrl = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, ((ctrl_ext | - BPCTLI_CTRL_EXT_MDIO_DIR80) - & - ~BPCTLI_CTRL_EXT_MDIO_DATA80)); - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, - ((ctrl | BPCTLI_CTRL_EXT_MCLK_DIR80) & - ~BPCTLI_CTRL_EXT_MCLK_DATA80)); - - } else if (pbpctl_dev->bp_540) { - ctrl = ctrl_ext = BP10G_READ_REG(pbpctl_dev, ESDP); - BP10G_WRITE_REG(pbpctl_dev, ESDP, ((ctrl | - BP540_MDIO_DIR | - BP540_MCLK_DIR) & - ~(BP540_MDIO_DATA | - BP540_MCLK_DATA))); - - } else if (pbpctl_dev->bp_10gb) { - ctrl_ext = BP10GB_READ_REG(pbpctl_dev, MISC_REG_SPIO); - - BP10GB_WRITE_REG(pbpctl_dev, MISC_REG_SPIO, - (ctrl_ext | BP10GB_MDIO_CLR | BP10GB_MCLK_CLR) - & ~(BP10GB_MCLK_DIR | BP10GB_MDIO_DIR | - BP10GB_MDIO_SET | BP10GB_MCLK_SET)); - - } else if (!pbpctl_dev->bp_10g) { - - ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ((ctrl_ext | - BPCTLI_CTRL_EXT_MCLK_DIR - | - BPCTLI_CTRL_EXT_MDIO_DIR) - & - ~ - (BPCTLI_CTRL_EXT_MDIO_DATA - | - BPCTLI_CTRL_EXT_MCLK_DATA))); - } else { - ctrl = BP10G_READ_REG(pbpctl_dev, ESDP); - ctrl_ext = BP10G_READ_REG(pbpctl_dev, EODSDP); - BP10G_WRITE_REG(pbpctl_dev, EODSDP, - (ctrl_ext & - ~(BP10G_MCLK_DATA_OUT | BP10G_MDIO_DATA_OUT))); - } - usec_delay(CMND_INTERVAL); - - /*send sync cmd */ - write_pulse(pbpctl_dev, ctrl_ext, SYNC_CMD_VAL, SYNC_CMD_LEN); - /*send wr cmd */ - write_pulse(pbpctl_dev, ctrl_ext, WR_CMD_VAL, WR_CMD_LEN); - write_pulse(pbpctl_dev, ctrl_ext, addr, ADDR_CMD_LEN); - - /*write data */ - write_pulse(pbpctl_dev, ctrl_ext, value, WR_DATA_LEN); - if (pbpctl_dev->bp_10g9) { - /*BP10G_WRITE_REG(pbpctl_dev, I2CCTL, (ctrl_ext&~(BP10G_MCLK_DATA_OUT9|BP10G_MDIO_DATA_OUT9))); */ - /* DATA 0 CLK 0 */ - BP10G_WRITE_REG(pbpctl_dev, I2CCTL, - (ctrl_ext & ~BP10G_MDIO_DATA_OUT9)); - BP10G_WRITE_REG(pbpctl_dev_c, ESDP, - ((ctrl | BP10G_MCLK_DIR_OUT9) & - ~(BP10G_MCLK_DATA_OUT9))); - - } else if (pbpctl_dev->bp_fiber5) { - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, ((ctrl_ext | - BPCTLI_CTRL_EXT_MCLK_DIR5 - | - BPCTLI_CTRL_EXT_MDIO_DIR5) - & - ~ - (BPCTLI_CTRL_EXT_MDIO_DATA5 - | - BPCTLI_CTRL_EXT_MCLK_DATA5))); - } else if (pbpctl_dev->bp_i80) { - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, ((ctrl_ext | - BPCTLI_CTRL_EXT_MDIO_DIR80) - & - ~BPCTLI_CTRL_EXT_MDIO_DATA80)); - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, - ((ctrl | BPCTLI_CTRL_EXT_MCLK_DIR80) & - ~BPCTLI_CTRL_EXT_MCLK_DATA80)); - } else if (pbpctl_dev->bp_540) { - BP10G_WRITE_REG(pbpctl_dev, ESDP, ((ctrl | - BP540_MDIO_DIR | - BP540_MCLK_DIR) & - ~(BP540_MDIO_DATA | - BP540_MCLK_DATA))); - } else if (pbpctl_dev->bp_10gb) { - BP10GB_WRITE_REG(pbpctl_dev, MISC_REG_SPIO, - (ctrl_ext | BP10GB_MDIO_CLR | BP10GB_MCLK_CLR) - & ~(BP10GB_MCLK_DIR | BP10GB_MDIO_DIR | - BP10GB_MDIO_SET | BP10GB_MCLK_SET)); - - } else if (!pbpctl_dev->bp_10g) - - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ((ctrl_ext | - BPCTLI_CTRL_EXT_MCLK_DIR - | - BPCTLI_CTRL_EXT_MDIO_DIR) - & - ~ - (BPCTLI_CTRL_EXT_MDIO_DATA - | - BPCTLI_CTRL_EXT_MCLK_DATA))); - else { - BP10G_WRITE_REG(pbpctl_dev, EODSDP, - (ctrl_ext & - ~(BP10G_MCLK_DATA_OUT | BP10G_MDIO_DATA_OUT))); - - } - - usec_delay(CMND_INTERVAL * 4); - - if ((pbpctl_dev->wdt_status == WDT_STATUS_EN) && - (pbpctl_dev->bp_ext_ver < PXG4BPFI_VER) && (addr == CMND_REG_ADDR)) - pbpctl_dev->bypass_wdt_on_time = jiffies; -#ifdef BP_SYNC_FLAG - spin_unlock_irqrestore(&pbpctl_dev->bypass_wr_lock, flags); -#else - atomic_set(&pbpctl_dev->wdt_busy, 0); -#endif - -} - -static void write_data(bpctl_dev_t *pbpctl_dev, unsigned char value) -{ - write_reg(pbpctl_dev, value, CMND_REG_ADDR); -} - -static int read_reg(bpctl_dev_t *pbpctl_dev, unsigned char addr) -{ - uint32_t ctrl_ext = 0, ctrl = 0, ctrl_value = 0; - bpctl_dev_t *pbpctl_dev_c = NULL; - -#ifdef BP_SYNC_FLAG - unsigned long flags; - spin_lock_irqsave(&pbpctl_dev->bypass_wr_lock, flags); -#else - atomic_set(&pbpctl_dev->wdt_busy, 1); -#endif - if (pbpctl_dev->bp_10g9) { - if (!(pbpctl_dev_c = get_status_port_fn(pbpctl_dev))) - return -1; - } - - if (pbpctl_dev->bp_10g9) { - ctrl_ext = BP10G_READ_REG(pbpctl_dev, I2CCTL); - ctrl = BP10G_READ_REG(pbpctl_dev_c, ESDP); - - /* BP10G_WRITE_REG(pbpctl_dev, I2CCTL, (ctrl_ext&~(BP10G_MCLK_DATA_OUT9|BP10G_MDIO_DATA_OUT9))); */ - /* DATA 0 CLK 0 */ - BP10G_WRITE_REG(pbpctl_dev, I2CCTL, - (ctrl_ext & ~BP10G_MDIO_DATA_OUT9)); - BP10G_WRITE_REG(pbpctl_dev_c, ESDP, - ((ctrl | BP10G_MCLK_DIR_OUT9) & - ~(BP10G_MCLK_DATA_OUT9))); - - } else if (pbpctl_dev->bp_fiber5) { - ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL); - - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, ((ctrl_ext | - BPCTLI_CTRL_EXT_MCLK_DIR5 - | - BPCTLI_CTRL_EXT_MDIO_DIR5) - & - ~ - (BPCTLI_CTRL_EXT_MDIO_DATA5 - | - BPCTLI_CTRL_EXT_MCLK_DATA5))); - } else if (pbpctl_dev->bp_i80) { - ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL); - ctrl = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); - - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, ((ctrl_ext | - BPCTLI_CTRL_EXT_MDIO_DIR80) - & - ~BPCTLI_CTRL_EXT_MDIO_DATA80)); - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, - ((ctrl | BPCTLI_CTRL_EXT_MCLK_DIR80) & - ~BPCTLI_CTRL_EXT_MCLK_DATA80)); - } else if (pbpctl_dev->bp_540) { - ctrl_ext = BP10G_READ_REG(pbpctl_dev, ESDP); - ctrl = BP10G_READ_REG(pbpctl_dev, ESDP); - - BP10G_WRITE_REG(pbpctl_dev, ESDP, ((ctrl | BP540_MCLK_DIR | - BP540_MDIO_DIR) & - ~(BP540_MDIO_DATA | - BP540_MCLK_DATA))); - } else if (pbpctl_dev->bp_10gb) { - ctrl_ext = BP10GB_READ_REG(pbpctl_dev, MISC_REG_SPIO); - - BP10GB_WRITE_REG(pbpctl_dev, MISC_REG_SPIO, - (ctrl_ext | BP10GB_MDIO_CLR | BP10GB_MCLK_CLR) - & ~(BP10GB_MCLK_DIR | BP10GB_MDIO_DIR | - BP10GB_MDIO_SET | BP10GB_MCLK_SET)); -#if 0 - - /*BP10GB_WRITE_REG(pbpctl_dev, MISC_REG_SPIO, (ctrl_ext | BP10GB_MCLK_DIR | BP10GB_MDIO_DIR| - BP10GB_MCLK_CLR|BP10GB_MDIO_CLR)); - ctrl_ext = BP10GB_READ_REG(pbpctl_dev, MISC_REG_SPIO); - printk("1reg=%x\n", ctrl_ext); */ - - BP10GB_WRITE_REG(pbpctl_dev, MISC_REG_SPIO, ((ctrl_ext | - BP10GB_MCLK_SET | - BP10GB_MDIO_CLR)) - & ~(BP10GB_MCLK_CLR | BP10GB_MDIO_SET | - BP10GB_MCLK_DIR | BP10GB_MDIO_DIR)); - - /* bnx2x_set_spio(pbpctl_dev, 5, MISC_REGISTERS_SPIO_OUTPUT_LOW); - bnx2x_set_spio(pbpctl_dev, 4, MISC_REGISTERS_SPIO_OUTPUT_LOW); - bnx2x_set_spio(pbpctl_dev, 4, MISC_REGISTERS_SPIO_INPUT_HI_Z); */ - - ctrl_ext = BP10GB_READ_REG(pbpctl_dev, MISC_REG_SPIO); - - printk("2reg=%x\n", ctrl_ext); - -#ifdef BP_SYNC_FLAG - spin_unlock_irqrestore(&pbpctl_dev->bypass_wr_lock, flags); -#else - atomic_set(&pbpctl_dev->wdt_busy, 0); -#endif - - return 0; - -#endif - - } else if (!pbpctl_dev->bp_10g) { - - ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); - - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ((ctrl_ext | - BPCTLI_CTRL_EXT_MCLK_DIR - | - BPCTLI_CTRL_EXT_MDIO_DIR) - & - ~ - (BPCTLI_CTRL_EXT_MDIO_DATA - | - BPCTLI_CTRL_EXT_MCLK_DATA))); - } else { - - ctrl = BP10G_READ_REG(pbpctl_dev, ESDP); - ctrl_ext = BP10G_READ_REG(pbpctl_dev, EODSDP); - BP10G_WRITE_REG(pbpctl_dev, EODSDP, - (ctrl_ext & - ~(BP10G_MCLK_DATA_OUT | BP10G_MDIO_DATA_OUT))); - - } - - usec_delay(CMND_INTERVAL); - - /*send sync cmd */ - write_pulse(pbpctl_dev, ctrl_ext, SYNC_CMD_VAL, SYNC_CMD_LEN); - /*send rd cmd */ - write_pulse(pbpctl_dev, ctrl_ext, RD_CMD_VAL, RD_CMD_LEN); - /*send addr */ - write_pulse(pbpctl_dev, ctrl_ext, addr, ADDR_CMD_LEN); - /*read data */ - /* zero */ - if (pbpctl_dev->bp_10g9) { - /* DATA 0 CLK 1 */ - /*BP10G_WRITE_REG(pbpctl_dev, I2CCTL, (ctrl_ext|BP10G_MCLK_DATA_OUT9|BP10G_MDIO_DATA_OUT9)); */ - BP10G_WRITE_REG(pbpctl_dev, I2CCTL, - (ctrl_ext | BP10G_MDIO_DATA_OUT9)); - BP10G_WRITE_REG(pbpctl_dev_c, ESDP, - (ctrl | BP10G_MCLK_DATA_OUT9 | - BP10G_MCLK_DIR_OUT9)); - - } else if (pbpctl_dev->bp_fiber5) { - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, ((ctrl_ext | - BPCTLI_CTRL_EXT_MCLK_DIR5 - | - BPCTLI_CTRL_EXT_MCLK_DATA5) - & - ~ - (BPCTLI_CTRL_EXT_MDIO_DIR5 - | - BPCTLI_CTRL_EXT_MDIO_DATA5))); - - } else if (pbpctl_dev->bp_i80) { - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, - (ctrl_ext & - ~(BPCTLI_CTRL_EXT_MDIO_DATA80 | - BPCTLI_CTRL_EXT_MDIO_DIR80))); - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, - (ctrl | BPCTLI_CTRL_EXT_MCLK_DIR80 | - BPCTLI_CTRL_EXT_MCLK_DATA80)); - - } else if (pbpctl_dev->bp_540) { - BP10G_WRITE_REG(pbpctl_dev, ESDP, - (((ctrl | BP540_MDIO_DIR | BP540_MCLK_DIR | - BP540_MCLK_DATA) & ~BP540_MDIO_DATA))); - - } else if (pbpctl_dev->bp_10gb) { - - BP10GB_WRITE_REG(pbpctl_dev, MISC_REG_SPIO, - (ctrl_ext | BP10GB_MDIO_DIR | BP10GB_MCLK_SET) - & ~(BP10GB_MCLK_DIR | BP10GB_MDIO_SET | - BP10GB_MDIO_CLR | BP10GB_MCLK_CLR)); - - } else if (!pbpctl_dev->bp_10g) - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ((ctrl_ext | - BPCTLI_CTRL_EXT_MCLK_DIR - | - BPCTLI_CTRL_EXT_MCLK_DATA) - & - ~ - (BPCTLI_CTRL_EXT_MDIO_DIR - | - BPCTLI_CTRL_EXT_MDIO_DATA))); - else { - - BP10G_WRITE_REG(pbpctl_dev, EODSDP, - (ctrl_ext | BP10G_MCLK_DATA_OUT | - BP10G_MDIO_DATA_OUT)); - - - } - usec_delay(PULSE_TIME); - - ctrl_value = read_pulse(pbpctl_dev, ctrl_ext, RD_DATA_LEN); - - if (pbpctl_dev->bp_10g9) { - ctrl_ext = BP10G_READ_REG(pbpctl_dev, I2CCTL); - ctrl = BP10G_READ_REG(pbpctl_dev_c, ESDP); - - /* BP10G_WRITE_REG(pbpctl_dev, I2CCTL, (ctrl_ext&~(BP10G_MCLK_DATA_OUT9|BP10G_MDIO_DATA_OUT9))); */ - /* DATA 0 CLK 0 */ - BP10G_WRITE_REG(pbpctl_dev, I2CCTL, - (ctrl_ext & ~BP10G_MDIO_DATA_OUT9)); - BP10G_WRITE_REG(pbpctl_dev_c, ESDP, - ((ctrl | BP10G_MCLK_DIR_OUT9) & - ~(BP10G_MCLK_DATA_OUT9))); - - } else if (pbpctl_dev->bp_fiber5) { - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, ((ctrl_ext | - BPCTLI_CTRL_EXT_MCLK_DIR5 - | - BPCTLI_CTRL_EXT_MDIO_DIR5) - & - ~ - (BPCTLI_CTRL_EXT_MDIO_DATA5 - | - BPCTLI_CTRL_EXT_MCLK_DATA5))); - } else if (pbpctl_dev->bp_i80) { - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, ((ctrl_ext | - BPCTLI_CTRL_EXT_MDIO_DIR80) - & - ~BPCTLI_CTRL_EXT_MDIO_DATA80)); - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, - ((ctrl | BPCTLI_CTRL_EXT_MCLK_DIR80) & - ~BPCTLI_CTRL_EXT_MCLK_DATA80)); - - } else if (pbpctl_dev->bp_540) { - ctrl = BP10G_READ_REG(pbpctl_dev, ESDP); - BP10G_WRITE_REG(pbpctl_dev, ESDP, ((ctrl | BP540_MCLK_DIR | - BP540_MDIO_DIR) & - ~(BP540_MDIO_DATA | - BP540_MCLK_DATA))); - - } else if (pbpctl_dev->bp_10gb) { - ctrl_ext = BP10GB_READ_REG(pbpctl_dev, MISC_REG_SPIO); - BP10GB_WRITE_REG(pbpctl_dev, MISC_REG_SPIO, - (ctrl_ext | BP10GB_MDIO_CLR | BP10GB_MCLK_CLR) - & ~(BP10GB_MCLK_DIR | BP10GB_MDIO_DIR | - BP10GB_MDIO_SET | BP10GB_MCLK_SET)); - - } else if (!pbpctl_dev->bp_10g) { - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ((ctrl_ext | - BPCTLI_CTRL_EXT_MCLK_DIR - | - BPCTLI_CTRL_EXT_MDIO_DIR) - & - ~ - (BPCTLI_CTRL_EXT_MDIO_DATA - | - BPCTLI_CTRL_EXT_MCLK_DATA))); - } else { - - ctrl = BP10G_READ_REG(pbpctl_dev, ESDP); - ctrl_ext = BP10G_READ_REG(pbpctl_dev, EODSDP); - BP10G_WRITE_REG(pbpctl_dev, EODSDP, - (ctrl_ext & - ~(BP10G_MCLK_DATA_OUT | BP10G_MDIO_DATA_OUT))); - - } - - usec_delay(CMND_INTERVAL * 4); -#ifdef BP_SYNC_FLAG - spin_unlock_irqrestore(&pbpctl_dev->bypass_wr_lock, flags); -#else - atomic_set(&pbpctl_dev->wdt_busy, 0); -#endif - - return ctrl_value; -} - -static int wdt_pulse(bpctl_dev_t *pbpctl_dev) -{ - uint32_t ctrl_ext = 0, ctrl = 0; - bpctl_dev_t *pbpctl_dev_c = NULL; - -#ifdef BP_SYNC_FLAG - unsigned long flags; - - spin_lock_irqsave(&pbpctl_dev->bypass_wr_lock, flags); -#else - - if ((atomic_read(&pbpctl_dev->wdt_busy)) == 1) - return -1; -#endif - if (pbpctl_dev->bp_10g9) { - if (!(pbpctl_dev_c = get_status_port_fn(pbpctl_dev))) - return -1; - } - - if (pbpctl_dev->bp_10g9) { - ctrl_ext = BP10G_READ_REG(pbpctl_dev, I2CCTL); - ctrl = BP10G_READ_REG(pbpctl_dev_c, ESDP); - - /* BP10G_WRITE_REG(pbpctl_dev, I2CCTL, (ctrl_ext&~(BP10G_MCLK_DATA_OUT9|BP10G_MDIO_DATA_OUT9))); */ - /* DATA 0 CLK 0 */ - BP10G_WRITE_REG(pbpctl_dev, I2CCTL, - (ctrl_ext & ~BP10G_MDIO_DATA_OUT9)); - BP10G_WRITE_REG(pbpctl_dev_c, ESDP, - ((ctrl | BP10G_MCLK_DIR_OUT9) & - ~(BP10G_MCLK_DATA_OUT9))); - - } else if (pbpctl_dev->bp_fiber5) { - ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL); - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, ((ctrl_ext | - BPCTLI_CTRL_EXT_MCLK_DIR5 - | - BPCTLI_CTRL_EXT_MDIO_DIR5) - & - ~ - (BPCTLI_CTRL_EXT_MDIO_DATA5 - | - BPCTLI_CTRL_EXT_MCLK_DATA5))); - } else if (pbpctl_dev->bp_i80) { - ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL); - ctrl = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, ((ctrl_ext | - BPCTLI_CTRL_EXT_MDIO_DIR80) - & - ~BPCTLI_CTRL_EXT_MDIO_DATA80)); - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, - ((ctrl | BPCTLI_CTRL_EXT_MCLK_DIR80) & - ~BPCTLI_CTRL_EXT_MCLK_DATA80)); - } else if (pbpctl_dev->bp_540) { - ctrl_ext = ctrl = BP10G_READ_REG(pbpctl_dev, ESDP); - BP10G_WRITE_REG(pbpctl_dev, ESDP, ((ctrl | BP540_MCLK_DIR | - BP540_MDIO_DIR) & - ~(BP540_MDIO_DATA | - BP540_MCLK_DATA))); - } else if (pbpctl_dev->bp_10gb) { - ctrl_ext = BP10GB_READ_REG(pbpctl_dev, MISC_REG_SPIO); - BP10GB_WRITE_REG(pbpctl_dev, MISC_REG_SPIO, - (ctrl_ext | BP10GB_MDIO_CLR | BP10GB_MCLK_CLR) - & ~(BP10GB_MCLK_DIR | BP10GB_MDIO_DIR | - BP10GB_MDIO_SET | BP10GB_MCLK_SET)); - - } else if (!pbpctl_dev->bp_10g) { - - ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ((ctrl_ext | - BPCTLI_CTRL_EXT_MCLK_DIR - | - BPCTLI_CTRL_EXT_MDIO_DIR) - & - ~ - (BPCTLI_CTRL_EXT_MDIO_DATA - | - BPCTLI_CTRL_EXT_MCLK_DATA))); - } else { - - ctrl = BP10G_READ_REG(pbpctl_dev, ESDP); - ctrl_ext = BP10G_READ_REG(pbpctl_dev, EODSDP); - BP10G_WRITE_REG(pbpctl_dev, EODSDP, - (ctrl_ext & - ~(BP10G_MCLK_DATA_OUT | BP10G_MDIO_DATA_OUT))); - - } - if (pbpctl_dev->bp_10g9) { - /* BP10G_WRITE_REG(pbpctl_dev, I2CCTL, ((ctrl_ext|BP10G_MCLK_DATA_OUT9)&~BP10G_MDIO_DATA_OUT9)); */ - /* DATA 0 CLK 1 */ - BP10G_WRITE_REG(pbpctl_dev, I2CCTL, - (ctrl_ext & ~BP10G_MDIO_DATA_OUT9)); - BP10G_WRITE_REG(pbpctl_dev_c, ESDP, - (ctrl | BP10G_MCLK_DATA_OUT9 | - BP10G_MCLK_DIR_OUT9)); - - } else if (pbpctl_dev->bp_fiber5) { - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, ((ctrl_ext | - BPCTLI_CTRL_EXT_MCLK_DIR5 - | - BPCTLI_CTRL_EXT_MDIO_DIR5 - | - BPCTLI_CTRL_EXT_MCLK_DATA5) - & - ~ - (BPCTLI_CTRL_EXT_MDIO_DATA5))); - } else if (pbpctl_dev->bp_i80) { - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, ((ctrl_ext | - BPCTLI_CTRL_EXT_MDIO_DIR80) - & - ~BPCTLI_CTRL_EXT_MDIO_DATA80)); - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, - (ctrl | BPCTLI_CTRL_EXT_MCLK_DIR80 | - BPCTLI_CTRL_EXT_MCLK_DATA80)); - - } else if (pbpctl_dev->bp_540) { - BP10G_WRITE_REG(pbpctl_dev, ESDP, ((ctrl | - BP540_MDIO_DIR | - BP540_MCLK_DIR | - BP540_MCLK_DATA) & - ~BP540_MDIO_DATA)); - - } else if (pbpctl_dev->bp_10gb) { - ctrl_ext = BP10GB_READ_REG(pbpctl_dev, MISC_REG_SPIO); - - BP10GB_WRITE_REG(pbpctl_dev, MISC_REG_SPIO, - (ctrl_ext | BP10GB_MDIO_CLR | BP10GB_MCLK_SET) - & ~(BP10GB_MCLK_DIR | BP10GB_MDIO_DIR | - BP10GB_MDIO_SET | BP10GB_MCLK_CLR)); - - } else if (!pbpctl_dev->bp_10g) - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ((ctrl_ext | - BPCTLI_CTRL_EXT_MCLK_DIR - | - BPCTLI_CTRL_EXT_MDIO_DIR - | - BPCTLI_CTRL_EXT_MCLK_DATA) - & - ~ - (BPCTLI_CTRL_EXT_MDIO_DATA))); - else { - - BP10G_WRITE_REG(pbpctl_dev, EODSDP, - ((ctrl_ext | BP10G_MCLK_DATA_OUT) & - ~BP10G_MDIO_DATA_OUT)); - - } - - usec_delay(WDT_INTERVAL); - if (pbpctl_dev->bp_10g9) { - /* BP10G_WRITE_REG(pbpctl_dev, I2CCTL, (ctrl_ext&~(BP10G_MCLK_DATA_OUT9|BP10G_MDIO_DATA_OUT9))); */ - /* DATA 0 CLK 0 */ - BP10G_WRITE_REG(pbpctl_dev, I2CCTL, - (ctrl_ext & ~BP10G_MDIO_DATA_OUT9)); - BP10G_WRITE_REG(pbpctl_dev_c, ESDP, - ((ctrl | BP10G_MCLK_DIR_OUT9) & - ~(BP10G_MCLK_DATA_OUT9))); - - } else if (pbpctl_dev->bp_fiber5) { - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, ((ctrl_ext | - BPCTLI_CTRL_EXT_MCLK_DIR5 - | - BPCTLI_CTRL_EXT_MDIO_DIR5) - & - ~ - (BPCTLI_CTRL_EXT_MCLK_DATA5 - | - BPCTLI_CTRL_EXT_MDIO_DATA5))); - } else if (pbpctl_dev->bp_i80) { - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, ((ctrl_ext | - BPCTLI_CTRL_EXT_MDIO_DIR80) - & - ~BPCTLI_CTRL_EXT_MDIO_DATA80)); - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, - ((ctrl | BPCTLI_CTRL_EXT_MCLK_DIR80) & - ~BPCTLI_CTRL_EXT_MCLK_DATA80)); - - } else if (pbpctl_dev->bp_540) { - BP10G_WRITE_REG(pbpctl_dev, ESDP, ((ctrl | BP540_MCLK_DIR | - BP540_MDIO_DIR) & - ~(BP540_MDIO_DATA | - BP540_MCLK_DATA))); - - } else if (pbpctl_dev->bp_10gb) { - ctrl_ext = BP10GB_READ_REG(pbpctl_dev, MISC_REG_SPIO); - BP10GB_WRITE_REG(pbpctl_dev, MISC_REG_SPIO, - (ctrl_ext | BP10GB_MDIO_CLR | BP10GB_MCLK_CLR) - & ~(BP10GB_MCLK_DIR | BP10GB_MDIO_DIR | - BP10GB_MDIO_SET | BP10GB_MCLK_SET)); - - } else if (!pbpctl_dev->bp_10g) - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ((ctrl_ext | - BPCTLI_CTRL_EXT_MCLK_DIR - | - BPCTLI_CTRL_EXT_MDIO_DIR) - & - ~ - (BPCTLI_CTRL_EXT_MCLK_DATA - | - BPCTLI_CTRL_EXT_MDIO_DATA))); - else { - - BP10G_WRITE_REG(pbpctl_dev, EODSDP, - (ctrl_ext & - ~(BP10G_MCLK_DATA_OUT | BP10G_MDIO_DATA_OUT))); - } - if ((pbpctl_dev->wdt_status == WDT_STATUS_EN) /*&& - (pbpctl_dev->bp_ext_verbypass_wdt_on_time = jiffies; -#ifdef BP_SYNC_FLAG - spin_unlock_irqrestore(&pbpctl_dev->bypass_wr_lock, flags); -#endif - usec_delay(CMND_INTERVAL * 4); - return 0; -} - -static void data_pulse(bpctl_dev_t *pbpctl_dev, unsigned char value) -{ - - uint32_t ctrl_ext = 0; -#ifdef BP_SYNC_FLAG - unsigned long flags; -#endif - wdt_time_left(pbpctl_dev); -#ifdef BP_SYNC_FLAG - spin_lock_irqsave(&pbpctl_dev->bypass_wr_lock, flags); -#else - atomic_set(&pbpctl_dev->wdt_busy, 1); -#endif - - ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ((ctrl_ext | - BPCTLI_CTRL_EXT_SDP6_DIR | - BPCTLI_CTRL_EXT_SDP7_DIR) & - ~(BPCTLI_CTRL_EXT_SDP6_DATA | - BPCTLI_CTRL_EXT_SDP7_DATA))); - - usec_delay(INIT_CMND_INTERVAL); - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ((ctrl_ext | - BPCTLI_CTRL_EXT_SDP6_DIR | - BPCTLI_CTRL_EXT_SDP7_DIR | - BPCTLI_CTRL_EXT_SDP6_DATA) & - ~ - (BPCTLI_CTRL_EXT_SDP7_DATA))); - usec_delay(INIT_CMND_INTERVAL); - - while (value) { - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ctrl_ext | - BPCTLI_CTRL_EXT_SDP6_DIR | - BPCTLI_CTRL_EXT_SDP7_DIR | - BPCTLI_CTRL_EXT_SDP6_DATA | - BPCTLI_CTRL_EXT_SDP7_DATA); - usec_delay(PULSE_INTERVAL); - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ((ctrl_ext | - BPCTLI_CTRL_EXT_SDP6_DIR - | - BPCTLI_CTRL_EXT_SDP7_DIR - | - BPCTLI_CTRL_EXT_SDP6_DATA) - & - ~BPCTLI_CTRL_EXT_SDP7_DATA)); - usec_delay(PULSE_INTERVAL); - value--; - - } - usec_delay(INIT_CMND_INTERVAL - PULSE_INTERVAL); - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ((ctrl_ext | - BPCTLI_CTRL_EXT_SDP6_DIR | - BPCTLI_CTRL_EXT_SDP7_DIR) & - ~(BPCTLI_CTRL_EXT_SDP6_DATA | - BPCTLI_CTRL_EXT_SDP7_DATA))); - usec_delay(WDT_TIME_CNT); - if (pbpctl_dev->wdt_status == WDT_STATUS_EN) - pbpctl_dev->bypass_wdt_on_time = jiffies; -#ifdef BP_SYNC_FLAG - spin_unlock_irqrestore(&pbpctl_dev->bypass_wr_lock, flags); -#else - atomic_set(&pbpctl_dev->wdt_busy, 0); -#endif - -} - -static int send_wdt_pulse(bpctl_dev_t *pbpctl_dev) -{ - uint32_t ctrl_ext = 0; - -#ifdef BP_SYNC_FLAG - unsigned long flags; - - spin_lock_irqsave(&pbpctl_dev->bypass_wr_lock, flags); -#else - - if ((atomic_read(&pbpctl_dev->wdt_busy)) == 1) - return -1; -#endif - wdt_time_left(pbpctl_dev); - ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); - - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ctrl_ext | /* 1 */ - BPCTLI_CTRL_EXT_SDP7_DIR | - BPCTLI_CTRL_EXT_SDP7_DATA); - usec_delay(PULSE_INTERVAL); - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ((ctrl_ext | /* 0 */ - BPCTLI_CTRL_EXT_SDP7_DIR) & - ~BPCTLI_CTRL_EXT_SDP7_DATA)); - - usec_delay(PULSE_INTERVAL); - if (pbpctl_dev->wdt_status == WDT_STATUS_EN) - pbpctl_dev->bypass_wdt_on_time = jiffies; -#ifdef BP_SYNC_FLAG - spin_unlock_irqrestore(&pbpctl_dev->bypass_wr_lock, flags); -#endif - - return 0; -} - -void send_bypass_clear_pulse(bpctl_dev_t *pbpctl_dev, unsigned int value) -{ - uint32_t ctrl_ext = 0; - - ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ((ctrl_ext | /* 0 */ - BPCTLI_CTRL_EXT_SDP6_DIR) & - ~BPCTLI_CTRL_EXT_SDP6_DATA)); - - usec_delay(PULSE_INTERVAL); - while (value) { - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ctrl_ext | /* 1 */ - BPCTLI_CTRL_EXT_SDP6_DIR | - BPCTLI_CTRL_EXT_SDP6_DATA); - usec_delay(PULSE_INTERVAL); - value--; - } - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ((ctrl_ext | /* 0 */ - BPCTLI_CTRL_EXT_SDP6_DIR) & - ~BPCTLI_CTRL_EXT_SDP6_DATA)); - usec_delay(PULSE_INTERVAL); -} - -/* #endif OLD_FW */ -#ifdef BYPASS_DEBUG - -int pulse_set_fn(bpctl_dev_t *pbpctl_dev, unsigned int counter) -{ - uint32_t ctrl_ext = 0; - - if (!pbpctl_dev) - return -1; - - ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); - write_pulse_1(pbpctl_dev, ctrl_ext, counter, counter); - - pbpctl_dev->bypass_wdt_status = 0; - if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { - write_pulse_1(pbpctl_dev, ctrl_ext, counter, counter); - } else { - wdt_time_left(pbpctl_dev); - if (pbpctl_dev->wdt_status == WDT_STATUS_EN) { - pbpctl_dev->wdt_status = 0; - data_pulse(pbpctl_dev, counter); - pbpctl_dev->wdt_status = WDT_STATUS_EN; - pbpctl_dev->bypass_wdt_on_time = jiffies; - - } else - data_pulse(pbpctl_dev, counter); - } - - return 0; -} - -int zero_set_fn(bpctl_dev_t *pbpctl_dev) -{ - uint32_t ctrl_ext = 0, ctrl_value = 0; - if (!pbpctl_dev) - return -1; - - if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { - printk("zero_set"); - - ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); - - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ((ctrl_ext | - BPCTLI_CTRL_EXT_MCLK_DIR) - & - ~ - (BPCTLI_CTRL_EXT_MCLK_DATA - | - BPCTLI_CTRL_EXT_MDIO_DIR - | - BPCTLI_CTRL_EXT_MDIO_DATA))); - - } - return ctrl_value; -} - -int pulse_get2_fn(bpctl_dev_t *pbpctl_dev) -{ - uint32_t ctrl_ext = 0, ctrl_value = 0; - if (!pbpctl_dev) - return -1; - - if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { - printk("pulse_get_fn\n"); - ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); - ctrl_value = read_pulse_2(pbpctl_dev, ctrl_ext); - printk("read:%d\n", ctrl_value); - } - return ctrl_value; -} - -int pulse_get1_fn(bpctl_dev_t *pbpctl_dev) -{ - uint32_t ctrl_ext = 0, ctrl_value = 0; - if (!pbpctl_dev) - return -1; - - if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { - - printk("pulse_get_fn\n"); - - ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); - ctrl_value = read_pulse_1(pbpctl_dev, ctrl_ext); - printk("read:%d\n", ctrl_value); - } - return ctrl_value; -} - -int gpio6_set_fn(bpctl_dev_t *pbpctl_dev) -{ - uint32_t ctrl_ext = 0; - - ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ctrl_ext | - BPCTLI_CTRL_EXT_SDP6_DIR | - BPCTLI_CTRL_EXT_SDP6_DATA); - return 0; -} - -int gpio7_set_fn(bpctl_dev_t *pbpctl_dev) -{ - uint32_t ctrl_ext = 0; - - ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ctrl_ext | - BPCTLI_CTRL_EXT_SDP7_DIR | - BPCTLI_CTRL_EXT_SDP7_DATA); - return 0; -} - -int gpio7_clear_fn(bpctl_dev_t *pbpctl_dev) -{ - uint32_t ctrl_ext = 0; - - ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ((ctrl_ext | - BPCTLI_CTRL_EXT_SDP7_DIR) & - ~BPCTLI_CTRL_EXT_SDP7_DATA)); - return 0; -} - -int gpio6_clear_fn(bpctl_dev_t *pbpctl_dev) -{ - uint32_t ctrl_ext = 0; - - ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ((ctrl_ext | - BPCTLI_CTRL_EXT_SDP6_DIR) & - ~BPCTLI_CTRL_EXT_SDP6_DATA)); - return 0; -} -#endif /*BYPASS_DEBUG */ - -static bpctl_dev_t *lookup_port(bpctl_dev_t *dev) -{ - 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; -} - -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) -{ - if (pbpctl_dev) { - if (pbpctl_dev->func == 1 || pbpctl_dev->func == 3) - return lookup_port(pbpctl_dev); - } - return NULL; -} - -/**************************************/ -/**************INTEL API***************/ -/**************************************/ - -static void write_data_port_int(bpctl_dev_t *pbpctl_dev, - unsigned char ctrl_value) -{ - uint32_t value; - - value = BPCTL_READ_REG(pbpctl_dev, CTRL); -/* Make SDP0 Pin Directonality to Output */ - value |= BPCTLI_CTRL_SDP0_DIR; - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, value); - - value &= ~BPCTLI_CTRL_SDP0_DATA; - value |= ((ctrl_value & 0x1) << BPCTLI_CTRL_SDP0_SHIFT); - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, value); - - value = (BPCTL_READ_REG(pbpctl_dev, CTRL_EXT)); -/* Make SDP2 Pin Directonality to Output */ - value |= BPCTLI_CTRL_EXT_SDP6_DIR; - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, value); - - value &= ~BPCTLI_CTRL_EXT_SDP6_DATA; - value |= (((ctrl_value & 0x2) >> 1) << BPCTLI_CTRL_EXT_SDP6_SHIFT); - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, value); - -} - -static int write_data_int(bpctl_dev_t *pbpctl_dev, unsigned char value) -{ - bpctl_dev_t *pbpctl_dev_b = NULL; - - if (!(pbpctl_dev_b = get_status_port_fn(pbpctl_dev))) - return -1; - atomic_set(&pbpctl_dev->wdt_busy, 1); - write_data_port_int(pbpctl_dev, value & 0x3); - write_data_port_int(pbpctl_dev_b, ((value & 0xc) >> 2)); - atomic_set(&pbpctl_dev->wdt_busy, 0); - - return 0; -} - -static int wdt_pulse_int(bpctl_dev_t *pbpctl_dev) -{ - - if ((atomic_read(&pbpctl_dev->wdt_busy)) == 1) - return -1; - - if ((write_data_int(pbpctl_dev, RESET_WDT_INT)) < 0) - return -1; - msec_delay_bp(CMND_INTERVAL_INT); - if ((write_data_int(pbpctl_dev, CMND_OFF_INT)) < 0) - return -1; - msec_delay_bp(CMND_INTERVAL_INT); - - if (pbpctl_dev->wdt_status == WDT_STATUS_EN) - pbpctl_dev->bypass_wdt_on_time = jiffies; - - return 0; -} - -/*************************************/ -/************* COMMANDS **************/ -/*************************************/ - -/* CMND_ON 0x4 (100)*/ -int cmnd_on(bpctl_dev_t *pbpctl_dev) -{ - int ret = BP_NOT_CAP; - - if (pbpctl_dev->bp_caps & SW_CTL_CAP) { - if (INTEL_IF_SERIES(pbpctl_dev->subdevice)) - return 0; - if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) - write_data(pbpctl_dev, CMND_ON); - else - data_pulse(pbpctl_dev, CMND_ON); - ret = 0; - } - return ret; -} - -/* CMND_OFF 0x2 (10)*/ -int cmnd_off(bpctl_dev_t *pbpctl_dev) -{ - int ret = BP_NOT_CAP; - - if (pbpctl_dev->bp_caps & SW_CTL_CAP) { - if (INTEL_IF_SERIES(pbpctl_dev->subdevice)) { - write_data_int(pbpctl_dev, CMND_OFF_INT); - msec_delay_bp(CMND_INTERVAL_INT); - } else if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) - write_data(pbpctl_dev, CMND_OFF); - else - data_pulse(pbpctl_dev, CMND_OFF); - ret = 0; - }; - return ret; -} - -/* BYPASS_ON (0xa)*/ -int bypass_on(bpctl_dev_t *pbpctl_dev) -{ - int ret = BP_NOT_CAP; - - if (pbpctl_dev->bp_caps & BP_CAP) { - if (INTEL_IF_SERIES(pbpctl_dev->subdevice)) { - write_data_int(pbpctl_dev, BYPASS_ON_INT); - msec_delay_bp(BYPASS_DELAY_INT); - pbpctl_dev->bp_status_un = 0; - } else if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { - write_data(pbpctl_dev, BYPASS_ON); - if (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER) - msec_delay_bp(LATCH_DELAY); - } else - data_pulse(pbpctl_dev, BYPASS_ON); - ret = 0; - }; - return ret; -} - -/* BYPASS_OFF (0x8 111)*/ -int bypass_off(bpctl_dev_t *pbpctl_dev) -{ - int ret = BP_NOT_CAP; - - if (pbpctl_dev->bp_caps & BP_CAP) { - if (INTEL_IF_SERIES(pbpctl_dev->subdevice)) { - write_data_int(pbpctl_dev, DIS_BYPASS_CAP_INT); - msec_delay_bp(BYPASS_DELAY_INT); - write_data_int(pbpctl_dev, PWROFF_BYPASS_ON_INT); - msec_delay_bp(BYPASS_DELAY_INT); - pbpctl_dev->bp_status_un = 0; - } else if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { - write_data(pbpctl_dev, BYPASS_OFF); - if (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER) - msec_delay_bp(LATCH_DELAY); - } else - data_pulse(pbpctl_dev, BYPASS_OFF); - ret = 0; - } - return ret; -} - -/* TAP_OFF (0x9)*/ -int tap_off(bpctl_dev_t *pbpctl_dev) -{ - int ret = BP_NOT_CAP; - if ((pbpctl_dev->bp_caps & TAP_CAP) - && (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER)) { - write_data(pbpctl_dev, TAP_OFF); - msec_delay_bp(LATCH_DELAY); - ret = 0; - }; - return ret; -} - -/* TAP_ON (0xb)*/ -int tap_on(bpctl_dev_t *pbpctl_dev) -{ - int ret = BP_NOT_CAP; - if ((pbpctl_dev->bp_caps & TAP_CAP) - && (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER)) { - write_data(pbpctl_dev, TAP_ON); - msec_delay_bp(LATCH_DELAY); - ret = 0; - }; - return ret; -} - -/* DISC_OFF (0x9)*/ -int disc_off(bpctl_dev_t *pbpctl_dev) -{ - int ret = 0; - if ((pbpctl_dev->bp_caps & DISC_CAP) && (pbpctl_dev->bp_ext_ver >= 0x8)) { - write_data(pbpctl_dev, DISC_OFF); - msec_delay_bp(LATCH_DELAY); - } else - ret = BP_NOT_CAP; - return ret; -} - -/* DISC_ON (0xb)*/ -int disc_on(bpctl_dev_t *pbpctl_dev) -{ - int ret = 0; - if ((pbpctl_dev->bp_caps & DISC_CAP) && (pbpctl_dev->bp_ext_ver >= 0x8)) { - write_data(pbpctl_dev, /*DISC_ON */ 0x85); - msec_delay_bp(LATCH_DELAY); - } else - ret = BP_NOT_CAP; - return ret; -} - -/* DISC_PORT_ON */ -int disc_port_on(bpctl_dev_t *pbpctl_dev) -{ - int ret = 0; - bpctl_dev_t *pbpctl_dev_m; - - if ((is_bypass_fn(pbpctl_dev)) == 1) - pbpctl_dev_m = pbpctl_dev; - else - pbpctl_dev_m = get_master_port_fn(pbpctl_dev); - if (pbpctl_dev_m == NULL) - return BP_NOT_CAP; - - if (pbpctl_dev_m->bp_caps_ex & DISC_PORT_CAP_EX) { - if (is_bypass_fn(pbpctl_dev) == 1) { - - write_data(pbpctl_dev_m, TX_DISA); - } else { - - write_data(pbpctl_dev_m, TX_DISB); - } - - msec_delay_bp(LATCH_DELAY); - - } - return ret; -} - -/* DISC_PORT_OFF */ -int disc_port_off(bpctl_dev_t *pbpctl_dev) -{ - int ret = 0; - bpctl_dev_t *pbpctl_dev_m; - - if ((is_bypass_fn(pbpctl_dev)) == 1) - pbpctl_dev_m = pbpctl_dev; - else - pbpctl_dev_m = get_master_port_fn(pbpctl_dev); - if (pbpctl_dev_m == NULL) - return BP_NOT_CAP; - - if (pbpctl_dev_m->bp_caps_ex & DISC_PORT_CAP_EX) { - if (is_bypass_fn(pbpctl_dev) == 1) - write_data(pbpctl_dev_m, TX_ENA); - else - write_data(pbpctl_dev_m, TX_ENB); - - msec_delay_bp(LATCH_DELAY); - - } - return ret; -} - -/*TWO_PORT_LINK_HW_EN (0xe)*/ -int tpl_hw_on(bpctl_dev_t *pbpctl_dev) -{ - int ret = 0, ctrl = 0; - bpctl_dev_t *pbpctl_dev_b = NULL; - - if (!(pbpctl_dev_b = get_status_port_fn(pbpctl_dev))) - return BP_NOT_CAP; - - if (pbpctl_dev->bp_caps_ex & TPL2_CAP_EX) { - cmnd_on(pbpctl_dev); - write_data(pbpctl_dev, TPL2_ON); - msec_delay_bp(LATCH_DELAY + EEPROM_WR_DELAY); - cmnd_off(pbpctl_dev); - return ret; - } - - if (TPL_IF_SERIES(pbpctl_dev->subdevice)) { - ctrl = BPCTL_READ_REG(pbpctl_dev_b, CTRL); - BPCTL_BP_WRITE_REG(pbpctl_dev_b, CTRL, - ((ctrl | BPCTLI_CTRL_SWDPIO0) & - ~BPCTLI_CTRL_SWDPIN0)); - } else - ret = BP_NOT_CAP; - return ret; -} - -/*TWO_PORT_LINK_HW_DIS (0xc)*/ -int tpl_hw_off(bpctl_dev_t *pbpctl_dev) -{ - int ret = 0, ctrl = 0; - bpctl_dev_t *pbpctl_dev_b = NULL; - - if (!(pbpctl_dev_b = get_status_port_fn(pbpctl_dev))) - return BP_NOT_CAP; - if (pbpctl_dev->bp_caps_ex & TPL2_CAP_EX) { - cmnd_on(pbpctl_dev); - write_data(pbpctl_dev, TPL2_OFF); - msec_delay_bp(LATCH_DELAY + EEPROM_WR_DELAY); - cmnd_off(pbpctl_dev); - return ret; - } - if (TPL_IF_SERIES(pbpctl_dev->subdevice)) { - ctrl = BPCTL_READ_REG(pbpctl_dev_b, CTRL); - BPCTL_BP_WRITE_REG(pbpctl_dev_b, CTRL, - (ctrl | BPCTLI_CTRL_SWDPIO0 | - BPCTLI_CTRL_SWDPIN0)); - } else - ret = BP_NOT_CAP; - return ret; -} - -/* WDT_OFF (0x6 110)*/ -int wdt_off(bpctl_dev_t *pbpctl_dev) -{ - int ret = BP_NOT_CAP; - - if (pbpctl_dev->bp_caps & WD_CTL_CAP) { - if (INTEL_IF_SERIES(pbpctl_dev->subdevice)) { - bypass_off(pbpctl_dev); - } else if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) - write_data(pbpctl_dev, WDT_OFF); - else - data_pulse(pbpctl_dev, WDT_OFF); - pbpctl_dev->wdt_status = WDT_STATUS_DIS; - ret = 0; - }; - return ret; -} - -/* WDT_ON (0x10)*/ - -/***Global***/ -static unsigned int - wdt_val_array[] = { 1000, 1500, 2000, 3000, 4000, 8000, 16000, 32000, 0 }; - -int wdt_on(bpctl_dev_t *pbpctl_dev, unsigned int timeout) -{ - - if (pbpctl_dev->bp_caps & WD_CTL_CAP) { - unsigned int pulse = 0, temp_value = 0, temp_cnt = 0; - pbpctl_dev->wdt_status = 0; - - if (INTEL_IF_SERIES(pbpctl_dev->subdevice)) { - for (; wdt_val_array[temp_cnt]; temp_cnt++) - if (timeout <= wdt_val_array[temp_cnt]) - break; - - if (!wdt_val_array[temp_cnt]) - temp_cnt--; - - timeout = wdt_val_array[temp_cnt]; - temp_cnt += 0x7; - - write_data_int(pbpctl_dev, DIS_BYPASS_CAP_INT); - msec_delay_bp(BYPASS_DELAY_INT); - pbpctl_dev->bp_status_un = 0; - write_data_int(pbpctl_dev, temp_cnt); - pbpctl_dev->bypass_wdt_on_time = jiffies; - msec_delay_bp(CMND_INTERVAL_INT); - pbpctl_dev->bypass_timer_interval = timeout; - } else { - timeout = - (timeout < - TIMEOUT_UNIT ? TIMEOUT_UNIT : (timeout > - WDT_TIMEOUT_MAX ? - WDT_TIMEOUT_MAX : - timeout)); - temp_value = timeout / 100; - while ((temp_value >>= 1)) - temp_cnt++; - if (timeout > ((1 << temp_cnt) * 100)) - temp_cnt++; - pbpctl_dev->bypass_wdt_on_time = jiffies; - pulse = (WDT_ON | temp_cnt); - if (pbpctl_dev->bp_ext_ver == OLD_IF_VER) - data_pulse(pbpctl_dev, pulse); - else - write_data(pbpctl_dev, pulse); - pbpctl_dev->bypass_timer_interval = - (1 << temp_cnt) * 100; - } - pbpctl_dev->wdt_status = WDT_STATUS_EN; - return 0; - } - return BP_NOT_CAP; -} - -void bp75_put_hw_semaphore_generic(bpctl_dev_t *pbpctl_dev) -{ - u32 swsm; - - swsm = BPCTL_READ_REG(pbpctl_dev, SWSM); - - swsm &= ~(BPCTLI_SWSM_SMBI | BPCTLI_SWSM_SWESMBI); - - BPCTL_WRITE_REG(pbpctl_dev, SWSM, swsm); -} - -s32 bp75_get_hw_semaphore_generic(bpctl_dev_t *pbpctl_dev) -{ - u32 swsm; - s32 ret_val = 0; - s32 timeout = 8192 + 1; - s32 i = 0; - - /* Get the SW semaphore */ - while (i < timeout) { - swsm = BPCTL_READ_REG(pbpctl_dev, SWSM); - if (!(swsm & BPCTLI_SWSM_SMBI)) - break; - - usec_delay(50); - i++; - } - - if (i == timeout) { - printk - ("bpctl_mod: Driver can't access device - SMBI bit is set.\n"); - ret_val = -1; - goto out; - } - - /* Get the FW semaphore. */ - for (i = 0; i < timeout; i++) { - swsm = BPCTL_READ_REG(pbpctl_dev, SWSM); - BPCTL_WRITE_REG(pbpctl_dev, SWSM, swsm | BPCTLI_SWSM_SWESMBI); - - /* Semaphore acquired if bit latched */ - if (BPCTL_READ_REG(pbpctl_dev, SWSM) & BPCTLI_SWSM_SWESMBI) - break; - - usec_delay(50); - } - - if (i == timeout) { - /* Release semaphores */ - bp75_put_hw_semaphore_generic(pbpctl_dev); - printk("bpctl_mod: Driver can't access the NVM\n"); - ret_val = -1; - goto out; - } - - out: - return ret_val; -} - -static void bp75_release_phy(bpctl_dev_t *pbpctl_dev) -{ - u16 mask = BPCTLI_SWFW_PHY0_SM; - u32 swfw_sync; - - if ((pbpctl_dev->func == 1) || (pbpctl_dev->func == 3)) - mask = BPCTLI_SWFW_PHY1_SM; - - while (bp75_get_hw_semaphore_generic(pbpctl_dev) != 0) ; - /* Empty */ - - swfw_sync = BPCTL_READ_REG(pbpctl_dev, SW_FW_SYNC); - swfw_sync &= ~mask; - BPCTL_WRITE_REG(pbpctl_dev, SW_FW_SYNC, swfw_sync); - - bp75_put_hw_semaphore_generic(pbpctl_dev); -} - -static s32 bp75_acquire_phy(bpctl_dev_t *pbpctl_dev) -{ - u16 mask = BPCTLI_SWFW_PHY0_SM; - u32 swfw_sync; - u32 swmask; - u32 fwmask; - s32 ret_val = 0; - s32 i = 0, timeout = 200; - - if ((pbpctl_dev->func == 1) || (pbpctl_dev->func == 3)) - mask = BPCTLI_SWFW_PHY1_SM; - - swmask = mask; - fwmask = mask << 16; - - while (i < timeout) { - if (bp75_get_hw_semaphore_generic(pbpctl_dev)) { - ret_val = -1; - goto out; - } - - swfw_sync = BPCTL_READ_REG(pbpctl_dev, SW_FW_SYNC); - if (!(swfw_sync & (fwmask | swmask))) - break; - - bp75_put_hw_semaphore_generic(pbpctl_dev); - mdelay(5); - i++; - } - - if (i == timeout) { - printk - ("bpctl_mod: Driver can't access resource, SW_FW_SYNC timeout.\n"); - ret_val = -1; - goto out; - } - - swfw_sync |= swmask; - BPCTL_WRITE_REG(pbpctl_dev, SW_FW_SYNC, swfw_sync); - - bp75_put_hw_semaphore_generic(pbpctl_dev); - - out: - return ret_val; -} - -s32 bp75_read_phy_reg_mdic(bpctl_dev_t *pbpctl_dev, u32 offset, u16 *data) -{ - u32 i, mdic = 0; - s32 ret_val = 0; - u32 phy_addr = 1; - - mdic = ((offset << BPCTLI_MDIC_REG_SHIFT) | - (phy_addr << BPCTLI_MDIC_PHY_SHIFT) | (BPCTLI_MDIC_OP_READ)); - - BPCTL_WRITE_REG(pbpctl_dev, MDIC, mdic); - - for (i = 0; i < (BPCTLI_GEN_POLL_TIMEOUT * 3); i++) { - usec_delay(50); - mdic = BPCTL_READ_REG(pbpctl_dev, MDIC); - if (mdic & BPCTLI_MDIC_READY) - break; - } - if (!(mdic & BPCTLI_MDIC_READY)) { - printk("bpctl_mod: MDI Read did not complete\n"); - ret_val = -1; - goto out; - } - if (mdic & BPCTLI_MDIC_ERROR) { - printk("bpctl_mod: MDI Error\n"); - ret_val = -1; - goto out; - } - *data = (u16) mdic; - - out: - return ret_val; -} - -s32 bp75_write_phy_reg_mdic(bpctl_dev_t *pbpctl_dev, u32 offset, u16 data) -{ - u32 i, mdic = 0; - s32 ret_val = 0; - u32 phy_addr = 1; - - mdic = (((u32) data) | - (offset << BPCTLI_MDIC_REG_SHIFT) | - (phy_addr << BPCTLI_MDIC_PHY_SHIFT) | (BPCTLI_MDIC_OP_WRITE)); - - BPCTL_WRITE_REG(pbpctl_dev, MDIC, mdic); - - for (i = 0; i < (BPCTLI_GEN_POLL_TIMEOUT * 3); i++) { - usec_delay(50); - mdic = BPCTL_READ_REG(pbpctl_dev, MDIC); - if (mdic & BPCTLI_MDIC_READY) - break; - } - if (!(mdic & BPCTLI_MDIC_READY)) { - printk("bpctl_mod: MDI Write did not complete\n"); - ret_val = -1; - goto out; - } - if (mdic & BPCTLI_MDIC_ERROR) { - printk("bpctl_mod: MDI Error\n"); - ret_val = -1; - goto out; - } - - out: - return ret_val; -} - -static s32 bp75_read_phy_reg(bpctl_dev_t *pbpctl_dev, u32 offset, u16 *data) -{ - s32 ret_val = 0; - - ret_val = bp75_acquire_phy(pbpctl_dev); - if (ret_val) - goto out; - - if (offset > BPCTLI_MAX_PHY_MULTI_PAGE_REG) { - ret_val = bp75_write_phy_reg_mdic(pbpctl_dev, - BPCTLI_IGP01E1000_PHY_PAGE_SELECT, - (u16) offset); - if (ret_val) - goto release; - } - - ret_val = - bp75_read_phy_reg_mdic(pbpctl_dev, - BPCTLI_MAX_PHY_REG_ADDRESS & offset, data); - - release: - bp75_release_phy(pbpctl_dev); - out: - return ret_val; -} - -static s32 bp75_write_phy_reg(bpctl_dev_t *pbpctl_dev, u32 offset, u16 data) -{ - s32 ret_val = 0; - - ret_val = bp75_acquire_phy(pbpctl_dev); - if (ret_val) - goto out; - - if (offset > BPCTLI_MAX_PHY_MULTI_PAGE_REG) { - ret_val = bp75_write_phy_reg_mdic(pbpctl_dev, - BPCTLI_IGP01E1000_PHY_PAGE_SELECT, - (u16) offset); - if (ret_val) - goto release; - } - - ret_val = - bp75_write_phy_reg_mdic(pbpctl_dev, - BPCTLI_MAX_PHY_REG_ADDRESS & offset, data); - - release: - bp75_release_phy(pbpctl_dev); - - out: - return ret_val; -} - -/* SET_TX (non-Bypass command :)) */ -static int set_tx(bpctl_dev_t *pbpctl_dev, int tx_state) -{ - int ret = 0, ctrl = 0; - bpctl_dev_t *pbpctl_dev_m; - if ((is_bypass_fn(pbpctl_dev)) == 1) - pbpctl_dev_m = pbpctl_dev; - else - pbpctl_dev_m = get_master_port_fn(pbpctl_dev); - if (pbpctl_dev_m == NULL) - return BP_NOT_CAP; - if (pbpctl_dev_m->bp_caps_ex & DISC_PORT_CAP_EX) { - ctrl = BPCTL_READ_REG(pbpctl_dev, CTRL); - if (!tx_state) { - if (pbpctl_dev->bp_540) { - ctrl = BP10G_READ_REG(pbpctl_dev, ESDP); - BP10G_WRITE_REG(pbpctl_dev, ESDP, - (ctrl | BP10G_SDP1_DIR | - BP10G_SDP1_DATA)); - - } else { - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, - (ctrl | BPCTLI_CTRL_SDP1_DIR - | BPCTLI_CTRL_SWDPIN1)); - } - } else { - if (pbpctl_dev->bp_540) { - ctrl = BP10G_READ_REG(pbpctl_dev, ESDP); - BP10G_WRITE_REG(pbpctl_dev, ESDP, - ((ctrl | BP10G_SDP1_DIR) & - ~BP10G_SDP1_DATA)); - } else { - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, - ((ctrl | - BPCTLI_CTRL_SDP1_DIR) & - ~BPCTLI_CTRL_SWDPIN1)); - } - return ret; - - } - } else if (pbpctl_dev->bp_caps & TX_CTL_CAP) { - if (PEG5_IF_SERIES(pbpctl_dev->subdevice)) { - if (tx_state) { - uint16_t mii_reg; - if (! - (ret = - bp75_read_phy_reg(pbpctl_dev, - BPCTLI_PHY_CONTROL, - &mii_reg))) { - if (mii_reg & BPCTLI_MII_CR_POWER_DOWN) { - ret = - bp75_write_phy_reg - (pbpctl_dev, - BPCTLI_PHY_CONTROL, - mii_reg & - ~BPCTLI_MII_CR_POWER_DOWN); - } - } - } else { - uint16_t mii_reg; - if (! - (ret = - bp75_read_phy_reg(pbpctl_dev, - BPCTLI_PHY_CONTROL, - &mii_reg))) { - - mii_reg |= BPCTLI_MII_CR_POWER_DOWN; - ret = - bp75_write_phy_reg(pbpctl_dev, - BPCTLI_PHY_CONTROL, - mii_reg); - } - } - - } - if (pbpctl_dev->bp_fiber5) { - ctrl = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); - - } else if (pbpctl_dev->bp_10gb) - ctrl = BP10GB_READ_REG(pbpctl_dev, MISC_REG_GPIO); - - else if (!pbpctl_dev->bp_10g) - ctrl = BPCTL_READ_REG(pbpctl_dev, CTRL); - else - ctrl = BP10G_READ_REG(pbpctl_dev, ESDP); - - if (!tx_state) - if (pbpctl_dev->bp_10g9) { - BP10G_WRITE_REG(pbpctl_dev, ESDP, - (ctrl | BP10G_SDP3_DATA | - BP10G_SDP3_DIR)); - - } else if (pbpctl_dev->bp_fiber5) { - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, - (ctrl | - BPCTLI_CTRL_EXT_SDP6_DIR | - BPCTLI_CTRL_EXT_SDP6_DATA)); - - } else if (pbpctl_dev->bp_10gb) { - if ((pbpctl_dev->func == 1) - || (pbpctl_dev->func == 3)) - BP10GB_WRITE_REG(pbpctl_dev, - MISC_REG_GPIO, - (ctrl | - BP10GB_GPIO0_SET_P1) & - ~(BP10GB_GPIO0_CLR_P1 | - BP10GB_GPIO0_OE_P1)); - else - BP10GB_WRITE_REG(pbpctl_dev, - MISC_REG_GPIO, - (ctrl | - BP10GB_GPIO0_OE_P0 | - BP10GB_GPIO0_SET_P0)); - - } else if (pbpctl_dev->bp_i80) { - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, - (ctrl | BPCTLI_CTRL_SDP1_DIR - | BPCTLI_CTRL_SWDPIN1)); - - } else if (pbpctl_dev->bp_540) { - ctrl = BP10G_READ_REG(pbpctl_dev, ESDP); - BP10G_WRITE_REG(pbpctl_dev, ESDP, - (ctrl | BP10G_SDP1_DIR | - BP10G_SDP1_DATA)); - - } - - else if (!pbpctl_dev->bp_10g) - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, - (ctrl | BPCTLI_CTRL_SWDPIO0 | - BPCTLI_CTRL_SWDPIN0)); - - else - BP10G_WRITE_REG(pbpctl_dev, ESDP, - (ctrl | BP10G_SDP0_DATA | - BP10G_SDP0_DIR)); - - else { - if (pbpctl_dev->bp_10g9) { - BP10G_WRITE_REG(pbpctl_dev, ESDP, - ((ctrl | BP10G_SDP3_DIR) & - ~BP10G_SDP3_DATA)); - - } else if (pbpctl_dev->bp_fiber5) { - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, - ((ctrl | - BPCTLI_CTRL_EXT_SDP6_DIR) & - ~BPCTLI_CTRL_EXT_SDP6_DATA)); - - } else if (pbpctl_dev->bp_10gb) { - if ((bpctl_dev_arr->func == 1) - || (bpctl_dev_arr->func == 3)) - BP10GB_WRITE_REG(pbpctl_dev, - MISC_REG_GPIO, - (ctrl | - BP10GB_GPIO0_CLR_P1) & - ~(BP10GB_GPIO0_SET_P1 | - BP10GB_GPIO0_OE_P1)); - else - BP10GB_WRITE_REG(pbpctl_dev, - MISC_REG_GPIO, - (ctrl | - BP10GB_GPIO0_OE_P0 | - BP10GB_GPIO0_CLR_P0)); - - } else if (pbpctl_dev->bp_i80) { - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, - ((ctrl | - BPCTLI_CTRL_SDP1_DIR) & - ~BPCTLI_CTRL_SWDPIN1)); - } else if (pbpctl_dev->bp_540) { - ctrl = BP10G_READ_REG(pbpctl_dev, ESDP); - BP10G_WRITE_REG(pbpctl_dev, ESDP, - ((ctrl | BP10G_SDP1_DIR) & - ~BP10G_SDP1_DATA)); - } - - else if (!pbpctl_dev->bp_10g) { - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, - ((ctrl | BPCTLI_CTRL_SWDPIO0) - & ~BPCTLI_CTRL_SWDPIN0)); - if (!PEGF_IF_SERIES(pbpctl_dev->subdevice)) { - BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, - (ctrl & - ~ - (BPCTLI_CTRL_SDP0_DATA - | - BPCTLI_CTRL_SDP0_DIR))); - } - } else - BP10G_WRITE_REG(pbpctl_dev, ESDP, - ((ctrl | BP10G_SDP0_DIR) & - ~BP10G_SDP0_DATA)); - - } - - } else - ret = BP_NOT_CAP; - return ret; - -} - -/* SET_FORCE_LINK (non-Bypass command :)) */ -static int set_bp_force_link(bpctl_dev_t *pbpctl_dev, int tx_state) -{ - int ret = 0, ctrl = 0; - - if (DBI_IF_SERIES(pbpctl_dev->subdevice)) { - - if ((pbpctl_dev->bp_10g) || (pbpctl_dev->bp_10g9)) { - - ctrl = BPCTL_READ_REG(pbpctl_dev, CTRL); - if (!tx_state) - BP10G_WRITE_REG(pbpctl_dev, ESDP, - ctrl & ~BP10G_SDP1_DIR); - else - BP10G_WRITE_REG(pbpctl_dev, ESDP, - ((ctrl | BP10G_SDP1_DIR) & - ~BP10G_SDP1_DATA)); - return ret; - } - - } - return BP_NOT_CAP; -} - -/*RESET_CONT 0x20 */ -int reset_cont(bpctl_dev_t *pbpctl_dev) -{ - int ret = BP_NOT_CAP; - - if (pbpctl_dev->bp_caps & SW_CTL_CAP) { - if (INTEL_IF_SERIES(pbpctl_dev->subdevice)) - return BP_NOT_CAP; - if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) - write_data(pbpctl_dev, RESET_CONT); - else - data_pulse(pbpctl_dev, RESET_CONT); - ret = 0; - }; - return ret; -} - -/*DIS_BYPASS_CAP 0x22 */ -int dis_bypass_cap(bpctl_dev_t *pbpctl_dev) -{ - - if (pbpctl_dev->bp_caps & BP_DIS_CAP) { - if (INTEL_IF_SERIES(pbpctl_dev->subdevice)) { - write_data_int(pbpctl_dev, DIS_BYPASS_CAP_INT); - msec_delay_bp(BYPASS_DELAY_INT); - } else { - write_data(pbpctl_dev, BYPASS_OFF); - msec_delay_bp(LATCH_DELAY); - write_data(pbpctl_dev, DIS_BYPASS_CAP); - msec_delay_bp(BYPASS_CAP_DELAY); - } - return 0; - } - return BP_NOT_CAP; -} - -/*EN_BYPASS_CAP 0x24 */ -int en_bypass_cap(bpctl_dev_t *pbpctl_dev) -{ - if (pbpctl_dev->bp_caps & BP_DIS_CAP) { - if (INTEL_IF_SERIES(pbpctl_dev->subdevice)) { - write_data_int(pbpctl_dev, PWROFF_BYPASS_ON_INT); - msec_delay_bp(BYPASS_DELAY_INT); - } else { - write_data(pbpctl_dev, EN_BYPASS_CAP); - msec_delay_bp(BYPASS_CAP_DELAY); - } - return 0; - } - return BP_NOT_CAP; -} - -/* BYPASS_STATE_PWRON 0x26*/ -int bypass_state_pwron(bpctl_dev_t *pbpctl_dev) -{ - if (pbpctl_dev->bp_caps & BP_PWUP_CTL_CAP) { - write_data(pbpctl_dev, BYPASS_STATE_PWRON); - if (pbpctl_dev->bp_ext_ver == PXG2BPI_VER) - msec_delay_bp(DFLT_PWRON_DELAY); - else - msec_delay_bp(LATCH_DELAY + EEPROM_WR_DELAY); - return 0; - } - return BP_NOT_CAP; -} - -/* NORMAL_STATE_PWRON 0x28*/ -int normal_state_pwron(bpctl_dev_t *pbpctl_dev) -{ - if ((pbpctl_dev->bp_caps & BP_PWUP_CTL_CAP) - || (pbpctl_dev->bp_caps & TAP_PWUP_CTL_CAP)) { - write_data(pbpctl_dev, NORMAL_STATE_PWRON); - if (pbpctl_dev->bp_ext_ver == PXG2BPI_VER) - msec_delay_bp(DFLT_PWRON_DELAY); - else - msec_delay_bp(LATCH_DELAY + EEPROM_WR_DELAY); - return 0; - } - return BP_NOT_CAP; -} - -/* BYPASS_STATE_PWROFF 0x27*/ -int bypass_state_pwroff(bpctl_dev_t *pbpctl_dev) -{ - if (pbpctl_dev->bp_caps & BP_PWOFF_CTL_CAP) { - write_data(pbpctl_dev, BYPASS_STATE_PWROFF); - msec_delay_bp(LATCH_DELAY + EEPROM_WR_DELAY); - return 0; - } - return BP_NOT_CAP; -} - -/* NORMAL_STATE_PWROFF 0x29*/ -int normal_state_pwroff(bpctl_dev_t *pbpctl_dev) -{ - if ((pbpctl_dev->bp_caps & BP_PWOFF_CTL_CAP)) { - write_data(pbpctl_dev, NORMAL_STATE_PWROFF); - msec_delay_bp(LATCH_DELAY + EEPROM_WR_DELAY); - return 0; - } - return BP_NOT_CAP; -} - -/*TAP_STATE_PWRON 0x2a*/ -int tap_state_pwron(bpctl_dev_t *pbpctl_dev) -{ - if (pbpctl_dev->bp_caps & TAP_PWUP_CTL_CAP) { - write_data(pbpctl_dev, TAP_STATE_PWRON); - msec_delay_bp(LATCH_DELAY + EEPROM_WR_DELAY); - return 0; - } - return BP_NOT_CAP; -} - -/*DIS_TAP_CAP 0x2c*/ -int dis_tap_cap(bpctl_dev_t *pbpctl_dev) -{ - if (pbpctl_dev->bp_caps & TAP_DIS_CAP) { - write_data(pbpctl_dev, DIS_TAP_CAP); - msec_delay_bp(BYPASS_CAP_DELAY); - return 0; - } - return BP_NOT_CAP; -} - -/*EN_TAP_CAP 0x2e*/ -int en_tap_cap(bpctl_dev_t *pbpctl_dev) -{ - if (pbpctl_dev->bp_caps & TAP_DIS_CAP) { - write_data(pbpctl_dev, EN_TAP_CAP); - msec_delay_bp(BYPASS_CAP_DELAY); - return 0; - } - return BP_NOT_CAP; -} - -/*DISC_STATE_PWRON 0x2a*/ -int disc_state_pwron(bpctl_dev_t *pbpctl_dev) -{ - if (pbpctl_dev->bp_caps & DISC_PWUP_CTL_CAP) { - if (pbpctl_dev->bp_ext_ver >= 0x8) { - write_data(pbpctl_dev, DISC_STATE_PWRON); - msec_delay_bp(LATCH_DELAY + EEPROM_WR_DELAY); - return BP_OK; - } - } - return BP_NOT_CAP; -} - -/*DIS_DISC_CAP 0x2c*/ -int dis_disc_cap(bpctl_dev_t *pbpctl_dev) -{ - if (pbpctl_dev->bp_caps & DISC_DIS_CAP) { - if (pbpctl_dev->bp_ext_ver >= 0x8) { - write_data(pbpctl_dev, DIS_DISC_CAP); - msec_delay_bp(BYPASS_CAP_DELAY); - return BP_OK; - } - } - return BP_NOT_CAP; -} - -/*DISC_STATE_PWRON 0x2a*/ -int disc_port_state_pwron(bpctl_dev_t *pbpctl_dev) -{ - int ret = 0; - bpctl_dev_t *pbpctl_dev_m; - - return BP_NOT_CAP; - - if ((is_bypass_fn(pbpctl_dev)) == 1) - pbpctl_dev_m = pbpctl_dev; - else - pbpctl_dev_m = get_master_port_fn(pbpctl_dev); - if (pbpctl_dev_m == NULL) - return BP_NOT_CAP; - - if (pbpctl_dev_m->bp_caps_ex & DISC_PORT_CAP_EX) { - if (is_bypass_fn(pbpctl_dev) == 1) - write_data(pbpctl_dev_m, TX_DISA_PWRUP); - else - write_data(pbpctl_dev_m, TX_DISB_PWRUP); - - msec_delay_bp(LATCH_DELAY); - - } - return ret; -} - -int normal_port_state_pwron(bpctl_dev_t *pbpctl_dev) -{ - int ret = 0; - bpctl_dev_t *pbpctl_dev_m; - return BP_NOT_CAP; - - if ((is_bypass_fn(pbpctl_dev)) == 1) - pbpctl_dev_m = pbpctl_dev; - else - pbpctl_dev_m = get_master_port_fn(pbpctl_dev); - if (pbpctl_dev_m == NULL) - return BP_NOT_CAP; - - if (pbpctl_dev_m->bp_caps_ex & DISC_PORT_CAP_EX) { - if (is_bypass_fn(pbpctl_dev) == 1) - write_data(pbpctl_dev_m, TX_ENA_PWRUP); - else - write_data(pbpctl_dev_m, TX_ENB_PWRUP); - - msec_delay_bp(LATCH_DELAY); - - } - return ret; -} - -/*EN_TAP_CAP 0x2e*/ -int en_disc_cap(bpctl_dev_t *pbpctl_dev) -{ - if (pbpctl_dev->bp_caps & DISC_DIS_CAP) { - if (pbpctl_dev->bp_ext_ver >= 0x8) { - write_data(pbpctl_dev, EN_DISC_CAP); - msec_delay_bp(BYPASS_CAP_DELAY); - return BP_OK; - } - } - return BP_NOT_CAP; -} - -int std_nic_on(bpctl_dev_t *pbpctl_dev) -{ - - if (pbpctl_dev->bp_caps & STD_NIC_CAP) { - - if (INTEL_IF_SERIES(pbpctl_dev->subdevice)) { - write_data_int(pbpctl_dev, DIS_BYPASS_CAP_INT); - msec_delay_bp(BYPASS_DELAY_INT); - pbpctl_dev->bp_status_un = 0; - return BP_OK; - } - - if (pbpctl_dev->bp_ext_ver >= 0x8) { - write_data(pbpctl_dev, STD_NIC_ON); - msec_delay_bp(BYPASS_CAP_DELAY); - return BP_OK; - - } - - if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { - wdt_off(pbpctl_dev); - - if (pbpctl_dev->bp_caps & BP_CAP) { - write_data(pbpctl_dev, BYPASS_OFF); - msec_delay_bp(LATCH_DELAY); - } - - if (pbpctl_dev->bp_caps & TAP_CAP) { - write_data(pbpctl_dev, TAP_OFF); - msec_delay_bp(LATCH_DELAY); - } - - write_data(pbpctl_dev, NORMAL_STATE_PWRON); - if (pbpctl_dev->bp_ext_ver == PXG2BPI_VER) - msec_delay_bp(DFLT_PWRON_DELAY); - else - msec_delay_bp(LATCH_DELAY + EEPROM_WR_DELAY); - - if (pbpctl_dev->bp_caps & BP_DIS_CAP) { - write_data(pbpctl_dev, DIS_BYPASS_CAP); - msec_delay_bp(BYPASS_CAP_DELAY); - } - - if (pbpctl_dev->bp_caps & TAP_DIS_CAP) { - write_data(pbpctl_dev, DIS_TAP_CAP); - msec_delay_bp(BYPASS_CAP_DELAY); - - } - return 0; - } - } - return BP_NOT_CAP; -} - -int std_nic_off(bpctl_dev_t *pbpctl_dev) -{ - - if (pbpctl_dev->bp_caps & STD_NIC_CAP) { - if (INTEL_IF_SERIES(pbpctl_dev->subdevice)) { - write_data_int(pbpctl_dev, PWROFF_BYPASS_ON_INT); - msec_delay_bp(BYPASS_DELAY_INT); - return BP_OK; - } - if (pbpctl_dev->bp_ext_ver >= 0x8) { - write_data(pbpctl_dev, STD_NIC_OFF); - msec_delay_bp(BYPASS_CAP_DELAY); - return BP_OK; - - } - - if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { - - if (pbpctl_dev->bp_caps & TAP_PWUP_CTL_CAP) { - write_data(pbpctl_dev, TAP_STATE_PWRON); - msec_delay_bp(LATCH_DELAY + EEPROM_WR_DELAY); - } - - if (pbpctl_dev->bp_caps & BP_PWUP_CTL_CAP) { - write_data(pbpctl_dev, BYPASS_STATE_PWRON); - if (pbpctl_dev->bp_ext_ver > PXG2BPI_VER) - msec_delay_bp(LATCH_DELAY + - EEPROM_WR_DELAY); - else - msec_delay_bp(DFLT_PWRON_DELAY); - } - - if (pbpctl_dev->bp_caps & TAP_DIS_CAP) { - write_data(pbpctl_dev, EN_TAP_CAP); - msec_delay_bp(BYPASS_CAP_DELAY); - } - if (pbpctl_dev->bp_caps & DISC_DIS_CAP) { - write_data(pbpctl_dev, EN_DISC_CAP); - msec_delay_bp(BYPASS_CAP_DELAY); - } - - if (pbpctl_dev->bp_caps & BP_DIS_CAP) { - write_data(pbpctl_dev, EN_BYPASS_CAP); - msec_delay_bp(BYPASS_CAP_DELAY); - } - - return 0; - } - } - return BP_NOT_CAP; -} - -int wdt_time_left(bpctl_dev_t *pbpctl_dev) -{ - - /* unsigned long curr_time=((long long)(jiffies*1000))/HZ, delta_time=0,wdt_on_time=((long long)(pbpctl_dev->bypass_wdt_on_time*1000))/HZ; */ - unsigned long curr_time = jiffies, delta_time = 0, wdt_on_time = - pbpctl_dev->bypass_wdt_on_time, delta_time_msec = 0; - int time_left = 0; - - switch (pbpctl_dev->wdt_status) { - case WDT_STATUS_DIS: - time_left = 0; - break; - case WDT_STATUS_EN: - delta_time = - (curr_time >= - wdt_on_time) ? (curr_time - wdt_on_time) : (~wdt_on_time + - curr_time); - delta_time_msec = jiffies_to_msecs(delta_time); - time_left = pbpctl_dev->bypass_timer_interval - delta_time_msec; - if (time_left < 0) { - time_left = -1; - pbpctl_dev->wdt_status = WDT_STATUS_EXP; - } - break; - case WDT_STATUS_EXP: - time_left = -1; - break; - } - - return time_left; -} - -static int wdt_timer(bpctl_dev_t *pbpctl_dev, int *time_left) -{ - int ret = 0; - if (pbpctl_dev->bp_caps & WD_CTL_CAP) { - { - if (pbpctl_dev->wdt_status == WDT_STATUS_UNKNOWN) - ret = BP_NOT_CAP; - else - *time_left = wdt_time_left(pbpctl_dev); - } - - } else - ret = BP_NOT_CAP; - return ret; -} - -static int wdt_timer_reload(bpctl_dev_t *pbpctl_dev) -{ - - int ret = 0; - - if ((pbpctl_dev->bp_caps & WD_CTL_CAP) && - (pbpctl_dev->wdt_status != WDT_STATUS_UNKNOWN)) { - if (pbpctl_dev->wdt_status == WDT_STATUS_DIS) - return 0; - if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) - ret = wdt_pulse(pbpctl_dev); - else if (INTEL_IF_SERIES(pbpctl_dev->subdevice)) - ret = wdt_pulse_int(pbpctl_dev); - else - ret = send_wdt_pulse(pbpctl_dev); - /* if (ret==-1) - mod_timer(&pbpctl_dev->bp_timer, jiffies+1);*/ - return 1; - } - return BP_NOT_CAP; -} - -static void wd_reset_timer(unsigned long param) -{ - bpctl_dev_t *pbpctl_dev = (bpctl_dev_t *) param; -#ifdef BP_SELF_TEST - struct sk_buff *skb_tmp; -#endif - - if ((pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) && - ((atomic_read(&pbpctl_dev->wdt_busy)) == 1)) { - mod_timer(&pbpctl_dev->bp_timer, jiffies + 1); - return; - } -#ifdef BP_SELF_TEST - - if (pbpctl_dev->bp_self_test_flag == 1) { - skb_tmp = dev_alloc_skb(BPTEST_DATA_LEN + 2); - if ((skb_tmp) && (pbpctl_dev->ndev) && (pbpctl_dev->bp_tx_data)) { - memcpy(skb_put(skb_tmp, BPTEST_DATA_LEN), - pbpctl_dev->bp_tx_data, BPTEST_DATA_LEN); - skb_tmp->dev = pbpctl_dev->ndev; - skb_tmp->protocol = - eth_type_trans(skb_tmp, pbpctl_dev->ndev); - skb_tmp->ip_summed = CHECKSUM_UNNECESSARY; - netif_receive_skb(skb_tmp); - goto bp_timer_reload; - return; - } - } -#endif - - wdt_timer_reload(pbpctl_dev); -#ifdef BP_SELF_TEST - bp_timer_reload: -#endif - if (pbpctl_dev->reset_time) { - mod_timer(&pbpctl_dev->bp_timer, - jiffies + (HZ * pbpctl_dev->reset_time) / 1000); - } -} - -/*WAIT_AT_PWRUP 0x80 */ -int bp_wait_at_pwup_en(bpctl_dev_t *pbpctl_dev) -{ - - if (pbpctl_dev->bp_caps & SW_CTL_CAP) { - if (pbpctl_dev->bp_ext_ver >= BP_FW_EXT_VER8) { - write_data(pbpctl_dev, BP_WAIT_AT_PWUP_EN); - msec_delay_bp(LATCH_DELAY + EEPROM_WR_DELAY); - - return BP_OK; - } - } - return BP_NOT_CAP; -} - -/*DIS_WAIT_AT_PWRUP 0x81 */ -int bp_wait_at_pwup_dis(bpctl_dev_t *pbpctl_dev) -{ - - if (pbpctl_dev->bp_caps & SW_CTL_CAP) { - - if (pbpctl_dev->bp_ext_ver >= BP_FW_EXT_VER8) { - write_data(pbpctl_dev, BP_WAIT_AT_PWUP_DIS); - msec_delay_bp(LATCH_DELAY + EEPROM_WR_DELAY); - - return BP_OK; - } - } - return BP_NOT_CAP; -} - -/*EN_HW_RESET 0x82 */ - -int bp_hw_reset_en(bpctl_dev_t *pbpctl_dev) -{ - - if (pbpctl_dev->bp_caps & SW_CTL_CAP) { - if (pbpctl_dev->bp_ext_ver >= BP_FW_EXT_VER8) { - write_data(pbpctl_dev, BP_HW_RESET_EN); - msec_delay_bp(LATCH_DELAY + EEPROM_WR_DELAY); - - return BP_OK; - } - } - return BP_NOT_CAP; -} - -/*DIS_HW_RESET 0x83 */ - -int bp_hw_reset_dis(bpctl_dev_t *pbpctl_dev) -{ - - if (pbpctl_dev->bp_caps & SW_CTL_CAP) { - if (pbpctl_dev->bp_ext_ver >= BP_FW_EXT_VER8) { - write_data(pbpctl_dev, BP_HW_RESET_DIS); - msec_delay_bp(LATCH_DELAY + EEPROM_WR_DELAY); - - return BP_OK; - } - } - return BP_NOT_CAP; -} - - -int wdt_exp_mode(bpctl_dev_t *pbpctl_dev, int mode) -{ - uint32_t status_reg = 0, status_reg1 = 0; - - if ((pbpctl_dev->bp_caps & (TAP_STATUS_CAP | DISC_CAP)) && - (pbpctl_dev->bp_caps & BP_CAP)) { - if (pbpctl_dev->bp_ext_ver >= PXE2TBPI_VER) { - - if ((pbpctl_dev->bp_ext_ver >= 0x8) && - (mode == 2) && (pbpctl_dev->bp_caps & DISC_CAP)) { - status_reg1 = - read_reg(pbpctl_dev, STATUS_DISC_REG_ADDR); - if (!(status_reg1 & WDTE_DISC_BPN_MASK)) - write_reg(pbpctl_dev, - status_reg1 | - WDTE_DISC_BPN_MASK, - STATUS_DISC_REG_ADDR); - return BP_OK; - } - } - status_reg = read_reg(pbpctl_dev, STATUS_TAP_REG_ADDR); - - if ((mode == 0) && (pbpctl_dev->bp_caps & BP_CAP)) { - if (pbpctl_dev->bp_ext_ver >= 0x8) { - status_reg1 = - read_reg(pbpctl_dev, STATUS_DISC_REG_ADDR); - if (status_reg1 & WDTE_DISC_BPN_MASK) - write_reg(pbpctl_dev, - status_reg1 & - ~WDTE_DISC_BPN_MASK, - STATUS_DISC_REG_ADDR); - } - if (status_reg & WDTE_TAP_BPN_MASK) - write_reg(pbpctl_dev, - status_reg & ~WDTE_TAP_BPN_MASK, - STATUS_TAP_REG_ADDR); - return BP_OK; - - } else if ((mode == 1) && (pbpctl_dev->bp_caps & TAP_CAP)) { - if (!(status_reg & WDTE_TAP_BPN_MASK)) - write_reg(pbpctl_dev, - status_reg | WDTE_TAP_BPN_MASK, - STATUS_TAP_REG_ADDR); - /*else return BP_NOT_CAP; */ - return BP_OK; - } - - } - return BP_NOT_CAP; -} - -int bypass_fw_ver(bpctl_dev_t *pbpctl_dev) -{ - if (is_bypass_fn(pbpctl_dev)) - return read_reg(pbpctl_dev, VER_REG_ADDR); - else - return BP_NOT_CAP; -} - -int bypass_sign_check(bpctl_dev_t *pbpctl_dev) -{ - - if (is_bypass_fn(pbpctl_dev)) - return (((read_reg(pbpctl_dev, PIC_SIGN_REG_ADDR)) == - PIC_SIGN_VALUE) ? 1 : 0); - else - return BP_NOT_CAP; -} - -static int tx_status(bpctl_dev_t *pbpctl_dev) -{ - uint32_t ctrl = 0; - bpctl_dev_t *pbpctl_dev_m; - if ((is_bypass_fn(pbpctl_dev)) == 1) - pbpctl_dev_m = pbpctl_dev; - else - pbpctl_dev_m = get_master_port_fn(pbpctl_dev); - if (pbpctl_dev_m == NULL) - return BP_NOT_CAP; - if (pbpctl_dev_m->bp_caps_ex & DISC_PORT_CAP_EX) { - - ctrl = BPCTL_READ_REG(pbpctl_dev, CTRL); - if (pbpctl_dev->bp_i80) - return ((ctrl & BPCTLI_CTRL_SWDPIN1) != 0 ? 0 : 1); - if (pbpctl_dev->bp_540) { - ctrl = BP10G_READ_REG(pbpctl_dev, ESDP); - - return ((ctrl & BP10G_SDP1_DATA) != 0 ? 0 : 1); - } - - } - - if (pbpctl_dev->bp_caps & TX_CTL_CAP) { - if (PEG5_IF_SERIES(pbpctl_dev->subdevice)) { - uint16_t mii_reg; - if (! - (bp75_read_phy_reg - (pbpctl_dev, BPCTLI_PHY_CONTROL, &mii_reg))) { - if (mii_reg & BPCTLI_MII_CR_POWER_DOWN) - return 0; - - else - return 1; - } - return -1; - } - - if (pbpctl_dev->bp_10g9) { - return ((BP10G_READ_REG(pbpctl_dev, ESDP) & - BP10G_SDP3_DATA) != 0 ? 0 : 1); - - } else if (pbpctl_dev->bp_fiber5) { - ctrl = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); - if (ctrl & BPCTLI_CTRL_EXT_SDP6_DATA) - return 0; - return 1; - } else if (pbpctl_dev->bp_10gb) { - ctrl = BP10GB_READ_REG(pbpctl_dev, MISC_REG_GPIO); - BP10GB_WRITE_REG(pbpctl_dev, MISC_REG_GPIO, - (ctrl | BP10GB_GPIO0_OE_P1) & - ~(BP10GB_GPIO0_SET_P1 | - BP10GB_GPIO0_CLR_P1)); - - if ((pbpctl_dev->func == 1) || (pbpctl_dev->func == 3)) - return (((BP10GB_READ_REG - (pbpctl_dev, - MISC_REG_GPIO)) & BP10GB_GPIO0_P1) != - 0 ? 0 : 1); - else - return (((BP10GB_READ_REG - (pbpctl_dev, - MISC_REG_GPIO)) & BP10GB_GPIO0_P0) != - 0 ? 0 : 1); - } - - if (!pbpctl_dev->bp_10g) { - - ctrl = BPCTL_READ_REG(pbpctl_dev, CTRL); - if (pbpctl_dev->bp_i80) - return ((ctrl & BPCTLI_CTRL_SWDPIN1) != - 0 ? 0 : 1); - if (pbpctl_dev->bp_540) { - ctrl = BP10G_READ_REG(pbpctl_dev, ESDP); - - return ((ctrl & BP10G_SDP1_DATA) != 0 ? 0 : 1); - } - - return ((ctrl & BPCTLI_CTRL_SWDPIN0) != 0 ? 0 : 1); - } else - return ((BP10G_READ_REG(pbpctl_dev, ESDP) & - BP10G_SDP0_DATA) != 0 ? 0 : 1); - - } - return BP_NOT_CAP; -} - -static int bp_force_link_status(bpctl_dev_t *pbpctl_dev) -{ - - if (DBI_IF_SERIES(pbpctl_dev->subdevice)) { - - if ((pbpctl_dev->bp_10g) || (pbpctl_dev->bp_10g9)) { - return ((BP10G_READ_REG(pbpctl_dev, ESDP) & - BP10G_SDP1_DIR) != 0 ? 1 : 0); - - } - } - return BP_NOT_CAP; -} - -int bypass_from_last_read(bpctl_dev_t *pbpctl_dev) -{ - uint32_t ctrl_ext = 0; - bpctl_dev_t *pbpctl_dev_b = NULL; - - if ((pbpctl_dev->bp_caps & SW_CTL_CAP) - && (pbpctl_dev_b = get_status_port_fn(pbpctl_dev))) { - ctrl_ext = BPCTL_READ_REG(pbpctl_dev_b, CTRL_EXT); - BPCTL_BP_WRITE_REG(pbpctl_dev_b, CTRL_EXT, - (ctrl_ext & ~BPCTLI_CTRL_EXT_SDP7_DIR)); - ctrl_ext = BPCTL_READ_REG(pbpctl_dev_b, CTRL_EXT); - if (ctrl_ext & BPCTLI_CTRL_EXT_SDP7_DATA) - return 0; - return 1; - } else - return BP_NOT_CAP; -} - -int bypass_status_clear(bpctl_dev_t *pbpctl_dev) -{ - bpctl_dev_t *pbpctl_dev_b = NULL; - - if ((pbpctl_dev->bp_caps & SW_CTL_CAP) - && (pbpctl_dev_b = get_status_port_fn(pbpctl_dev))) { - - send_bypass_clear_pulse(pbpctl_dev_b, 1); - return 0; - } else - return BP_NOT_CAP; -} - -int bypass_flag_status(bpctl_dev_t *pbpctl_dev) -{ - - if ((pbpctl_dev->bp_caps & BP_CAP)) { - if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { - return ((((read_reg(pbpctl_dev, STATUS_REG_ADDR)) & - BYPASS_FLAG_MASK) == - BYPASS_FLAG_MASK) ? 1 : 0); - } - } - return BP_NOT_CAP; -} - -int bypass_flag_status_clear(bpctl_dev_t *pbpctl_dev) -{ - - if (pbpctl_dev->bp_caps & BP_CAP) { - if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { - uint32_t status_reg = 0; - status_reg = read_reg(pbpctl_dev, STATUS_REG_ADDR); - write_reg(pbpctl_dev, status_reg & ~BYPASS_FLAG_MASK, - STATUS_REG_ADDR); - return 0; - } - } - return BP_NOT_CAP; -} - -int bypass_change_status(bpctl_dev_t *pbpctl_dev) -{ - int ret = BP_NOT_CAP; - - if (pbpctl_dev->bp_caps & BP_STATUS_CHANGE_CAP) { - if (pbpctl_dev->bp_ext_ver >= 0x8) { - ret = bypass_flag_status(pbpctl_dev); - bypass_flag_status_clear(pbpctl_dev); - } else if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { - ret = bypass_flag_status(pbpctl_dev); - bypass_flag_status_clear(pbpctl_dev); - } else { - ret = bypass_from_last_read(pbpctl_dev); - bypass_status_clear(pbpctl_dev); - } - } - return ret; -} - -int bypass_off_status(bpctl_dev_t *pbpctl_dev) -{ - - if (pbpctl_dev->bp_caps & BP_CAP) { - if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { - return ((((read_reg(pbpctl_dev, STATUS_REG_ADDR)) & - BYPASS_OFF_MASK) == BYPASS_OFF_MASK) ? 1 : 0); - } - } - return BP_NOT_CAP; -} - -static int bypass_status(bpctl_dev_t *pbpctl_dev) -{ - u32 ctrl_ext = 0; - if (pbpctl_dev->bp_caps & BP_CAP) { - - bpctl_dev_t *pbpctl_dev_b = NULL; - - if (!(pbpctl_dev_b = get_status_port_fn(pbpctl_dev))) - return BP_NOT_CAP; - - if (INTEL_IF_SERIES(pbpctl_dev->subdevice)) { - - if (!pbpctl_dev->bp_status_un) - return (((BPCTL_READ_REG - (pbpctl_dev_b, - CTRL_EXT)) & - BPCTLI_CTRL_EXT_SDP7_DATA) != - 0 ? 1 : 0); - else - return BP_NOT_CAP; - } - if (pbpctl_dev->bp_ext_ver >= 0x8) { - - if (pbpctl_dev->bp_10g9) { - ctrl_ext = BP10G_READ_REG(pbpctl_dev_b, I2CCTL); - BP10G_WRITE_REG(pbpctl_dev_b, I2CCTL, - (ctrl_ext | BP10G_I2C_CLK_OUT)); - return ((BP10G_READ_REG(pbpctl_dev_b, I2CCTL) & - BP10G_I2C_CLK_IN) != 0 ? 0 : 1); - - } else if (pbpctl_dev->bp_540) { - return (((BP10G_READ_REG(pbpctl_dev_b, ESDP)) & - BP10G_SDP0_DATA) != 0 ? 0 : 1); - } - - else if ((pbpctl_dev->bp_fiber5) - || (pbpctl_dev->bp_i80)) { - return (((BPCTL_READ_REG(pbpctl_dev_b, CTRL)) & - BPCTLI_CTRL_SWDPIN0) != 0 ? 0 : 1); - } else if (pbpctl_dev->bp_10gb) { - ctrl_ext = - BP10GB_READ_REG(pbpctl_dev, MISC_REG_GPIO); - BP10GB_WRITE_REG(pbpctl_dev, MISC_REG_GPIO, - (ctrl_ext | BP10GB_GPIO3_OE_P0) - & ~(BP10GB_GPIO3_SET_P0 | - BP10GB_GPIO3_CLR_P0)); - - return (((BP10GB_READ_REG - (pbpctl_dev, - MISC_REG_GPIO)) & BP10GB_GPIO3_P0) != - 0 ? 0 : 1); - } - - else if (!pbpctl_dev->bp_10g) - return (((BPCTL_READ_REG - (pbpctl_dev_b, - CTRL_EXT)) & - BPCTLI_CTRL_EXT_SDP7_DATA) != - 0 ? 0 : 1); - - else { - ctrl_ext = BP10G_READ_REG(pbpctl_dev_b, EODSDP); - BP10G_WRITE_REG(pbpctl_dev_b, EODSDP, - (ctrl_ext | - BP10G_SDP7_DATA_OUT)); - return ((BP10G_READ_REG(pbpctl_dev_b, EODSDP) & - BP10G_SDP7_DATA_IN) != 0 ? 0 : 1); - } - - } else if (pbpctl_dev->media_type == bp_copper) { - - return (((BPCTL_READ_REG(pbpctl_dev_b, CTRL)) & - BPCTLI_CTRL_SWDPIN1) != 0 ? 1 : 0); - } else { - if ((bypass_status_clear(pbpctl_dev)) >= 0) - return bypass_from_last_read(pbpctl_dev); - } - - } - return BP_NOT_CAP; -} - -int default_pwron_status(bpctl_dev_t *pbpctl_dev) -{ - - if (pbpctl_dev->bp_caps & SW_CTL_CAP) { - if (pbpctl_dev->bp_caps & BP_PWUP_CTL_CAP) { - if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { - return ((((read_reg - (pbpctl_dev, - STATUS_REG_ADDR)) & DFLT_PWRON_MASK) - == DFLT_PWRON_MASK) ? 0 : 1); - } - } /*else if ((!pbpctl_dev->bp_caps&BP_DIS_CAP)&& - (pbpctl_dev->bp_caps&BP_PWUP_ON_CAP)) - return 1; */ - } - return BP_NOT_CAP; -} - -static int default_pwroff_status(bpctl_dev_t *pbpctl_dev) -{ - - /*if ((!pbpctl_dev->bp_caps&BP_DIS_CAP)&& - (pbpctl_dev->bp_caps&BP_PWOFF_ON_CAP)) - return 1; */ - if ((pbpctl_dev->bp_caps & SW_CTL_CAP) - && (pbpctl_dev->bp_caps & BP_PWOFF_CTL_CAP)) { - return ((((read_reg(pbpctl_dev, STATUS_REG_ADDR)) & - DFLT_PWROFF_MASK) == DFLT_PWROFF_MASK) ? 0 : 1); - } - return BP_NOT_CAP; -} - -int dis_bypass_cap_status(bpctl_dev_t *pbpctl_dev) -{ - - if (pbpctl_dev->bp_caps & BP_DIS_CAP) { - if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { - return ((((read_reg(pbpctl_dev, STATUS_REG_ADDR)) & - DIS_BYPASS_CAP_MASK) == - DIS_BYPASS_CAP_MASK) ? 1 : 0); - } - } - return BP_NOT_CAP; -} - -int cmd_en_status(bpctl_dev_t *pbpctl_dev) -{ - - if (pbpctl_dev->bp_caps & SW_CTL_CAP) { - if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { - return ((((read_reg(pbpctl_dev, STATUS_REG_ADDR)) & - CMND_EN_MASK) == CMND_EN_MASK) ? 1 : 0); - } - } - return BP_NOT_CAP; -} - -int wdt_en_status(bpctl_dev_t *pbpctl_dev) -{ - - if (pbpctl_dev->bp_caps & WD_CTL_CAP) { - if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { - return ((((read_reg(pbpctl_dev, STATUS_REG_ADDR)) & - WDT_EN_MASK) == WDT_EN_MASK) ? 1 : 0); - } - } - return BP_NOT_CAP; -} - -int wdt_programmed(bpctl_dev_t *pbpctl_dev, int *timeout) -{ - int ret = 0; - if (pbpctl_dev->bp_caps & WD_CTL_CAP) { - if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { - if ((read_reg(pbpctl_dev, STATUS_REG_ADDR)) & - WDT_EN_MASK) { - u8 wdt_val; - wdt_val = read_reg(pbpctl_dev, WDT_REG_ADDR); - *timeout = (1 << wdt_val) * 100; - } else - *timeout = 0; - } else { - int curr_wdt_status = pbpctl_dev->wdt_status; - if (curr_wdt_status == WDT_STATUS_UNKNOWN) - *timeout = -1; - else - *timeout = - curr_wdt_status == - 0 ? 0 : pbpctl_dev->bypass_timer_interval; - }; - } else - ret = BP_NOT_CAP; - return ret; -} - -int bypass_support(bpctl_dev_t *pbpctl_dev) -{ - int ret = 0; - - if (pbpctl_dev->bp_caps & SW_CTL_CAP) { - if (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER) { - ret = - ((((read_reg(pbpctl_dev, PRODUCT_CAP_REG_ADDR)) & - BYPASS_SUPPORT_MASK) == - BYPASS_SUPPORT_MASK) ? 1 : 0); - } else if (pbpctl_dev->bp_ext_ver == PXG2BPI_VER) - ret = 1; - } else - ret = BP_NOT_CAP; - return ret; -} - -int tap_support(bpctl_dev_t *pbpctl_dev) -{ - int ret = 0; - - if (pbpctl_dev->bp_caps & SW_CTL_CAP) { - if (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER) { - ret = - ((((read_reg(pbpctl_dev, PRODUCT_CAP_REG_ADDR)) & - TAP_SUPPORT_MASK) == TAP_SUPPORT_MASK) ? 1 : 0); - } else if (pbpctl_dev->bp_ext_ver == PXG2BPI_VER) - ret = 0; - } else - ret = BP_NOT_CAP; - return ret; -} - -int normal_support(bpctl_dev_t *pbpctl_dev) -{ - int ret = BP_NOT_CAP; - - if (pbpctl_dev->bp_caps & SW_CTL_CAP) { - if (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER) { - ret = - ((((read_reg(pbpctl_dev, PRODUCT_CAP_REG_ADDR)) & - NORMAL_UNSUPPORT_MASK) == - NORMAL_UNSUPPORT_MASK) ? 0 : 1); - } else - ret = 1; - }; - return ret; -} - -int get_bp_prod_caps(bpctl_dev_t *pbpctl_dev) -{ - if ((pbpctl_dev->bp_caps & SW_CTL_CAP) && - (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER)) - return read_reg(pbpctl_dev, PRODUCT_CAP_REG_ADDR); - return BP_NOT_CAP; - -} - -int tap_flag_status(bpctl_dev_t *pbpctl_dev) -{ - - if (pbpctl_dev->bp_caps & TAP_STATUS_CAP) { - if (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER) - return ((((read_reg(pbpctl_dev, STATUS_TAP_REG_ADDR)) & - TAP_FLAG_MASK) == TAP_FLAG_MASK) ? 1 : 0); - - } - return BP_NOT_CAP; -} - -int tap_flag_status_clear(bpctl_dev_t *pbpctl_dev) -{ - uint32_t status_reg = 0; - if (pbpctl_dev->bp_caps & TAP_STATUS_CAP) { - if (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER) { - status_reg = read_reg(pbpctl_dev, STATUS_TAP_REG_ADDR); - write_reg(pbpctl_dev, status_reg & ~TAP_FLAG_MASK, - STATUS_TAP_REG_ADDR); - return 0; - } - } - return BP_NOT_CAP; -} - -int tap_change_status(bpctl_dev_t *pbpctl_dev) -{ - int ret = BP_NOT_CAP; - if (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER) { - if (pbpctl_dev->bp_caps & TAP_CAP) { - if (pbpctl_dev->bp_caps & BP_CAP) { - ret = tap_flag_status(pbpctl_dev); - tap_flag_status_clear(pbpctl_dev); - } else { - ret = bypass_from_last_read(pbpctl_dev); - bypass_status_clear(pbpctl_dev); - } - } - } - return ret; -} - -int tap_off_status(bpctl_dev_t *pbpctl_dev) -{ - if (pbpctl_dev->bp_caps & TAP_CAP) { - if (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER) - return ((((read_reg(pbpctl_dev, STATUS_TAP_REG_ADDR)) & - TAP_OFF_MASK) == TAP_OFF_MASK) ? 1 : 0); - } - return BP_NOT_CAP; -} - -int tap_status(bpctl_dev_t *pbpctl_dev) -{ - u32 ctrl_ext = 0; - - if (pbpctl_dev->bp_caps & TAP_CAP) { - bpctl_dev_t *pbpctl_dev_b = NULL; - - if (!(pbpctl_dev_b = get_status_port_fn(pbpctl_dev))) - return BP_NOT_CAP; - - if (pbpctl_dev->bp_ext_ver >= 0x8) { - if (!pbpctl_dev->bp_10g) - return (((BPCTL_READ_REG - (pbpctl_dev_b, - CTRL_EXT)) & - BPCTLI_CTRL_EXT_SDP6_DATA) != - 0 ? 0 : 1); - else { - ctrl_ext = BP10G_READ_REG(pbpctl_dev_b, EODSDP); - BP10G_WRITE_REG(pbpctl_dev_b, EODSDP, - (ctrl_ext | - BP10G_SDP6_DATA_OUT)); - return ((BP10G_READ_REG(pbpctl_dev_b, EODSDP) & - BP10G_SDP6_DATA_IN) != 0 ? 0 : 1); - } - - } else if (pbpctl_dev->media_type == bp_copper) - return (((BPCTL_READ_REG(pbpctl_dev, CTRL)) & - BPCTLI_CTRL_SWDPIN0) != 0 ? 1 : 0); - else { - if ((bypass_status_clear(pbpctl_dev)) >= 0) - return bypass_from_last_read(pbpctl_dev); - } - - } - return BP_NOT_CAP; -} - -int default_pwron_tap_status(bpctl_dev_t *pbpctl_dev) -{ - if (pbpctl_dev->bp_caps & TAP_PWUP_CTL_CAP) { - if (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER) - return ((((read_reg(pbpctl_dev, STATUS_TAP_REG_ADDR)) & - DFLT_PWRON_TAP_MASK) == - DFLT_PWRON_TAP_MASK) ? 1 : 0); - } - return BP_NOT_CAP; -} - -int dis_tap_cap_status(bpctl_dev_t *pbpctl_dev) -{ - if (pbpctl_dev->bp_caps & TAP_PWUP_CTL_CAP) { - if (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER) - return ((((read_reg(pbpctl_dev, STATUS_TAP_REG_ADDR)) & - DIS_TAP_CAP_MASK) == - DIS_TAP_CAP_MASK) ? 1 : 0); - } - return BP_NOT_CAP; -} - -int disc_flag_status(bpctl_dev_t *pbpctl_dev) -{ - - if (pbpctl_dev->bp_caps & DISC_CAP) { - if (pbpctl_dev->bp_ext_ver >= 0x8) - return ((((read_reg(pbpctl_dev, STATUS_DISC_REG_ADDR)) & - DISC_FLAG_MASK) == DISC_FLAG_MASK) ? 1 : 0); - - } - return BP_NOT_CAP; -} - -int disc_flag_status_clear(bpctl_dev_t *pbpctl_dev) -{ - uint32_t status_reg = 0; - if (pbpctl_dev->bp_caps & DISC_CAP) { - if (pbpctl_dev->bp_ext_ver >= 0x8) { - status_reg = read_reg(pbpctl_dev, STATUS_DISC_REG_ADDR); - write_reg(pbpctl_dev, status_reg & ~DISC_FLAG_MASK, - STATUS_DISC_REG_ADDR); - return BP_OK; - } - } - return BP_NOT_CAP; -} - -int disc_change_status(bpctl_dev_t *pbpctl_dev) -{ - int ret = BP_NOT_CAP; - if (pbpctl_dev->bp_caps & DISC_CAP) { - ret = disc_flag_status(pbpctl_dev); - disc_flag_status_clear(pbpctl_dev); - return ret; - } - return BP_NOT_CAP; -} - -int disc_off_status(bpctl_dev_t *pbpctl_dev) -{ - bpctl_dev_t *pbpctl_dev_b = NULL; - u32 ctrl_ext = 0; - - if (pbpctl_dev->bp_caps & DISC_CAP) { - if (!(pbpctl_dev_b = get_status_port_fn(pbpctl_dev))) - return BP_NOT_CAP; - if (DISCF_IF_SERIES(pbpctl_dev->subdevice)) - return ((((read_reg(pbpctl_dev, STATUS_DISC_REG_ADDR)) & - DISC_OFF_MASK) == DISC_OFF_MASK) ? 1 : 0); - - if (pbpctl_dev->bp_i80) { - return (((BPCTL_READ_REG(pbpctl_dev_b, CTRL_EXT)) & - BPCTLI_CTRL_EXT_SDP6_DATA) != 0 ? 1 : 0); - - } - if (pbpctl_dev->bp_540) { - ctrl_ext = BP10G_READ_REG(pbpctl_dev_b, ESDP); - return ((BP10G_READ_REG(pbpctl_dev_b, ESDP) & - BP10G_SDP2_DATA) != 0 ? 1 : 0); - - } - if (pbpctl_dev->media_type == bp_copper) { - -#if 0 - return ((((read_reg(pbpctl_dev, STATUS_DISC_REG_ADDR)) & - DISC_OFF_MASK) == DISC_OFF_MASK) ? 1 : 0); -#endif - if (!pbpctl_dev->bp_10g) - return (((BPCTL_READ_REG(pbpctl_dev_b, CTRL)) & - BPCTLI_CTRL_SWDPIN1) != 0 ? 1 : 0); - else - return ((BP10G_READ_REG(pbpctl_dev_b, ESDP) & - BP10G_SDP1_DATA) != 0 ? 1 : 0); - - } else { - - if (pbpctl_dev->bp_10g9) { - ctrl_ext = BP10G_READ_REG(pbpctl_dev_b, I2CCTL); - BP10G_WRITE_REG(pbpctl_dev_b, I2CCTL, - (ctrl_ext | - BP10G_I2C_DATA_OUT)); - return ((BP10G_READ_REG(pbpctl_dev_b, I2CCTL) & - BP10G_I2C_DATA_IN) != 0 ? 1 : 0); - - } else if (pbpctl_dev->bp_fiber5) { - return (((BPCTL_READ_REG(pbpctl_dev_b, CTRL)) & - BPCTLI_CTRL_SWDPIN1) != 0 ? 1 : 0); - } else if (pbpctl_dev->bp_10gb) { - ctrl_ext = - BP10GB_READ_REG(pbpctl_dev, MISC_REG_GPIO); - BP10GB_WRITE_REG(pbpctl_dev, MISC_REG_GPIO, - (ctrl_ext | BP10GB_GPIO3_OE_P1) - & ~(BP10GB_GPIO3_SET_P1 | - BP10GB_GPIO3_CLR_P1)); - - return (((BP10GB_READ_REG - (pbpctl_dev, - MISC_REG_GPIO)) & BP10GB_GPIO3_P1) != - 0 ? 1 : 0); - } - if (!pbpctl_dev->bp_10g) { - - return (((BPCTL_READ_REG - (pbpctl_dev_b, - CTRL_EXT)) & - BPCTLI_CTRL_EXT_SDP6_DATA) != - 0 ? 1 : 0); - } else { - ctrl_ext = BP10G_READ_REG(pbpctl_dev_b, EODSDP); - BP10G_WRITE_REG(pbpctl_dev_b, EODSDP, - (ctrl_ext | - BP10G_SDP6_DATA_OUT)); - return (((BP10G_READ_REG(pbpctl_dev_b, EODSDP)) - & BP10G_SDP6_DATA_IN) != 0 ? 1 : 0); - } - - } - } - return BP_NOT_CAP; -} - -static int disc_status(bpctl_dev_t *pbpctl_dev) -{ - int ctrl = 0; - if (pbpctl_dev->bp_caps & DISC_CAP) { - - if ((ctrl = disc_off_status(pbpctl_dev)) < 0) - return ctrl; - return ((ctrl == 0) ? 1 : 0); - - } - return BP_NOT_CAP; -} - -int default_pwron_disc_status(bpctl_dev_t *pbpctl_dev) -{ - if (pbpctl_dev->bp_caps & DISC_PWUP_CTL_CAP) { - if (pbpctl_dev->bp_ext_ver >= 0x8) - return ((((read_reg(pbpctl_dev, STATUS_DISC_REG_ADDR)) & - DFLT_PWRON_DISC_MASK) == - DFLT_PWRON_DISC_MASK) ? 1 : 0); - } - return BP_NOT_CAP; -} - -int dis_disc_cap_status(bpctl_dev_t *pbpctl_dev) -{ - if (pbpctl_dev->bp_caps & DIS_DISC_CAP) { - if (pbpctl_dev->bp_ext_ver >= 0x8) - return ((((read_reg(pbpctl_dev, STATUS_DISC_REG_ADDR)) & - DIS_DISC_CAP_MASK) == - DIS_DISC_CAP_MASK) ? 1 : 0); - } - return BP_NOT_CAP; -} - -int disc_port_status(bpctl_dev_t *pbpctl_dev) -{ - int ret = BP_NOT_CAP; - bpctl_dev_t *pbpctl_dev_m; - - if ((is_bypass_fn(pbpctl_dev)) == 1) - pbpctl_dev_m = pbpctl_dev; - else - pbpctl_dev_m = get_master_port_fn(pbpctl_dev); - if (pbpctl_dev_m == NULL) - return BP_NOT_CAP; - - if (pbpctl_dev_m->bp_caps_ex & DISC_PORT_CAP_EX) { - if (is_bypass_fn(pbpctl_dev) == 1) { - return ((((read_reg(pbpctl_dev, STATUS_TAP_REG_ADDR)) & - TX_DISA_MASK) == TX_DISA_MASK) ? 1 : 0); - } else - return ((((read_reg(pbpctl_dev, STATUS_TAP_REG_ADDR)) & - TX_DISB_MASK) == TX_DISB_MASK) ? 1 : 0); - - } - return ret; -} - -int default_pwron_disc_port_status(bpctl_dev_t *pbpctl_dev) -{ - int ret = BP_NOT_CAP; - bpctl_dev_t *pbpctl_dev_m; - - if ((is_bypass_fn(pbpctl_dev)) == 1) - pbpctl_dev_m = pbpctl_dev; - else - pbpctl_dev_m = get_master_port_fn(pbpctl_dev); - if (pbpctl_dev_m == NULL) - return BP_NOT_CAP; - - if (pbpctl_dev_m->bp_caps_ex & DISC_PORT_CAP_EX) { - if (is_bypass_fn(pbpctl_dev) == 1) - return ret; - /* return((((read_reg(pbpctl_dev,STATUS_TAP_REG_ADDR)) & TX_DISA_MASK)==TX_DISA_MASK)?1:0); */ - else - return ret; - /* return((((read_reg(pbpctl_dev,STATUS_TAP_REG_ADDR)) & TX_DISA_MASK)==TX_DISA_MASK)?1:0); */ - - } - return ret; -} - -int wdt_exp_mode_status(bpctl_dev_t *pbpctl_dev) -{ - if (pbpctl_dev->bp_caps & WD_CTL_CAP) { - if (pbpctl_dev->bp_ext_ver <= PXG2BPI_VER) - return 0; /* bypass mode */ - else if (pbpctl_dev->bp_ext_ver == PXG2TBPI_VER) - return 1; /* tap mode */ - else if (pbpctl_dev->bp_ext_ver >= PXE2TBPI_VER) { - if (pbpctl_dev->bp_ext_ver >= 0x8) { - if (((read_reg - (pbpctl_dev, - STATUS_DISC_REG_ADDR)) & - WDTE_DISC_BPN_MASK) == WDTE_DISC_BPN_MASK) - return 2; - } - return ((((read_reg(pbpctl_dev, STATUS_TAP_REG_ADDR)) & - WDTE_TAP_BPN_MASK) == - WDTE_TAP_BPN_MASK) ? 1 : 0); - } - } - return BP_NOT_CAP; -} - -int tpl2_flag_status(bpctl_dev_t *pbpctl_dev) -{ - - if (pbpctl_dev->bp_caps_ex & TPL2_CAP_EX) { - return ((((read_reg(pbpctl_dev, STATUS_DISC_REG_ADDR)) & - TPL2_FLAG_MASK) == TPL2_FLAG_MASK) ? 1 : 0); - - } - return BP_NOT_CAP; -} - -int tpl_hw_status(bpctl_dev_t *pbpctl_dev) -{ - bpctl_dev_t *pbpctl_dev_b = NULL; - - if (!(pbpctl_dev_b = get_status_port_fn(pbpctl_dev))) - return BP_NOT_CAP; - - if (TPL_IF_SERIES(pbpctl_dev->subdevice)) - return (((BPCTL_READ_REG(pbpctl_dev, CTRL)) & - BPCTLI_CTRL_SWDPIN0) != 0 ? 1 : 0); - return BP_NOT_CAP; -} - - -int bp_wait_at_pwup_status(bpctl_dev_t *pbpctl_dev) -{ - if (pbpctl_dev->bp_caps & SW_CTL_CAP) { - if (pbpctl_dev->bp_ext_ver >= 0x8) - return ((((read_reg(pbpctl_dev, CONT_CONFIG_REG_ADDR)) & - WAIT_AT_PWUP_MASK) == - WAIT_AT_PWUP_MASK) ? 1 : 0); - } - return BP_NOT_CAP; -} - -int bp_hw_reset_status(bpctl_dev_t *pbpctl_dev) -{ - - if (pbpctl_dev->bp_caps & SW_CTL_CAP) { - - if (pbpctl_dev->bp_ext_ver >= 0x8) - return ((((read_reg(pbpctl_dev, CONT_CONFIG_REG_ADDR)) & - EN_HW_RESET_MASK) == - EN_HW_RESET_MASK) ? 1 : 0); - } - return BP_NOT_CAP; -} - - -int std_nic_status(bpctl_dev_t *pbpctl_dev) -{ - int status_val = 0; - - if (pbpctl_dev->bp_caps & STD_NIC_CAP) { - if (INTEL_IF_SERIES(pbpctl_dev->subdevice)) - return BP_NOT_CAP; - if (pbpctl_dev->bp_ext_ver >= BP_FW_EXT_VER8) { - return ((((read_reg(pbpctl_dev, STATUS_DISC_REG_ADDR)) & - STD_NIC_ON_MASK) == STD_NIC_ON_MASK) ? 1 : 0); - } - - if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { - if (pbpctl_dev->bp_caps & BP_CAP) { - status_val = - read_reg(pbpctl_dev, STATUS_REG_ADDR); - if (((!(status_val & WDT_EN_MASK)) - && ((status_val & STD_NIC_MASK) == - STD_NIC_MASK))) - status_val = 1; - else - return 0; - } - if (pbpctl_dev->bp_caps & TAP_CAP) { - status_val = - read_reg(pbpctl_dev, STATUS_TAP_REG_ADDR); - if ((status_val & STD_NIC_TAP_MASK) == - STD_NIC_TAP_MASK) - status_val = 1; - else - return 0; - } - if (pbpctl_dev->bp_caps & TAP_CAP) { - if ((disc_off_status(pbpctl_dev))) - status_val = 1; - else - return 0; - } - - return status_val; - } - } - return BP_NOT_CAP; -} - -/******************************************************/ -/**************SW_INIT*********************************/ -/******************************************************/ -void bypass_caps_init(bpctl_dev_t *pbpctl_dev) -{ - u_int32_t ctrl_ext = 0; - bpctl_dev_t *pbpctl_dev_m = NULL; - -#ifdef BYPASS_DEBUG - int ret = 0; - if (!(INTEL_IF_SERIES(adapter->bp_device_block.subdevice))) { - ret = read_reg(pbpctl_dev, VER_REG_ADDR); - printk("VER_REG reg1=%x\n", ret); - ret = read_reg(pbpctl_dev, PRODUCT_CAP_REG_ADDR); - printk("PRODUCT_CAP reg=%x\n", ret); - ret = read_reg(pbpctl_dev, STATUS_TAP_REG_ADDR); - printk("STATUS_TAP reg1=%x\n", ret); - ret = read_reg(pbpctl_dev, 0x7); - printk("SIG_REG reg1=%x\n", ret); - ret = read_reg(pbpctl_dev, STATUS_REG_ADDR); - printk("STATUS_REG_ADDR=%x\n", ret); - ret = read_reg(pbpctl_dev, WDT_REG_ADDR); - printk("WDT_REG_ADDR=%x\n", ret); - ret = read_reg(pbpctl_dev, TMRL_REG_ADDR); - printk("TMRL_REG_ADDR=%x\n", ret); - ret = read_reg(pbpctl_dev, TMRH_REG_ADDR); - printk("TMRH_REG_ADDR=%x\n", ret); - } -#endif - if ((pbpctl_dev->bp_fiber5) || (pbpctl_dev->bp_10g9)) { - pbpctl_dev->media_type = bp_fiber; - } else if (pbpctl_dev->bp_10gb) { - if (BP10GB_CX4_SERIES(pbpctl_dev->subdevice)) - pbpctl_dev->media_type = bp_cx4; - else - pbpctl_dev->media_type = bp_fiber; - - } - - else if (pbpctl_dev->bp_540) - pbpctl_dev->media_type = bp_none; - else if (!pbpctl_dev->bp_10g) { - - ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); - if ((ctrl_ext & BPCTLI_CTRL_EXT_LINK_MODE_MASK) == 0x0) - pbpctl_dev->media_type = bp_copper; - else - pbpctl_dev->media_type = bp_fiber; - - } else { - if (BP10G_CX4_SERIES(pbpctl_dev->subdevice)) - pbpctl_dev->media_type = bp_cx4; - else - pbpctl_dev->media_type = bp_fiber; - } - - if (is_bypass_fn(pbpctl_dev)) { - - pbpctl_dev->bp_caps |= BP_PWOFF_ON_CAP; - if (pbpctl_dev->media_type == bp_fiber) - pbpctl_dev->bp_caps |= - (TX_CTL_CAP | TX_STATUS_CAP | TPL_CAP); - - if (TPL_IF_SERIES(pbpctl_dev->subdevice)) { - pbpctl_dev->bp_caps |= TPL_CAP; - } - - if (INTEL_IF_SERIES(pbpctl_dev->subdevice)) { - pbpctl_dev->bp_caps |= - (BP_CAP | BP_STATUS_CAP | SW_CTL_CAP | - BP_PWUP_ON_CAP | BP_PWUP_OFF_CAP | BP_PWOFF_OFF_CAP - | WD_CTL_CAP | WD_STATUS_CAP | STD_NIC_CAP | - WD_TIMEOUT_CAP); - - pbpctl_dev->bp_ext_ver = OLD_IF_VER; - return; - } - - if ((pbpctl_dev->bp_fw_ver == 0xff) && - OLD_IF_SERIES(pbpctl_dev->subdevice)) { - - pbpctl_dev->bp_caps |= - (BP_CAP | BP_STATUS_CAP | BP_STATUS_CHANGE_CAP | - SW_CTL_CAP | BP_PWUP_ON_CAP | WD_CTL_CAP | - WD_STATUS_CAP | WD_TIMEOUT_CAP); - - pbpctl_dev->bp_ext_ver = OLD_IF_VER; - return; - } - - else { - switch (pbpctl_dev->bp_fw_ver) { - case BP_FW_VER_A0: - case BP_FW_VER_A1:{ - pbpctl_dev->bp_ext_ver = - (pbpctl_dev-> - bp_fw_ver & EXT_VER_MASK); - break; - } - default:{ - if ((bypass_sign_check(pbpctl_dev)) != - 1) { - pbpctl_dev->bp_caps = 0; - return; - } - pbpctl_dev->bp_ext_ver = - (pbpctl_dev-> - bp_fw_ver & EXT_VER_MASK); - } - } - } - - if (pbpctl_dev->bp_ext_ver == PXG2BPI_VER) - pbpctl_dev->bp_caps |= - (BP_CAP | BP_STATUS_CAP | BP_STATUS_CHANGE_CAP | - SW_CTL_CAP | BP_DIS_CAP | BP_DIS_STATUS_CAP | - BP_PWUP_ON_CAP | BP_PWUP_OFF_CAP | BP_PWUP_CTL_CAP - | WD_CTL_CAP | STD_NIC_CAP | WD_STATUS_CAP | - WD_TIMEOUT_CAP); - else if (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER) { - int cap_reg; - - pbpctl_dev->bp_caps |= - (SW_CTL_CAP | WD_CTL_CAP | WD_STATUS_CAP | - WD_TIMEOUT_CAP); - cap_reg = get_bp_prod_caps(pbpctl_dev); - - if ((cap_reg & NORMAL_UNSUPPORT_MASK) == - NORMAL_UNSUPPORT_MASK) - pbpctl_dev->bp_caps |= NIC_CAP_NEG; - else - pbpctl_dev->bp_caps |= STD_NIC_CAP; - - if ((normal_support(pbpctl_dev)) == 1) - - pbpctl_dev->bp_caps |= STD_NIC_CAP; - - else - pbpctl_dev->bp_caps |= NIC_CAP_NEG; - if ((cap_reg & BYPASS_SUPPORT_MASK) == - BYPASS_SUPPORT_MASK) { - pbpctl_dev->bp_caps |= - (BP_CAP | BP_STATUS_CAP | - BP_STATUS_CHANGE_CAP | BP_DIS_CAP | - BP_DIS_STATUS_CAP | BP_PWUP_ON_CAP | - BP_PWUP_OFF_CAP | BP_PWUP_CTL_CAP); - if (pbpctl_dev->bp_ext_ver >= BP_FW_EXT_VER7) - pbpctl_dev->bp_caps |= - BP_PWOFF_ON_CAP | BP_PWOFF_OFF_CAP | - BP_PWOFF_CTL_CAP; - } - if ((cap_reg & TAP_SUPPORT_MASK) == TAP_SUPPORT_MASK) { - pbpctl_dev->bp_caps |= - (TAP_CAP | TAP_STATUS_CAP | - TAP_STATUS_CHANGE_CAP | TAP_DIS_CAP | - TAP_DIS_STATUS_CAP | TAP_PWUP_ON_CAP | - TAP_PWUP_OFF_CAP | TAP_PWUP_CTL_CAP); - } - if (pbpctl_dev->bp_ext_ver >= BP_FW_EXT_VER8) { - if ((cap_reg & DISC_SUPPORT_MASK) == - DISC_SUPPORT_MASK) - pbpctl_dev->bp_caps |= - (DISC_CAP | DISC_DIS_CAP | - DISC_PWUP_CTL_CAP); - if ((cap_reg & TPL2_SUPPORT_MASK) == - TPL2_SUPPORT_MASK) { - pbpctl_dev->bp_caps_ex |= TPL2_CAP_EX; - pbpctl_dev->bp_caps |= TPL_CAP; - pbpctl_dev->bp_tpl_flag = - tpl2_flag_status(pbpctl_dev); - } - - } - - if (pbpctl_dev->bp_ext_ver >= BP_FW_EXT_VER9) { - if ((cap_reg & DISC_PORT_SUPPORT_MASK) == - DISC_PORT_SUPPORT_MASK) { - pbpctl_dev->bp_caps_ex |= - DISC_PORT_CAP_EX; - pbpctl_dev->bp_caps |= - (TX_CTL_CAP | TX_STATUS_CAP); - } - - } - - } - if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { - if ((read_reg(pbpctl_dev, STATUS_REG_ADDR)) & - WDT_EN_MASK) - pbpctl_dev->wdt_status = WDT_STATUS_EN; - else - pbpctl_dev->wdt_status = WDT_STATUS_DIS; - } - - } else if ((P2BPFI_IF_SERIES(pbpctl_dev->subdevice)) || - (PEGF5_IF_SERIES(pbpctl_dev->subdevice)) || - (PEGF80_IF_SERIES(pbpctl_dev->subdevice)) || - (BP10G9_IF_SERIES(pbpctl_dev->subdevice))) { - pbpctl_dev->bp_caps |= (TX_CTL_CAP | TX_STATUS_CAP); - } - if ((pbpctl_dev->subdevice & 0xa00) == 0xa00) - pbpctl_dev->bp_caps |= (TX_CTL_CAP | TX_STATUS_CAP); - if (PEG5_IF_SERIES(pbpctl_dev->subdevice)) - pbpctl_dev->bp_caps |= (TX_CTL_CAP | TX_STATUS_CAP); - - if (BP10GB_IF_SERIES(pbpctl_dev->subdevice)) { - pbpctl_dev->bp_caps &= ~(TX_CTL_CAP | TX_STATUS_CAP); - } - pbpctl_dev_m = get_master_port_fn(pbpctl_dev); - if (pbpctl_dev_m != NULL) { - int cap_reg = 0; - if (pbpctl_dev_m->bp_ext_ver >= 0x9) { - cap_reg = get_bp_prod_caps(pbpctl_dev_m); - if ((cap_reg & DISC_PORT_SUPPORT_MASK) == - DISC_PORT_SUPPORT_MASK) - pbpctl_dev->bp_caps |= - (TX_CTL_CAP | TX_STATUS_CAP); - pbpctl_dev->bp_caps_ex |= DISC_PORT_CAP_EX; - } - } -} - -int bypass_off_init(bpctl_dev_t *pbpctl_dev) -{ - int ret = 0; - - if ((ret = cmnd_on(pbpctl_dev)) < 0) - return ret; - if (INTEL_IF_SERIES(pbpctl_dev->subdevice)) - return dis_bypass_cap(pbpctl_dev); - wdt_off(pbpctl_dev); - if (pbpctl_dev->bp_caps & BP_CAP) - bypass_off(pbpctl_dev); - if (pbpctl_dev->bp_caps & TAP_CAP) - tap_off(pbpctl_dev); - cmnd_off(pbpctl_dev); - return 0; -} - -void remove_bypass_wd_auto(bpctl_dev_t *pbpctl_dev) -{ -#ifdef BP_SELF_TEST - bpctl_dev_t *pbpctl_dev_sl = NULL; -#endif - - if (pbpctl_dev->bp_caps & WD_CTL_CAP) { - - del_timer_sync(&pbpctl_dev->bp_timer); -#ifdef BP_SELF_TEST - pbpctl_dev_sl = get_status_port_fn(pbpctl_dev); - if (pbpctl_dev_sl && (pbpctl_dev_sl->ndev)) { - if ((pbpctl_dev_sl->ndev->netdev_ops) - && (pbpctl_dev_sl->old_ops)) { - rtnl_lock(); - pbpctl_dev_sl->ndev->netdev_ops = - pbpctl_dev_sl->old_ops; - pbpctl_dev_sl->old_ops = NULL; - - rtnl_unlock(); - - } - - } -#endif - } - -} - -int init_bypass_wd_auto(bpctl_dev_t *pbpctl_dev) -{ - if (pbpctl_dev->bp_caps & WD_CTL_CAP) { - init_timer(&pbpctl_dev->bp_timer); - pbpctl_dev->bp_timer.function = &wd_reset_timer; - pbpctl_dev->bp_timer.data = (unsigned long)pbpctl_dev; - return 1; - } - return BP_NOT_CAP; -} - -#ifdef BP_SELF_TEST -int bp_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) -{ - bpctl_dev_t *pbpctl_dev = NULL, *pbpctl_dev_m = NULL; - int idx_dev = 0; - struct ethhdr *eth = (struct ethhdr *)skb->data; - - for (idx_dev = 0; - ((bpctl_dev_arr[idx_dev].ndev != NULL) && (idx_dev < device_num)); - idx_dev++) { - if (bpctl_dev_arr[idx_dev].ndev == dev) { - pbpctl_dev = &bpctl_dev_arr[idx_dev]; - break; - } - } - if (!pbpctl_dev) - return 1; - if ((htons(ETH_P_BPTEST) == eth->h_proto)) { - - pbpctl_dev_m = get_master_port_fn(pbpctl_dev); - if (pbpctl_dev_m) { - - if (bypass_status(pbpctl_dev_m)) { - cmnd_on(pbpctl_dev_m); - bypass_off(pbpctl_dev_m); - cmnd_off(pbpctl_dev_m); - } - wdt_timer_reload(pbpctl_dev_m); - } - dev_kfree_skb_irq(skb); - return 0; - } - return pbpctl_dev->hard_start_xmit_save(skb, dev); -} -#endif - -int set_bypass_wd_auto(bpctl_dev_t *pbpctl_dev, unsigned int param) -{ - if (pbpctl_dev->bp_caps & WD_CTL_CAP) { - if (pbpctl_dev->reset_time != param) { - if (INTEL_IF_SERIES(pbpctl_dev->subdevice)) - pbpctl_dev->reset_time = - (param < - WDT_AUTO_MIN_INT) ? WDT_AUTO_MIN_INT : - param; - else - pbpctl_dev->reset_time = param; - if (param) - mod_timer(&pbpctl_dev->bp_timer, jiffies); - } - return 0; - } - return BP_NOT_CAP; -} - -int get_bypass_wd_auto(bpctl_dev_t *pbpctl_dev) -{ - - if (pbpctl_dev->bp_caps & WD_CTL_CAP) { - return pbpctl_dev->reset_time; - } - return BP_NOT_CAP; -} - -#ifdef BP_SELF_TEST - -int set_bp_self_test(bpctl_dev_t *pbpctl_dev, unsigned int param) -{ - bpctl_dev_t *pbpctl_dev_sl = NULL; - - if (pbpctl_dev->bp_caps & WD_CTL_CAP) { - pbpctl_dev->bp_self_test_flag = param == 0 ? 0 : 1; - pbpctl_dev_sl = get_status_port_fn(pbpctl_dev); - - if ((pbpctl_dev_sl->ndev) && (pbpctl_dev_sl->ndev->netdev_ops)) { - rtnl_lock(); - if (pbpctl_dev->bp_self_test_flag == 1) { - - pbpctl_dev_sl->old_ops = - pbpctl_dev_sl->ndev->netdev_ops; - pbpctl_dev_sl->new_ops = - *pbpctl_dev_sl->old_ops; - pbpctl_dev_sl->new_ops.ndo_start_xmit = - bp_hard_start_xmit; - pbpctl_dev_sl->ndev->netdev_ops = - &pbpctl_dev_sl->new_ops; - - } else if (pbpctl_dev_sl->old_ops) { - pbpctl_dev_sl->ndev->netdev_ops = - pbpctl_dev_sl->old_ops; - pbpctl_dev_sl->old_ops = NULL; - } - rtnl_unlock(); - } - - set_bypass_wd_auto(pbpctl_dev, param); - return 0; - } - return BP_NOT_CAP; -} - -int get_bp_self_test(bpctl_dev_t *pbpctl_dev) -{ - - if (pbpctl_dev->bp_caps & WD_CTL_CAP) { - if (pbpctl_dev->bp_self_test_flag == 1) - return pbpctl_dev->reset_time; - else - return 0; - } - return BP_NOT_CAP; -} - -#endif - -/**************************************************************/ -/************************* API ********************************/ -/**************************************************************/ - -int is_bypass_fn(bpctl_dev_t *pbpctl_dev) -{ - if (!pbpctl_dev) - return -1; - - return (((pbpctl_dev->func == 0) || (pbpctl_dev->func == 2)) ? 1 : 0); -} - -int set_bypass_fn(bpctl_dev_t *pbpctl_dev, int bypass_mode) -{ - int ret = 0; - - if (!(pbpctl_dev->bp_caps & BP_CAP)) - return BP_NOT_CAP; - if ((ret = cmnd_on(pbpctl_dev)) < 0) - return ret; - if (!bypass_mode) - ret = bypass_off(pbpctl_dev); - else - ret = bypass_on(pbpctl_dev); - cmnd_off(pbpctl_dev); - - return ret; -} - -int get_bypass_fn(bpctl_dev_t *pbpctl_dev) -{ - return bypass_status(pbpctl_dev); -} - -int get_bypass_change_fn(bpctl_dev_t *pbpctl_dev) -{ - if (!pbpctl_dev) - return -1; - - return bypass_change_status(pbpctl_dev); -} - -int set_dis_bypass_fn(bpctl_dev_t *pbpctl_dev, int dis_param) -{ - int ret = 0; - if (!pbpctl_dev) - return -1; - - if (!(pbpctl_dev->bp_caps & BP_DIS_CAP)) - return BP_NOT_CAP; - if ((ret = cmnd_on(pbpctl_dev)) < 0) - return ret; - if (dis_param) - ret = dis_bypass_cap(pbpctl_dev); - else - ret = en_bypass_cap(pbpctl_dev); - cmnd_off(pbpctl_dev); - return ret; -} - -int get_dis_bypass_fn(bpctl_dev_t *pbpctl_dev) -{ - if (!pbpctl_dev) - return -1; - - return dis_bypass_cap_status(pbpctl_dev); -} - -int set_bypass_pwoff_fn(bpctl_dev_t *pbpctl_dev, int bypass_mode) -{ - int ret = 0; - if (!pbpctl_dev) - return -1; - - if (!(pbpctl_dev->bp_caps & BP_PWOFF_CTL_CAP)) - return BP_NOT_CAP; - if ((ret = cmnd_on(pbpctl_dev)) < 0) - return ret; - if (bypass_mode) - ret = bypass_state_pwroff(pbpctl_dev); - else - ret = normal_state_pwroff(pbpctl_dev); - cmnd_off(pbpctl_dev); - return ret; -} - -int get_bypass_pwoff_fn(bpctl_dev_t *pbpctl_dev) -{ - if (!pbpctl_dev) - return -1; - - return default_pwroff_status(pbpctl_dev); -} - -int set_bypass_pwup_fn(bpctl_dev_t *pbpctl_dev, int bypass_mode) -{ - int ret = 0; - if (!pbpctl_dev) - return -1; - - if (!(pbpctl_dev->bp_caps & BP_PWUP_CTL_CAP)) - return BP_NOT_CAP; - if ((ret = cmnd_on(pbpctl_dev)) < 0) - return ret; - if (bypass_mode) - ret = bypass_state_pwron(pbpctl_dev); - else - ret = normal_state_pwron(pbpctl_dev); - cmnd_off(pbpctl_dev); - return ret; -} - -int get_bypass_pwup_fn(bpctl_dev_t *pbpctl_dev) -{ - if (!pbpctl_dev) - return -1; - - return default_pwron_status(pbpctl_dev); -} - -int set_bypass_wd_fn(bpctl_dev_t *pbpctl_dev, int timeout) -{ - int ret = 0; - if (!pbpctl_dev) - return -1; - - if (!(pbpctl_dev->bp_caps & WD_CTL_CAP)) - return BP_NOT_CAP; - - if ((ret = cmnd_on(pbpctl_dev)) < 0) - return ret; - if (!timeout) - ret = wdt_off(pbpctl_dev); - else { - wdt_on(pbpctl_dev, timeout); - ret = pbpctl_dev->bypass_timer_interval; - } - cmnd_off(pbpctl_dev); - return ret; -} - -int get_bypass_wd_fn(bpctl_dev_t *pbpctl_dev, int *timeout) -{ - if (!pbpctl_dev) - return -1; - - return wdt_programmed(pbpctl_dev, timeout); -} - -int get_wd_expire_time_fn(bpctl_dev_t *pbpctl_dev, int *time_left) -{ - if (!pbpctl_dev) - return -1; - - return wdt_timer(pbpctl_dev, time_left); -} - -int reset_bypass_wd_timer_fn(bpctl_dev_t *pbpctl_dev) -{ - if (!pbpctl_dev) - return -1; - - return wdt_timer_reload(pbpctl_dev); -} - -int get_wd_set_caps_fn(bpctl_dev_t *pbpctl_dev) -{ - int bp_status = 0; - - unsigned int step_value = TIMEOUT_MAX_STEP + 1, bit_cnt = 0; - if (!pbpctl_dev) - return -1; - - if (INTEL_IF_SERIES(pbpctl_dev->subdevice)) - return BP_NOT_CAP; - - while ((step_value >>= 1)) - bit_cnt++; - - if (is_bypass_fn(pbpctl_dev)) { - bp_status = - WD_STEP_COUNT_MASK(bit_cnt) | WDT_STEP_TIME | - WD_MIN_TIME_MASK(TIMEOUT_UNIT / 100); - } else - return -1; - - return bp_status; -} - -int set_std_nic_fn(bpctl_dev_t *pbpctl_dev, int nic_mode) -{ - int ret = 0; - if (!pbpctl_dev) - return -1; - - if (!(pbpctl_dev->bp_caps & STD_NIC_CAP)) - return BP_NOT_CAP; - - if ((ret = cmnd_on(pbpctl_dev)) < 0) - return ret; - if (nic_mode) - ret = std_nic_on(pbpctl_dev); - else - ret = std_nic_off(pbpctl_dev); - cmnd_off(pbpctl_dev); - return ret; -} - -int get_std_nic_fn(bpctl_dev_t *pbpctl_dev) -{ - if (!pbpctl_dev) - return -1; - - return std_nic_status(pbpctl_dev); -} - -int set_tap_fn(bpctl_dev_t *pbpctl_dev, int tap_mode) -{ - if (!pbpctl_dev) - return -1; - - if ((pbpctl_dev->bp_caps & TAP_CAP) && ((cmnd_on(pbpctl_dev)) >= 0)) { - if (!tap_mode) - tap_off(pbpctl_dev); - else - tap_on(pbpctl_dev); - cmnd_off(pbpctl_dev); - return 0; - } - return BP_NOT_CAP; -} - -int get_tap_fn(bpctl_dev_t *pbpctl_dev) -{ - if (!pbpctl_dev) - return -1; - - return tap_status(pbpctl_dev); -} - -int set_tap_pwup_fn(bpctl_dev_t *pbpctl_dev, int tap_mode) -{ - int ret = 0; - if (!pbpctl_dev) - return -1; - - if ((pbpctl_dev->bp_caps & TAP_PWUP_CTL_CAP) - && ((cmnd_on(pbpctl_dev)) >= 0)) { - if (tap_mode) - ret = tap_state_pwron(pbpctl_dev); - else - ret = normal_state_pwron(pbpctl_dev); - cmnd_off(pbpctl_dev); - } else - ret = BP_NOT_CAP; - return ret; -} - -int get_tap_pwup_fn(bpctl_dev_t *pbpctl_dev) -{ - int ret = 0; - if (!pbpctl_dev) - return -1; - - if ((ret = default_pwron_tap_status(pbpctl_dev)) < 0) - return ret; - return ((ret == 0) ? 1 : 0); -} - -int get_tap_change_fn(bpctl_dev_t *pbpctl_dev) -{ - if (!pbpctl_dev) - return -1; - - return tap_change_status(pbpctl_dev); -} - -int set_dis_tap_fn(bpctl_dev_t *pbpctl_dev, int dis_param) -{ - int ret = 0; - if (!pbpctl_dev) - return -1; - - if ((pbpctl_dev->bp_caps & TAP_DIS_CAP) && ((cmnd_on(pbpctl_dev)) >= 0)) { - if (dis_param) - ret = dis_tap_cap(pbpctl_dev); - else - ret = en_tap_cap(pbpctl_dev); - cmnd_off(pbpctl_dev); - return ret; - } else - return BP_NOT_CAP; -} - -int get_dis_tap_fn(bpctl_dev_t *pbpctl_dev) -{ - if (!pbpctl_dev) - return -1; - - return dis_tap_cap_status(pbpctl_dev); -} - -int set_disc_fn(bpctl_dev_t *pbpctl_dev, int disc_mode) -{ - if (!pbpctl_dev) - return -1; - - if ((pbpctl_dev->bp_caps & DISC_CAP) && ((cmnd_on(pbpctl_dev)) >= 0)) { - if (!disc_mode) - disc_off(pbpctl_dev); - else - disc_on(pbpctl_dev); - cmnd_off(pbpctl_dev); - - return BP_OK; - } - return BP_NOT_CAP; -} - -int get_disc_fn(bpctl_dev_t *pbpctl_dev) -{ - int ret = 0; - if (!pbpctl_dev) - return -1; - - ret = disc_status(pbpctl_dev); - - return ret; -} - -int set_disc_pwup_fn(bpctl_dev_t *pbpctl_dev, int disc_mode) -{ - int ret = 0; - if (!pbpctl_dev) - return -1; - - if ((pbpctl_dev->bp_caps & DISC_PWUP_CTL_CAP) - && ((cmnd_on(pbpctl_dev)) >= 0)) { - if (disc_mode) - ret = disc_state_pwron(pbpctl_dev); - else - ret = normal_state_pwron(pbpctl_dev); - cmnd_off(pbpctl_dev); - } else - ret = BP_NOT_CAP; - return ret; -} - -int get_disc_pwup_fn(bpctl_dev_t *pbpctl_dev) -{ - int ret = 0; - if (!pbpctl_dev) - return -1; - - ret = default_pwron_disc_status(pbpctl_dev); - return (ret == 0 ? 1 : (ret < 0 ? BP_NOT_CAP : 0)); -} - -int get_disc_change_fn(bpctl_dev_t *pbpctl_dev) -{ - int ret = 0; - if (!pbpctl_dev) - return -1; - - ret = disc_change_status(pbpctl_dev); - return ret; -} - -int set_dis_disc_fn(bpctl_dev_t *pbpctl_dev, int dis_param) -{ - int ret = 0; - if (!pbpctl_dev) - return -1; - - if ((pbpctl_dev->bp_caps & DISC_DIS_CAP) - && ((cmnd_on(pbpctl_dev)) >= 0)) { - if (dis_param) - ret = dis_disc_cap(pbpctl_dev); - else - ret = en_disc_cap(pbpctl_dev); - cmnd_off(pbpctl_dev); - return ret; - } else - return BP_NOT_CAP; -} - -int get_dis_disc_fn(bpctl_dev_t *pbpctl_dev) -{ - int ret = 0; - if (!pbpctl_dev) - return -1; - - ret = dis_disc_cap_status(pbpctl_dev); - - return ret; -} - -int set_disc_port_fn(bpctl_dev_t *pbpctl_dev, int disc_mode) -{ - int ret = BP_NOT_CAP; - if (!pbpctl_dev) - return -1; - - if (!disc_mode) - ret = disc_port_off(pbpctl_dev); - else - ret = disc_port_on(pbpctl_dev); - - return ret; -} - -int get_disc_port_fn(bpctl_dev_t *pbpctl_dev) -{ - if (!pbpctl_dev) - return -1; - - return disc_port_status(pbpctl_dev); -} - -int set_disc_port_pwup_fn(bpctl_dev_t *pbpctl_dev, int disc_mode) -{ - int ret = BP_NOT_CAP; - if (!pbpctl_dev) - return -1; - - if (!disc_mode) - ret = normal_port_state_pwron(pbpctl_dev); - else - ret = disc_port_state_pwron(pbpctl_dev); - - return ret; -} - -int get_disc_port_pwup_fn(bpctl_dev_t *pbpctl_dev) -{ - int ret = 0; - if (!pbpctl_dev) - return -1; - - if ((ret = default_pwron_disc_port_status(pbpctl_dev)) < 0) - return ret; - return ((ret == 0) ? 1 : 0); -} - -int get_wd_exp_mode_fn(bpctl_dev_t *pbpctl_dev) -{ - if (!pbpctl_dev) - return -1; - - return wdt_exp_mode_status(pbpctl_dev); -} - -int set_wd_exp_mode_fn(bpctl_dev_t *pbpctl_dev, int param) -{ - if (!pbpctl_dev) - return -1; - - return wdt_exp_mode(pbpctl_dev, param); -} - -int reset_cont_fn(bpctl_dev_t *pbpctl_dev) -{ - int ret = 0; - if (!pbpctl_dev) - return -1; - - if ((ret = cmnd_on(pbpctl_dev)) < 0) - return ret; - return reset_cont(pbpctl_dev); -} - -int set_tx_fn(bpctl_dev_t *pbpctl_dev, int tx_state) -{ - - bpctl_dev_t *pbpctl_dev_b = NULL; - if (!pbpctl_dev) - return -1; - - if ((pbpctl_dev->bp_caps & TPL_CAP) && - (pbpctl_dev->bp_caps & SW_CTL_CAP)) { - if ((pbpctl_dev->bp_tpl_flag)) - return BP_NOT_CAP; - } else if ((pbpctl_dev_b = get_master_port_fn(pbpctl_dev))) { - if ((pbpctl_dev_b->bp_caps & TPL_CAP) && - (pbpctl_dev_b->bp_tpl_flag)) - return BP_NOT_CAP; - } - return set_tx(pbpctl_dev, tx_state); -} - -int set_bp_force_link_fn(int dev_num, int tx_state) -{ - static bpctl_dev_t *bpctl_dev_curr; - - if ((dev_num < 0) || (dev_num > device_num) - || (bpctl_dev_arr[dev_num].pdev == NULL)) - return -1; - bpctl_dev_curr = &bpctl_dev_arr[dev_num]; - - return set_bp_force_link(bpctl_dev_curr, tx_state); -} - -int set_wd_autoreset_fn(bpctl_dev_t *pbpctl_dev, int param) -{ - if (!pbpctl_dev) - return -1; - - return set_bypass_wd_auto(pbpctl_dev, param); -} - -int get_wd_autoreset_fn(bpctl_dev_t *pbpctl_dev) -{ - if (!pbpctl_dev) - return -1; - - return get_bypass_wd_auto(pbpctl_dev); -} - -#ifdef BP_SELF_TEST -int set_bp_self_test_fn(bpctl_dev_t *pbpctl_dev, int param) -{ - if (!pbpctl_dev) - return -1; - - return set_bp_self_test(pbpctl_dev, param); -} - -int get_bp_self_test_fn(bpctl_dev_t *pbpctl_dev) -{ - if (!pbpctl_dev) - return -1; - - return get_bp_self_test(pbpctl_dev); -} - -#endif - -int get_bypass_caps_fn(bpctl_dev_t *pbpctl_dev) -{ - if (!pbpctl_dev) - return -1; - - return pbpctl_dev->bp_caps; - -} - -int get_bypass_slave_fn(bpctl_dev_t *pbpctl_dev, bpctl_dev_t **pbpctl_dev_out) -{ - int idx_dev = 0; - if (!pbpctl_dev) - return -1; - - 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)) { - if ((pbpctl_dev->func == 0) - && (bpctl_dev_arr[idx_dev].func == 1)) { - *pbpctl_dev_out = - &bpctl_dev_arr[idx_dev]; - return 1; - } - if ((pbpctl_dev->func == 2) && - (bpctl_dev_arr[idx_dev].func == 3)) { - *pbpctl_dev_out = - &bpctl_dev_arr[idx_dev]; - return 1; - } - } - } - return -1; - } else - return 0; -} - -int is_bypass(bpctl_dev_t *pbpctl_dev) -{ - if (!pbpctl_dev) - return -1; - - if ((pbpctl_dev->func == 0) || (pbpctl_dev->func == 2)) - return 1; - else - return 0; -} - -int get_tx_fn(bpctl_dev_t *pbpctl_dev) -{ - bpctl_dev_t *pbpctl_dev_b = NULL; - if (!pbpctl_dev) - return -1; - - if ((pbpctl_dev->bp_caps & TPL_CAP) && - (pbpctl_dev->bp_caps & SW_CTL_CAP)) { - if ((pbpctl_dev->bp_tpl_flag)) - return BP_NOT_CAP; - } else if ((pbpctl_dev_b = get_master_port_fn(pbpctl_dev))) { - if ((pbpctl_dev_b->bp_caps & TPL_CAP) && - (pbpctl_dev_b->bp_tpl_flag)) - return BP_NOT_CAP; - } - return tx_status(pbpctl_dev); -} - -int get_bp_force_link_fn(int dev_num) -{ - static bpctl_dev_t *bpctl_dev_curr; - - if ((dev_num < 0) || (dev_num > device_num) - || (bpctl_dev_arr[dev_num].pdev == NULL)) - return -1; - bpctl_dev_curr = &bpctl_dev_arr[dev_num]; - - return bp_force_link_status(bpctl_dev_curr); -} - -static int get_bypass_link_status(bpctl_dev_t *pbpctl_dev) -{ - if (!pbpctl_dev) - return -1; - - if (pbpctl_dev->media_type == bp_fiber) - return ((BPCTL_READ_REG(pbpctl_dev, CTRL) & - BPCTLI_CTRL_SWDPIN1)); - else - return ((BPCTL_READ_REG(pbpctl_dev, STATUS) & - BPCTLI_STATUS_LU)); - -} - -static void bp_tpl_timer_fn(unsigned long param) -{ - bpctl_dev_t *pbpctl_dev = (bpctl_dev_t *) param; - uint32_t link1, link2; - bpctl_dev_t *pbpctl_dev_b = NULL; - - if (!(pbpctl_dev_b = get_status_port_fn(pbpctl_dev))) - return; - - if (!pbpctl_dev->bp_tpl_flag) { - set_tx(pbpctl_dev_b, 1); - set_tx(pbpctl_dev, 1); - return; - } - link1 = get_bypass_link_status(pbpctl_dev); - - link2 = get_bypass_link_status(pbpctl_dev_b); - if ((link1) && (tx_status(pbpctl_dev))) { - if ((!link2) && (tx_status(pbpctl_dev_b))) { - set_tx(pbpctl_dev, 0); - } else if (!tx_status(pbpctl_dev_b)) { - set_tx(pbpctl_dev_b, 1); - } - } else if ((!link1) && (tx_status(pbpctl_dev))) { - if ((link2) && (tx_status(pbpctl_dev_b))) { - set_tx(pbpctl_dev_b, 0); - } - } else if ((link1) && (!tx_status(pbpctl_dev))) { - if ((link2) && (tx_status(pbpctl_dev_b))) { - set_tx(pbpctl_dev, 1); - } - } else if ((!link1) && (!tx_status(pbpctl_dev))) { - if ((link2) && (tx_status(pbpctl_dev_b))) { - set_tx(pbpctl_dev, 1); - } - } - - mod_timer(&pbpctl_dev->bp_tpl_timer, jiffies + BP_LINK_MON_DELAY * HZ); -} - -void remove_bypass_tpl_auto(bpctl_dev_t *pbpctl_dev) -{ - bpctl_dev_t *pbpctl_dev_b = NULL; - if (!pbpctl_dev) - return; - pbpctl_dev_b = get_status_port_fn(pbpctl_dev); - - if (pbpctl_dev->bp_caps & TPL_CAP) { - del_timer_sync(&pbpctl_dev->bp_tpl_timer); - pbpctl_dev->bp_tpl_flag = 0; - pbpctl_dev_b = get_status_port_fn(pbpctl_dev); - if (pbpctl_dev_b) - set_tx(pbpctl_dev_b, 1); - set_tx(pbpctl_dev, 1); - } - return; -} - -int init_bypass_tpl_auto(bpctl_dev_t *pbpctl_dev) -{ - if (!pbpctl_dev) - return -1; - if (pbpctl_dev->bp_caps & TPL_CAP) { - init_timer(&pbpctl_dev->bp_tpl_timer); - pbpctl_dev->bp_tpl_timer.function = &bp_tpl_timer_fn; - pbpctl_dev->bp_tpl_timer.data = (unsigned long)pbpctl_dev; - return BP_OK; - } - return BP_NOT_CAP; -} - -int set_bypass_tpl_auto(bpctl_dev_t *pbpctl_dev, unsigned int param) -{ - if (!pbpctl_dev) - return -1; - if (pbpctl_dev->bp_caps & TPL_CAP) { - if ((param) && (!pbpctl_dev->bp_tpl_flag)) { - pbpctl_dev->bp_tpl_flag = param; - mod_timer(&pbpctl_dev->bp_tpl_timer, jiffies + 1); - return BP_OK; - }; - if ((!param) && (pbpctl_dev->bp_tpl_flag)) - remove_bypass_tpl_auto(pbpctl_dev); - - return BP_OK; - } - return BP_NOT_CAP; -} - -int get_bypass_tpl_auto(bpctl_dev_t *pbpctl_dev) -{ - if (!pbpctl_dev) - return -1; - if (pbpctl_dev->bp_caps & TPL_CAP) { - return pbpctl_dev->bp_tpl_flag; - } - return BP_NOT_CAP; -} - -int set_tpl_fn(bpctl_dev_t *pbpctl_dev, int tpl_mode) -{ - - bpctl_dev_t *pbpctl_dev_b = NULL; - if (!pbpctl_dev) - return -1; - - pbpctl_dev_b = get_status_port_fn(pbpctl_dev); - - if (pbpctl_dev->bp_caps & TPL_CAP) { - if (tpl_mode) { - if ((pbpctl_dev_b = get_status_port_fn(pbpctl_dev))) - set_tx(pbpctl_dev_b, 1); - set_tx(pbpctl_dev, 1); - } - if ((TPL_IF_SERIES(pbpctl_dev->subdevice)) || - (pbpctl_dev->bp_caps_ex & TPL2_CAP_EX)) { - pbpctl_dev->bp_tpl_flag = tpl_mode; - if (!tpl_mode) - tpl_hw_off(pbpctl_dev); - else - tpl_hw_on(pbpctl_dev); - } else - set_bypass_tpl_auto(pbpctl_dev, tpl_mode); - return 0; - } - return BP_NOT_CAP; -} - -int get_tpl_fn(bpctl_dev_t *pbpctl_dev) -{ - int ret = BP_NOT_CAP; - if (!pbpctl_dev) - return -1; - - if (pbpctl_dev->bp_caps & TPL_CAP) { - if (pbpctl_dev->bp_caps_ex & TPL2_CAP_EX) - return tpl2_flag_status(pbpctl_dev); - ret = pbpctl_dev->bp_tpl_flag; - } - return ret; -} - -int set_bp_wait_at_pwup_fn(bpctl_dev_t *pbpctl_dev, int tap_mode) -{ - if (!pbpctl_dev) - return -1; - - if (pbpctl_dev->bp_caps & SW_CTL_CAP) { - /* bp_lock(pbp_device_block); */ - cmnd_on(pbpctl_dev); - if (!tap_mode) - bp_wait_at_pwup_dis(pbpctl_dev); - else - bp_wait_at_pwup_en(pbpctl_dev); - cmnd_off(pbpctl_dev); - - /* bp_unlock(pbp_device_block); */ - return BP_OK; - } - return BP_NOT_CAP; -} - -int get_bp_wait_at_pwup_fn(bpctl_dev_t *pbpctl_dev) -{ - int ret = 0; - if (!pbpctl_dev) - return -1; - - /* bp_lock(pbp_device_block); */ - ret = bp_wait_at_pwup_status(pbpctl_dev); - /* bp_unlock(pbp_device_block); */ - - return ret; -} - -int set_bp_hw_reset_fn(bpctl_dev_t *pbpctl_dev, int tap_mode) -{ - if (!pbpctl_dev) - return -1; - - if (pbpctl_dev->bp_caps & SW_CTL_CAP) { - /* bp_lock(pbp_device_block); */ - cmnd_on(pbpctl_dev); - - if (!tap_mode) - bp_hw_reset_dis(pbpctl_dev); - else - bp_hw_reset_en(pbpctl_dev); - cmnd_off(pbpctl_dev); - /* bp_unlock(pbp_device_block); */ - return BP_OK; - } - return BP_NOT_CAP; -} - -int get_bp_hw_reset_fn(bpctl_dev_t *pbpctl_dev) -{ - int ret = 0; - if (!pbpctl_dev) - return -1; - - /* bp_lock(pbp_device_block); */ - ret = bp_hw_reset_status(pbpctl_dev); - - /* bp_unlock(pbp_device_block); */ - - return ret; -} - - -int get_bypass_info_fn(bpctl_dev_t *pbpctl_dev, char *dev_name, - char *add_param) -{ - if (!pbpctl_dev) - return -1; - if (!is_bypass_fn(pbpctl_dev)) - return -1; - strcpy(dev_name, pbpctl_dev->name); - *add_param = pbpctl_dev->bp_fw_ver; - return 0; -} - -int get_dev_idx_bsf(int bus, int slot, int func) -{ - int idx_dev = 0; - for (idx_dev = 0; - ((bpctl_dev_arr[idx_dev].pdev != NULL) && (idx_dev < device_num)); - idx_dev++) { - if ((bus == bpctl_dev_arr[idx_dev].bus) - && (slot == bpctl_dev_arr[idx_dev].slot) - && (func == bpctl_dev_arr[idx_dev].func)) - - return idx_dev; - } - return -1; -} - -static void str_low(char *str) -{ - int i; - - for (i = 0; i < strlen(str); i++) - if ((str[i] >= 65) && (str[i] <= 90)) - str[i] += 32; -} - -static unsigned long str_to_hex(char *p) -{ - unsigned long hex = 0; - unsigned long length = strlen(p), shift = 0; - unsigned char dig = 0; - - str_low(p); - length = strlen(p); - - if (length == 0) - return 0; - - do { - dig = p[--length]; - dig = dig < 'a' ? (dig - '0') : (dig - 'a' + 0xa); - hex |= (dig << shift); - shift += 4; - } while (length); - return hex; -} - -static int get_dev_idx(int ifindex) -{ - int idx_dev = 0; - - for (idx_dev = 0; - ((bpctl_dev_arr[idx_dev].pdev != NULL) && (idx_dev < device_num)); - idx_dev++) { - if (ifindex == bpctl_dev_arr[idx_dev].ifindex) - return idx_dev; - } - - return -1; -} - -static bpctl_dev_t *get_dev_idx_p(int ifindex) -{ - int idx_dev = 0; - - for (idx_dev = 0; - ((bpctl_dev_arr[idx_dev].pdev != NULL) && (idx_dev < device_num)); - idx_dev++) { - if (ifindex == bpctl_dev_arr[idx_dev].ifindex) - return &bpctl_dev_arr[idx_dev]; - } - - return NULL; -} - -static void if_scan_init(void) -{ - int idx_dev = 0; - struct net_device *dev; - int ifindex; - /* rcu_read_lock(); */ - /* rtnl_lock(); */ - /* rcu_read_lock(); */ - - for_each_netdev(&init_net, dev) { - - struct ethtool_drvinfo drvinfo; - char cbuf[32]; - char *buf = NULL; - char res[10]; - int i = 0; - int bus = 0, slot = 0, func = 0; - ifindex = dev->ifindex; - - memset(res, 0, 10); - memset(&drvinfo, 0, sizeof(struct ethtool_drvinfo)); - - if (dev->ethtool_ops && dev->ethtool_ops->get_drvinfo) { - memset(&drvinfo, 0, sizeof(drvinfo)); - dev->ethtool_ops->get_drvinfo(dev, &drvinfo); - } else - continue; - if (!strcmp(drvinfo.bus_info, "N/A")) - continue; - memcpy(&cbuf, drvinfo.bus_info, 32); - buf = &cbuf[0]; - - while (*buf++ != ':') ; - for (i = 0; i < 10; i++, buf++) { - if (*buf == ':') - break; - res[i] = *buf; - - } - buf++; - bus = str_to_hex(res); - memset(res, 0, 10); - - for (i = 0; i < 10; i++, buf++) { - if (*buf == '.') - break; - res[i] = *buf; - - } - buf++; - slot = str_to_hex(res); - func = str_to_hex(buf); - idx_dev = get_dev_idx_bsf(bus, slot, func); - - if (idx_dev != -1) { - - bpctl_dev_arr[idx_dev].ifindex = ifindex; - bpctl_dev_arr[idx_dev].ndev = dev; - - } - - } - /* rtnl_unlock(); */ - /* rcu_read_unlock(); */ - -} - -static long device_ioctl(struct file *file, /* see include/linux/fs.h */ - unsigned int ioctl_num, /* number and param for ioctl */ - unsigned long ioctl_param) -{ - struct bpctl_cmd bpctl_cmd; - int dev_idx = 0; - bpctl_dev_t *pbpctl_dev_out; - void __user *argp = (void __user *)ioctl_param; - int ret = 0; - unsigned long flags; - - static bpctl_dev_t *pbpctl_dev; - - /* lock_kernel(); */ - lock_bpctl(); - /* local_irq_save(flags); */ - /* if(!spin_trylock_irqsave(&bpvm_lock)){ - local_irq_restore(flags); - unlock_bpctl(); - unlock_kernel(); - return -1; - } */ - /* spin_lock_irqsave(&bpvm_lock, flags); */ - -/* -* Switch according to the ioctl called -*/ - if (ioctl_num == IOCTL_TX_MSG(IF_SCAN)) { - if_scan_init(); - ret = SUCCESS; - goto bp_exit; - } - if (copy_from_user(&bpctl_cmd, argp, sizeof(struct bpctl_cmd))) { - - ret = -EFAULT; - goto bp_exit; - } - - if (ioctl_num == IOCTL_TX_MSG(GET_DEV_NUM)) { - bpctl_cmd.out_param[0] = device_num; - if (copy_to_user - (argp, (void *)&bpctl_cmd, sizeof(struct bpctl_cmd))) { - ret = -EFAULT; - goto bp_exit; - } - ret = SUCCESS; - goto bp_exit; - - } - /* lock_bpctl(); */ - /* preempt_disable(); */ - local_irq_save(flags); - if (!spin_trylock(&bpvm_lock)) { - local_irq_restore(flags); - unlock_bpctl(); - return -1; - } - -/* preempt_disable(); - rcu_read_lock(); - spin_lock_irqsave(&bpvm_lock, flags); -*/ - if ((bpctl_cmd.in_param[5]) || - (bpctl_cmd.in_param[6]) || (bpctl_cmd.in_param[7])) - dev_idx = get_dev_idx_bsf(bpctl_cmd.in_param[5], - bpctl_cmd.in_param[6], - bpctl_cmd.in_param[7]); - else if (bpctl_cmd.in_param[1] == 0) - dev_idx = bpctl_cmd.in_param[0]; - else - dev_idx = get_dev_idx(bpctl_cmd.in_param[1]); - - if (dev_idx < 0 || dev_idx > device_num) { - /* unlock_bpctl(); - preempt_enable(); */ - ret = -EOPNOTSUPP; - /* preempt_enable(); - rcu_read_unlock(); */ - spin_unlock_irqrestore(&bpvm_lock, flags); - goto bp_exit; - } - - bpctl_cmd.out_param[0] = bpctl_dev_arr[dev_idx].bus; - bpctl_cmd.out_param[1] = bpctl_dev_arr[dev_idx].slot; - bpctl_cmd.out_param[2] = bpctl_dev_arr[dev_idx].func; - bpctl_cmd.out_param[3] = bpctl_dev_arr[dev_idx].ifindex; - - if ((bpctl_dev_arr[dev_idx].bp_10gb) - && (!(bpctl_dev_arr[dev_idx].ifindex))) { - printk("Please load network driver for %s adapter!\n", - bpctl_dev_arr[dev_idx].name); - bpctl_cmd.status = -1; - ret = SUCCESS; - /* preempt_enable(); */ - /* rcu_read_unlock(); */ - spin_unlock_irqrestore(&bpvm_lock, flags); - goto bp_exit; - - } - if ((bpctl_dev_arr[dev_idx].bp_10gb) && (bpctl_dev_arr[dev_idx].ndev)) { - if (!(bpctl_dev_arr[dev_idx].ndev->flags & IFF_UP)) { - if (!(bpctl_dev_arr[dev_idx].ndev->flags & IFF_UP)) { - printk - ("Please bring up network interfaces for %s adapter!\n", - bpctl_dev_arr[dev_idx].name); - bpctl_cmd.status = -1; - ret = SUCCESS; - /* preempt_enable(); */ - /* rcu_read_unlock(); */ - spin_unlock_irqrestore(&bpvm_lock, flags); - goto bp_exit; - } - - } - } - - if ((dev_idx < 0) || (dev_idx > device_num) - || (bpctl_dev_arr[dev_idx].pdev == NULL)) { - bpctl_cmd.status = -1; - goto bpcmd_exit; - } - - pbpctl_dev = &bpctl_dev_arr[dev_idx]; - - switch (ioctl_num) { - case IOCTL_TX_MSG(SET_BYPASS_PWOFF): - bpctl_cmd.status = - set_bypass_pwoff_fn(pbpctl_dev, bpctl_cmd.in_param[2]); - break; - - case IOCTL_TX_MSG(GET_BYPASS_PWOFF): - bpctl_cmd.status = get_bypass_pwoff_fn(pbpctl_dev); - break; - - case IOCTL_TX_MSG(SET_BYPASS_PWUP): - bpctl_cmd.status = - set_bypass_pwup_fn(pbpctl_dev, bpctl_cmd.in_param[2]); - break; - - case IOCTL_TX_MSG(GET_BYPASS_PWUP): - bpctl_cmd.status = get_bypass_pwup_fn(pbpctl_dev); - break; - - case IOCTL_TX_MSG(SET_BYPASS_WD): - bpctl_cmd.status = - set_bypass_wd_fn(pbpctl_dev, bpctl_cmd.in_param[2]); - break; - - case IOCTL_TX_MSG(GET_BYPASS_WD): - bpctl_cmd.status = - get_bypass_wd_fn(pbpctl_dev, (int *)&(bpctl_cmd.data[0])); - break; - - case IOCTL_TX_MSG(GET_WD_EXPIRE_TIME): - bpctl_cmd.status = - get_wd_expire_time_fn(pbpctl_dev, - (int *)&(bpctl_cmd.data[0])); - break; - - case IOCTL_TX_MSG(RESET_BYPASS_WD_TIMER): - bpctl_cmd.status = reset_bypass_wd_timer_fn(pbpctl_dev); - break; - - case IOCTL_TX_MSG(GET_WD_SET_CAPS): - bpctl_cmd.status = get_wd_set_caps_fn(pbpctl_dev); - break; - - case IOCTL_TX_MSG(SET_STD_NIC): - bpctl_cmd.status = - set_std_nic_fn(pbpctl_dev, bpctl_cmd.in_param[2]); - break; - - case IOCTL_TX_MSG(GET_STD_NIC): - bpctl_cmd.status = get_std_nic_fn(pbpctl_dev); - break; - - case IOCTL_TX_MSG(SET_TAP): - bpctl_cmd.status = - set_tap_fn(pbpctl_dev, bpctl_cmd.in_param[2]); - break; - - case IOCTL_TX_MSG(GET_TAP): - bpctl_cmd.status = get_tap_fn(pbpctl_dev); - break; - - case IOCTL_TX_MSG(GET_TAP_CHANGE): - bpctl_cmd.status = get_tap_change_fn(pbpctl_dev); - break; - - case IOCTL_TX_MSG(SET_DIS_TAP): - bpctl_cmd.status = - set_dis_tap_fn(pbpctl_dev, bpctl_cmd.in_param[2]); - break; - - case IOCTL_TX_MSG(GET_DIS_TAP): - bpctl_cmd.status = get_dis_tap_fn(pbpctl_dev); - break; - - case IOCTL_TX_MSG(SET_TAP_PWUP): - bpctl_cmd.status = - set_tap_pwup_fn(pbpctl_dev, bpctl_cmd.in_param[2]); - break; - - case IOCTL_TX_MSG(GET_TAP_PWUP): - bpctl_cmd.status = get_tap_pwup_fn(pbpctl_dev); - break; - - case IOCTL_TX_MSG(SET_WD_EXP_MODE): - bpctl_cmd.status = - set_wd_exp_mode_fn(pbpctl_dev, bpctl_cmd.in_param[2]); - break; - - case IOCTL_TX_MSG(GET_WD_EXP_MODE): - bpctl_cmd.status = get_wd_exp_mode_fn(pbpctl_dev); - break; - - case IOCTL_TX_MSG(GET_DIS_BYPASS): - bpctl_cmd.status = get_dis_bypass_fn(pbpctl_dev); - break; - - case IOCTL_TX_MSG(SET_DIS_BYPASS): - bpctl_cmd.status = - set_dis_bypass_fn(pbpctl_dev, bpctl_cmd.in_param[2]); - break; - - case IOCTL_TX_MSG(GET_BYPASS_CHANGE): - bpctl_cmd.status = get_bypass_change_fn(pbpctl_dev); - break; - - case IOCTL_TX_MSG(GET_BYPASS): - bpctl_cmd.status = get_bypass_fn(pbpctl_dev); - break; - - case IOCTL_TX_MSG(SET_BYPASS): - bpctl_cmd.status = - set_bypass_fn(pbpctl_dev, bpctl_cmd.in_param[2]); - break; - - case IOCTL_TX_MSG(GET_BYPASS_CAPS): - bpctl_cmd.status = get_bypass_caps_fn(pbpctl_dev); - /*preempt_enable(); */ - /*rcu_read_unlock();*/ - spin_unlock_irqrestore(&bpvm_lock, flags); - if (copy_to_user - (argp, (void *)&bpctl_cmd, sizeof(struct bpctl_cmd))) { - /*unlock_bpctl(); */ - /*preempt_enable(); */ - ret = -EFAULT; - goto bp_exit; - } - goto bp_exit; - - case IOCTL_TX_MSG(GET_BYPASS_SLAVE): - bpctl_cmd.status = - get_bypass_slave_fn(pbpctl_dev, &pbpctl_dev_out); - if (bpctl_cmd.status == 1) { - bpctl_cmd.out_param[4] = pbpctl_dev_out->bus; - bpctl_cmd.out_param[5] = pbpctl_dev_out->slot; - bpctl_cmd.out_param[6] = pbpctl_dev_out->func; - bpctl_cmd.out_param[7] = pbpctl_dev_out->ifindex; - } - break; - - case IOCTL_TX_MSG(IS_BYPASS): - bpctl_cmd.status = is_bypass(pbpctl_dev); - break; - case IOCTL_TX_MSG(SET_TX): - bpctl_cmd.status = set_tx_fn(pbpctl_dev, bpctl_cmd.in_param[2]); - break; - case IOCTL_TX_MSG(GET_TX): - bpctl_cmd.status = get_tx_fn(pbpctl_dev); - break; - case IOCTL_TX_MSG(SET_WD_AUTORESET): - bpctl_cmd.status = - set_wd_autoreset_fn(pbpctl_dev, bpctl_cmd.in_param[2]); - - break; - case IOCTL_TX_MSG(GET_WD_AUTORESET): - - bpctl_cmd.status = get_wd_autoreset_fn(pbpctl_dev); - break; - case IOCTL_TX_MSG(SET_DISC): - bpctl_cmd.status = - set_disc_fn(pbpctl_dev, bpctl_cmd.in_param[2]); - break; - case IOCTL_TX_MSG(GET_DISC): - bpctl_cmd.status = get_disc_fn(pbpctl_dev); - break; - case IOCTL_TX_MSG(GET_DISC_CHANGE): - bpctl_cmd.status = get_disc_change_fn(pbpctl_dev); - break; - case IOCTL_TX_MSG(SET_DIS_DISC): - bpctl_cmd.status = - set_dis_disc_fn(pbpctl_dev, bpctl_cmd.in_param[2]); - break; - case IOCTL_TX_MSG(GET_DIS_DISC): - bpctl_cmd.status = get_dis_disc_fn(pbpctl_dev); - break; - case IOCTL_TX_MSG(SET_DISC_PWUP): - bpctl_cmd.status = - set_disc_pwup_fn(pbpctl_dev, bpctl_cmd.in_param[2]); - break; - case IOCTL_TX_MSG(GET_DISC_PWUP): - bpctl_cmd.status = get_disc_pwup_fn(pbpctl_dev); - break; - - case IOCTL_TX_MSG(GET_BYPASS_INFO): - - bpctl_cmd.status = - get_bypass_info_fn(pbpctl_dev, (char *)&bpctl_cmd.data, - (char *)&bpctl_cmd.out_param[4]); - break; - - case IOCTL_TX_MSG(SET_TPL): - bpctl_cmd.status = - set_tpl_fn(pbpctl_dev, bpctl_cmd.in_param[2]); - break; - - case IOCTL_TX_MSG(GET_TPL): - bpctl_cmd.status = get_tpl_fn(pbpctl_dev); - break; - case IOCTL_TX_MSG(SET_BP_WAIT_AT_PWUP): - bpctl_cmd.status = - set_bp_wait_at_pwup_fn(pbpctl_dev, bpctl_cmd.in_param[2]); - break; - - case IOCTL_TX_MSG(GET_BP_WAIT_AT_PWUP): - bpctl_cmd.status = get_bp_wait_at_pwup_fn(pbpctl_dev); - break; - case IOCTL_TX_MSG(SET_BP_HW_RESET): - bpctl_cmd.status = - set_bp_hw_reset_fn(pbpctl_dev, bpctl_cmd.in_param[2]); - break; - - case IOCTL_TX_MSG(GET_BP_HW_RESET): - bpctl_cmd.status = get_bp_hw_reset_fn(pbpctl_dev); - break; -#ifdef BP_SELF_TEST - case IOCTL_TX_MSG(SET_BP_SELF_TEST): - bpctl_cmd.status = - set_bp_self_test_fn(pbpctl_dev, bpctl_cmd.in_param[2]); - - break; - case IOCTL_TX_MSG(GET_BP_SELF_TEST): - bpctl_cmd.status = get_bp_self_test_fn(pbpctl_dev); - break; - -#endif -#if 0 - case IOCTL_TX_MSG(SET_DISC_PORT): - bpctl_cmd.status = - set_disc_port_fn(pbpctl_dev, bpctl_cmd.in_param[2]); - break; - - case IOCTL_TX_MSG(GET_DISC_PORT): - bpctl_cmd.status = get_disc_port_fn(pbpctl_dev); - break; - - case IOCTL_TX_MSG(SET_DISC_PORT_PWUP): - bpctl_cmd.status = - set_disc_port_pwup_fn(pbpctl_dev, bpctl_cmd.in_param[2]); - break; - - case IOCTL_TX_MSG(GET_DISC_PORT_PWUP): - bpctl_cmd.status = get_disc_port_pwup_fn(pbpctl_dev); - break; -#endif - case IOCTL_TX_MSG(SET_BP_FORCE_LINK): - bpctl_cmd.status = - set_bp_force_link_fn(dev_idx, bpctl_cmd.in_param[2]); - break; - - case IOCTL_TX_MSG(GET_BP_FORCE_LINK): - bpctl_cmd.status = get_bp_force_link_fn(dev_idx); - break; - - default: - /* unlock_bpctl(); */ - - ret = -EOPNOTSUPP; - /* preempt_enable(); */ - /* rcu_read_unlock();*/ - spin_unlock_irqrestore(&bpvm_lock, flags); - goto bp_exit; - } - /* unlock_bpctl(); */ - /* preempt_enable(); */ - bpcmd_exit: - /* rcu_read_unlock(); */ - spin_unlock_irqrestore(&bpvm_lock, flags); - if (copy_to_user(argp, (void *)&bpctl_cmd, sizeof(struct bpctl_cmd))) - ret = -EFAULT; - ret = SUCCESS; - bp_exit: - /* unlock_kernel(); */ - /* spin_unlock_irqrestore(&bpvm_lock, flags); */ - unlock_bpctl(); - /* unlock_kernel(); */ - return ret; -} - -struct file_operations Fops = { - .owner = THIS_MODULE, - .unlocked_ioctl = device_ioctl, - .open = device_open, - .release = device_release, /* a.k.a. close */ -}; - -#ifndef PCI_DEVICE -#define PCI_DEVICE(vend,dev) \ - .vendor = (vend), .device = (dev), \ - .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID -#endif - -#define SILICOM_E1000BP_ETHERNET_DEVICE(device_id) {\ - PCI_DEVICE(SILICOM_VID, device_id)} - -typedef enum { - PXG2BPFI, - PXG2BPFIL, - PXG2BPFILX, - PXG2BPFILLX, - PXGBPI, - PXGBPIG, - PXG2TBFI, - PXG4BPI, - PXG4BPFI, - PEG4BPI, - PEG2BPI, - PEG4BPIN, - PEG2BPFI, - PEG2BPFILX, - PMCXG2BPFI, - PMCXG2BPFIN, - PEG4BPII, - PEG4BPFII, - PXG4BPFILX, - PMCXG2BPIN, - PMCXG4BPIN, - PXG2BISC1, - PEG2TBFI, - PXG2TBI, - PXG4BPFID, - PEG4BPFI, - PEG4BPIPT, - PXG6BPI, - PEG4BPIL, - PMCXG2BPIN2, - PMCXG4BPIN2, - PMCX2BPI, - PEG2BPFID, - PEG2BPFIDLX, - PMCX4BPI, - MEG2BPFILN, - MEG2BPFINX, - PEG4BPFILX, - PE10G2BPISR, - PE10G2BPILR, - MHIO8AD, - PE10G2BPICX4, - PEG2BPI5, - PEG6BPI, - PEG4BPFI5, - PEG4BPFI5LX, - MEG2BPFILXLN, - PEG2BPIX1, - MEG2BPFILXNX, - XE10G2BPIT, - XE10G2BPICX4, - XE10G2BPISR, - XE10G2BPILR, - PEG4BPIIO, - XE10G2BPIXR, - PE10GDBISR, - PE10GDBILR, - PEG2BISC6, - PEG6BPIFC, - PE10G2BPTCX4, - PE10G2BPTSR, - PE10G2BPTLR, - PE10G2BPTT, - PEG4BPI6, - PEG4BPFI6, - PEG4BPFI6LX, - PEG4BPFI6ZX, - PEG2BPI6, - PEG2BPFI6, - PEG2BPFI6LX, - PEG2BPFI6ZX, - PEG2BPFI6FLXM, - PEG4BPI6FC, - PEG4BPFI6FC, - PEG4BPFI6FCLX, - PEG4BPFI6FCZX, - PEG6BPI6, - PEG2BPI6SC6, - MEG2BPI6, - XEG2BPI6, - MEG4BPI6, - PEG2BPFI5, - PEG2BPFI5LX, - PXEG4BPFI, - M1EG2BPI6, - M1EG2BPFI6, - M1EG2BPFI6LX, - M1EG2BPFI6ZX, - M1EG4BPI6, - M1EG4BPFI6, - M1EG4BPFI6LX, - M1EG4BPFI6ZX, - M1EG6BPI6, - M1E2G4BPi80, - M1E2G4BPFi80, - M1E2G4BPFi80LX, - M1E2G4BPFi80ZX, - PE210G2SPI9, - M1E10G2BPI9CX4, - M1E10G2BPI9SR, - M1E10G2BPI9LR, - M1E10G2BPI9T, - PE210G2BPI9CX4, - PE210G2BPI9SR, - PE210G2BPI9LR, - PE210G2BPI9T, - M2EG2BPFI6, - M2EG2BPFI6LX, - M2EG2BPFI6ZX, - M2EG4BPI6, - M2EG4BPFI6, - M2EG4BPFI6LX, - M2EG4BPFI6ZX, - M2EG6BPI6, - PEG2DBI6, - PEG2DBFI6, - PEG2DBFI6LX, - PEG2DBFI6ZX, - PE2G4BPi80, - PE2G4BPFi80, - PE2G4BPFi80LX, - PE2G4BPFi80ZX, - PE2G4BPi80L, - M6E2G8BPi80A, - - PE2G2BPi35, - PAC1200BPi35, - PE2G2BPFi35, - PE2G2BPFi35LX, - PE2G2BPFi35ZX, - PE2G4BPi35, - PE2G4BPi35L, - PE2G4BPFi35, - PE2G4BPFi35LX, - PE2G4BPFi35ZX, - - PE2G6BPi35, - PE2G6BPi35CX, - - PE2G2BPi80, - PE2G2BPFi80, - PE2G2BPFi80LX, - PE2G2BPFi80ZX, - M2E10G2BPI9CX4, - M2E10G2BPI9SR, - M2E10G2BPI9LR, - M2E10G2BPI9T, - M6E2G8BPi80, - PE210G2DBi9SR, - PE210G2DBi9SRRB, - PE210G2DBi9LR, - PE210G2DBi9LRRB, - PE310G4DBi940SR, - PE310G4BPi9T, - PE310G4BPi9SR, - PE310G4BPi9LR, - PE210G2BPi40, -} board_t; - -typedef struct _bpmod_info_t { - unsigned int vendor; - unsigned int device; - unsigned int subvendor; - unsigned int subdevice; - unsigned int index; - char *bp_name; - -} bpmod_info_t; - -typedef struct _dev_desc { - char *name; -} dev_desc_t; - -dev_desc_t dev_desc[] = { - {"Silicom Bypass PXG2BPFI-SD series adapter"}, - {"Silicom Bypass PXG2BPFIL-SD series adapter"}, - {"Silicom Bypass PXG2BPFILX-SD series adapter"}, - {"Silicom Bypass PXG2BPFILLX-SD series adapter"}, - {"Silicom Bypass PXG2BPI-SD series adapter"}, - {"Silicom Bypass PXG2BPIG-SD series adapter"}, - {"Silicom Bypass PXG2TBFI-SD series adapter"}, - {"Silicom Bypass PXG4BPI-SD series adapter"}, - {"Silicom Bypass PXG4BPFI-SD series adapter"}, - {"Silicom Bypass PEG4BPI-SD series adapter"}, - {"Silicom Bypass PEG2BPI-SD series adapter"}, - {"Silicom Bypass PEG4BPIN-SD series adapter"}, - {"Silicom Bypass PEG2BPFI-SD series adapter"}, - {"Silicom Bypass PEG2BPFI-LX-SD series adapter"}, - {"Silicom Bypass PMCX2BPFI-SD series adapter"}, - {"Silicom Bypass PMCX2BPFI-N series adapter"}, - {"Intel Bypass PEG2BPII series adapter"}, - {"Intel Bypass PEG2BPFII series adapter"}, - {"Silicom Bypass PXG4BPFILX-SD series adapter"}, - {"Silicom Bypass PMCX2BPI-N series adapter"}, - {"Silicom Bypass PMCX4BPI-N series adapter"}, - {"Silicom Bypass PXG2BISC1-SD series adapter"}, - {"Silicom Bypass PEG2TBFI-SD series adapter"}, - {"Silicom Bypass PXG2TBI-SD series adapter"}, - {"Silicom Bypass PXG4BPFID-SD series adapter"}, - {"Silicom Bypass PEG4BPFI-SD series adapter"}, - {"Silicom Bypass PEG4BPIPT-SD series adapter"}, - {"Silicom Bypass PXG6BPI-SD series adapter"}, - {"Silicom Bypass PEG4BPIL-SD series adapter"}, - {"Silicom Bypass PMCX2BPI-N2 series adapter"}, - {"Silicom Bypass PMCX4BPI-N2 series adapter"}, - {"Silicom Bypass PMCX2BPI-SD series adapter"}, - {"Silicom Bypass PEG2BPFID-SD series adapter"}, - {"Silicom Bypass PEG2BPFIDLX-SD series adapter"}, - {"Silicom Bypass PMCX4BPI-SD series adapter"}, - {"Silicom Bypass MEG2BPFILN-SD series adapter"}, - {"Silicom Bypass MEG2BPFINX-SD series adapter"}, - {"Silicom Bypass PEG4BPFILX-SD series adapter"}, - {"Silicom Bypass PE10G2BPISR-SD series adapter"}, - {"Silicom Bypass PE10G2BPILR-SD series adapter"}, - {"Silicom Bypass MHIO8AD-SD series adapter"}, - {"Silicom Bypass PE10G2BPICX4-SD series adapter"}, - {"Silicom Bypass PEG2BPI5-SD series adapter"}, - {"Silicom Bypass PEG6BPI5-SD series adapter"}, - {"Silicom Bypass PEG4BPFI5-SD series adapter"}, - {"Silicom Bypass PEG4BPFI5LX-SD series adapter"}, - {"Silicom Bypass MEG2BPFILXLN-SD series adapter"}, - {"Silicom Bypass PEG2BPIX1-SD series adapter"}, - {"Silicom Bypass MEG2BPFILXNX-SD series adapter"}, - {"Silicom Bypass XE10G2BPIT-SD series adapter"}, - {"Silicom Bypass XE10G2BPICX4-SD series adapter"}, - {"Silicom Bypass XE10G2BPISR-SD series adapter"}, - {"Silicom Bypass XE10G2BPILR-SD series adapter"}, - {"Intel Bypass PEG2BPFII0 series adapter"}, - {"Silicom Bypass XE10G2BPIXR series adapter"}, - {"Silicom Bypass PE10G2DBISR series adapter"}, - {"Silicom Bypass PEG2BI5SC6 series adapter"}, - {"Silicom Bypass PEG6BPI5FC series adapter"}, - - {"Silicom Bypass PE10G2BPTCX4 series adapter"}, - {"Silicom Bypass PE10G2BPTSR series adapter"}, - {"Silicom Bypass PE10G2BPTLR series adapter"}, - {"Silicom Bypass PE10G2BPTT series adapter"}, - {"Silicom Bypass PEG4BPI6 series adapter"}, - {"Silicom Bypass PEG4BPFI6 series adapter"}, - {"Silicom Bypass PEG4BPFI6LX series adapter"}, - {"Silicom Bypass PEG4BPFI6ZX series adapter"}, - {"Silicom Bypass PEG2BPI6 series adapter"}, - {"Silicom Bypass PEG2BPFI6 series adapter"}, - {"Silicom Bypass PEG2BPFI6LX series adapter"}, - {"Silicom Bypass PEG2BPFI6ZX series adapter"}, - {"Silicom Bypass PEG2BPFI6FLXM series adapter"}, - {"Silicom Bypass PEG4BPI6FC series adapter"}, - {"Silicom Bypass PEG4BPFI6FC series adapter"}, - {"Silicom Bypass PEG4BPFI6FCLX series adapter"}, - {"Silicom Bypass PEG4BPFI6FCZX series adapter"}, - {"Silicom Bypass PEG6BPI6 series adapter"}, - {"Silicom Bypass PEG2BPI6SC6 series adapter"}, - {"Silicom Bypass MEG2BPI6 series adapter"}, - {"Silicom Bypass XEG2BPI6 series adapter"}, - {"Silicom Bypass MEG4BPI6 series adapter"}, - {"Silicom Bypass PEG2BPFI5-SD series adapter"}, - {"Silicom Bypass PEG2BPFI5LX-SD series adapter"}, - {"Silicom Bypass PXEG4BPFI-SD series adapter"}, - {"Silicom Bypass MxEG2BPI6 series adapter"}, - {"Silicom Bypass MxEG2BPFI6 series adapter"}, - {"Silicom Bypass MxEG2BPFI6LX series adapter"}, - {"Silicom Bypass MxEG2BPFI6ZX series adapter"}, - {"Silicom Bypass MxEG4BPI6 series adapter"}, - {"Silicom Bypass MxEG4BPFI6 series adapter"}, - {"Silicom Bypass MxEG4BPFI6LX series adapter"}, - {"Silicom Bypass MxEG4BPFI6ZX series adapter"}, - {"Silicom Bypass MxEG6BPI6 series adapter"}, - {"Silicom Bypass MxE2G4BPi80 series adapter"}, - {"Silicom Bypass MxE2G4BPFi80 series adapter"}, - {"Silicom Bypass MxE2G4BPFi80LX series adapter"}, - {"Silicom Bypass MxE2G4BPFi80ZX series adapter"}, - - {"Silicom Bypass PE210G2SPI9 series adapter"}, - - {"Silicom Bypass MxE210G2BPI9CX4 series adapter"}, - {"Silicom Bypass MxE210G2BPI9SR series adapter"}, - {"Silicom Bypass MxE210G2BPI9LR series adapter"}, - {"Silicom Bypass MxE210G2BPI9T series adapter"}, - - {"Silicom Bypass PE210G2BPI9CX4 series adapter"}, - {"Silicom Bypass PE210G2BPI9SR series adapter"}, - {"Silicom Bypass PE210G2BPI9LR series adapter"}, - {"Silicom Bypass PE210G2BPI9T series adapter"}, - - {"Silicom Bypass M2EG2BPFI6 series adapter"}, - {"Silicom Bypass M2EG2BPFI6LX series adapter"}, - {"Silicom Bypass M2EG2BPFI6ZX series adapter"}, - {"Silicom Bypass M2EG4BPI6 series adapter"}, - {"Silicom Bypass M2EG4BPFI6 series adapter"}, - {"Silicom Bypass M2EG4BPFI6LX series adapter"}, - {"Silicom Bypass M2EG4BPFI6ZX series adapter"}, - {"Silicom Bypass M2EG6BPI6 series adapter"}, - - {"Silicom Bypass PEG2DBI6 series adapter"}, - {"Silicom Bypass PEG2DBFI6 series adapter"}, - {"Silicom Bypass PEG2DBFI6LX series adapter"}, - {"Silicom Bypass PEG2DBFI6ZX series adapter"}, - - {"Silicom Bypass PE2G4BPi80 series adapter"}, - {"Silicom Bypass PE2G4BPFi80 series adapter"}, - {"Silicom Bypass PE2G4BPFi80LX series adapter"}, - {"Silicom Bypass PE2G4BPFi80ZX series adapter"}, - - {"Silicom Bypass PE2G4BPi80L series adapter"}, - {"Silicom Bypass MxE2G8BPi80A series adapter"}, - - {"Silicom Bypass PE2G2BPi35 series adapter"}, - {"Silicom Bypass PAC1200BPi35 series adapter"}, - {"Silicom Bypass PE2G2BPFi35 series adapter"}, - {"Silicom Bypass PE2G2BPFi35LX series adapter"}, - {"Silicom Bypass PE2G2BPFi35ZX series adapter"}, - - {"Silicom Bypass PE2G4BPi35 series adapter"}, - {"Silicom Bypass PE2G4BPi35L series adapter"}, - {"Silicom Bypass PE2G4BPFi35 series adapter"}, - {"Silicom Bypass PE2G4BPFi35LX series adapter"}, - {"Silicom Bypass PE2G4BPFi35ZX series adapter"}, - - {"Silicom Bypass PE2G6BPi35 series adapter"}, - {"Silicom Bypass PE2G6BPi35CX series adapter"}, - - {"Silicom Bypass PE2G2BPi80 series adapter"}, - {"Silicom Bypass PE2G2BPFi80 series adapter"}, - {"Silicom Bypass PE2G2BPFi80LX series adapter"}, - {"Silicom Bypass PE2G2BPFi80ZX series adapter"}, - - {"Silicom Bypass M2E10G2BPI9CX4 series adapter"}, - {"Silicom Bypass M2E10G2BPI9SR series adapter"}, - {"Silicom Bypass M2E10G2BPI9LR series adapter"}, - {"Silicom Bypass M2E10G2BPI9T series adapter"}, - {"Silicom Bypass MxE2G8BPi80 series adapter"}, - {"Silicom Bypass PE210G2DBi9SR series adapter"}, - {"Silicom Bypass PE210G2DBi9SRRB series adapter"}, - {"Silicom Bypass PE210G2DBi9LR series adapter"}, - {"Silicom Bypass PE210G2DBi9LRRB series adapter"}, - {"Silicom Bypass PE310G4DBi9-SR series adapter"}, - {"Silicom Bypass PE310G4BPi9T series adapter"}, - {"Silicom Bypass PE310G4BPi9SR series adapter"}, - {"Silicom Bypass PE310G4BPi9LR series adapter"}, - {"Silicom Bypass PE210G2BPi40T series adapter"}, - {0}, -}; - -static bpmod_info_t tx_ctl_pci_tbl[] = { - {0x8086, 0x107a, SILICOM_SVID, SILICOM_PXG2BPFI_SSID, PXG2BPFI, - "PXG2BPFI-SD"}, - {0x8086, 0x107a, SILICOM_SVID, SILICOM_PXG2BPFIL_SSID, PXG2BPFIL, - "PXG2BPFIL-SD"}, - {0x8086, 0x107a, SILICOM_SVID, SILICOM_PXG2BPFILX_SSID, PXG2BPFILX, - "PXG2BPFILX-SD"}, - {0x8086, 0x107a, SILICOM_SVID, SILICOM_PXG2BPFILLX_SSID, PXG2BPFILLX, - "PXG2BPFILLXSD"}, - {0x8086, 0x1010, SILICOM_SVID, SILICOM_PXGBPI_SSID, PXGBPI, - "PXG2BPI-SD"}, - {0x8086, 0x1079, SILICOM_SVID, SILICOM_PXGBPIG_SSID, PXGBPIG, - "PXG2BPIG-SD"}, - {0x8086, 0x107a, SILICOM_SVID, SILICOM_PXG2TBFI_SSID, PXG2TBFI, - "PXG2TBFI-SD"}, - {0x8086, 0x1079, SILICOM_SVID, SILICOM_PXG4BPI_SSID, PXG4BPI, - "PXG4BPI-SD"}, - {0x8086, 0x107a, SILICOM_SVID, SILICOM_PXG4BPFI_SSID, PXG4BPFI, - "PXG4BPFI-SD"}, - {0x8086, 0x107a, SILICOM_SVID, SILICOM_PXG4BPFILX_SSID, PXG4BPFILX, - "PXG4BPFILX-SD"}, - {0x8086, 0x1079, SILICOM_SVID, SILICOM_PEG4BPI_SSID, PEG4BPI, - "PEXG4BPI-SD"}, - {0x8086, 0x105e, SILICOM_SVID, SILICOM_PEG2BPI_SSID, PEG2BPI, - "PEG2BPI-SD"}, - {0x8086, 0x105e, SILICOM_SVID, SILICOM_PEG4BPIN_SSID, PEG4BPIN, - "PEG4BPI-SD"}, - {0x8086, 0x105f, SILICOM_SVID, SILICOM_PEG2BPFI_SSID, PEG2BPFI, - "PEG2BPFI-SD"}, - {0x8086, 0x105f, SILICOM_SVID, SILICOM_PEG2BPFILX_SSID, PEG2BPFILX, - "PEG2BPFILX-SD"}, - {0x8086, 0x107a, SILICOM_SVID, SILICOM_PMCXG2BPFI_SSID, PMCXG2BPFI, - "PMCX2BPFI-SD"}, - {0x8086, 0x107a, NOKIA_PMCXG2BPFIN_SVID, NOKIA_PMCXG2BPFIN_SSID, - PMCXG2BPFIN, "PMCX2BPFI-N"}, - {0x8086, INTEL_PEG4BPII_PID, 0x8086, INTEL_PEG4BPII_SSID, PEG4BPII, - "PEG4BPII"}, - {0x8086, INTEL_PEG4BPIIO_PID, 0x8086, INTEL_PEG4BPIIO_SSID, PEG4BPIIO, - "PEG4BPII0"}, - {0x8086, INTEL_PEG4BPFII_PID, 0x8086, INTEL_PEG4BPFII_SSID, PEG4BPFII, - "PEG4BPFII"}, - {0x8086, 0x1079, NOKIA_PMCXG2BPFIN_SVID, NOKIA_PMCXG2BPIN_SSID, - PMCXG2BPIN, "PMCX2BPI-N"}, - {0x8086, 0x1079, NOKIA_PMCXG2BPFIN_SVID, NOKIA_PMCXG4BPIN_SSID, - PMCXG4BPIN, "PMCX4BPI-N"}, - {0x8086, 0x1079, SILICOM_SVID, SILICOM_PXG2BISC1_SSID, PXG2BISC1, - "PXG2BISC1-SD"}, - {0x8086, 0x105f, SILICOM_SVID, SILICOM_PEG2TBFI_SSID, PEG2TBFI, - "PEG2TBFI-SD"}, - {0x8086, 0x1079, SILICOM_SVID, SILICOM_PXG2TBI_SSID, PXG2TBI, - "PXG2TBI-SD"}, - {0x8086, 0x107a, SILICOM_SVID, SILICOM_PXG4BPFID_SSID, PXG4BPFID, - "PXG4BPFID-SD"}, - {0x8086, 0x105f, SILICOM_SVID, SILICOM_PEG4BPFI_SSID, PEG4BPFI, - "PEG4BPFI-SD"}, - {0x8086, 0x105e, SILICOM_SVID, SILICOM_PEG4BPIPT_SSID, PEG4BPIPT, - "PEG4BPIPT-SD"}, - {0x8086, 0x1079, SILICOM_SVID, SILICOM_PXG6BPI_SSID, PXG6BPI, - "PXG6BPI-SD"}, - {0x8086, 0x10a7, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PEG4BPIL_SSID /*PCI_ANY_ID */ , PEG4BPIL, "PEG4BPIL-SD"}, - {0x8086, 0x1079, NOKIA_PMCXG2BPFIN_SVID, NOKIA_PMCXG2BPIN2_SSID, - PMCXG2BPIN2, "PMCX2BPI-N2"}, - {0x8086, 0x1079, NOKIA_PMCXG2BPFIN_SVID, NOKIA_PMCXG4BPIN2_SSID, - PMCXG4BPIN2, "PMCX4BPI-N2"}, - {0x8086, 0x1079, SILICOM_SVID, SILICOM_PMCX2BPI_SSID, PMCX2BPI, - "PMCX2BPI-SD"}, - {0x8086, 0x1079, SILICOM_SVID, SILICOM_PMCX4BPI_SSID, PMCX4BPI, - "PMCX4BPI-SD"}, - {0x8086, 0x105f, SILICOM_SVID, SILICOM_PEG2BPFID_SSID, PEG2BPFID, - "PEG2BPFID-SD"}, - {0x8086, 0x105f, SILICOM_SVID, SILICOM_PEG2BPFIDLX_SSID, PEG2BPFIDLX, - "PEG2BPFIDLXSD"}, - {0x8086, 0x105f, SILICOM_SVID, SILICOM_MEG2BPFILN_SSID, MEG2BPFILN, - "MEG2BPFILN-SD"}, - {0x8086, 0x105f, SILICOM_SVID, SILICOM_MEG2BPFINX_SSID, MEG2BPFINX, - "MEG2BPFINX-SD"}, - {0x8086, 0x105f, SILICOM_SVID, SILICOM_PEG4BPFILX_SSID, PEG4BPFILX, - "PEG4BPFILX-SD"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID, SILICOM_PE10G2BPISR_SSID, - PE10G2BPISR, "PE10G2BPISR"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID, SILICOM_PE10G2BPILR_SSID, - PE10G2BPILR, "PE10G2BPILR"}, - {0x8086, 0x10a9, SILICOM_SVID, SILICOM_MHIO8AD_SSID, MHIO8AD, - "MHIO8AD-SD"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID, SILICOM_PE10G2BPICX4_SSID, - PE10G2BPISR, "PE10G2BPICX4"}, - {0x8086, 0x10a7, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PEG2BPI5_SSID /*PCI_ANY_ID */ , PEG2BPI5, "PEG2BPI5-SD"}, - {0x8086, 0x10a7, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PEG6BPI_SSID /*PCI_ANY_ID */ , PEG6BPI, "PEG6BPI5"}, - {0x8086, 0x10a9, SILICOM_SVID /*PCI_ANY_ID */ , SILICOM_PEG4BPFI5_SSID, - PEG4BPFI5, "PEG4BPFI5"}, - {0x8086, 0x10a9, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PEG4BPFI5LX_SSID, PEG4BPFI5LX, "PEG4BPFI5LX"}, - {0x8086, 0x105f, SILICOM_SVID, SILICOM_MEG2BPFILXLN_SSID, MEG2BPFILXLN, - "MEG2BPFILXLN"}, - {0x8086, 0x105e, SILICOM_SVID, SILICOM_PEG2BPIX1_SSID, PEG2BPIX1, - "PEG2BPIX1-SD"}, - {0x8086, 0x105f, SILICOM_SVID, SILICOM_MEG2BPFILXNX_SSID, MEG2BPFILXNX, - "MEG2BPFILXNX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID, SILICOM_XE10G2BPIT_SSID, XE10G2BPIT, - "XE10G2BPIT"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID, SILICOM_XE10G2BPICX4_SSID, - XE10G2BPICX4, "XE10G2BPICX4"}, - {0x8086, 0x10C6, SILICOM_SVID, SILICOM_XE10G2BPISR_SSID, XE10G2BPISR, - "XE10G2BPISR"}, - {0x8086, 0x10C6, SILICOM_SVID, SILICOM_XE10G2BPILR_SSID, XE10G2BPILR, - "XE10G2BPILR"}, - {0x8086, 0x10C6, NOKIA_XE10G2BPIXR_SVID, NOKIA_XE10G2BPIXR_SSID, - XE10G2BPIXR, "XE10G2BPIXR"}, - {0x8086, 0x10C6, SILICOM_SVID, SILICOM_PE10GDBISR_SSID, PE10GDBISR, - "PE10G2DBISR"}, - {0x8086, 0x10C6, SILICOM_SVID, SILICOM_PE10GDBILR_SSID, PE10GDBILR, - "PE10G2DBILR"}, - {0x8086, 0x10a7, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PEG2BISC6_SSID /*PCI_ANY_ID */ , PEG2BISC6, "PEG2BI5SC6"}, - {0x8086, 0x10a7, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PEG6BPIFC_SSID /*PCI_ANY_ID */ , PEG6BPIFC, "PEG6BPI5FC"}, - - {BROADCOM_VID, BROADCOM_PE10G2_PID, SILICOM_SVID, - SILICOM_PE10G2BPTCX4_SSID, PE10G2BPTCX4, "PE10G2BPTCX4"}, - {BROADCOM_VID, BROADCOM_PE10G2_PID, SILICOM_SVID, - SILICOM_PE10G2BPTSR_SSID, PE10G2BPTSR, "PE10G2BPTSR"}, - {BROADCOM_VID, BROADCOM_PE10G2_PID, SILICOM_SVID, - SILICOM_PE10G2BPTLR_SSID, PE10G2BPTLR, "PE10G2BPTLR"}, - {BROADCOM_VID, BROADCOM_PE10G2_PID, SILICOM_SVID, - SILICOM_PE10G2BPTT_SSID, PE10G2BPTT, "PE10G2BPTT"}, - - /* {BROADCOM_VID, BROADCOM_PE10G2_PID, PCI_ANY_ID, PCI_ANY_ID, PE10G2BPTCX4, "PE10G2BPTCX4"}, */ - - {0x8086, 0x10c9, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PEG4BPI6_SSID /*PCI_ANY_ID */ , PEG4BPI6, "PEG4BPI6"}, - {0x8086, 0x10e6, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PEG4BPFI6_SSID /*PCI_ANY_ID */ , PEG4BPFI6, "PEG4BPFI6"}, - {0x8086, 0x10e6, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PEG4BPFI6LX_SSID /*PCI_ANY_ID */ , PEG4BPFI6LX, "PEG4BPFI6LX"}, - {0x8086, 0x10e6, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PEG4BPFI6ZX_SSID /*PCI_ANY_ID */ , PEG4BPFI6ZX, "PEG4BPFI6ZX"}, - {0x8086, 0x10c9, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PEG2BPI6_SSID /*PCI_ANY_ID */ , PEG2BPI6, "PEG2BPI6"}, - {0x8086, 0x10e6, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PEG2BPFI6_SSID /*PCI_ANY_ID */ , PEG2BPFI6, "PEG2BPFI6"}, - {0x8086, 0x10e6, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PEG2BPFI6LX_SSID /*PCI_ANY_ID */ , PEG2BPFI6LX, "PEG2BPFI6LX"}, - {0x8086, 0x10e6, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PEG2BPFI6ZX_SSID /*PCI_ANY_ID */ , PEG2BPFI6ZX, "PEG2BPFI6ZX"}, - {0x8086, 0x10e7, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PEG2BPFI6FLXM_SSID /*PCI_ANY_ID */ , PEG2BPFI6FLXM, - "PEG2BPFI6FLXM"}, - {0x8086, 0x10c9, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PEG4BPI6FC_SSID /*PCI_ANY_ID */ , PEG4BPI6FC, "PEG4BPI6FC"}, - {0x8086, 0x10e6, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PEG4BPFI6FC_SSID /*PCI_ANY_ID */ , PEG4BPFI6FC, "PEG4BPFI6FC"}, - {0x8086, 0x10e6, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PEG4BPFI6FCLX_SSID /*PCI_ANY_ID */ , PEG4BPFI6FCLX, - "PEG4BPFI6FCLX"}, - {0x8086, 0x10e6, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PEG4BPFI6FCZX_SSID /*PCI_ANY_ID */ , PEG4BPFI6FCZX, - "PEG4BPFI6FCZX"}, - {0x8086, 0x10c9, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PEG6BPI6_SSID /*PCI_ANY_ID */ , PEG6BPI6, "PEG6BPI6"}, - {0x8086, 0x10c9, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PEG2BPI6SC6_SSID /*PCI_ANY_ID */ , PEG2BPI6SC6, - "PEG6BPI62SC6"}, - {0x8086, 0x10c9, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_MEG2BPI6_SSID /*PCI_ANY_ID */ , MEG2BPI6, "MEG2BPI6"}, - {0x8086, 0x10c9, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_XEG2BPI6_SSID /*PCI_ANY_ID */ , XEG2BPI6, "XEG2BPI6"}, - {0x8086, 0x10c9, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_MEG4BPI6_SSID /*PCI_ANY_ID */ , MEG4BPI6, "MEG4BPI6"}, - - {0x8086, 0x10a9, SILICOM_SVID /*PCI_ANY_ID */ , SILICOM_PEG2BPFI5_SSID, - PEG2BPFI5, "PEG2BPFI5"}, - {0x8086, 0x10a9, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PEG2BPFI5LX_SSID, PEG2BPFI5LX, "PEG2BPFI5LX"}, - - {0x8086, 0x105f, SILICOM_SVID, SILICOM_PXEG4BPFI_SSID, PXEG4BPFI, - "PXEG4BPFI-SD"}, - - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_M1EG2BPI6_SSID /*PCI_ANY_ID */ , M1EG2BPI6, "MxEG2BPI6"}, - - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_M1EG2BPFI6_SSID /*PCI_ANY_ID */ , M1EG2BPFI6, "MxEG2BPFI6"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_M1EG2BPFI6LX_SSID /*PCI_ANY_ID */ , M1EG2BPFI6LX, - "MxEG2BPFI6LX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_M1EG2BPFI6ZX_SSID /*PCI_ANY_ID */ , M1EG2BPFI6ZX, - "MxEG2BPFI6ZX"}, - - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_M1EG4BPI6_SSID /*PCI_ANY_ID */ , M1EG4BPI6, "MxEG4BPI6"}, - - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_M1EG4BPFI6_SSID /*PCI_ANY_ID */ , M1EG4BPFI6, "MxEG4BPFI6"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_M1EG4BPFI6LX_SSID /*PCI_ANY_ID */ , M1EG4BPFI6LX, - "MxEG4BPFI6LX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_M1EG4BPFI6ZX_SSID /*PCI_ANY_ID */ , M1EG4BPFI6ZX, - "MxEG4BPFI6ZX"}, - - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_M1EG6BPI6_SSID /*PCI_ANY_ID */ , M1EG6BPI6, "MxEG6BPI6"}, - - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_M1E2G4BPi80_SSID /*PCI_ANY_ID */ , M1E2G4BPi80, "MxE2G4BPi80"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_M1E2G4BPFi80_SSID /*PCI_ANY_ID */ , M1E2G4BPFi80, - "MxE2G4BPFi80"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_M1E2G4BPFi80LX_SSID /*PCI_ANY_ID */ , M1E2G4BPFi80LX, - "MxE2G4BPFi80LX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_M1E2G4BPFi80ZX_SSID /*PCI_ANY_ID */ , M1E2G4BPFi80ZX, - "MxE2G4BPFi80ZX"}, - - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_M2EG2BPFI6_SSID /*PCI_ANY_ID */ , M2EG2BPFI6, "M2EG2BPFI6"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_M2EG2BPFI6LX_SSID /*PCI_ANY_ID */ , M2EG2BPFI6LX, - "M2EG2BPFI6LX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_M2EG2BPFI6ZX_SSID /*PCI_ANY_ID */ , M2EG2BPFI6ZX, - "M2EG2BPFI6ZX"}, - - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_M2EG4BPI6_SSID /*PCI_ANY_ID */ , M2EG4BPI6, "M2EG4BPI6"}, - - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_M2EG4BPFI6_SSID /*PCI_ANY_ID */ , M2EG4BPFI6, "M2EG4BPFI6"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_M2EG4BPFI6LX_SSID /*PCI_ANY_ID */ , M2EG4BPFI6LX, - "M2EG4BPFI6LX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_M2EG4BPFI6ZX_SSID /*PCI_ANY_ID */ , M2EG4BPFI6ZX, - "M2EG4BPFI6ZX"}, - - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_M2EG6BPI6_SSID /*PCI_ANY_ID */ , M2EG6BPI6, "M2EG6BPI6"}, - - {0x8086, 0x10c9, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PEG2DBI6_SSID /*PCI_ANY_ID */ , PEG2DBI6, "PEG2DBI6"}, - {0x8086, 0x10e6, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PEG2DBFI6_SSID /*PCI_ANY_ID */ , PEG2DBFI6, "PEG2DBFI6"}, - {0x8086, 0x10e6, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PEG2DBFI6LX_SSID /*PCI_ANY_ID */ , PEG2DBFI6LX, "PEG2DBFI6LX"}, - {0x8086, 0x10e6, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PEG2DBFI6ZX_SSID /*PCI_ANY_ID */ , PEG2DBFI6ZX, "PEG2DBFI6ZX"}, - - {0x8086, 0x10F9, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PE210G2DBi9SR_SSID, PE210G2DBi9SR, "PE210G2DBi9SR"}, - {0x8086, 0x10F9, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PE210G2DBi9LR_SSID, PE210G2DBi9LR, "PE210G2DBi9LR"}, - {0x8086, 0x10F9, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PE310G4DBi940SR_SSID, PE310G4DBi940SR, "PE310G4DBi9SR"}, - - {0x8086, 0x10Fb, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PE310G4BPi9T_SSID, PE310G4BPi9T, "PE310G4BPi9T"}, - {0x8086, 0x10Fb, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PE310G4BPi9SR_SSID, PE310G4BPi9SR, "PE310G4BPi9SR"}, - {0x8086, 0x10Fb, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PE310G4BPi9LR_SSID, PE310G4BPi9LR, "PE310G4BPi9LR"}, - - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PE2G4BPi80_SSID /*PCI_ANY_ID */ , PE2G4BPi80, "PE2G4BPi80"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PE2G4BPFi80_SSID /*PCI_ANY_ID */ , PE2G4BPFi80, "PE2G4BPFi80"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PE2G4BPFi80LX_SSID /*PCI_ANY_ID */ , PE2G4BPFi80LX, - "PE2G4BPFi80LX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PE2G4BPFi80ZX_SSID /*PCI_ANY_ID */ , PE2G4BPFi80ZX, - "PE2G4BPFi80ZX"}, - - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PE2G4BPi80L_SSID /*PCI_ANY_ID */ , PE2G4BPi80L, "PE2G4BPi80L"}, - - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_M6E2G8BPi80A_SSID /*PCI_ANY_ID */ , M6E2G8BPi80A, - "MxE2G8BPi80A"}, - - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PE2G2BPi35_SSID /*PCI_ANY_ID */ , PE2G2BPi35, "PE2G2BPi35"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PAC1200BPi35_SSID /*PCI_ANY_ID */ , PAC1200BPi35, - "PAC1200BPi35"}, - - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PE2G2BPFi35_SSID /*PCI_ANY_ID */ , PE2G2BPFi35, "PE2G2BPFi35"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PE2G2BPFi35LX_SSID /*PCI_ANY_ID */ , PE2G2BPFi35LX, - "PE2G2BPFi35LX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PE2G2BPFi35ZX_SSID /*PCI_ANY_ID */ , PE2G2BPFi35ZX, - "PE2G2BPFi35ZX"}, - - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PE2G4BPi35_SSID /*PCI_ANY_ID */ , PE2G4BPi35, "PE2G4BPi35"}, - - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PE2G4BPi35L_SSID /*PCI_ANY_ID */ , PE2G4BPi35L, "PE2G4BPi35L"}, - - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PE2G4BPFi35_SSID /*PCI_ANY_ID */ , PE2G4BPFi35, "PE2G4BPFi35"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PE2G4BPFi35LX_SSID /*PCI_ANY_ID */ , PE2G4BPFi35LX, - "PE2G4BPFi35LX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PE2G4BPFi35ZX_SSID /*PCI_ANY_ID */ , PE2G4BPFi35ZX, - "PE2G4BPFi35ZX"}, - - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PE2G6BPi35_SSID /*PCI_ANY_ID */ , PE2G6BPi35, "PE2G6BPi35"}, - - - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xaa0, PE2G6BPi35CX, - "PE2G6BPi35CX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xaa1, PE2G6BPi35CX, - "PE2G6BPi35CX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xaa2, PE2G6BPi35CX, - "PE2G6BPi35CX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xaa3, PE2G6BPi35CX, - "PE2G6BPi35CX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xaa4, PE2G6BPi35CX, - "PE2G6BPi35CX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xaa5, PE2G6BPi35CX, - "PE2G6BPi35CX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xaa6, PE2G6BPi35CX, - "PE2G6BPi35CX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xaa7, PE2G6BPi35CX, - "PE2G6BPi35CX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xaa8, PE2G6BPi35CX, - "PE2G6BPi35CX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xaa9, PE2G6BPi35CX, - "PE2G6BPi35CX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xaaa, PE2G6BPi35CX, - "PE2G6BPi35CX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xaab, PE2G6BPi35CX, - "PE2G6BPi35CX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xaac, PE2G6BPi35CX, - "PE2G6BPi35CX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xaad, PE2G6BPi35CX, - "PE2G6BPi35CX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xaae, PE2G6BPi35CX, - "PE2G6BPi35CX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xaaf, PE2G6BPi35CX, - "PE2G6BPi35CX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xab0, PE2G6BPi35CX, - "PE2G6BPi35CX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xab1, PE2G6BPi35CX, - "PE2G6BPi35CX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xab2, PE2G6BPi35CX, - "PE2G6BPi35CX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xab3, PE2G6BPi35CX, - "PE2G6BPi35CX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xab4, PE2G6BPi35CX, - "PE2G6BPi35CX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xab5, PE2G6BPi35CX, - "PE2G6BPi35CX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xab6, PE2G6BPi35CX, - "PE2G6BPi35CX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xab7, PE2G6BPi35CX, - "PE2G6BPi35CX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xab8, PE2G6BPi35CX, - "PE2G6BPi35CX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xab9, PE2G6BPi35CX, - "PE2G6BPi35CX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xaba, PE2G6BPi35CX, - "PE2G6BPi35CX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xabb, PE2G6BPi35CX, - "PE2G6BPi35CX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xabc, PE2G6BPi35CX, - "PE2G6BPi35CX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xabd, PE2G6BPi35CX, - "PE2G6BPi35CX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xabe, PE2G6BPi35CX, - "PE2G6BPi35CX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xabf, PE2G6BPi35CX, - "PE2G6BPi35CX"}, - - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PE2G2BPi80_SSID /*PCI_ANY_ID */ , PE2G2BPi80, "PE2G2BPi80"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PE2G2BPFi80_SSID /*PCI_ANY_ID */ , PE2G2BPFi80, "PE2G2BPFi80"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PE2G2BPFi80LX_SSID /*PCI_ANY_ID */ , PE2G2BPFi80LX, - "PE2G2BPFi80LX"}, - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PE2G2BPFi80ZX_SSID /*PCI_ANY_ID */ , PE2G2BPFi80ZX, - "PE2G2BPFi80ZX"}, - - {0x8086, 0x10c9, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_MEG2BPI6_SSID /*PCI_ANY_ID */ , MEG2BPI6, "MEG2BPI6"}, - {0x8086, 0x10c9, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_XEG2BPI6_SSID /*PCI_ANY_ID */ , XEG2BPI6, "XEG2BPI6"}, - -#if 0 - {0x8086, 0x10fb, 0x8086, INTEL_PE210G2SPI9_SSID, PE210G2SPI9, - "PE210G2SPI9"}, -#endif - {0x8086, 0x10fb, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_M1E10G2BPI9CX4_SSID /*PCI_ANY_ID */ , M1E10G2BPI9CX4, - "MxE210G2BPI9CX4"}, - {0x8086, 0x10fb, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_M1E10G2BPI9SR_SSID /*PCI_ANY_ID */ , M1E10G2BPI9SR, - "MxE210G2BPI9SR"}, - {0x8086, 0x10fb, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_M1E10G2BPI9LR_SSID /*PCI_ANY_ID */ , M1E10G2BPI9LR, - "MxE210G2BPI9LR"}, - {0x8086, 0x10fb, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_M1E10G2BPI9T_SSID /*PCI_ANY_ID */ , M1E10G2BPI9T, - "MxE210G2BPI9T"}, - - {0x8086, 0x10fb, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_M2E10G2BPI9CX4_SSID /*PCI_ANY_ID */ , M2E10G2BPI9CX4, - "M2E10G2BPI9CX4"}, - {0x8086, 0x10fb, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_M2E10G2BPI9SR_SSID /*PCI_ANY_ID */ , M2E10G2BPI9SR, - "M2E10G2BPI9SR"}, - {0x8086, 0x10fb, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_M2E10G2BPI9LR_SSID /*PCI_ANY_ID */ , M2E10G2BPI9LR, - "M2E10G2BPI9LR"}, - {0x8086, 0x10fb, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_M2E10G2BPI9T_SSID /*PCI_ANY_ID */ , M2E10G2BPI9T, - "M2E10G2BPI9T"}, - - {0x8086, 0x10fb, SILICOM_SVID, SILICOM_PE210G2BPI9CX4_SSID, - PE210G2BPI9CX4, "PE210G2BPI9CX4"}, - {0x8086, 0x10fb, SILICOM_SVID, SILICOM_PE210G2BPI9SR_SSID, - PE210G2BPI9SR, "PE210G2BPI9SR"}, - {0x8086, 0x10fb, SILICOM_SVID, SILICOM_PE210G2BPI9LR_SSID, - PE210G2BPI9LR, "PE210G2BPI9LR"}, - {0x8086, 0x10fb, SILICOM_SVID, SILICOM_PE210G2BPI9T_SSID, PE210G2BPI9T, - "PE210G2BPI9T"}, - -#if 0 - {0x1374, 0x2c, SILICOM_SVID, SILICOM_PXG4BPI_SSID, PXG4BPI, - "PXG4BPI-SD"}, - - {0x1374, 0x2d, SILICOM_SVID, SILICOM_PXG4BPFI_SSID, PXG4BPFI, - "PXG4BPFI-SD"}, - - {0x1374, 0x3f, SILICOM_SVID, SILICOM_PXG2TBI_SSID, PXG2TBI, - "PXG2TBI-SD"}, - - {0x1374, 0x3d, SILICOM_SVID, SILICOM_PXG2BISC1_SSID, PXG2BISC1, - "PXG2BISC1-SD"}, - - {0x1374, 0x40, SILICOM_SVID, SILICOM_PEG4BPFI_SSID, PEG4BPFI, - "PEG4BPFI-SD"}, - -#ifdef BP_SELF_TEST - {0x1374, 0x28, SILICOM_SVID, 0x28, PXGBPI, "PXG2BPI-SD"}, -#endif -#endif - {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_M6E2G8BPi80_SSID /*PCI_ANY_ID */ , M6E2G8BPi80, "MxE2G8BPi80"}, - {0x8086, 0x1528, SILICOM_SVID /*PCI_ANY_ID */ , - SILICOM_PE210G2BPi40_SSID /*PCI_ANY_ID */ , PE210G2BPi40, - "PE210G2BPi40T"}, - - /* required last entry */ - {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 -*/ - -static int __init bypass_init_module(void) -{ - int ret_val, idx, idx_dev = 0; - struct pci_dev *pdev1 = NULL; - bpctl_dev_t *dev; - - printk(BP_MOD_DESCR " v" BP_MOD_VER "\n"); - ret_val = register_chrdev(major_num, DEVICE_NAME, &Fops); - if (ret_val < 0) { - printk("%s failed with %d\n", DEVICE_NAME, ret_val); - return ret_val; - } - major_num = ret_val; /* dynamic */ - 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))) { - - device_num++; - } - } - if (!device_num) { - printk("No such device\n"); - unregister_chrdev(major_num, DEVICE_NAME); - return -1; - } - - bpctl_dev_arr = kmalloc((device_num) * sizeof(bpctl_dev_t), GFP_KERNEL); - - if (!bpctl_dev_arr) { - printk("Allocation error\n"); - unregister_chrdev(major_num, DEVICE_NAME); - return -1; - } - 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))) { - if (init_one(dev, &tx_ctl_pci_tbl[idx], pdev1) < 0) - return -1; - dev++; - } - } - if_scan_init(); - - sema_init(&bpctl_sema, 1); - spin_lock_init(&bpvm_lock); - { - - bpctl_dev_t *pbpctl_dev_c = NULL; - 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, ", - dev->name); - dev->bp_fw_ver = bypass_fw_ver(dev); - printk("firmware version: 0x%x\n", - dev->bp_fw_ver); - } - 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); - - } - - } - } - - register_netdevice_notifier(&bp_notifier_block); -#ifdef BP_PROC_SUPPORT - { - int i = 0; - /* unsigned long flags; */ - /* rcu_read_lock(); */ - bp_proc_create(); - for (i = 0; i < device_num; i++) { - if (bpctl_dev_arr[i].ifindex) { - /* spin_lock_irqsave(&bpvm_lock, flags); */ - bypass_proc_remove_dev_sd(&bpctl_dev_arr[i]); - bypass_proc_create_dev_sd(&bpctl_dev_arr[i]); - /* spin_unlock_irqrestore(&bpvm_lock, flags); */ - } - - } - /* rcu_read_unlock(); */ - } -#endif - - return 0; -} - -/* -* Cleanup - unregister the appropriate file from /proc -*/ -static void __exit bypass_cleanup_module(void) -{ - int i; - unregister_netdevice_notifier(&bp_notifier_block); - - for (i = 0; i < device_num; i++) { - /* unsigned long flags; */ -#ifdef BP_PROC_SUPPORT -/* spin_lock_irqsave(&bpvm_lock, flags); - rcu_read_lock(); */ - bypass_proc_remove_dev_sd(&bpctl_dev_arr[i]); -/* spin_unlock_irqrestore(&bpvm_lock, flags); - rcu_read_unlock(); */ -#endif - remove_bypass_wd_auto(&bpctl_dev_arr[i]); - bpctl_dev_arr[i].reset_time = 0; - - remove_bypass_tpl_auto(&bpctl_dev_arr[i]); - } - - /* unmap all devices */ - for (i = 0; i < device_num; i++) { -#ifdef BP_SELF_TEST - if (bpctl_dev_arr[i].bp_tx_data) - kfree(bpctl_dev_arr[i].bp_tx_data); -#endif - iounmap((void *)(bpctl_dev_arr[i].mem_map)); - } - - /* free all devices space */ - if (bpctl_dev_arr) - kfree(bpctl_dev_arr); - -/* -* Unregister the device -*/ - unregister_chrdev(major_num, DEVICE_NAME); -} - -module_init(bypass_init_module); -module_exit(bypass_cleanup_module); - -int is_bypass_sd(int ifindex) -{ - return is_bypass(get_dev_idx_p(ifindex)); -} - -int set_bypass_sd(int ifindex, int bypass_mode) -{ - - return set_bypass_fn(get_dev_idx_p(ifindex), bypass_mode); -} - -int get_bypass_sd(int ifindex) -{ - - return get_bypass_fn(get_dev_idx_p(ifindex)); -} - -int get_bypass_change_sd(int ifindex) -{ - - return get_bypass_change_fn(get_dev_idx_p(ifindex)); -} - -int set_dis_bypass_sd(int ifindex, int dis_param) -{ - return set_dis_bypass_fn(get_dev_idx_p(ifindex), dis_param); -} - -int get_dis_bypass_sd(int ifindex) -{ - - return get_dis_bypass_fn(get_dev_idx_p(ifindex)); -} - -int set_bypass_pwoff_sd(int ifindex, int bypass_mode) -{ - return set_bypass_pwoff_fn(get_dev_idx_p(ifindex), bypass_mode); - -} - -int get_bypass_pwoff_sd(int ifindex) -{ - return get_bypass_pwoff_fn(get_dev_idx_p(ifindex)); - -} - -int set_bypass_pwup_sd(int ifindex, int bypass_mode) -{ - return set_bypass_pwup_fn(get_dev_idx_p(ifindex), bypass_mode); - -} - -int get_bypass_pwup_sd(int ifindex) -{ - return get_bypass_pwup_fn(get_dev_idx_p(ifindex)); - -} - -int set_bypass_wd_sd(int if_index, int ms_timeout, int *ms_timeout_set) -{ - if ((is_bypass(get_dev_idx_p(if_index))) <= 0) - return BP_NOT_CAP; - *ms_timeout_set = set_bypass_wd_fn(get_dev_idx_p(if_index), ms_timeout); - return 0; -} - -int get_bypass_wd_sd(int ifindex, int *timeout) -{ - return get_bypass_wd_fn(get_dev_idx_p(ifindex), timeout); - -} - -int get_wd_expire_time_sd(int ifindex, int *time_left) -{ - return get_wd_expire_time_fn(get_dev_idx_p(ifindex), time_left); -} - -int reset_bypass_wd_timer_sd(int ifindex) -{ - return reset_bypass_wd_timer_fn(get_dev_idx_p(ifindex)); - -} - -int get_wd_set_caps_sd(int ifindex) -{ - return get_wd_set_caps_fn(get_dev_idx_p(ifindex)); - -} - -int set_std_nic_sd(int ifindex, int nic_mode) -{ - return set_std_nic_fn(get_dev_idx_p(ifindex), nic_mode); - -} - -int get_std_nic_sd(int ifindex) -{ - return get_std_nic_fn(get_dev_idx_p(ifindex)); - -} - -int set_tap_sd(int ifindex, int tap_mode) -{ - return set_tap_fn(get_dev_idx_p(ifindex), tap_mode); - -} - -int get_tap_sd(int ifindex) -{ - return get_tap_fn(get_dev_idx_p(ifindex)); - -} - -int set_tap_pwup_sd(int ifindex, int tap_mode) -{ - return set_tap_pwup_fn(get_dev_idx_p(ifindex), tap_mode); - -} - -int get_tap_pwup_sd(int ifindex) -{ - return get_tap_pwup_fn(get_dev_idx_p(ifindex)); - -} - -int get_tap_change_sd(int ifindex) -{ - return get_tap_change_fn(get_dev_idx_p(ifindex)); - -} - -int set_dis_tap_sd(int ifindex, int dis_param) -{ - return set_dis_tap_fn(get_dev_idx_p(ifindex), dis_param); - -} - -int get_dis_tap_sd(int ifindex) -{ - return get_dis_tap_fn(get_dev_idx_p(ifindex)); - -} - -int set_bp_disc_sd(int ifindex, int disc_mode) -{ - return set_disc_fn(get_dev_idx_p(ifindex), disc_mode); - -} - -int get_bp_disc_sd(int ifindex) -{ - return get_disc_fn(get_dev_idx_p(ifindex)); - -} - -int set_bp_disc_pwup_sd(int ifindex, int disc_mode) -{ - return set_disc_pwup_fn(get_dev_idx_p(ifindex), disc_mode); - -} - -int get_bp_disc_pwup_sd(int ifindex) -{ - return get_disc_pwup_fn(get_dev_idx_p(ifindex)); - -} - -int get_bp_disc_change_sd(int ifindex) -{ - return get_disc_change_fn(get_dev_idx_p(ifindex)); - -} - -int set_bp_dis_disc_sd(int ifindex, int dis_param) -{ - return set_dis_disc_fn(get_dev_idx_p(ifindex), dis_param); - -} - -int get_bp_dis_disc_sd(int ifindex) -{ - return get_dis_disc_fn(get_dev_idx_p(ifindex)); - -} - -int get_wd_exp_mode_sd(int ifindex) -{ - return get_wd_exp_mode_fn(get_dev_idx_p(ifindex)); -} - -int set_wd_exp_mode_sd(int ifindex, int param) -{ - return set_wd_exp_mode_fn(get_dev_idx_p(ifindex), param); - -} - -int reset_cont_sd(int ifindex) -{ - return reset_cont_fn(get_dev_idx_p(ifindex)); - -} - -int set_tx_sd(int ifindex, int tx_state) -{ - return set_tx_fn(get_dev_idx_p(ifindex), tx_state); - -} - -int set_tpl_sd(int ifindex, int tpl_state) -{ - return set_tpl_fn(get_dev_idx_p(ifindex), tpl_state); - -} - -int set_bp_hw_reset_sd(int ifindex, int status) -{ - return set_bp_hw_reset_fn(get_dev_idx_p(ifindex), status); - -} - -int set_wd_autoreset_sd(int ifindex, int param) -{ - return set_wd_autoreset_fn(get_dev_idx_p(ifindex), param); - -} - -int get_wd_autoreset_sd(int ifindex) -{ - return get_wd_autoreset_fn(get_dev_idx_p(ifindex)); - -} - -int get_bypass_caps_sd(int ifindex) -{ - return get_bypass_caps_fn(get_dev_idx_p(ifindex)); -} - -int get_bypass_slave_sd(int ifindex) -{ - bpctl_dev_t *pbpctl_dev_out; - int ret = get_bypass_slave_fn(get_dev_idx_p(ifindex), &pbpctl_dev_out); - if (ret == 1) - return pbpctl_dev_out->ifindex; - return -1; - -} - -int get_tx_sd(int ifindex) -{ - return get_tx_fn(get_dev_idx_p(ifindex)); - -} - -int get_tpl_sd(int ifindex) -{ - return get_tpl_fn(get_dev_idx_p(ifindex)); - -} - -int get_bp_hw_reset_sd(int ifindex) -{ - return get_bp_hw_reset_fn(get_dev_idx_p(ifindex)); - -} - -int get_bypass_info_sd(int ifindex, struct bp_info *bp_info) -{ - return get_bypass_info_fn(get_dev_idx_p(ifindex), bp_info->prod_name, &bp_info->fw_ver); -} - -int bp_if_scan_sd(void) -{ - if_scan_init(); - return 0; -} - -EXPORT_SYMBOL_NOVERS(is_bypass_sd); -EXPORT_SYMBOL_NOVERS(get_bypass_slave_sd); -EXPORT_SYMBOL_NOVERS(get_bypass_caps_sd); -EXPORT_SYMBOL_NOVERS(get_wd_set_caps_sd); -EXPORT_SYMBOL_NOVERS(set_bypass_sd); -EXPORT_SYMBOL_NOVERS(get_bypass_sd); -EXPORT_SYMBOL_NOVERS(get_bypass_change_sd); -EXPORT_SYMBOL_NOVERS(set_dis_bypass_sd); -EXPORT_SYMBOL_NOVERS(get_dis_bypass_sd); -EXPORT_SYMBOL_NOVERS(set_bypass_pwoff_sd); -EXPORT_SYMBOL_NOVERS(get_bypass_pwoff_sd); -EXPORT_SYMBOL_NOVERS(set_bypass_pwup_sd); -EXPORT_SYMBOL_NOVERS(get_bypass_pwup_sd); -EXPORT_SYMBOL_NOVERS(set_bypass_wd_sd); -EXPORT_SYMBOL_NOVERS(get_bypass_wd_sd); -EXPORT_SYMBOL_NOVERS(get_wd_expire_time_sd); -EXPORT_SYMBOL_NOVERS(reset_bypass_wd_timer_sd); -EXPORT_SYMBOL_NOVERS(set_std_nic_sd); -EXPORT_SYMBOL_NOVERS(get_std_nic_sd); -EXPORT_SYMBOL_NOVERS(set_tx_sd); -EXPORT_SYMBOL_NOVERS(get_tx_sd); -EXPORT_SYMBOL_NOVERS(set_tpl_sd); -EXPORT_SYMBOL_NOVERS(get_tpl_sd); -EXPORT_SYMBOL_NOVERS(set_bp_hw_reset_sd); -EXPORT_SYMBOL_NOVERS(get_bp_hw_reset_sd); -EXPORT_SYMBOL_NOVERS(set_tap_sd); -EXPORT_SYMBOL_NOVERS(get_tap_sd); -EXPORT_SYMBOL_NOVERS(get_tap_change_sd); -EXPORT_SYMBOL_NOVERS(set_dis_tap_sd); -EXPORT_SYMBOL_NOVERS(get_dis_tap_sd); -EXPORT_SYMBOL_NOVERS(set_tap_pwup_sd); -EXPORT_SYMBOL_NOVERS(get_tap_pwup_sd); -EXPORT_SYMBOL_NOVERS(set_wd_exp_mode_sd); -EXPORT_SYMBOL_NOVERS(get_wd_exp_mode_sd); -EXPORT_SYMBOL_NOVERS(set_wd_autoreset_sd); -EXPORT_SYMBOL_NOVERS(get_wd_autoreset_sd); -EXPORT_SYMBOL_NOVERS(set_bp_disc_sd); -EXPORT_SYMBOL_NOVERS(get_bp_disc_sd); -EXPORT_SYMBOL_NOVERS(get_bp_disc_change_sd); -EXPORT_SYMBOL_NOVERS(set_bp_dis_disc_sd); -EXPORT_SYMBOL_NOVERS(get_bp_dis_disc_sd); -EXPORT_SYMBOL_NOVERS(set_bp_disc_pwup_sd); -EXPORT_SYMBOL_NOVERS(get_bp_disc_pwup_sd); -EXPORT_SYMBOL_NOVERS(get_bypass_info_sd); -EXPORT_SYMBOL_NOVERS(bp_if_scan_sd); - -#define BP_PROC_DIR "bypass" - -static struct proc_dir_entry *bp_procfs_dir; - -int bp_proc_create(void) -{ - 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", - BP_PROC_DIR); - return -1; - } - return 0; -} - -static int procfs_add(char *proc_name, const struct file_operations *fops, - bpctl_dev_t *dev) -{ - struct bypass_pfs_sd *pfs = &dev->bypass_pfs_set; - if (!proc_create_data(proc_name, 0644, pfs->bypass_entry, fops, dev)) - return -1; - return 0; -} - -#define RO_FOPS(name) \ -static int name##_open(struct inode *inode, struct file *file) \ -{ \ - return single_open(file, show_##name, PDE(inode)->data);\ -} \ -static const struct file_operations name##_ops = { \ - .open = name##_open, \ - .read = seq_read, \ - .llseek = seq_lseek, \ - .release = single_release, \ -}; - -#define RW_FOPS(name) \ -static int name##_open(struct inode *inode, struct file *file) \ -{ \ - return single_open(file, show_##name, PDE(inode)->data);\ -} \ -static const struct file_operations name##_ops = { \ - .open = name##_open, \ - .read = seq_read, \ - .write = name##_write, \ - .llseek = seq_lseek, \ - .release = single_release, \ -}; - -static int show_bypass_info(struct seq_file *m, void *v) -{ - bpctl_dev_t *dev = m->private; - - 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) - -static int show_bypass_slave(struct seq_file *m, void *v) -{ - 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) - -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) - seq_printf(m, "-1\n"); - else - seq_printf(m, "0x%x\n", ret); - return 0; -} -RO_FOPS(bypass_caps) - -static int show_wd_set_caps(struct seq_file *m, void *v) -{ - bpctl_dev_t *dev = m->private; - int ret = get_wd_set_caps_fn(dev); - if (ret == BP_NOT_CAP) - seq_printf(m, "-1\n"); - else - seq_printf(m, "0x%x\n", ret); - return 0; -} -RO_FOPS(wd_set_caps) - -static int user_on_off(const void __user *buffer, size_t count) -{ - - char kbuf[256]; - int 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) - return 1; - if (strcmp(kbuf, "off") == 0) - return 0; - return 0; -} - -static ssize_t bypass_write(struct file *file, const char __user *buffer, - size_t count, loff_t *pos) -{ - int bypass_param = user_on_off(buffer, count); - if (bypass_param < 0) - return -1; - - set_bypass_fn(PDE(file_inode(file))->data, bypass_param); - return count; -} -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) - -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; - - set_tap_fn(PDE(file_inode(file))->data, tap_param); - return count; -} -static int show_tap(struct seq_file *m, void *v) -{ - bpctl_dev_t *dev = m->private; - int ret = get_tap_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(tap) - -static ssize_t disc_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; - - set_disc_fn(PDE(file_inode(file))->data, tap_param); - return count; -} -static int show_disc(struct seq_file *m, void *v) -{ - bpctl_dev_t *dev = m->private; - int ret = get_disc_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(disc) - -static int show_bypass_change(struct seq_file *m, void *v) -{ - bpctl_dev_t *dev = m->private; - int ret = get_bypass_change_fn(dev); - if (ret == 1) - seq_printf(m, "on\n"); - else if (ret == 0) - seq_printf(m, "off\n"); - else - seq_printf(m, "fail\n"); - return 0; -} -RO_FOPS(bypass_change) - -static int show_tap_change(struct seq_file *m, void *v) -{ - bpctl_dev_t *dev = m->private; - int ret = get_tap_change_fn(dev); - if (ret == 1) - seq_printf(m, "on\n"); - else if (ret == 0) - seq_printf(m, "off\n"); - else - seq_printf(m, "fail\n"); - return 0; -} -RO_FOPS(tap_change) - -static int show_disc_change(struct seq_file *m, void *v) -{ - bpctl_dev_t *dev = m->private; - int ret = get_disc_change_fn(dev); - if (ret == 1) - seq_printf(m, "on\n"); - else if (ret == 0) - seq_printf(m, "off\n"); - else - seq_printf(m, "fail\n"); - return 0; -} -RO_FOPS(disc_change) - -static ssize_t bypass_wd_write(struct file *file, const char __user *buffer, - size_t count, loff_t *pos) -{ - bpctl_dev_t *dev = PDE(file_inode(file))->data; - int timeout; - int ret = kstrtoint_from_user(buffer, count, 10, &timeout); - if (ret) - return ret; - set_bypass_wd_fn(dev, timeout); - return count; -} -static int show_bypass_wd(struct seq_file *m, void *v) -{ - bpctl_dev_t *dev = m->private; - int ret = 0, timeout = 0; - - ret = get_bypass_wd_fn(dev, &timeout); - if (ret == BP_NOT_CAP) - seq_printf(m, "fail\n"); - else if (timeout == -1) - seq_printf(m, "unknown\n"); - else if (timeout == 0) - seq_printf(m, "disable\n"); - else - seq_printf(m, "%d\n", timeout); - return 0; -} -RW_FOPS(bypass_wd) - -static int show_wd_expire_time(struct seq_file *m, void *v) -{ - bpctl_dev_t *dev = m->private; - int ret = 0, timeout = 0; - ret = get_wd_expire_time_fn(dev, &timeout); - if (ret == BP_NOT_CAP) - seq_printf(m, "fail\n"); - else if (timeout == -1) - seq_printf(m, "expire\n"); - else if (timeout == 0) - seq_printf(m, "disable\n"); - else - seq_printf(m, "%d\n", timeout); - return 0; -} -RO_FOPS(wd_expire_time) - -static ssize_t tpl_write(struct file *file, const char __user *buffer, - size_t count, loff_t *pos) -{ - bpctl_dev_t *dev = PDE(file_inode(file))->data; - int tpl_param = user_on_off(buffer, count); - if (tpl_param < 0) - return -1; - - 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) - 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(tpl) - -#ifdef PMC_FIX_FLAG -static ssize_t wait_at_pwup_write(struct file *file, const char __user *buffer, - size_t count, loff_t *pos) -{ - bpctl_dev_t *dev = PDE(file_inode(file))->data; - int tpl_param = user_on_off(buffer, count); - if (tpl_param < 0) - return -1; - - 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) - 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(wait_at_pwup) - -static ssize_t hw_reset_write(struct file *file, const char __user *buffer, - size_t count, loff_t *pos) -{ - bpctl_dev_t *dev = PDE(file_inode(file))->data; - int tpl_param = user_on_off(buffer, count); - if (tpl_param < 0) - return -1; - - 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) - 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(hw_reset) - -#endif /*PMC_WAIT_FLAG */ - -static int show_reset_bypass_wd(struct seq_file *m, void *v) -{ - bpctl_dev_t *dev = m->private; - int ret = reset_bypass_wd_timer_fn(dev); - if (ret == BP_NOT_CAP) - seq_printf(m, "fail\n"); - else if (ret == 0) - seq_printf(m, "disable\n"); - else if (ret == 1) - seq_printf(m, "success\n"); - return 0; -} -RO_FOPS(reset_bypass_wd) - -static ssize_t dis_bypass_write(struct file *file, const char __user *buffer, - size_t count, loff_t *pos) -{ - int bypass_param = user_on_off(buffer, count); - if (bypass_param < 0) - return -EINVAL; - - set_dis_bypass_fn(PDE(file_inode(file))->data, bypass_param); - return count; -} -static int show_dis_bypass(struct seq_file *m, void *v) -{ - 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) - -static ssize_t dis_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 -EINVAL; - - set_dis_tap_fn(PDE(file_inode(file))->data, tap_param); - return count; -} -static int show_dis_tap(struct seq_file *m, void *v) -{ - bpctl_dev_t *dev = m->private; - int ret = get_dis_tap_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_tap) - -static ssize_t dis_disc_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 -EINVAL; - - set_dis_disc_fn(PDE(file_inode(file))->data, tap_param); - return count; -} -static int show_dis_disc(struct seq_file *m, void *v) -{ - bpctl_dev_t *dev = m->private; - int ret = get_dis_disc_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_disc) - -static ssize_t bypass_pwup_write(struct file *file, const char __user *buffer, - size_t count, loff_t *pos) -{ - int bypass_param = user_on_off(buffer, count); - if (bypass_param < 0) - return -EINVAL; - - set_bypass_pwup_fn(PDE(file_inode(file))->data, bypass_param); - return count; -} -static int show_bypass_pwup(struct seq_file *m, void *v) -{ - 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) - -static ssize_t bypass_pwoff_write(struct file *file, const char __user *buffer, - size_t count, loff_t *pos) -{ - int bypass_param = user_on_off(buffer, count); - if (bypass_param < 0) - return -EINVAL; - - set_bypass_pwoff_fn(PDE(file_inode(file))->data, bypass_param); - return count; -} -static int show_bypass_pwoff(struct seq_file *m, void *v) -{ - bpctl_dev_t *dev = m->private; - int ret = get_bypass_pwoff_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_pwoff) - -static ssize_t tap_pwup_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 -EINVAL; - - set_tap_pwup_fn(PDE(file_inode(file))->data, tap_param); - return count; -} -static int show_tap_pwup(struct seq_file *m, void *v) -{ - bpctl_dev_t *dev = m->private; - int ret = get_tap_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(tap_pwup) - -static ssize_t disc_pwup_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 -EINVAL; - - set_disc_pwup_fn(PDE(file_inode(file))->data, 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) - seq_printf(m, "fail\n"); - else if (ret == 0) - seq_printf(m, "off\n"); - else - seq_printf(m, "on\n"); - return 0; -} -RW_FOPS(disc_pwup) - -static ssize_t std_nic_write(struct file *file, const char __user *buffer, - size_t count, loff_t *pos) -{ - int bypass_param = user_on_off(buffer, count); - if (bypass_param < 0) - return -EINVAL; - - set_std_nic_fn(PDE(file_inode(file))->data, bypass_param); - return count; -} -static int show_std_nic(struct seq_file *m, void *v) -{ - bpctl_dev_t *dev = m->private; - int ret = get_std_nic_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(std_nic) - -static ssize_t wd_exp_mode_write(struct file *file, const char __user *buffer, - size_t count, loff_t *pos) -{ - char kbuf[256]; - 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(PDE(file_inode(file))->data, bypass_param); - - return count; -} -static int show_wd_exp_mode(struct seq_file *m, void *v) -{ - 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 - seq_printf(m, "fail\n"); - return 0; -} -RW_FOPS(wd_exp_mode) - -static ssize_t wd_autoreset_write(struct file *file, const char __user *buffer, - size_t count, loff_t *pos) -{ - int timeout; - int ret = kstrtoint_from_user(buffer, count, 10, &timeout); - if (ret) - return ret; - set_wd_autoreset_fn(PDE(file_inode(file))->data, timeout); - return count; -} -static int show_wd_autoreset(struct seq_file *m, void *v) -{ - 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; -} -RW_FOPS(wd_autoreset) - -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 = NULL; - int ret = 0; - - if (!pbp_device_block->ndev) - return -1; - sprintf(current_pfs->dir_name, "bypass_%s", - pbp_device_block->ndev->name); - - if (!bp_procfs_dir) - return -1; - - /* create device proc dir */ - 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; - -#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 */ - 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) { - ENTRY(bypass); - ENTRY(dis_bypass); - ENTRY(bypass_pwup); - ENTRY(bypass_pwoff); - ENTRY(bypass_change); - } - if (pbp_device_block->bp_caps & TAP_CAP) { - ENTRY(tap); - ENTRY(dis_tap); - ENTRY(tap_pwup); - ENTRY(tap_change); - } - if (pbp_device_block->bp_caps & DISC_CAP) { - ENTRY(disc); - ENTRY(dis_disc); - ENTRY(disc_pwup); - ENTRY(disc_change); - } - - ENTRY(wd_exp_mode); - ENTRY(wd_autoreset); - ENTRY(tpl); -#ifdef PMC_FIX_FLAG - ENTRY(wait_at_pwup); - ENTRY(hw_reset); -#endif - } -#undef ENTRY - 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; - remove_proc_subtree(current_pfs->dir_name, bp_procfs_dir); - current_pfs->bypass_entry = NULL; - return 0; -} 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 -#include -#include -/* #include */ -#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/bpctl_mod.c b/drivers/staging/silicom/bpctl_mod.c new file mode 100644 index 00000000000..f64ee07c15a --- /dev/null +++ b/drivers/staging/silicom/bpctl_mod.c @@ -0,0 +1,7933 @@ +/******************************************************************************/ +/* */ +/* Bypass Control utility, Copyright (c) 2005-20011 Silicom */ +/* */ +/* 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. */ +/* Copyright(c) 2007 - 2009 Intel Corporation. All rights reserved. */ +/* */ +/* */ +/******************************************************************************/ + +#include /* We're doing kernel work */ +#include /* Specifically, a module */ +#include +#include +#include +#include +#include +#include +#include + +#include /* for get_user and put_user */ +#include +#include +#include + +#include "bp_ioctl.h" +#include "bp_mod.h" +#include "bypass.h" +#include "libbp_sd.h" + +#define SUCCESS 0 +#define BP_MOD_VER "9.0.4" +#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"); +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION(BP_MOD_DESCR); +MODULE_VERSION(BP_MOD_VER); +spinlock_t bpvm_lock; + +#define lock_bpctl() \ +if (down_interruptible(&bpctl_sema)) { \ + return -ERESTARTSYS; \ +} \ + +#define unlock_bpctl() \ + up(&bpctl_sema); + +/* Media Types */ +typedef enum { + bp_copper = 0, + bp_fiber, + bp_cx4, + bp_none, +} bp_media_type; + +struct bypass_pfs_sd { + char dir_name[32]; + struct proc_dir_entry *bypass_entry; +}; + +typedef struct _bpctl_dev { + char *name; + char *desc; + struct pci_dev *pdev; /* PCI device */ + struct net_device *ndev; /* net device */ + unsigned long mem_map; + uint8_t bus; + uint8_t slot; + uint8_t func; + u_int32_t device; + u_int32_t vendor; + u_int32_t subvendor; + u_int32_t subdevice; + int ifindex; + uint32_t bp_caps; + uint32_t bp_caps_ex; + uint8_t bp_fw_ver; + int bp_ext_ver; + int wdt_status; + unsigned long bypass_wdt_on_time; + uint32_t bypass_timer_interval; + struct timer_list bp_timer; + uint32_t reset_time; + uint8_t bp_status_un; + atomic_t wdt_busy; + bp_media_type media_type; + int bp_tpl_flag; + struct timer_list bp_tpl_timer; + spinlock_t bypass_wr_lock; + int bp_10g; + int bp_10gb; + int bp_fiber5; + int bp_10g9; + int bp_i80; + int bp_540; + int (*hard_start_xmit_save) (struct sk_buff *skb, + struct net_device *dev); + const struct net_device_ops *old_ops; + struct net_device_ops new_ops; + int bp_self_test_flag; + char *bp_tx_data; + struct bypass_pfs_sd bypass_pfs_set; + +} bpctl_dev_t; + +static bpctl_dev_t *bpctl_dev_arr; + +static struct semaphore bpctl_sema; +static int device_num = 0; + +static int get_dev_idx(int ifindex); +static bpctl_dev_t *get_master_port_fn(bpctl_dev_t *pbpctl_dev); +static int disc_status(bpctl_dev_t *pbpctl_dev); +static int bypass_status(bpctl_dev_t *pbpctl_dev); +static int wdt_timer(bpctl_dev_t *pbpctl_dev, int *time_left); +static bpctl_dev_t *get_status_port_fn(bpctl_dev_t *pbpctl_dev); +static void if_scan_init(void); + +int bypass_proc_create_dev_sd(bpctl_dev_t *pbp_device_block); +int bypass_proc_remove_dev_sd(bpctl_dev_t *pbp_device_block); +int bp_proc_create(void); + +int is_bypass_fn(bpctl_dev_t *pbpctl_dev); +int get_dev_idx_bsf(int bus, int slot, int func); + +static unsigned long str_to_hex(char *p); +static int bp_device_event(struct notifier_block *unused, + unsigned long event, void *ptr) +{ + struct net_device *dev = ptr; + static bpctl_dev_t *pbpctl_dev = NULL, *pbpctl_dev_m = NULL; + int dev_num = 0, ret = 0, ret_d = 0, time_left = 0; + /* printk("BP_PROC_SUPPORT event =%d %s %d\n", event,dev->name, dev->ifindex ); */ + /* return NOTIFY_DONE; */ + if (!dev) + return NOTIFY_DONE; + if (event == NETDEV_REGISTER) { + { + struct ethtool_drvinfo drvinfo; + char cbuf[32]; + char *buf = NULL; + char res[10]; + int i = 0, ifindex, idx_dev = 0; + int bus = 0, slot = 0, func = 0; + ifindex = dev->ifindex; + + memset(res, 0, 10); + memset(&drvinfo, 0, sizeof(struct ethtool_drvinfo)); + + if (dev->ethtool_ops && dev->ethtool_ops->get_drvinfo) { + memset(&drvinfo, 0, sizeof(drvinfo)); + dev->ethtool_ops->get_drvinfo(dev, &drvinfo); + } else + return NOTIFY_DONE; + if (!drvinfo.bus_info) + return NOTIFY_DONE; + if (!strcmp(drvinfo.bus_info, "N/A")) + return NOTIFY_DONE; + memcpy(&cbuf, drvinfo.bus_info, 32); + buf = &cbuf[0]; + + while (*buf++ != ':') ; + for (i = 0; i < 10; i++, buf++) { + if (*buf == ':') + break; + res[i] = *buf; + + } + buf++; + bus = str_to_hex(res); + memset(res, 0, 10); + + for (i = 0; i < 10; i++, buf++) { + if (*buf == '.') + break; + res[i] = *buf; + + } + buf++; + slot = str_to_hex(res); + func = str_to_hex(buf); + idx_dev = get_dev_idx_bsf(bus, slot, func); + + if (idx_dev != -1) { + + bpctl_dev_arr[idx_dev].ifindex = ifindex; + bpctl_dev_arr[idx_dev].ndev = dev; + + bypass_proc_remove_dev_sd(&bpctl_dev_arr + [idx_dev]); + bypass_proc_create_dev_sd(&bpctl_dev_arr + [idx_dev]); + + } + + } + return NOTIFY_DONE; + + } + if (event == NETDEV_UNREGISTER) { + int idx_dev = 0; + for (idx_dev = 0; + ((bpctl_dev_arr[idx_dev].pdev != NULL) + && (idx_dev < device_num)); idx_dev++) { + if (bpctl_dev_arr[idx_dev].ndev == dev) { + bypass_proc_remove_dev_sd(&bpctl_dev_arr + [idx_dev]); + bpctl_dev_arr[idx_dev].ndev = NULL; + + return NOTIFY_DONE; + + } + + } + return NOTIFY_DONE; + } + if (event == NETDEV_CHANGENAME) { + int idx_dev = 0; + for (idx_dev = 0; + ((bpctl_dev_arr[idx_dev].pdev != NULL) + && (idx_dev < device_num)); idx_dev++) { + if (bpctl_dev_arr[idx_dev].ndev == dev) { + bypass_proc_remove_dev_sd(&bpctl_dev_arr + [idx_dev]); + bypass_proc_create_dev_sd(&bpctl_dev_arr + [idx_dev]); + + return NOTIFY_DONE; + + } + + } + return NOTIFY_DONE; + + } + + switch (event) { + + case NETDEV_CHANGE:{ + if (netif_carrier_ok(dev)) + return NOTIFY_DONE; + + if (((dev_num = get_dev_idx(dev->ifindex)) == -1) || + (!(pbpctl_dev = &bpctl_dev_arr[dev_num]))) + return NOTIFY_DONE; + + if ((is_bypass_fn(pbpctl_dev)) == 1) + pbpctl_dev_m = pbpctl_dev; + else + pbpctl_dev_m = get_master_port_fn(pbpctl_dev); + if (!pbpctl_dev_m) + return NOTIFY_DONE; + ret = bypass_status(pbpctl_dev_m); + if (ret == 1) + printk("bpmod: %s is in the Bypass mode now", + dev->name); + ret_d = disc_status(pbpctl_dev_m); + if (ret_d == 1) + printk + ("bpmod: %s is in the Disconnect mode now", + dev->name); + if (ret || ret_d) { + wdt_timer(pbpctl_dev_m, &time_left); + if (time_left == -1) + printk("; WDT has expired"); + printk(".\n"); + + } + return NOTIFY_DONE; + + } + + default: + return NOTIFY_DONE; + + } + return NOTIFY_DONE; + +} + +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); + +static void write_pulse(bpctl_dev_t *pbpctl_dev, + unsigned int ctrl_ext, + unsigned char value, unsigned char len) +{ + unsigned char ctrl_val = 0; + unsigned int i = len; + unsigned int ctrl = 0; + bpctl_dev_t *pbpctl_dev_c = NULL; + + if (pbpctl_dev->bp_i80) + ctrl = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); + if (pbpctl_dev->bp_540) + ctrl = BP10G_READ_REG(pbpctl_dev, ESDP); + + if (pbpctl_dev->bp_10g9) { + if (!(pbpctl_dev_c = get_status_port_fn(pbpctl_dev))) + return; + ctrl = BP10G_READ_REG(pbpctl_dev_c, ESDP); + } + + while (i--) { + ctrl_val = (value >> i) & 0x1; + if (ctrl_val) { + if (pbpctl_dev->bp_10g9) { + + /* To start management : MCLK 1, MDIO 1, output */ + /* DATA 1 CLK 1 */ + /*BP10G_WRITE_REG(pbpctl_dev, I2CCTL, (ctrl_ext|BP10G_MCLK_DATA_OUT9|BP10G_MDIO_DATA_OUT9)); */ + BP10G_WRITE_REG(pbpctl_dev, I2CCTL, + ctrl_ext | + BP10G_MDIO_DATA_OUT9); + BP10G_WRITE_REG(pbpctl_dev_c, ESDP, + (ctrl | BP10G_MCLK_DATA_OUT9 | + BP10G_MCLK_DIR_OUT9)); + + } else if (pbpctl_dev->bp_fiber5) { + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, (ctrl_ext | + BPCTLI_CTRL_EXT_MCLK_DIR5 + | + BPCTLI_CTRL_EXT_MDIO_DIR5 + | + BPCTLI_CTRL_EXT_MDIO_DATA5 + | + BPCTLI_CTRL_EXT_MCLK_DATA5)); + + } else if (pbpctl_dev->bp_i80) { + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, (ctrl_ext | + BPCTLI_CTRL_EXT_MDIO_DIR80 + | + BPCTLI_CTRL_EXT_MDIO_DATA80)); + + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, (ctrl | + BPCTLI_CTRL_EXT_MCLK_DIR80 + | + BPCTLI_CTRL_EXT_MCLK_DATA80)); + + } else if (pbpctl_dev->bp_540) { + BP10G_WRITE_REG(pbpctl_dev, ESDP, (ctrl | + BP540_MDIO_DIR + | + BP540_MDIO_DATA + | + BP540_MCLK_DIR + | + BP540_MCLK_DATA)); + + } else if (pbpctl_dev->bp_10gb) { + BP10GB_WRITE_REG(pbpctl_dev, MISC_REG_SPIO, + (ctrl_ext | BP10GB_MDIO_SET | + BP10GB_MCLK_SET) & + ~(BP10GB_MCLK_DIR | + BP10GB_MDIO_DIR | + BP10GB_MDIO_CLR | + BP10GB_MCLK_CLR)); + + } else if (!pbpctl_dev->bp_10g) + /* To start management : MCLK 1, MDIO 1, output */ + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, + (ctrl_ext | + BPCTLI_CTRL_EXT_MCLK_DIR | + BPCTLI_CTRL_EXT_MDIO_DIR | + BPCTLI_CTRL_EXT_MDIO_DATA | + BPCTLI_CTRL_EXT_MCLK_DATA)); + else { + + /* To start management : MCLK 1, MDIO 1, output*/ + BP10G_WRITE_REG(pbpctl_dev, EODSDP, + (ctrl_ext | BP10G_MCLK_DATA_OUT + | BP10G_MDIO_DATA_OUT)); + + } + + usec_delay(PULSE_TIME); + if (pbpctl_dev->bp_10g9) { + + /*BP10G_WRITE_REG(pbpctl_dev, I2CCTL, ((ctrl_ext|BP10G_MDIO_DATA_OUT9)&~(BP10G_MCLK_DATA_OUT9))); */ + /* DATA 1 CLK 0 */ + BP10G_WRITE_REG(pbpctl_dev, I2CCTL, + ctrl_ext | + BP10G_MDIO_DATA_OUT9); + BP10G_WRITE_REG(pbpctl_dev_c, ESDP, + (ctrl | BP10G_MCLK_DIR_OUT9) & + ~BP10G_MCLK_DATA_OUT9); + + } else if (pbpctl_dev->bp_fiber5) { + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, + ((ctrl_ext | + BPCTLI_CTRL_EXT_MCLK_DIR5 | + BPCTLI_CTRL_EXT_MDIO_DIR5 | + BPCTLI_CTRL_EXT_MDIO_DATA5) + & + ~ + (BPCTLI_CTRL_EXT_MCLK_DATA5))); + + } else if (pbpctl_dev->bp_i80) { + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, (ctrl_ext | + BPCTLI_CTRL_EXT_MDIO_DIR80 + | + BPCTLI_CTRL_EXT_MDIO_DATA80)); + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, + ((ctrl | + BPCTLI_CTRL_EXT_MCLK_DIR80) + & + ~ + (BPCTLI_CTRL_EXT_MCLK_DATA80))); + + } else if (pbpctl_dev->bp_540) { + BP10G_WRITE_REG(pbpctl_dev, ESDP, + (ctrl | BP540_MDIO_DIR | + BP540_MDIO_DATA | + BP540_MCLK_DIR) & + ~(BP540_MCLK_DATA)); + + } else if (pbpctl_dev->bp_10gb) { + + BP10GB_WRITE_REG(pbpctl_dev, MISC_REG_SPIO, + (ctrl_ext | BP10GB_MDIO_SET | + BP10GB_MCLK_CLR) & + ~(BP10GB_MCLK_DIR | + BP10GB_MDIO_DIR | + BP10GB_MDIO_CLR | + BP10GB_MCLK_SET)); + + } else if (!pbpctl_dev->bp_10g) + + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, + ((ctrl_ext | + BPCTLI_CTRL_EXT_MCLK_DIR | + BPCTLI_CTRL_EXT_MDIO_DIR | + BPCTLI_CTRL_EXT_MDIO_DATA) + & + ~ + (BPCTLI_CTRL_EXT_MCLK_DATA))); + else { + + BP10G_WRITE_REG(pbpctl_dev, EODSDP, + ((ctrl_ext | + BP10G_MDIO_DATA_OUT) & + ~(BP10G_MCLK_DATA_OUT))); + } + + usec_delay(PULSE_TIME); + + } else { + if (pbpctl_dev->bp_10g9) { + /* DATA 0 CLK 1 */ + /*BP10G_WRITE_REG(pbpctl_dev, I2CCTL, ((ctrl_ext|BP10G_MCLK_DATA_OUT9)&~BP10G_MDIO_DATA_OUT9)); */ + BP10G_WRITE_REG(pbpctl_dev, I2CCTL, + (ctrl_ext & + ~BP10G_MDIO_DATA_OUT9)); + BP10G_WRITE_REG(pbpctl_dev_c, ESDP, + (ctrl | BP10G_MCLK_DATA_OUT9 | + BP10G_MCLK_DIR_OUT9)); + + } else if (pbpctl_dev->bp_fiber5) { + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, + ((ctrl_ext | + BPCTLI_CTRL_EXT_MCLK_DIR5 | + BPCTLI_CTRL_EXT_MDIO_DIR5 | + BPCTLI_CTRL_EXT_MCLK_DATA5) + & + ~ + (BPCTLI_CTRL_EXT_MDIO_DATA5))); + + } else if (pbpctl_dev->bp_i80) { + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, + ((ctrl_ext | + BPCTLI_CTRL_EXT_MDIO_DIR80) + & + ~ + (BPCTLI_CTRL_EXT_MDIO_DATA80))); + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, + (ctrl | + BPCTLI_CTRL_EXT_MCLK_DIR80 | + BPCTLI_CTRL_EXT_MCLK_DATA80)); + + } else if (pbpctl_dev->bp_540) { + BP10G_WRITE_REG(pbpctl_dev, ESDP, + ((ctrl | BP540_MCLK_DIR | + BP540_MCLK_DATA | + BP540_MDIO_DIR) & + ~(BP540_MDIO_DATA))); + + } else if (pbpctl_dev->bp_10gb) { + BP10GB_WRITE_REG(pbpctl_dev, MISC_REG_SPIO, + (ctrl_ext | BP10GB_MDIO_CLR | + BP10GB_MCLK_SET) & + ~(BP10GB_MCLK_DIR | + BP10GB_MDIO_DIR | + BP10GB_MDIO_SET | + BP10GB_MCLK_CLR)); + + } else if (!pbpctl_dev->bp_10g) + + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, + ((ctrl_ext | + BPCTLI_CTRL_EXT_MCLK_DIR | + BPCTLI_CTRL_EXT_MDIO_DIR | + BPCTLI_CTRL_EXT_MCLK_DATA) + & + ~ + (BPCTLI_CTRL_EXT_MDIO_DATA))); + else { + + BP10G_WRITE_REG(pbpctl_dev, EODSDP, + ((ctrl_ext | + BP10G_MCLK_DATA_OUT) & + ~BP10G_MDIO_DATA_OUT)); + + } + usec_delay(PULSE_TIME); + if (pbpctl_dev->bp_10g9) { + /* DATA 0 CLK 0 */ + /*BP10G_WRITE_REG(pbpctl_dev, I2CCTL, (ctrl_ext&~(BP10G_MCLK_DATA_OUT9|BP10G_MDIO_DATA_OUT9))); */ + BP10G_WRITE_REG(pbpctl_dev, I2CCTL, + (ctrl_ext & + ~BP10G_MDIO_DATA_OUT9)); + BP10G_WRITE_REG(pbpctl_dev_c, ESDP, + ((ctrl | BP10G_MCLK_DIR_OUT9) & + ~(BP10G_MCLK_DATA_OUT9))); + + } else if (pbpctl_dev->bp_fiber5) { + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, + ((ctrl_ext | + BPCTLI_CTRL_EXT_MCLK_DIR5 | + BPCTLI_CTRL_EXT_MDIO_DIR5) + & + ~(BPCTLI_CTRL_EXT_MCLK_DATA5 + | + BPCTLI_CTRL_EXT_MDIO_DATA5))); + + } else if (pbpctl_dev->bp_i80) { + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, + ((ctrl_ext | + BPCTLI_CTRL_EXT_MDIO_DIR80) + & + ~BPCTLI_CTRL_EXT_MDIO_DATA80)); + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, + ((ctrl | + BPCTLI_CTRL_EXT_MCLK_DIR80) + & + ~ + (BPCTLI_CTRL_EXT_MCLK_DATA80))); + + } else if (pbpctl_dev->bp_540) { + BP10G_WRITE_REG(pbpctl_dev, ESDP, + ((ctrl | BP540_MCLK_DIR | + BP540_MDIO_DIR) & + ~(BP540_MDIO_DATA | + BP540_MCLK_DATA))); + } else if (pbpctl_dev->bp_10gb) { + + BP10GB_WRITE_REG(pbpctl_dev, MISC_REG_SPIO, + (ctrl_ext | BP10GB_MDIO_CLR | + BP10GB_MCLK_CLR) & + ~(BP10GB_MCLK_DIR | + BP10GB_MDIO_DIR | + BP10GB_MDIO_SET | + BP10GB_MCLK_SET)); + + } else if (!pbpctl_dev->bp_10g) + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, + ((ctrl_ext | + BPCTLI_CTRL_EXT_MCLK_DIR | + BPCTLI_CTRL_EXT_MDIO_DIR) & + ~(BPCTLI_CTRL_EXT_MCLK_DATA + | + BPCTLI_CTRL_EXT_MDIO_DATA))); + else { + + BP10G_WRITE_REG(pbpctl_dev, EODSDP, + (ctrl_ext & + ~(BP10G_MCLK_DATA_OUT | + BP10G_MDIO_DATA_OUT))); + } + + usec_delay(PULSE_TIME); + } + + } +} + +static int read_pulse(bpctl_dev_t *pbpctl_dev, unsigned int ctrl_ext, + unsigned char len) +{ + unsigned char ctrl_val = 0; + unsigned int i = len; + unsigned int ctrl = 0; + bpctl_dev_t *pbpctl_dev_c = NULL; + + if (pbpctl_dev->bp_i80) + ctrl = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); + if (pbpctl_dev->bp_540) + ctrl = BP10G_READ_REG(pbpctl_dev, ESDP); + if (pbpctl_dev->bp_10g9) { + if (!(pbpctl_dev_c = get_status_port_fn(pbpctl_dev))) + return -1; + ctrl = BP10G_READ_REG(pbpctl_dev_c, ESDP); + } + + + while (i--) { + if (pbpctl_dev->bp_10g9) { + /*BP10G_WRITE_REG(pbpctl_dev, I2CCTL, ((ctrl_ext|BP10G_MDIO_DATA_OUT9)&~BP10G_MCLK_DATA_OUT9)); */ + /* DATA ? CLK 0 */ + BP10G_WRITE_REG(pbpctl_dev_c, ESDP, + ((ctrl | BP10G_MCLK_DIR_OUT9) & + ~(BP10G_MCLK_DATA_OUT9))); + + } else if (pbpctl_dev->bp_fiber5) { + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, ((ctrl_ext | + BPCTLI_CTRL_EXT_MCLK_DIR5) + & + ~ + (BPCTLI_CTRL_EXT_MDIO_DIR5 + | + BPCTLI_CTRL_EXT_MCLK_DATA5))); + + } else if (pbpctl_dev->bp_i80) { + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, + (ctrl_ext & + ~BPCTLI_CTRL_EXT_MDIO_DIR80)); + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, + ((ctrl | BPCTLI_CTRL_EXT_MCLK_DIR80) + & ~(BPCTLI_CTRL_EXT_MCLK_DATA80))); + + } else if (pbpctl_dev->bp_540) { + BP10G_WRITE_REG(pbpctl_dev, ESDP, + ((ctrl | BP540_MCLK_DIR) & + ~(BP540_MDIO_DIR | BP540_MCLK_DATA))); + + } else if (pbpctl_dev->bp_10gb) { + + BP10GB_WRITE_REG(pbpctl_dev, MISC_REG_SPIO, + (ctrl_ext | BP10GB_MDIO_DIR | + BP10GB_MCLK_CLR) & ~(BP10GB_MCLK_DIR | + BP10GB_MDIO_CLR | + BP10GB_MDIO_SET | + BP10GB_MCLK_SET)); + + } else if (!pbpctl_dev->bp_10g) + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ((ctrl_ext | + BPCTLI_CTRL_EXT_MCLK_DIR) + & + ~ + (BPCTLI_CTRL_EXT_MDIO_DIR + | + BPCTLI_CTRL_EXT_MCLK_DATA))); + else { + + BP10G_WRITE_REG(pbpctl_dev, EODSDP, ((ctrl_ext | BP10G_MDIO_DATA_OUT) & ~BP10G_MCLK_DATA_OUT)); /* ? */ + /* printk("0x28=0x%x\n",BP10G_READ_REG(pbpctl_dev,EODSDP);); */ + + } + + usec_delay(PULSE_TIME); + if (pbpctl_dev->bp_10g9) { + /*BP10G_WRITE_REG(pbpctl_dev, I2CCTL, (ctrl_ext|BP10G_MCLK_DATA_OUT9|BP10G_MDIO_DATA_OUT9)); */ + /* DATA ? CLK 1 */ + BP10G_WRITE_REG(pbpctl_dev_c, ESDP, + (ctrl | BP10G_MCLK_DATA_OUT9 | + BP10G_MCLK_DIR_OUT9)); + + } else if (pbpctl_dev->bp_fiber5) { + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, ((ctrl_ext | + BPCTLI_CTRL_EXT_MCLK_DIR5 + | + BPCTLI_CTRL_EXT_MCLK_DATA5) + & + ~ + (BPCTLI_CTRL_EXT_MDIO_DIR5))); + + } else if (pbpctl_dev->bp_i80) { + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, + (ctrl_ext & + ~(BPCTLI_CTRL_EXT_MDIO_DIR80))); + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, + (ctrl | BPCTLI_CTRL_EXT_MCLK_DIR80 | + BPCTLI_CTRL_EXT_MCLK_DATA80)); + + } else if (pbpctl_dev->bp_540) { + BP10G_WRITE_REG(pbpctl_dev, ESDP, + ((ctrl | BP540_MCLK_DIR | + BP540_MCLK_DATA) & + ~(BP540_MDIO_DIR))); + + } else if (pbpctl_dev->bp_10gb) { + BP10GB_WRITE_REG(pbpctl_dev, MISC_REG_SPIO, + (ctrl_ext | BP10GB_MDIO_DIR | + BP10GB_MCLK_SET) & ~(BP10GB_MCLK_DIR | + BP10GB_MDIO_CLR | + BP10GB_MDIO_SET | + BP10GB_MCLK_CLR)); + + } else if (!pbpctl_dev->bp_10g) + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ((ctrl_ext | + BPCTLI_CTRL_EXT_MCLK_DIR + | + BPCTLI_CTRL_EXT_MCLK_DATA) + & + ~ + (BPCTLI_CTRL_EXT_MDIO_DIR))); + else { + + BP10G_WRITE_REG(pbpctl_dev, EODSDP, + (ctrl_ext | BP10G_MCLK_DATA_OUT | + BP10G_MDIO_DATA_OUT)); + + } + if (pbpctl_dev->bp_10g9) { + ctrl_ext = BP10G_READ_REG(pbpctl_dev, I2CCTL); + + } else if ((pbpctl_dev->bp_fiber5) || (pbpctl_dev->bp_i80)) { + ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL); + } else if (pbpctl_dev->bp_540) { + ctrl_ext = BP10G_READ_REG(pbpctl_dev, ESDP); + } else if (pbpctl_dev->bp_10gb) + ctrl_ext = BP10GB_READ_REG(pbpctl_dev, MISC_REG_SPIO); + + else if (!pbpctl_dev->bp_10g) + ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); + else + ctrl_ext = BP10G_READ_REG(pbpctl_dev, EODSDP); + + usec_delay(PULSE_TIME); + if (pbpctl_dev->bp_10g9) { + if (ctrl_ext & BP10G_MDIO_DATA_IN9) + ctrl_val |= 1 << i; + + } else if (pbpctl_dev->bp_fiber5) { + if (ctrl_ext & BPCTLI_CTRL_EXT_MDIO_DATA5) + ctrl_val |= 1 << i; + } else if (pbpctl_dev->bp_i80) { + if (ctrl_ext & BPCTLI_CTRL_EXT_MDIO_DATA80) + ctrl_val |= 1 << i; + } else if (pbpctl_dev->bp_540) { + if (ctrl_ext & BP540_MDIO_DATA) + ctrl_val |= 1 << i; + } else if (pbpctl_dev->bp_10gb) { + if (ctrl_ext & BP10GB_MDIO_DATA) + ctrl_val |= 1 << i; + + } else if (!pbpctl_dev->bp_10g) { + + if (ctrl_ext & BPCTLI_CTRL_EXT_MDIO_DATA) + ctrl_val |= 1 << i; + } else { + + if (ctrl_ext & BP10G_MDIO_DATA_IN) + ctrl_val |= 1 << i; + } + + } + + return ctrl_val; +} + +static void write_reg(bpctl_dev_t *pbpctl_dev, unsigned char value, + unsigned char addr) +{ + uint32_t ctrl_ext = 0, ctrl = 0; + bpctl_dev_t *pbpctl_dev_c = NULL; + unsigned long flags; + if (pbpctl_dev->bp_10g9) { + if (!(pbpctl_dev_c = get_status_port_fn(pbpctl_dev))) + return; + } + if ((pbpctl_dev->wdt_status == WDT_STATUS_EN) && + (pbpctl_dev->bp_ext_ver < PXG4BPFI_VER)) + wdt_time_left(pbpctl_dev); + +#ifdef BP_SYNC_FLAG + spin_lock_irqsave(&pbpctl_dev->bypass_wr_lock, flags); +#else + atomic_set(&pbpctl_dev->wdt_busy, 1); +#endif + if (pbpctl_dev->bp_10g9) { + + ctrl_ext = BP10G_READ_REG(pbpctl_dev, I2CCTL); + ctrl = BP10G_READ_REG(pbpctl_dev_c, ESDP); + /* DATA 0 CLK 0 */ + /* BP10G_WRITE_REG(pbpctl_dev, I2CCTL, (ctrl_ext&~(BP10G_MCLK_DATA_OUT9|BP10G_MDIO_DATA_OUT9))); */ + BP10G_WRITE_REG(pbpctl_dev, I2CCTL, + (ctrl_ext & ~BP10G_MDIO_DATA_OUT9)); + BP10G_WRITE_REG(pbpctl_dev_c, ESDP, + ((ctrl | BP10G_MCLK_DIR_OUT9) & + ~(BP10G_MCLK_DATA_OUT9))); + + } else if (pbpctl_dev->bp_fiber5) { + ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL); + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, ((ctrl_ext | + BPCTLI_CTRL_EXT_MCLK_DIR5 + | + BPCTLI_CTRL_EXT_MDIO_DIR5) + & + ~ + (BPCTLI_CTRL_EXT_MDIO_DATA5 + | + BPCTLI_CTRL_EXT_MCLK_DATA5))); + } else if (pbpctl_dev->bp_i80) { + ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL); + ctrl = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, ((ctrl_ext | + BPCTLI_CTRL_EXT_MDIO_DIR80) + & + ~BPCTLI_CTRL_EXT_MDIO_DATA80)); + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, + ((ctrl | BPCTLI_CTRL_EXT_MCLK_DIR80) & + ~BPCTLI_CTRL_EXT_MCLK_DATA80)); + + } else if (pbpctl_dev->bp_540) { + ctrl = ctrl_ext = BP10G_READ_REG(pbpctl_dev, ESDP); + BP10G_WRITE_REG(pbpctl_dev, ESDP, ((ctrl | + BP540_MDIO_DIR | + BP540_MCLK_DIR) & + ~(BP540_MDIO_DATA | + BP540_MCLK_DATA))); + + } else if (pbpctl_dev->bp_10gb) { + ctrl_ext = BP10GB_READ_REG(pbpctl_dev, MISC_REG_SPIO); + + BP10GB_WRITE_REG(pbpctl_dev, MISC_REG_SPIO, + (ctrl_ext | BP10GB_MDIO_CLR | BP10GB_MCLK_CLR) + & ~(BP10GB_MCLK_DIR | BP10GB_MDIO_DIR | + BP10GB_MDIO_SET | BP10GB_MCLK_SET)); + + } else if (!pbpctl_dev->bp_10g) { + + ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ((ctrl_ext | + BPCTLI_CTRL_EXT_MCLK_DIR + | + BPCTLI_CTRL_EXT_MDIO_DIR) + & + ~ + (BPCTLI_CTRL_EXT_MDIO_DATA + | + BPCTLI_CTRL_EXT_MCLK_DATA))); + } else { + ctrl = BP10G_READ_REG(pbpctl_dev, ESDP); + ctrl_ext = BP10G_READ_REG(pbpctl_dev, EODSDP); + BP10G_WRITE_REG(pbpctl_dev, EODSDP, + (ctrl_ext & + ~(BP10G_MCLK_DATA_OUT | BP10G_MDIO_DATA_OUT))); + } + usec_delay(CMND_INTERVAL); + + /*send sync cmd */ + write_pulse(pbpctl_dev, ctrl_ext, SYNC_CMD_VAL, SYNC_CMD_LEN); + /*send wr cmd */ + write_pulse(pbpctl_dev, ctrl_ext, WR_CMD_VAL, WR_CMD_LEN); + write_pulse(pbpctl_dev, ctrl_ext, addr, ADDR_CMD_LEN); + + /*write data */ + write_pulse(pbpctl_dev, ctrl_ext, value, WR_DATA_LEN); + if (pbpctl_dev->bp_10g9) { + /*BP10G_WRITE_REG(pbpctl_dev, I2CCTL, (ctrl_ext&~(BP10G_MCLK_DATA_OUT9|BP10G_MDIO_DATA_OUT9))); */ + /* DATA 0 CLK 0 */ + BP10G_WRITE_REG(pbpctl_dev, I2CCTL, + (ctrl_ext & ~BP10G_MDIO_DATA_OUT9)); + BP10G_WRITE_REG(pbpctl_dev_c, ESDP, + ((ctrl | BP10G_MCLK_DIR_OUT9) & + ~(BP10G_MCLK_DATA_OUT9))); + + } else if (pbpctl_dev->bp_fiber5) { + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, ((ctrl_ext | + BPCTLI_CTRL_EXT_MCLK_DIR5 + | + BPCTLI_CTRL_EXT_MDIO_DIR5) + & + ~ + (BPCTLI_CTRL_EXT_MDIO_DATA5 + | + BPCTLI_CTRL_EXT_MCLK_DATA5))); + } else if (pbpctl_dev->bp_i80) { + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, ((ctrl_ext | + BPCTLI_CTRL_EXT_MDIO_DIR80) + & + ~BPCTLI_CTRL_EXT_MDIO_DATA80)); + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, + ((ctrl | BPCTLI_CTRL_EXT_MCLK_DIR80) & + ~BPCTLI_CTRL_EXT_MCLK_DATA80)); + } else if (pbpctl_dev->bp_540) { + BP10G_WRITE_REG(pbpctl_dev, ESDP, ((ctrl | + BP540_MDIO_DIR | + BP540_MCLK_DIR) & + ~(BP540_MDIO_DATA | + BP540_MCLK_DATA))); + } else if (pbpctl_dev->bp_10gb) { + BP10GB_WRITE_REG(pbpctl_dev, MISC_REG_SPIO, + (ctrl_ext | BP10GB_MDIO_CLR | BP10GB_MCLK_CLR) + & ~(BP10GB_MCLK_DIR | BP10GB_MDIO_DIR | + BP10GB_MDIO_SET | BP10GB_MCLK_SET)); + + } else if (!pbpctl_dev->bp_10g) + + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ((ctrl_ext | + BPCTLI_CTRL_EXT_MCLK_DIR + | + BPCTLI_CTRL_EXT_MDIO_DIR) + & + ~ + (BPCTLI_CTRL_EXT_MDIO_DATA + | + BPCTLI_CTRL_EXT_MCLK_DATA))); + else { + BP10G_WRITE_REG(pbpctl_dev, EODSDP, + (ctrl_ext & + ~(BP10G_MCLK_DATA_OUT | BP10G_MDIO_DATA_OUT))); + + } + + usec_delay(CMND_INTERVAL * 4); + + if ((pbpctl_dev->wdt_status == WDT_STATUS_EN) && + (pbpctl_dev->bp_ext_ver < PXG4BPFI_VER) && (addr == CMND_REG_ADDR)) + pbpctl_dev->bypass_wdt_on_time = jiffies; +#ifdef BP_SYNC_FLAG + spin_unlock_irqrestore(&pbpctl_dev->bypass_wr_lock, flags); +#else + atomic_set(&pbpctl_dev->wdt_busy, 0); +#endif + +} + +static void write_data(bpctl_dev_t *pbpctl_dev, unsigned char value) +{ + write_reg(pbpctl_dev, value, CMND_REG_ADDR); +} + +static int read_reg(bpctl_dev_t *pbpctl_dev, unsigned char addr) +{ + uint32_t ctrl_ext = 0, ctrl = 0, ctrl_value = 0; + bpctl_dev_t *pbpctl_dev_c = NULL; + +#ifdef BP_SYNC_FLAG + unsigned long flags; + spin_lock_irqsave(&pbpctl_dev->bypass_wr_lock, flags); +#else + atomic_set(&pbpctl_dev->wdt_busy, 1); +#endif + if (pbpctl_dev->bp_10g9) { + if (!(pbpctl_dev_c = get_status_port_fn(pbpctl_dev))) + return -1; + } + + if (pbpctl_dev->bp_10g9) { + ctrl_ext = BP10G_READ_REG(pbpctl_dev, I2CCTL); + ctrl = BP10G_READ_REG(pbpctl_dev_c, ESDP); + + /* BP10G_WRITE_REG(pbpctl_dev, I2CCTL, (ctrl_ext&~(BP10G_MCLK_DATA_OUT9|BP10G_MDIO_DATA_OUT9))); */ + /* DATA 0 CLK 0 */ + BP10G_WRITE_REG(pbpctl_dev, I2CCTL, + (ctrl_ext & ~BP10G_MDIO_DATA_OUT9)); + BP10G_WRITE_REG(pbpctl_dev_c, ESDP, + ((ctrl | BP10G_MCLK_DIR_OUT9) & + ~(BP10G_MCLK_DATA_OUT9))); + + } else if (pbpctl_dev->bp_fiber5) { + ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL); + + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, ((ctrl_ext | + BPCTLI_CTRL_EXT_MCLK_DIR5 + | + BPCTLI_CTRL_EXT_MDIO_DIR5) + & + ~ + (BPCTLI_CTRL_EXT_MDIO_DATA5 + | + BPCTLI_CTRL_EXT_MCLK_DATA5))); + } else if (pbpctl_dev->bp_i80) { + ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL); + ctrl = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); + + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, ((ctrl_ext | + BPCTLI_CTRL_EXT_MDIO_DIR80) + & + ~BPCTLI_CTRL_EXT_MDIO_DATA80)); + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, + ((ctrl | BPCTLI_CTRL_EXT_MCLK_DIR80) & + ~BPCTLI_CTRL_EXT_MCLK_DATA80)); + } else if (pbpctl_dev->bp_540) { + ctrl_ext = BP10G_READ_REG(pbpctl_dev, ESDP); + ctrl = BP10G_READ_REG(pbpctl_dev, ESDP); + + BP10G_WRITE_REG(pbpctl_dev, ESDP, ((ctrl | BP540_MCLK_DIR | + BP540_MDIO_DIR) & + ~(BP540_MDIO_DATA | + BP540_MCLK_DATA))); + } else if (pbpctl_dev->bp_10gb) { + ctrl_ext = BP10GB_READ_REG(pbpctl_dev, MISC_REG_SPIO); + + BP10GB_WRITE_REG(pbpctl_dev, MISC_REG_SPIO, + (ctrl_ext | BP10GB_MDIO_CLR | BP10GB_MCLK_CLR) + & ~(BP10GB_MCLK_DIR | BP10GB_MDIO_DIR | + BP10GB_MDIO_SET | BP10GB_MCLK_SET)); +#if 0 + + /*BP10GB_WRITE_REG(pbpctl_dev, MISC_REG_SPIO, (ctrl_ext | BP10GB_MCLK_DIR | BP10GB_MDIO_DIR| + BP10GB_MCLK_CLR|BP10GB_MDIO_CLR)); + ctrl_ext = BP10GB_READ_REG(pbpctl_dev, MISC_REG_SPIO); + printk("1reg=%x\n", ctrl_ext); */ + + BP10GB_WRITE_REG(pbpctl_dev, MISC_REG_SPIO, ((ctrl_ext | + BP10GB_MCLK_SET | + BP10GB_MDIO_CLR)) + & ~(BP10GB_MCLK_CLR | BP10GB_MDIO_SET | + BP10GB_MCLK_DIR | BP10GB_MDIO_DIR)); + + /* bnx2x_set_spio(pbpctl_dev, 5, MISC_REGISTERS_SPIO_OUTPUT_LOW); + bnx2x_set_spio(pbpctl_dev, 4, MISC_REGISTERS_SPIO_OUTPUT_LOW); + bnx2x_set_spio(pbpctl_dev, 4, MISC_REGISTERS_SPIO_INPUT_HI_Z); */ + + ctrl_ext = BP10GB_READ_REG(pbpctl_dev, MISC_REG_SPIO); + + printk("2reg=%x\n", ctrl_ext); + +#ifdef BP_SYNC_FLAG + spin_unlock_irqrestore(&pbpctl_dev->bypass_wr_lock, flags); +#else + atomic_set(&pbpctl_dev->wdt_busy, 0); +#endif + + return 0; + +#endif + + } else if (!pbpctl_dev->bp_10g) { + + ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); + + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ((ctrl_ext | + BPCTLI_CTRL_EXT_MCLK_DIR + | + BPCTLI_CTRL_EXT_MDIO_DIR) + & + ~ + (BPCTLI_CTRL_EXT_MDIO_DATA + | + BPCTLI_CTRL_EXT_MCLK_DATA))); + } else { + + ctrl = BP10G_READ_REG(pbpctl_dev, ESDP); + ctrl_ext = BP10G_READ_REG(pbpctl_dev, EODSDP); + BP10G_WRITE_REG(pbpctl_dev, EODSDP, + (ctrl_ext & + ~(BP10G_MCLK_DATA_OUT | BP10G_MDIO_DATA_OUT))); + + } + + usec_delay(CMND_INTERVAL); + + /*send sync cmd */ + write_pulse(pbpctl_dev, ctrl_ext, SYNC_CMD_VAL, SYNC_CMD_LEN); + /*send rd cmd */ + write_pulse(pbpctl_dev, ctrl_ext, RD_CMD_VAL, RD_CMD_LEN); + /*send addr */ + write_pulse(pbpctl_dev, ctrl_ext, addr, ADDR_CMD_LEN); + /*read data */ + /* zero */ + if (pbpctl_dev->bp_10g9) { + /* DATA 0 CLK 1 */ + /*BP10G_WRITE_REG(pbpctl_dev, I2CCTL, (ctrl_ext|BP10G_MCLK_DATA_OUT9|BP10G_MDIO_DATA_OUT9)); */ + BP10G_WRITE_REG(pbpctl_dev, I2CCTL, + (ctrl_ext | BP10G_MDIO_DATA_OUT9)); + BP10G_WRITE_REG(pbpctl_dev_c, ESDP, + (ctrl | BP10G_MCLK_DATA_OUT9 | + BP10G_MCLK_DIR_OUT9)); + + } else if (pbpctl_dev->bp_fiber5) { + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, ((ctrl_ext | + BPCTLI_CTRL_EXT_MCLK_DIR5 + | + BPCTLI_CTRL_EXT_MCLK_DATA5) + & + ~ + (BPCTLI_CTRL_EXT_MDIO_DIR5 + | + BPCTLI_CTRL_EXT_MDIO_DATA5))); + + } else if (pbpctl_dev->bp_i80) { + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, + (ctrl_ext & + ~(BPCTLI_CTRL_EXT_MDIO_DATA80 | + BPCTLI_CTRL_EXT_MDIO_DIR80))); + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, + (ctrl | BPCTLI_CTRL_EXT_MCLK_DIR80 | + BPCTLI_CTRL_EXT_MCLK_DATA80)); + + } else if (pbpctl_dev->bp_540) { + BP10G_WRITE_REG(pbpctl_dev, ESDP, + (((ctrl | BP540_MDIO_DIR | BP540_MCLK_DIR | + BP540_MCLK_DATA) & ~BP540_MDIO_DATA))); + + } else if (pbpctl_dev->bp_10gb) { + + BP10GB_WRITE_REG(pbpctl_dev, MISC_REG_SPIO, + (ctrl_ext | BP10GB_MDIO_DIR | BP10GB_MCLK_SET) + & ~(BP10GB_MCLK_DIR | BP10GB_MDIO_SET | + BP10GB_MDIO_CLR | BP10GB_MCLK_CLR)); + + } else if (!pbpctl_dev->bp_10g) + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ((ctrl_ext | + BPCTLI_CTRL_EXT_MCLK_DIR + | + BPCTLI_CTRL_EXT_MCLK_DATA) + & + ~ + (BPCTLI_CTRL_EXT_MDIO_DIR + | + BPCTLI_CTRL_EXT_MDIO_DATA))); + else { + + BP10G_WRITE_REG(pbpctl_dev, EODSDP, + (ctrl_ext | BP10G_MCLK_DATA_OUT | + BP10G_MDIO_DATA_OUT)); + + + } + usec_delay(PULSE_TIME); + + ctrl_value = read_pulse(pbpctl_dev, ctrl_ext, RD_DATA_LEN); + + if (pbpctl_dev->bp_10g9) { + ctrl_ext = BP10G_READ_REG(pbpctl_dev, I2CCTL); + ctrl = BP10G_READ_REG(pbpctl_dev_c, ESDP); + + /* BP10G_WRITE_REG(pbpctl_dev, I2CCTL, (ctrl_ext&~(BP10G_MCLK_DATA_OUT9|BP10G_MDIO_DATA_OUT9))); */ + /* DATA 0 CLK 0 */ + BP10G_WRITE_REG(pbpctl_dev, I2CCTL, + (ctrl_ext & ~BP10G_MDIO_DATA_OUT9)); + BP10G_WRITE_REG(pbpctl_dev_c, ESDP, + ((ctrl | BP10G_MCLK_DIR_OUT9) & + ~(BP10G_MCLK_DATA_OUT9))); + + } else if (pbpctl_dev->bp_fiber5) { + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, ((ctrl_ext | + BPCTLI_CTRL_EXT_MCLK_DIR5 + | + BPCTLI_CTRL_EXT_MDIO_DIR5) + & + ~ + (BPCTLI_CTRL_EXT_MDIO_DATA5 + | + BPCTLI_CTRL_EXT_MCLK_DATA5))); + } else if (pbpctl_dev->bp_i80) { + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, ((ctrl_ext | + BPCTLI_CTRL_EXT_MDIO_DIR80) + & + ~BPCTLI_CTRL_EXT_MDIO_DATA80)); + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, + ((ctrl | BPCTLI_CTRL_EXT_MCLK_DIR80) & + ~BPCTLI_CTRL_EXT_MCLK_DATA80)); + + } else if (pbpctl_dev->bp_540) { + ctrl = BP10G_READ_REG(pbpctl_dev, ESDP); + BP10G_WRITE_REG(pbpctl_dev, ESDP, ((ctrl | BP540_MCLK_DIR | + BP540_MDIO_DIR) & + ~(BP540_MDIO_DATA | + BP540_MCLK_DATA))); + + } else if (pbpctl_dev->bp_10gb) { + ctrl_ext = BP10GB_READ_REG(pbpctl_dev, MISC_REG_SPIO); + BP10GB_WRITE_REG(pbpctl_dev, MISC_REG_SPIO, + (ctrl_ext | BP10GB_MDIO_CLR | BP10GB_MCLK_CLR) + & ~(BP10GB_MCLK_DIR | BP10GB_MDIO_DIR | + BP10GB_MDIO_SET | BP10GB_MCLK_SET)); + + } else if (!pbpctl_dev->bp_10g) { + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ((ctrl_ext | + BPCTLI_CTRL_EXT_MCLK_DIR + | + BPCTLI_CTRL_EXT_MDIO_DIR) + & + ~ + (BPCTLI_CTRL_EXT_MDIO_DATA + | + BPCTLI_CTRL_EXT_MCLK_DATA))); + } else { + + ctrl = BP10G_READ_REG(pbpctl_dev, ESDP); + ctrl_ext = BP10G_READ_REG(pbpctl_dev, EODSDP); + BP10G_WRITE_REG(pbpctl_dev, EODSDP, + (ctrl_ext & + ~(BP10G_MCLK_DATA_OUT | BP10G_MDIO_DATA_OUT))); + + } + + usec_delay(CMND_INTERVAL * 4); +#ifdef BP_SYNC_FLAG + spin_unlock_irqrestore(&pbpctl_dev->bypass_wr_lock, flags); +#else + atomic_set(&pbpctl_dev->wdt_busy, 0); +#endif + + return ctrl_value; +} + +static int wdt_pulse(bpctl_dev_t *pbpctl_dev) +{ + uint32_t ctrl_ext = 0, ctrl = 0; + bpctl_dev_t *pbpctl_dev_c = NULL; + +#ifdef BP_SYNC_FLAG + unsigned long flags; + + spin_lock_irqsave(&pbpctl_dev->bypass_wr_lock, flags); +#else + + if ((atomic_read(&pbpctl_dev->wdt_busy)) == 1) + return -1; +#endif + if (pbpctl_dev->bp_10g9) { + if (!(pbpctl_dev_c = get_status_port_fn(pbpctl_dev))) + return -1; + } + + if (pbpctl_dev->bp_10g9) { + ctrl_ext = BP10G_READ_REG(pbpctl_dev, I2CCTL); + ctrl = BP10G_READ_REG(pbpctl_dev_c, ESDP); + + /* BP10G_WRITE_REG(pbpctl_dev, I2CCTL, (ctrl_ext&~(BP10G_MCLK_DATA_OUT9|BP10G_MDIO_DATA_OUT9))); */ + /* DATA 0 CLK 0 */ + BP10G_WRITE_REG(pbpctl_dev, I2CCTL, + (ctrl_ext & ~BP10G_MDIO_DATA_OUT9)); + BP10G_WRITE_REG(pbpctl_dev_c, ESDP, + ((ctrl | BP10G_MCLK_DIR_OUT9) & + ~(BP10G_MCLK_DATA_OUT9))); + + } else if (pbpctl_dev->bp_fiber5) { + ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL); + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, ((ctrl_ext | + BPCTLI_CTRL_EXT_MCLK_DIR5 + | + BPCTLI_CTRL_EXT_MDIO_DIR5) + & + ~ + (BPCTLI_CTRL_EXT_MDIO_DATA5 + | + BPCTLI_CTRL_EXT_MCLK_DATA5))); + } else if (pbpctl_dev->bp_i80) { + ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL); + ctrl = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, ((ctrl_ext | + BPCTLI_CTRL_EXT_MDIO_DIR80) + & + ~BPCTLI_CTRL_EXT_MDIO_DATA80)); + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, + ((ctrl | BPCTLI_CTRL_EXT_MCLK_DIR80) & + ~BPCTLI_CTRL_EXT_MCLK_DATA80)); + } else if (pbpctl_dev->bp_540) { + ctrl_ext = ctrl = BP10G_READ_REG(pbpctl_dev, ESDP); + BP10G_WRITE_REG(pbpctl_dev, ESDP, ((ctrl | BP540_MCLK_DIR | + BP540_MDIO_DIR) & + ~(BP540_MDIO_DATA | + BP540_MCLK_DATA))); + } else if (pbpctl_dev->bp_10gb) { + ctrl_ext = BP10GB_READ_REG(pbpctl_dev, MISC_REG_SPIO); + BP10GB_WRITE_REG(pbpctl_dev, MISC_REG_SPIO, + (ctrl_ext | BP10GB_MDIO_CLR | BP10GB_MCLK_CLR) + & ~(BP10GB_MCLK_DIR | BP10GB_MDIO_DIR | + BP10GB_MDIO_SET | BP10GB_MCLK_SET)); + + } else if (!pbpctl_dev->bp_10g) { + + ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ((ctrl_ext | + BPCTLI_CTRL_EXT_MCLK_DIR + | + BPCTLI_CTRL_EXT_MDIO_DIR) + & + ~ + (BPCTLI_CTRL_EXT_MDIO_DATA + | + BPCTLI_CTRL_EXT_MCLK_DATA))); + } else { + + ctrl = BP10G_READ_REG(pbpctl_dev, ESDP); + ctrl_ext = BP10G_READ_REG(pbpctl_dev, EODSDP); + BP10G_WRITE_REG(pbpctl_dev, EODSDP, + (ctrl_ext & + ~(BP10G_MCLK_DATA_OUT | BP10G_MDIO_DATA_OUT))); + + } + if (pbpctl_dev->bp_10g9) { + /* BP10G_WRITE_REG(pbpctl_dev, I2CCTL, ((ctrl_ext|BP10G_MCLK_DATA_OUT9)&~BP10G_MDIO_DATA_OUT9)); */ + /* DATA 0 CLK 1 */ + BP10G_WRITE_REG(pbpctl_dev, I2CCTL, + (ctrl_ext & ~BP10G_MDIO_DATA_OUT9)); + BP10G_WRITE_REG(pbpctl_dev_c, ESDP, + (ctrl | BP10G_MCLK_DATA_OUT9 | + BP10G_MCLK_DIR_OUT9)); + + } else if (pbpctl_dev->bp_fiber5) { + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, ((ctrl_ext | + BPCTLI_CTRL_EXT_MCLK_DIR5 + | + BPCTLI_CTRL_EXT_MDIO_DIR5 + | + BPCTLI_CTRL_EXT_MCLK_DATA5) + & + ~ + (BPCTLI_CTRL_EXT_MDIO_DATA5))); + } else if (pbpctl_dev->bp_i80) { + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, ((ctrl_ext | + BPCTLI_CTRL_EXT_MDIO_DIR80) + & + ~BPCTLI_CTRL_EXT_MDIO_DATA80)); + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, + (ctrl | BPCTLI_CTRL_EXT_MCLK_DIR80 | + BPCTLI_CTRL_EXT_MCLK_DATA80)); + + } else if (pbpctl_dev->bp_540) { + BP10G_WRITE_REG(pbpctl_dev, ESDP, ((ctrl | + BP540_MDIO_DIR | + BP540_MCLK_DIR | + BP540_MCLK_DATA) & + ~BP540_MDIO_DATA)); + + } else if (pbpctl_dev->bp_10gb) { + ctrl_ext = BP10GB_READ_REG(pbpctl_dev, MISC_REG_SPIO); + + BP10GB_WRITE_REG(pbpctl_dev, MISC_REG_SPIO, + (ctrl_ext | BP10GB_MDIO_CLR | BP10GB_MCLK_SET) + & ~(BP10GB_MCLK_DIR | BP10GB_MDIO_DIR | + BP10GB_MDIO_SET | BP10GB_MCLK_CLR)); + + } else if (!pbpctl_dev->bp_10g) + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ((ctrl_ext | + BPCTLI_CTRL_EXT_MCLK_DIR + | + BPCTLI_CTRL_EXT_MDIO_DIR + | + BPCTLI_CTRL_EXT_MCLK_DATA) + & + ~ + (BPCTLI_CTRL_EXT_MDIO_DATA))); + else { + + BP10G_WRITE_REG(pbpctl_dev, EODSDP, + ((ctrl_ext | BP10G_MCLK_DATA_OUT) & + ~BP10G_MDIO_DATA_OUT)); + + } + + usec_delay(WDT_INTERVAL); + if (pbpctl_dev->bp_10g9) { + /* BP10G_WRITE_REG(pbpctl_dev, I2CCTL, (ctrl_ext&~(BP10G_MCLK_DATA_OUT9|BP10G_MDIO_DATA_OUT9))); */ + /* DATA 0 CLK 0 */ + BP10G_WRITE_REG(pbpctl_dev, I2CCTL, + (ctrl_ext & ~BP10G_MDIO_DATA_OUT9)); + BP10G_WRITE_REG(pbpctl_dev_c, ESDP, + ((ctrl | BP10G_MCLK_DIR_OUT9) & + ~(BP10G_MCLK_DATA_OUT9))); + + } else if (pbpctl_dev->bp_fiber5) { + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, ((ctrl_ext | + BPCTLI_CTRL_EXT_MCLK_DIR5 + | + BPCTLI_CTRL_EXT_MDIO_DIR5) + & + ~ + (BPCTLI_CTRL_EXT_MCLK_DATA5 + | + BPCTLI_CTRL_EXT_MDIO_DATA5))); + } else if (pbpctl_dev->bp_i80) { + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, ((ctrl_ext | + BPCTLI_CTRL_EXT_MDIO_DIR80) + & + ~BPCTLI_CTRL_EXT_MDIO_DATA80)); + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, + ((ctrl | BPCTLI_CTRL_EXT_MCLK_DIR80) & + ~BPCTLI_CTRL_EXT_MCLK_DATA80)); + + } else if (pbpctl_dev->bp_540) { + BP10G_WRITE_REG(pbpctl_dev, ESDP, ((ctrl | BP540_MCLK_DIR | + BP540_MDIO_DIR) & + ~(BP540_MDIO_DATA | + BP540_MCLK_DATA))); + + } else if (pbpctl_dev->bp_10gb) { + ctrl_ext = BP10GB_READ_REG(pbpctl_dev, MISC_REG_SPIO); + BP10GB_WRITE_REG(pbpctl_dev, MISC_REG_SPIO, + (ctrl_ext | BP10GB_MDIO_CLR | BP10GB_MCLK_CLR) + & ~(BP10GB_MCLK_DIR | BP10GB_MDIO_DIR | + BP10GB_MDIO_SET | BP10GB_MCLK_SET)); + + } else if (!pbpctl_dev->bp_10g) + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ((ctrl_ext | + BPCTLI_CTRL_EXT_MCLK_DIR + | + BPCTLI_CTRL_EXT_MDIO_DIR) + & + ~ + (BPCTLI_CTRL_EXT_MCLK_DATA + | + BPCTLI_CTRL_EXT_MDIO_DATA))); + else { + + BP10G_WRITE_REG(pbpctl_dev, EODSDP, + (ctrl_ext & + ~(BP10G_MCLK_DATA_OUT | BP10G_MDIO_DATA_OUT))); + } + if ((pbpctl_dev->wdt_status == WDT_STATUS_EN) /*&& + (pbpctl_dev->bp_ext_verbypass_wdt_on_time = jiffies; +#ifdef BP_SYNC_FLAG + spin_unlock_irqrestore(&pbpctl_dev->bypass_wr_lock, flags); +#endif + usec_delay(CMND_INTERVAL * 4); + return 0; +} + +static void data_pulse(bpctl_dev_t *pbpctl_dev, unsigned char value) +{ + + uint32_t ctrl_ext = 0; +#ifdef BP_SYNC_FLAG + unsigned long flags; +#endif + wdt_time_left(pbpctl_dev); +#ifdef BP_SYNC_FLAG + spin_lock_irqsave(&pbpctl_dev->bypass_wr_lock, flags); +#else + atomic_set(&pbpctl_dev->wdt_busy, 1); +#endif + + ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ((ctrl_ext | + BPCTLI_CTRL_EXT_SDP6_DIR | + BPCTLI_CTRL_EXT_SDP7_DIR) & + ~(BPCTLI_CTRL_EXT_SDP6_DATA | + BPCTLI_CTRL_EXT_SDP7_DATA))); + + usec_delay(INIT_CMND_INTERVAL); + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ((ctrl_ext | + BPCTLI_CTRL_EXT_SDP6_DIR | + BPCTLI_CTRL_EXT_SDP7_DIR | + BPCTLI_CTRL_EXT_SDP6_DATA) & + ~ + (BPCTLI_CTRL_EXT_SDP7_DATA))); + usec_delay(INIT_CMND_INTERVAL); + + while (value) { + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ctrl_ext | + BPCTLI_CTRL_EXT_SDP6_DIR | + BPCTLI_CTRL_EXT_SDP7_DIR | + BPCTLI_CTRL_EXT_SDP6_DATA | + BPCTLI_CTRL_EXT_SDP7_DATA); + usec_delay(PULSE_INTERVAL); + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ((ctrl_ext | + BPCTLI_CTRL_EXT_SDP6_DIR + | + BPCTLI_CTRL_EXT_SDP7_DIR + | + BPCTLI_CTRL_EXT_SDP6_DATA) + & + ~BPCTLI_CTRL_EXT_SDP7_DATA)); + usec_delay(PULSE_INTERVAL); + value--; + + } + usec_delay(INIT_CMND_INTERVAL - PULSE_INTERVAL); + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ((ctrl_ext | + BPCTLI_CTRL_EXT_SDP6_DIR | + BPCTLI_CTRL_EXT_SDP7_DIR) & + ~(BPCTLI_CTRL_EXT_SDP6_DATA | + BPCTLI_CTRL_EXT_SDP7_DATA))); + usec_delay(WDT_TIME_CNT); + if (pbpctl_dev->wdt_status == WDT_STATUS_EN) + pbpctl_dev->bypass_wdt_on_time = jiffies; +#ifdef BP_SYNC_FLAG + spin_unlock_irqrestore(&pbpctl_dev->bypass_wr_lock, flags); +#else + atomic_set(&pbpctl_dev->wdt_busy, 0); +#endif + +} + +static int send_wdt_pulse(bpctl_dev_t *pbpctl_dev) +{ + uint32_t ctrl_ext = 0; + +#ifdef BP_SYNC_FLAG + unsigned long flags; + + spin_lock_irqsave(&pbpctl_dev->bypass_wr_lock, flags); +#else + + if ((atomic_read(&pbpctl_dev->wdt_busy)) == 1) + return -1; +#endif + wdt_time_left(pbpctl_dev); + ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); + + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ctrl_ext | /* 1 */ + BPCTLI_CTRL_EXT_SDP7_DIR | + BPCTLI_CTRL_EXT_SDP7_DATA); + usec_delay(PULSE_INTERVAL); + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ((ctrl_ext | /* 0 */ + BPCTLI_CTRL_EXT_SDP7_DIR) & + ~BPCTLI_CTRL_EXT_SDP7_DATA)); + + usec_delay(PULSE_INTERVAL); + if (pbpctl_dev->wdt_status == WDT_STATUS_EN) + pbpctl_dev->bypass_wdt_on_time = jiffies; +#ifdef BP_SYNC_FLAG + spin_unlock_irqrestore(&pbpctl_dev->bypass_wr_lock, flags); +#endif + + return 0; +} + +void send_bypass_clear_pulse(bpctl_dev_t *pbpctl_dev, unsigned int value) +{ + uint32_t ctrl_ext = 0; + + ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ((ctrl_ext | /* 0 */ + BPCTLI_CTRL_EXT_SDP6_DIR) & + ~BPCTLI_CTRL_EXT_SDP6_DATA)); + + usec_delay(PULSE_INTERVAL); + while (value) { + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ctrl_ext | /* 1 */ + BPCTLI_CTRL_EXT_SDP6_DIR | + BPCTLI_CTRL_EXT_SDP6_DATA); + usec_delay(PULSE_INTERVAL); + value--; + } + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ((ctrl_ext | /* 0 */ + BPCTLI_CTRL_EXT_SDP6_DIR) & + ~BPCTLI_CTRL_EXT_SDP6_DATA)); + usec_delay(PULSE_INTERVAL); +} + +/* #endif OLD_FW */ +#ifdef BYPASS_DEBUG + +int pulse_set_fn(bpctl_dev_t *pbpctl_dev, unsigned int counter) +{ + uint32_t ctrl_ext = 0; + + if (!pbpctl_dev) + return -1; + + ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); + write_pulse_1(pbpctl_dev, ctrl_ext, counter, counter); + + pbpctl_dev->bypass_wdt_status = 0; + if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { + write_pulse_1(pbpctl_dev, ctrl_ext, counter, counter); + } else { + wdt_time_left(pbpctl_dev); + if (pbpctl_dev->wdt_status == WDT_STATUS_EN) { + pbpctl_dev->wdt_status = 0; + data_pulse(pbpctl_dev, counter); + pbpctl_dev->wdt_status = WDT_STATUS_EN; + pbpctl_dev->bypass_wdt_on_time = jiffies; + + } else + data_pulse(pbpctl_dev, counter); + } + + return 0; +} + +int zero_set_fn(bpctl_dev_t *pbpctl_dev) +{ + uint32_t ctrl_ext = 0, ctrl_value = 0; + if (!pbpctl_dev) + return -1; + + if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { + printk("zero_set"); + + ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); + + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ((ctrl_ext | + BPCTLI_CTRL_EXT_MCLK_DIR) + & + ~ + (BPCTLI_CTRL_EXT_MCLK_DATA + | + BPCTLI_CTRL_EXT_MDIO_DIR + | + BPCTLI_CTRL_EXT_MDIO_DATA))); + + } + return ctrl_value; +} + +int pulse_get2_fn(bpctl_dev_t *pbpctl_dev) +{ + uint32_t ctrl_ext = 0, ctrl_value = 0; + if (!pbpctl_dev) + return -1; + + if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { + printk("pulse_get_fn\n"); + ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); + ctrl_value = read_pulse_2(pbpctl_dev, ctrl_ext); + printk("read:%d\n", ctrl_value); + } + return ctrl_value; +} + +int pulse_get1_fn(bpctl_dev_t *pbpctl_dev) +{ + uint32_t ctrl_ext = 0, ctrl_value = 0; + if (!pbpctl_dev) + return -1; + + if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { + + printk("pulse_get_fn\n"); + + ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); + ctrl_value = read_pulse_1(pbpctl_dev, ctrl_ext); + printk("read:%d\n", ctrl_value); + } + return ctrl_value; +} + +int gpio6_set_fn(bpctl_dev_t *pbpctl_dev) +{ + uint32_t ctrl_ext = 0; + + ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ctrl_ext | + BPCTLI_CTRL_EXT_SDP6_DIR | + BPCTLI_CTRL_EXT_SDP6_DATA); + return 0; +} + +int gpio7_set_fn(bpctl_dev_t *pbpctl_dev) +{ + uint32_t ctrl_ext = 0; + + ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ctrl_ext | + BPCTLI_CTRL_EXT_SDP7_DIR | + BPCTLI_CTRL_EXT_SDP7_DATA); + return 0; +} + +int gpio7_clear_fn(bpctl_dev_t *pbpctl_dev) +{ + uint32_t ctrl_ext = 0; + + ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ((ctrl_ext | + BPCTLI_CTRL_EXT_SDP7_DIR) & + ~BPCTLI_CTRL_EXT_SDP7_DATA)); + return 0; +} + +int gpio6_clear_fn(bpctl_dev_t *pbpctl_dev) +{ + uint32_t ctrl_ext = 0; + + ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, ((ctrl_ext | + BPCTLI_CTRL_EXT_SDP6_DIR) & + ~BPCTLI_CTRL_EXT_SDP6_DATA)); + return 0; +} +#endif /*BYPASS_DEBUG */ + +static bpctl_dev_t *lookup_port(bpctl_dev_t *dev) +{ + 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; +} + +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) +{ + if (pbpctl_dev) { + if (pbpctl_dev->func == 1 || pbpctl_dev->func == 3) + return lookup_port(pbpctl_dev); + } + return NULL; +} + +/**************************************/ +/**************INTEL API***************/ +/**************************************/ + +static void write_data_port_int(bpctl_dev_t *pbpctl_dev, + unsigned char ctrl_value) +{ + uint32_t value; + + value = BPCTL_READ_REG(pbpctl_dev, CTRL); +/* Make SDP0 Pin Directonality to Output */ + value |= BPCTLI_CTRL_SDP0_DIR; + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, value); + + value &= ~BPCTLI_CTRL_SDP0_DATA; + value |= ((ctrl_value & 0x1) << BPCTLI_CTRL_SDP0_SHIFT); + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, value); + + value = (BPCTL_READ_REG(pbpctl_dev, CTRL_EXT)); +/* Make SDP2 Pin Directonality to Output */ + value |= BPCTLI_CTRL_EXT_SDP6_DIR; + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, value); + + value &= ~BPCTLI_CTRL_EXT_SDP6_DATA; + value |= (((ctrl_value & 0x2) >> 1) << BPCTLI_CTRL_EXT_SDP6_SHIFT); + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, value); + +} + +static int write_data_int(bpctl_dev_t *pbpctl_dev, unsigned char value) +{ + bpctl_dev_t *pbpctl_dev_b = NULL; + + if (!(pbpctl_dev_b = get_status_port_fn(pbpctl_dev))) + return -1; + atomic_set(&pbpctl_dev->wdt_busy, 1); + write_data_port_int(pbpctl_dev, value & 0x3); + write_data_port_int(pbpctl_dev_b, ((value & 0xc) >> 2)); + atomic_set(&pbpctl_dev->wdt_busy, 0); + + return 0; +} + +static int wdt_pulse_int(bpctl_dev_t *pbpctl_dev) +{ + + if ((atomic_read(&pbpctl_dev->wdt_busy)) == 1) + return -1; + + if ((write_data_int(pbpctl_dev, RESET_WDT_INT)) < 0) + return -1; + msec_delay_bp(CMND_INTERVAL_INT); + if ((write_data_int(pbpctl_dev, CMND_OFF_INT)) < 0) + return -1; + msec_delay_bp(CMND_INTERVAL_INT); + + if (pbpctl_dev->wdt_status == WDT_STATUS_EN) + pbpctl_dev->bypass_wdt_on_time = jiffies; + + return 0; +} + +/*************************************/ +/************* COMMANDS **************/ +/*************************************/ + +/* CMND_ON 0x4 (100)*/ +int cmnd_on(bpctl_dev_t *pbpctl_dev) +{ + int ret = BP_NOT_CAP; + + if (pbpctl_dev->bp_caps & SW_CTL_CAP) { + if (INTEL_IF_SERIES(pbpctl_dev->subdevice)) + return 0; + if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) + write_data(pbpctl_dev, CMND_ON); + else + data_pulse(pbpctl_dev, CMND_ON); + ret = 0; + } + return ret; +} + +/* CMND_OFF 0x2 (10)*/ +int cmnd_off(bpctl_dev_t *pbpctl_dev) +{ + int ret = BP_NOT_CAP; + + if (pbpctl_dev->bp_caps & SW_CTL_CAP) { + if (INTEL_IF_SERIES(pbpctl_dev->subdevice)) { + write_data_int(pbpctl_dev, CMND_OFF_INT); + msec_delay_bp(CMND_INTERVAL_INT); + } else if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) + write_data(pbpctl_dev, CMND_OFF); + else + data_pulse(pbpctl_dev, CMND_OFF); + ret = 0; + }; + return ret; +} + +/* BYPASS_ON (0xa)*/ +int bypass_on(bpctl_dev_t *pbpctl_dev) +{ + int ret = BP_NOT_CAP; + + if (pbpctl_dev->bp_caps & BP_CAP) { + if (INTEL_IF_SERIES(pbpctl_dev->subdevice)) { + write_data_int(pbpctl_dev, BYPASS_ON_INT); + msec_delay_bp(BYPASS_DELAY_INT); + pbpctl_dev->bp_status_un = 0; + } else if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { + write_data(pbpctl_dev, BYPASS_ON); + if (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER) + msec_delay_bp(LATCH_DELAY); + } else + data_pulse(pbpctl_dev, BYPASS_ON); + ret = 0; + }; + return ret; +} + +/* BYPASS_OFF (0x8 111)*/ +int bypass_off(bpctl_dev_t *pbpctl_dev) +{ + int ret = BP_NOT_CAP; + + if (pbpctl_dev->bp_caps & BP_CAP) { + if (INTEL_IF_SERIES(pbpctl_dev->subdevice)) { + write_data_int(pbpctl_dev, DIS_BYPASS_CAP_INT); + msec_delay_bp(BYPASS_DELAY_INT); + write_data_int(pbpctl_dev, PWROFF_BYPASS_ON_INT); + msec_delay_bp(BYPASS_DELAY_INT); + pbpctl_dev->bp_status_un = 0; + } else if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { + write_data(pbpctl_dev, BYPASS_OFF); + if (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER) + msec_delay_bp(LATCH_DELAY); + } else + data_pulse(pbpctl_dev, BYPASS_OFF); + ret = 0; + } + return ret; +} + +/* TAP_OFF (0x9)*/ +int tap_off(bpctl_dev_t *pbpctl_dev) +{ + int ret = BP_NOT_CAP; + if ((pbpctl_dev->bp_caps & TAP_CAP) + && (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER)) { + write_data(pbpctl_dev, TAP_OFF); + msec_delay_bp(LATCH_DELAY); + ret = 0; + }; + return ret; +} + +/* TAP_ON (0xb)*/ +int tap_on(bpctl_dev_t *pbpctl_dev) +{ + int ret = BP_NOT_CAP; + if ((pbpctl_dev->bp_caps & TAP_CAP) + && (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER)) { + write_data(pbpctl_dev, TAP_ON); + msec_delay_bp(LATCH_DELAY); + ret = 0; + }; + return ret; +} + +/* DISC_OFF (0x9)*/ +int disc_off(bpctl_dev_t *pbpctl_dev) +{ + int ret = 0; + if ((pbpctl_dev->bp_caps & DISC_CAP) && (pbpctl_dev->bp_ext_ver >= 0x8)) { + write_data(pbpctl_dev, DISC_OFF); + msec_delay_bp(LATCH_DELAY); + } else + ret = BP_NOT_CAP; + return ret; +} + +/* DISC_ON (0xb)*/ +int disc_on(bpctl_dev_t *pbpctl_dev) +{ + int ret = 0; + if ((pbpctl_dev->bp_caps & DISC_CAP) && (pbpctl_dev->bp_ext_ver >= 0x8)) { + write_data(pbpctl_dev, /*DISC_ON */ 0x85); + msec_delay_bp(LATCH_DELAY); + } else + ret = BP_NOT_CAP; + return ret; +} + +/* DISC_PORT_ON */ +int disc_port_on(bpctl_dev_t *pbpctl_dev) +{ + int ret = 0; + bpctl_dev_t *pbpctl_dev_m; + + if ((is_bypass_fn(pbpctl_dev)) == 1) + pbpctl_dev_m = pbpctl_dev; + else + pbpctl_dev_m = get_master_port_fn(pbpctl_dev); + if (pbpctl_dev_m == NULL) + return BP_NOT_CAP; + + if (pbpctl_dev_m->bp_caps_ex & DISC_PORT_CAP_EX) { + if (is_bypass_fn(pbpctl_dev) == 1) { + + write_data(pbpctl_dev_m, TX_DISA); + } else { + + write_data(pbpctl_dev_m, TX_DISB); + } + + msec_delay_bp(LATCH_DELAY); + + } + return ret; +} + +/* DISC_PORT_OFF */ +int disc_port_off(bpctl_dev_t *pbpctl_dev) +{ + int ret = 0; + bpctl_dev_t *pbpctl_dev_m; + + if ((is_bypass_fn(pbpctl_dev)) == 1) + pbpctl_dev_m = pbpctl_dev; + else + pbpctl_dev_m = get_master_port_fn(pbpctl_dev); + if (pbpctl_dev_m == NULL) + return BP_NOT_CAP; + + if (pbpctl_dev_m->bp_caps_ex & DISC_PORT_CAP_EX) { + if (is_bypass_fn(pbpctl_dev) == 1) + write_data(pbpctl_dev_m, TX_ENA); + else + write_data(pbpctl_dev_m, TX_ENB); + + msec_delay_bp(LATCH_DELAY); + + } + return ret; +} + +/*TWO_PORT_LINK_HW_EN (0xe)*/ +int tpl_hw_on(bpctl_dev_t *pbpctl_dev) +{ + int ret = 0, ctrl = 0; + bpctl_dev_t *pbpctl_dev_b = NULL; + + if (!(pbpctl_dev_b = get_status_port_fn(pbpctl_dev))) + return BP_NOT_CAP; + + if (pbpctl_dev->bp_caps_ex & TPL2_CAP_EX) { + cmnd_on(pbpctl_dev); + write_data(pbpctl_dev, TPL2_ON); + msec_delay_bp(LATCH_DELAY + EEPROM_WR_DELAY); + cmnd_off(pbpctl_dev); + return ret; + } + + if (TPL_IF_SERIES(pbpctl_dev->subdevice)) { + ctrl = BPCTL_READ_REG(pbpctl_dev_b, CTRL); + BPCTL_BP_WRITE_REG(pbpctl_dev_b, CTRL, + ((ctrl | BPCTLI_CTRL_SWDPIO0) & + ~BPCTLI_CTRL_SWDPIN0)); + } else + ret = BP_NOT_CAP; + return ret; +} + +/*TWO_PORT_LINK_HW_DIS (0xc)*/ +int tpl_hw_off(bpctl_dev_t *pbpctl_dev) +{ + int ret = 0, ctrl = 0; + bpctl_dev_t *pbpctl_dev_b = NULL; + + if (!(pbpctl_dev_b = get_status_port_fn(pbpctl_dev))) + return BP_NOT_CAP; + if (pbpctl_dev->bp_caps_ex & TPL2_CAP_EX) { + cmnd_on(pbpctl_dev); + write_data(pbpctl_dev, TPL2_OFF); + msec_delay_bp(LATCH_DELAY + EEPROM_WR_DELAY); + cmnd_off(pbpctl_dev); + return ret; + } + if (TPL_IF_SERIES(pbpctl_dev->subdevice)) { + ctrl = BPCTL_READ_REG(pbpctl_dev_b, CTRL); + BPCTL_BP_WRITE_REG(pbpctl_dev_b, CTRL, + (ctrl | BPCTLI_CTRL_SWDPIO0 | + BPCTLI_CTRL_SWDPIN0)); + } else + ret = BP_NOT_CAP; + return ret; +} + +/* WDT_OFF (0x6 110)*/ +int wdt_off(bpctl_dev_t *pbpctl_dev) +{ + int ret = BP_NOT_CAP; + + if (pbpctl_dev->bp_caps & WD_CTL_CAP) { + if (INTEL_IF_SERIES(pbpctl_dev->subdevice)) { + bypass_off(pbpctl_dev); + } else if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) + write_data(pbpctl_dev, WDT_OFF); + else + data_pulse(pbpctl_dev, WDT_OFF); + pbpctl_dev->wdt_status = WDT_STATUS_DIS; + ret = 0; + }; + return ret; +} + +/* WDT_ON (0x10)*/ + +/***Global***/ +static unsigned int + wdt_val_array[] = { 1000, 1500, 2000, 3000, 4000, 8000, 16000, 32000, 0 }; + +int wdt_on(bpctl_dev_t *pbpctl_dev, unsigned int timeout) +{ + + if (pbpctl_dev->bp_caps & WD_CTL_CAP) { + unsigned int pulse = 0, temp_value = 0, temp_cnt = 0; + pbpctl_dev->wdt_status = 0; + + if (INTEL_IF_SERIES(pbpctl_dev->subdevice)) { + for (; wdt_val_array[temp_cnt]; temp_cnt++) + if (timeout <= wdt_val_array[temp_cnt]) + break; + + if (!wdt_val_array[temp_cnt]) + temp_cnt--; + + timeout = wdt_val_array[temp_cnt]; + temp_cnt += 0x7; + + write_data_int(pbpctl_dev, DIS_BYPASS_CAP_INT); + msec_delay_bp(BYPASS_DELAY_INT); + pbpctl_dev->bp_status_un = 0; + write_data_int(pbpctl_dev, temp_cnt); + pbpctl_dev->bypass_wdt_on_time = jiffies; + msec_delay_bp(CMND_INTERVAL_INT); + pbpctl_dev->bypass_timer_interval = timeout; + } else { + timeout = + (timeout < + TIMEOUT_UNIT ? TIMEOUT_UNIT : (timeout > + WDT_TIMEOUT_MAX ? + WDT_TIMEOUT_MAX : + timeout)); + temp_value = timeout / 100; + while ((temp_value >>= 1)) + temp_cnt++; + if (timeout > ((1 << temp_cnt) * 100)) + temp_cnt++; + pbpctl_dev->bypass_wdt_on_time = jiffies; + pulse = (WDT_ON | temp_cnt); + if (pbpctl_dev->bp_ext_ver == OLD_IF_VER) + data_pulse(pbpctl_dev, pulse); + else + write_data(pbpctl_dev, pulse); + pbpctl_dev->bypass_timer_interval = + (1 << temp_cnt) * 100; + } + pbpctl_dev->wdt_status = WDT_STATUS_EN; + return 0; + } + return BP_NOT_CAP; +} + +void bp75_put_hw_semaphore_generic(bpctl_dev_t *pbpctl_dev) +{ + u32 swsm; + + swsm = BPCTL_READ_REG(pbpctl_dev, SWSM); + + swsm &= ~(BPCTLI_SWSM_SMBI | BPCTLI_SWSM_SWESMBI); + + BPCTL_WRITE_REG(pbpctl_dev, SWSM, swsm); +} + +s32 bp75_get_hw_semaphore_generic(bpctl_dev_t *pbpctl_dev) +{ + u32 swsm; + s32 ret_val = 0; + s32 timeout = 8192 + 1; + s32 i = 0; + + /* Get the SW semaphore */ + while (i < timeout) { + swsm = BPCTL_READ_REG(pbpctl_dev, SWSM); + if (!(swsm & BPCTLI_SWSM_SMBI)) + break; + + usec_delay(50); + i++; + } + + if (i == timeout) { + printk + ("bpctl_mod: Driver can't access device - SMBI bit is set.\n"); + ret_val = -1; + goto out; + } + + /* Get the FW semaphore. */ + for (i = 0; i < timeout; i++) { + swsm = BPCTL_READ_REG(pbpctl_dev, SWSM); + BPCTL_WRITE_REG(pbpctl_dev, SWSM, swsm | BPCTLI_SWSM_SWESMBI); + + /* Semaphore acquired if bit latched */ + if (BPCTL_READ_REG(pbpctl_dev, SWSM) & BPCTLI_SWSM_SWESMBI) + break; + + usec_delay(50); + } + + if (i == timeout) { + /* Release semaphores */ + bp75_put_hw_semaphore_generic(pbpctl_dev); + printk("bpctl_mod: Driver can't access the NVM\n"); + ret_val = -1; + goto out; + } + + out: + return ret_val; +} + +static void bp75_release_phy(bpctl_dev_t *pbpctl_dev) +{ + u16 mask = BPCTLI_SWFW_PHY0_SM; + u32 swfw_sync; + + if ((pbpctl_dev->func == 1) || (pbpctl_dev->func == 3)) + mask = BPCTLI_SWFW_PHY1_SM; + + while (bp75_get_hw_semaphore_generic(pbpctl_dev) != 0) ; + /* Empty */ + + swfw_sync = BPCTL_READ_REG(pbpctl_dev, SW_FW_SYNC); + swfw_sync &= ~mask; + BPCTL_WRITE_REG(pbpctl_dev, SW_FW_SYNC, swfw_sync); + + bp75_put_hw_semaphore_generic(pbpctl_dev); +} + +static s32 bp75_acquire_phy(bpctl_dev_t *pbpctl_dev) +{ + u16 mask = BPCTLI_SWFW_PHY0_SM; + u32 swfw_sync; + u32 swmask; + u32 fwmask; + s32 ret_val = 0; + s32 i = 0, timeout = 200; + + if ((pbpctl_dev->func == 1) || (pbpctl_dev->func == 3)) + mask = BPCTLI_SWFW_PHY1_SM; + + swmask = mask; + fwmask = mask << 16; + + while (i < timeout) { + if (bp75_get_hw_semaphore_generic(pbpctl_dev)) { + ret_val = -1; + goto out; + } + + swfw_sync = BPCTL_READ_REG(pbpctl_dev, SW_FW_SYNC); + if (!(swfw_sync & (fwmask | swmask))) + break; + + bp75_put_hw_semaphore_generic(pbpctl_dev); + mdelay(5); + i++; + } + + if (i == timeout) { + printk + ("bpctl_mod: Driver can't access resource, SW_FW_SYNC timeout.\n"); + ret_val = -1; + goto out; + } + + swfw_sync |= swmask; + BPCTL_WRITE_REG(pbpctl_dev, SW_FW_SYNC, swfw_sync); + + bp75_put_hw_semaphore_generic(pbpctl_dev); + + out: + return ret_val; +} + +s32 bp75_read_phy_reg_mdic(bpctl_dev_t *pbpctl_dev, u32 offset, u16 *data) +{ + u32 i, mdic = 0; + s32 ret_val = 0; + u32 phy_addr = 1; + + mdic = ((offset << BPCTLI_MDIC_REG_SHIFT) | + (phy_addr << BPCTLI_MDIC_PHY_SHIFT) | (BPCTLI_MDIC_OP_READ)); + + BPCTL_WRITE_REG(pbpctl_dev, MDIC, mdic); + + for (i = 0; i < (BPCTLI_GEN_POLL_TIMEOUT * 3); i++) { + usec_delay(50); + mdic = BPCTL_READ_REG(pbpctl_dev, MDIC); + if (mdic & BPCTLI_MDIC_READY) + break; + } + if (!(mdic & BPCTLI_MDIC_READY)) { + printk("bpctl_mod: MDI Read did not complete\n"); + ret_val = -1; + goto out; + } + if (mdic & BPCTLI_MDIC_ERROR) { + printk("bpctl_mod: MDI Error\n"); + ret_val = -1; + goto out; + } + *data = (u16) mdic; + + out: + return ret_val; +} + +s32 bp75_write_phy_reg_mdic(bpctl_dev_t *pbpctl_dev, u32 offset, u16 data) +{ + u32 i, mdic = 0; + s32 ret_val = 0; + u32 phy_addr = 1; + + mdic = (((u32) data) | + (offset << BPCTLI_MDIC_REG_SHIFT) | + (phy_addr << BPCTLI_MDIC_PHY_SHIFT) | (BPCTLI_MDIC_OP_WRITE)); + + BPCTL_WRITE_REG(pbpctl_dev, MDIC, mdic); + + for (i = 0; i < (BPCTLI_GEN_POLL_TIMEOUT * 3); i++) { + usec_delay(50); + mdic = BPCTL_READ_REG(pbpctl_dev, MDIC); + if (mdic & BPCTLI_MDIC_READY) + break; + } + if (!(mdic & BPCTLI_MDIC_READY)) { + printk("bpctl_mod: MDI Write did not complete\n"); + ret_val = -1; + goto out; + } + if (mdic & BPCTLI_MDIC_ERROR) { + printk("bpctl_mod: MDI Error\n"); + ret_val = -1; + goto out; + } + + out: + return ret_val; +} + +static s32 bp75_read_phy_reg(bpctl_dev_t *pbpctl_dev, u32 offset, u16 *data) +{ + s32 ret_val = 0; + + ret_val = bp75_acquire_phy(pbpctl_dev); + if (ret_val) + goto out; + + if (offset > BPCTLI_MAX_PHY_MULTI_PAGE_REG) { + ret_val = bp75_write_phy_reg_mdic(pbpctl_dev, + BPCTLI_IGP01E1000_PHY_PAGE_SELECT, + (u16) offset); + if (ret_val) + goto release; + } + + ret_val = + bp75_read_phy_reg_mdic(pbpctl_dev, + BPCTLI_MAX_PHY_REG_ADDRESS & offset, data); + + release: + bp75_release_phy(pbpctl_dev); + out: + return ret_val; +} + +static s32 bp75_write_phy_reg(bpctl_dev_t *pbpctl_dev, u32 offset, u16 data) +{ + s32 ret_val = 0; + + ret_val = bp75_acquire_phy(pbpctl_dev); + if (ret_val) + goto out; + + if (offset > BPCTLI_MAX_PHY_MULTI_PAGE_REG) { + ret_val = bp75_write_phy_reg_mdic(pbpctl_dev, + BPCTLI_IGP01E1000_PHY_PAGE_SELECT, + (u16) offset); + if (ret_val) + goto release; + } + + ret_val = + bp75_write_phy_reg_mdic(pbpctl_dev, + BPCTLI_MAX_PHY_REG_ADDRESS & offset, data); + + release: + bp75_release_phy(pbpctl_dev); + + out: + return ret_val; +} + +/* SET_TX (non-Bypass command :)) */ +static int set_tx(bpctl_dev_t *pbpctl_dev, int tx_state) +{ + int ret = 0, ctrl = 0; + bpctl_dev_t *pbpctl_dev_m; + if ((is_bypass_fn(pbpctl_dev)) == 1) + pbpctl_dev_m = pbpctl_dev; + else + pbpctl_dev_m = get_master_port_fn(pbpctl_dev); + if (pbpctl_dev_m == NULL) + return BP_NOT_CAP; + if (pbpctl_dev_m->bp_caps_ex & DISC_PORT_CAP_EX) { + ctrl = BPCTL_READ_REG(pbpctl_dev, CTRL); + if (!tx_state) { + if (pbpctl_dev->bp_540) { + ctrl = BP10G_READ_REG(pbpctl_dev, ESDP); + BP10G_WRITE_REG(pbpctl_dev, ESDP, + (ctrl | BP10G_SDP1_DIR | + BP10G_SDP1_DATA)); + + } else { + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, + (ctrl | BPCTLI_CTRL_SDP1_DIR + | BPCTLI_CTRL_SWDPIN1)); + } + } else { + if (pbpctl_dev->bp_540) { + ctrl = BP10G_READ_REG(pbpctl_dev, ESDP); + BP10G_WRITE_REG(pbpctl_dev, ESDP, + ((ctrl | BP10G_SDP1_DIR) & + ~BP10G_SDP1_DATA)); + } else { + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, + ((ctrl | + BPCTLI_CTRL_SDP1_DIR) & + ~BPCTLI_CTRL_SWDPIN1)); + } + return ret; + + } + } else if (pbpctl_dev->bp_caps & TX_CTL_CAP) { + if (PEG5_IF_SERIES(pbpctl_dev->subdevice)) { + if (tx_state) { + uint16_t mii_reg; + if (! + (ret = + bp75_read_phy_reg(pbpctl_dev, + BPCTLI_PHY_CONTROL, + &mii_reg))) { + if (mii_reg & BPCTLI_MII_CR_POWER_DOWN) { + ret = + bp75_write_phy_reg + (pbpctl_dev, + BPCTLI_PHY_CONTROL, + mii_reg & + ~BPCTLI_MII_CR_POWER_DOWN); + } + } + } else { + uint16_t mii_reg; + if (! + (ret = + bp75_read_phy_reg(pbpctl_dev, + BPCTLI_PHY_CONTROL, + &mii_reg))) { + + mii_reg |= BPCTLI_MII_CR_POWER_DOWN; + ret = + bp75_write_phy_reg(pbpctl_dev, + BPCTLI_PHY_CONTROL, + mii_reg); + } + } + + } + if (pbpctl_dev->bp_fiber5) { + ctrl = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); + + } else if (pbpctl_dev->bp_10gb) + ctrl = BP10GB_READ_REG(pbpctl_dev, MISC_REG_GPIO); + + else if (!pbpctl_dev->bp_10g) + ctrl = BPCTL_READ_REG(pbpctl_dev, CTRL); + else + ctrl = BP10G_READ_REG(pbpctl_dev, ESDP); + + if (!tx_state) + if (pbpctl_dev->bp_10g9) { + BP10G_WRITE_REG(pbpctl_dev, ESDP, + (ctrl | BP10G_SDP3_DATA | + BP10G_SDP3_DIR)); + + } else if (pbpctl_dev->bp_fiber5) { + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, + (ctrl | + BPCTLI_CTRL_EXT_SDP6_DIR | + BPCTLI_CTRL_EXT_SDP6_DATA)); + + } else if (pbpctl_dev->bp_10gb) { + if ((pbpctl_dev->func == 1) + || (pbpctl_dev->func == 3)) + BP10GB_WRITE_REG(pbpctl_dev, + MISC_REG_GPIO, + (ctrl | + BP10GB_GPIO0_SET_P1) & + ~(BP10GB_GPIO0_CLR_P1 | + BP10GB_GPIO0_OE_P1)); + else + BP10GB_WRITE_REG(pbpctl_dev, + MISC_REG_GPIO, + (ctrl | + BP10GB_GPIO0_OE_P0 | + BP10GB_GPIO0_SET_P0)); + + } else if (pbpctl_dev->bp_i80) { + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, + (ctrl | BPCTLI_CTRL_SDP1_DIR + | BPCTLI_CTRL_SWDPIN1)); + + } else if (pbpctl_dev->bp_540) { + ctrl = BP10G_READ_REG(pbpctl_dev, ESDP); + BP10G_WRITE_REG(pbpctl_dev, ESDP, + (ctrl | BP10G_SDP1_DIR | + BP10G_SDP1_DATA)); + + } + + else if (!pbpctl_dev->bp_10g) + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, + (ctrl | BPCTLI_CTRL_SWDPIO0 | + BPCTLI_CTRL_SWDPIN0)); + + else + BP10G_WRITE_REG(pbpctl_dev, ESDP, + (ctrl | BP10G_SDP0_DATA | + BP10G_SDP0_DIR)); + + else { + if (pbpctl_dev->bp_10g9) { + BP10G_WRITE_REG(pbpctl_dev, ESDP, + ((ctrl | BP10G_SDP3_DIR) & + ~BP10G_SDP3_DATA)); + + } else if (pbpctl_dev->bp_fiber5) { + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL_EXT, + ((ctrl | + BPCTLI_CTRL_EXT_SDP6_DIR) & + ~BPCTLI_CTRL_EXT_SDP6_DATA)); + + } else if (pbpctl_dev->bp_10gb) { + if ((bpctl_dev_arr->func == 1) + || (bpctl_dev_arr->func == 3)) + BP10GB_WRITE_REG(pbpctl_dev, + MISC_REG_GPIO, + (ctrl | + BP10GB_GPIO0_CLR_P1) & + ~(BP10GB_GPIO0_SET_P1 | + BP10GB_GPIO0_OE_P1)); + else + BP10GB_WRITE_REG(pbpctl_dev, + MISC_REG_GPIO, + (ctrl | + BP10GB_GPIO0_OE_P0 | + BP10GB_GPIO0_CLR_P0)); + + } else if (pbpctl_dev->bp_i80) { + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, + ((ctrl | + BPCTLI_CTRL_SDP1_DIR) & + ~BPCTLI_CTRL_SWDPIN1)); + } else if (pbpctl_dev->bp_540) { + ctrl = BP10G_READ_REG(pbpctl_dev, ESDP); + BP10G_WRITE_REG(pbpctl_dev, ESDP, + ((ctrl | BP10G_SDP1_DIR) & + ~BP10G_SDP1_DATA)); + } + + else if (!pbpctl_dev->bp_10g) { + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, + ((ctrl | BPCTLI_CTRL_SWDPIO0) + & ~BPCTLI_CTRL_SWDPIN0)); + if (!PEGF_IF_SERIES(pbpctl_dev->subdevice)) { + BPCTL_BP_WRITE_REG(pbpctl_dev, CTRL, + (ctrl & + ~ + (BPCTLI_CTRL_SDP0_DATA + | + BPCTLI_CTRL_SDP0_DIR))); + } + } else + BP10G_WRITE_REG(pbpctl_dev, ESDP, + ((ctrl | BP10G_SDP0_DIR) & + ~BP10G_SDP0_DATA)); + + } + + } else + ret = BP_NOT_CAP; + return ret; + +} + +/* SET_FORCE_LINK (non-Bypass command :)) */ +static int set_bp_force_link(bpctl_dev_t *pbpctl_dev, int tx_state) +{ + int ret = 0, ctrl = 0; + + if (DBI_IF_SERIES(pbpctl_dev->subdevice)) { + + if ((pbpctl_dev->bp_10g) || (pbpctl_dev->bp_10g9)) { + + ctrl = BPCTL_READ_REG(pbpctl_dev, CTRL); + if (!tx_state) + BP10G_WRITE_REG(pbpctl_dev, ESDP, + ctrl & ~BP10G_SDP1_DIR); + else + BP10G_WRITE_REG(pbpctl_dev, ESDP, + ((ctrl | BP10G_SDP1_DIR) & + ~BP10G_SDP1_DATA)); + return ret; + } + + } + return BP_NOT_CAP; +} + +/*RESET_CONT 0x20 */ +int reset_cont(bpctl_dev_t *pbpctl_dev) +{ + int ret = BP_NOT_CAP; + + if (pbpctl_dev->bp_caps & SW_CTL_CAP) { + if (INTEL_IF_SERIES(pbpctl_dev->subdevice)) + return BP_NOT_CAP; + if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) + write_data(pbpctl_dev, RESET_CONT); + else + data_pulse(pbpctl_dev, RESET_CONT); + ret = 0; + }; + return ret; +} + +/*DIS_BYPASS_CAP 0x22 */ +int dis_bypass_cap(bpctl_dev_t *pbpctl_dev) +{ + + if (pbpctl_dev->bp_caps & BP_DIS_CAP) { + if (INTEL_IF_SERIES(pbpctl_dev->subdevice)) { + write_data_int(pbpctl_dev, DIS_BYPASS_CAP_INT); + msec_delay_bp(BYPASS_DELAY_INT); + } else { + write_data(pbpctl_dev, BYPASS_OFF); + msec_delay_bp(LATCH_DELAY); + write_data(pbpctl_dev, DIS_BYPASS_CAP); + msec_delay_bp(BYPASS_CAP_DELAY); + } + return 0; + } + return BP_NOT_CAP; +} + +/*EN_BYPASS_CAP 0x24 */ +int en_bypass_cap(bpctl_dev_t *pbpctl_dev) +{ + if (pbpctl_dev->bp_caps & BP_DIS_CAP) { + if (INTEL_IF_SERIES(pbpctl_dev->subdevice)) { + write_data_int(pbpctl_dev, PWROFF_BYPASS_ON_INT); + msec_delay_bp(BYPASS_DELAY_INT); + } else { + write_data(pbpctl_dev, EN_BYPASS_CAP); + msec_delay_bp(BYPASS_CAP_DELAY); + } + return 0; + } + return BP_NOT_CAP; +} + +/* BYPASS_STATE_PWRON 0x26*/ +int bypass_state_pwron(bpctl_dev_t *pbpctl_dev) +{ + if (pbpctl_dev->bp_caps & BP_PWUP_CTL_CAP) { + write_data(pbpctl_dev, BYPASS_STATE_PWRON); + if (pbpctl_dev->bp_ext_ver == PXG2BPI_VER) + msec_delay_bp(DFLT_PWRON_DELAY); + else + msec_delay_bp(LATCH_DELAY + EEPROM_WR_DELAY); + return 0; + } + return BP_NOT_CAP; +} + +/* NORMAL_STATE_PWRON 0x28*/ +int normal_state_pwron(bpctl_dev_t *pbpctl_dev) +{ + if ((pbpctl_dev->bp_caps & BP_PWUP_CTL_CAP) + || (pbpctl_dev->bp_caps & TAP_PWUP_CTL_CAP)) { + write_data(pbpctl_dev, NORMAL_STATE_PWRON); + if (pbpctl_dev->bp_ext_ver == PXG2BPI_VER) + msec_delay_bp(DFLT_PWRON_DELAY); + else + msec_delay_bp(LATCH_DELAY + EEPROM_WR_DELAY); + return 0; + } + return BP_NOT_CAP; +} + +/* BYPASS_STATE_PWROFF 0x27*/ +int bypass_state_pwroff(bpctl_dev_t *pbpctl_dev) +{ + if (pbpctl_dev->bp_caps & BP_PWOFF_CTL_CAP) { + write_data(pbpctl_dev, BYPASS_STATE_PWROFF); + msec_delay_bp(LATCH_DELAY + EEPROM_WR_DELAY); + return 0; + } + return BP_NOT_CAP; +} + +/* NORMAL_STATE_PWROFF 0x29*/ +int normal_state_pwroff(bpctl_dev_t *pbpctl_dev) +{ + if ((pbpctl_dev->bp_caps & BP_PWOFF_CTL_CAP)) { + write_data(pbpctl_dev, NORMAL_STATE_PWROFF); + msec_delay_bp(LATCH_DELAY + EEPROM_WR_DELAY); + return 0; + } + return BP_NOT_CAP; +} + +/*TAP_STATE_PWRON 0x2a*/ +int tap_state_pwron(bpctl_dev_t *pbpctl_dev) +{ + if (pbpctl_dev->bp_caps & TAP_PWUP_CTL_CAP) { + write_data(pbpctl_dev, TAP_STATE_PWRON); + msec_delay_bp(LATCH_DELAY + EEPROM_WR_DELAY); + return 0; + } + return BP_NOT_CAP; +} + +/*DIS_TAP_CAP 0x2c*/ +int dis_tap_cap(bpctl_dev_t *pbpctl_dev) +{ + if (pbpctl_dev->bp_caps & TAP_DIS_CAP) { + write_data(pbpctl_dev, DIS_TAP_CAP); + msec_delay_bp(BYPASS_CAP_DELAY); + return 0; + } + return BP_NOT_CAP; +} + +/*EN_TAP_CAP 0x2e*/ +int en_tap_cap(bpctl_dev_t *pbpctl_dev) +{ + if (pbpctl_dev->bp_caps & TAP_DIS_CAP) { + write_data(pbpctl_dev, EN_TAP_CAP); + msec_delay_bp(BYPASS_CAP_DELAY); + return 0; + } + return BP_NOT_CAP; +} + +/*DISC_STATE_PWRON 0x2a*/ +int disc_state_pwron(bpctl_dev_t *pbpctl_dev) +{ + if (pbpctl_dev->bp_caps & DISC_PWUP_CTL_CAP) { + if (pbpctl_dev->bp_ext_ver >= 0x8) { + write_data(pbpctl_dev, DISC_STATE_PWRON); + msec_delay_bp(LATCH_DELAY + EEPROM_WR_DELAY); + return BP_OK; + } + } + return BP_NOT_CAP; +} + +/*DIS_DISC_CAP 0x2c*/ +int dis_disc_cap(bpctl_dev_t *pbpctl_dev) +{ + if (pbpctl_dev->bp_caps & DISC_DIS_CAP) { + if (pbpctl_dev->bp_ext_ver >= 0x8) { + write_data(pbpctl_dev, DIS_DISC_CAP); + msec_delay_bp(BYPASS_CAP_DELAY); + return BP_OK; + } + } + return BP_NOT_CAP; +} + +/*DISC_STATE_PWRON 0x2a*/ +int disc_port_state_pwron(bpctl_dev_t *pbpctl_dev) +{ + int ret = 0; + bpctl_dev_t *pbpctl_dev_m; + + return BP_NOT_CAP; + + if ((is_bypass_fn(pbpctl_dev)) == 1) + pbpctl_dev_m = pbpctl_dev; + else + pbpctl_dev_m = get_master_port_fn(pbpctl_dev); + if (pbpctl_dev_m == NULL) + return BP_NOT_CAP; + + if (pbpctl_dev_m->bp_caps_ex & DISC_PORT_CAP_EX) { + if (is_bypass_fn(pbpctl_dev) == 1) + write_data(pbpctl_dev_m, TX_DISA_PWRUP); + else + write_data(pbpctl_dev_m, TX_DISB_PWRUP); + + msec_delay_bp(LATCH_DELAY); + + } + return ret; +} + +int normal_port_state_pwron(bpctl_dev_t *pbpctl_dev) +{ + int ret = 0; + bpctl_dev_t *pbpctl_dev_m; + return BP_NOT_CAP; + + if ((is_bypass_fn(pbpctl_dev)) == 1) + pbpctl_dev_m = pbpctl_dev; + else + pbpctl_dev_m = get_master_port_fn(pbpctl_dev); + if (pbpctl_dev_m == NULL) + return BP_NOT_CAP; + + if (pbpctl_dev_m->bp_caps_ex & DISC_PORT_CAP_EX) { + if (is_bypass_fn(pbpctl_dev) == 1) + write_data(pbpctl_dev_m, TX_ENA_PWRUP); + else + write_data(pbpctl_dev_m, TX_ENB_PWRUP); + + msec_delay_bp(LATCH_DELAY); + + } + return ret; +} + +/*EN_TAP_CAP 0x2e*/ +int en_disc_cap(bpctl_dev_t *pbpctl_dev) +{ + if (pbpctl_dev->bp_caps & DISC_DIS_CAP) { + if (pbpctl_dev->bp_ext_ver >= 0x8) { + write_data(pbpctl_dev, EN_DISC_CAP); + msec_delay_bp(BYPASS_CAP_DELAY); + return BP_OK; + } + } + return BP_NOT_CAP; +} + +int std_nic_on(bpctl_dev_t *pbpctl_dev) +{ + + if (pbpctl_dev->bp_caps & STD_NIC_CAP) { + + if (INTEL_IF_SERIES(pbpctl_dev->subdevice)) { + write_data_int(pbpctl_dev, DIS_BYPASS_CAP_INT); + msec_delay_bp(BYPASS_DELAY_INT); + pbpctl_dev->bp_status_un = 0; + return BP_OK; + } + + if (pbpctl_dev->bp_ext_ver >= 0x8) { + write_data(pbpctl_dev, STD_NIC_ON); + msec_delay_bp(BYPASS_CAP_DELAY); + return BP_OK; + + } + + if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { + wdt_off(pbpctl_dev); + + if (pbpctl_dev->bp_caps & BP_CAP) { + write_data(pbpctl_dev, BYPASS_OFF); + msec_delay_bp(LATCH_DELAY); + } + + if (pbpctl_dev->bp_caps & TAP_CAP) { + write_data(pbpctl_dev, TAP_OFF); + msec_delay_bp(LATCH_DELAY); + } + + write_data(pbpctl_dev, NORMAL_STATE_PWRON); + if (pbpctl_dev->bp_ext_ver == PXG2BPI_VER) + msec_delay_bp(DFLT_PWRON_DELAY); + else + msec_delay_bp(LATCH_DELAY + EEPROM_WR_DELAY); + + if (pbpctl_dev->bp_caps & BP_DIS_CAP) { + write_data(pbpctl_dev, DIS_BYPASS_CAP); + msec_delay_bp(BYPASS_CAP_DELAY); + } + + if (pbpctl_dev->bp_caps & TAP_DIS_CAP) { + write_data(pbpctl_dev, DIS_TAP_CAP); + msec_delay_bp(BYPASS_CAP_DELAY); + + } + return 0; + } + } + return BP_NOT_CAP; +} + +int std_nic_off(bpctl_dev_t *pbpctl_dev) +{ + + if (pbpctl_dev->bp_caps & STD_NIC_CAP) { + if (INTEL_IF_SERIES(pbpctl_dev->subdevice)) { + write_data_int(pbpctl_dev, PWROFF_BYPASS_ON_INT); + msec_delay_bp(BYPASS_DELAY_INT); + return BP_OK; + } + if (pbpctl_dev->bp_ext_ver >= 0x8) { + write_data(pbpctl_dev, STD_NIC_OFF); + msec_delay_bp(BYPASS_CAP_DELAY); + return BP_OK; + + } + + if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { + + if (pbpctl_dev->bp_caps & TAP_PWUP_CTL_CAP) { + write_data(pbpctl_dev, TAP_STATE_PWRON); + msec_delay_bp(LATCH_DELAY + EEPROM_WR_DELAY); + } + + if (pbpctl_dev->bp_caps & BP_PWUP_CTL_CAP) { + write_data(pbpctl_dev, BYPASS_STATE_PWRON); + if (pbpctl_dev->bp_ext_ver > PXG2BPI_VER) + msec_delay_bp(LATCH_DELAY + + EEPROM_WR_DELAY); + else + msec_delay_bp(DFLT_PWRON_DELAY); + } + + if (pbpctl_dev->bp_caps & TAP_DIS_CAP) { + write_data(pbpctl_dev, EN_TAP_CAP); + msec_delay_bp(BYPASS_CAP_DELAY); + } + if (pbpctl_dev->bp_caps & DISC_DIS_CAP) { + write_data(pbpctl_dev, EN_DISC_CAP); + msec_delay_bp(BYPASS_CAP_DELAY); + } + + if (pbpctl_dev->bp_caps & BP_DIS_CAP) { + write_data(pbpctl_dev, EN_BYPASS_CAP); + msec_delay_bp(BYPASS_CAP_DELAY); + } + + return 0; + } + } + return BP_NOT_CAP; +} + +int wdt_time_left(bpctl_dev_t *pbpctl_dev) +{ + + /* unsigned long curr_time=((long long)(jiffies*1000))/HZ, delta_time=0,wdt_on_time=((long long)(pbpctl_dev->bypass_wdt_on_time*1000))/HZ; */ + unsigned long curr_time = jiffies, delta_time = 0, wdt_on_time = + pbpctl_dev->bypass_wdt_on_time, delta_time_msec = 0; + int time_left = 0; + + switch (pbpctl_dev->wdt_status) { + case WDT_STATUS_DIS: + time_left = 0; + break; + case WDT_STATUS_EN: + delta_time = + (curr_time >= + wdt_on_time) ? (curr_time - wdt_on_time) : (~wdt_on_time + + curr_time); + delta_time_msec = jiffies_to_msecs(delta_time); + time_left = pbpctl_dev->bypass_timer_interval - delta_time_msec; + if (time_left < 0) { + time_left = -1; + pbpctl_dev->wdt_status = WDT_STATUS_EXP; + } + break; + case WDT_STATUS_EXP: + time_left = -1; + break; + } + + return time_left; +} + +static int wdt_timer(bpctl_dev_t *pbpctl_dev, int *time_left) +{ + int ret = 0; + if (pbpctl_dev->bp_caps & WD_CTL_CAP) { + { + if (pbpctl_dev->wdt_status == WDT_STATUS_UNKNOWN) + ret = BP_NOT_CAP; + else + *time_left = wdt_time_left(pbpctl_dev); + } + + } else + ret = BP_NOT_CAP; + return ret; +} + +static int wdt_timer_reload(bpctl_dev_t *pbpctl_dev) +{ + + int ret = 0; + + if ((pbpctl_dev->bp_caps & WD_CTL_CAP) && + (pbpctl_dev->wdt_status != WDT_STATUS_UNKNOWN)) { + if (pbpctl_dev->wdt_status == WDT_STATUS_DIS) + return 0; + if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) + ret = wdt_pulse(pbpctl_dev); + else if (INTEL_IF_SERIES(pbpctl_dev->subdevice)) + ret = wdt_pulse_int(pbpctl_dev); + else + ret = send_wdt_pulse(pbpctl_dev); + /* if (ret==-1) + mod_timer(&pbpctl_dev->bp_timer, jiffies+1);*/ + return 1; + } + return BP_NOT_CAP; +} + +static void wd_reset_timer(unsigned long param) +{ + bpctl_dev_t *pbpctl_dev = (bpctl_dev_t *) param; +#ifdef BP_SELF_TEST + struct sk_buff *skb_tmp; +#endif + + if ((pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) && + ((atomic_read(&pbpctl_dev->wdt_busy)) == 1)) { + mod_timer(&pbpctl_dev->bp_timer, jiffies + 1); + return; + } +#ifdef BP_SELF_TEST + + if (pbpctl_dev->bp_self_test_flag == 1) { + skb_tmp = dev_alloc_skb(BPTEST_DATA_LEN + 2); + if ((skb_tmp) && (pbpctl_dev->ndev) && (pbpctl_dev->bp_tx_data)) { + memcpy(skb_put(skb_tmp, BPTEST_DATA_LEN), + pbpctl_dev->bp_tx_data, BPTEST_DATA_LEN); + skb_tmp->dev = pbpctl_dev->ndev; + skb_tmp->protocol = + eth_type_trans(skb_tmp, pbpctl_dev->ndev); + skb_tmp->ip_summed = CHECKSUM_UNNECESSARY; + netif_receive_skb(skb_tmp); + goto bp_timer_reload; + return; + } + } +#endif + + wdt_timer_reload(pbpctl_dev); +#ifdef BP_SELF_TEST + bp_timer_reload: +#endif + if (pbpctl_dev->reset_time) { + mod_timer(&pbpctl_dev->bp_timer, + jiffies + (HZ * pbpctl_dev->reset_time) / 1000); + } +} + +/*WAIT_AT_PWRUP 0x80 */ +int bp_wait_at_pwup_en(bpctl_dev_t *pbpctl_dev) +{ + + if (pbpctl_dev->bp_caps & SW_CTL_CAP) { + if (pbpctl_dev->bp_ext_ver >= BP_FW_EXT_VER8) { + write_data(pbpctl_dev, BP_WAIT_AT_PWUP_EN); + msec_delay_bp(LATCH_DELAY + EEPROM_WR_DELAY); + + return BP_OK; + } + } + return BP_NOT_CAP; +} + +/*DIS_WAIT_AT_PWRUP 0x81 */ +int bp_wait_at_pwup_dis(bpctl_dev_t *pbpctl_dev) +{ + + if (pbpctl_dev->bp_caps & SW_CTL_CAP) { + + if (pbpctl_dev->bp_ext_ver >= BP_FW_EXT_VER8) { + write_data(pbpctl_dev, BP_WAIT_AT_PWUP_DIS); + msec_delay_bp(LATCH_DELAY + EEPROM_WR_DELAY); + + return BP_OK; + } + } + return BP_NOT_CAP; +} + +/*EN_HW_RESET 0x82 */ + +int bp_hw_reset_en(bpctl_dev_t *pbpctl_dev) +{ + + if (pbpctl_dev->bp_caps & SW_CTL_CAP) { + if (pbpctl_dev->bp_ext_ver >= BP_FW_EXT_VER8) { + write_data(pbpctl_dev, BP_HW_RESET_EN); + msec_delay_bp(LATCH_DELAY + EEPROM_WR_DELAY); + + return BP_OK; + } + } + return BP_NOT_CAP; +} + +/*DIS_HW_RESET 0x83 */ + +int bp_hw_reset_dis(bpctl_dev_t *pbpctl_dev) +{ + + if (pbpctl_dev->bp_caps & SW_CTL_CAP) { + if (pbpctl_dev->bp_ext_ver >= BP_FW_EXT_VER8) { + write_data(pbpctl_dev, BP_HW_RESET_DIS); + msec_delay_bp(LATCH_DELAY + EEPROM_WR_DELAY); + + return BP_OK; + } + } + return BP_NOT_CAP; +} + + +int wdt_exp_mode(bpctl_dev_t *pbpctl_dev, int mode) +{ + uint32_t status_reg = 0, status_reg1 = 0; + + if ((pbpctl_dev->bp_caps & (TAP_STATUS_CAP | DISC_CAP)) && + (pbpctl_dev->bp_caps & BP_CAP)) { + if (pbpctl_dev->bp_ext_ver >= PXE2TBPI_VER) { + + if ((pbpctl_dev->bp_ext_ver >= 0x8) && + (mode == 2) && (pbpctl_dev->bp_caps & DISC_CAP)) { + status_reg1 = + read_reg(pbpctl_dev, STATUS_DISC_REG_ADDR); + if (!(status_reg1 & WDTE_DISC_BPN_MASK)) + write_reg(pbpctl_dev, + status_reg1 | + WDTE_DISC_BPN_MASK, + STATUS_DISC_REG_ADDR); + return BP_OK; + } + } + status_reg = read_reg(pbpctl_dev, STATUS_TAP_REG_ADDR); + + if ((mode == 0) && (pbpctl_dev->bp_caps & BP_CAP)) { + if (pbpctl_dev->bp_ext_ver >= 0x8) { + status_reg1 = + read_reg(pbpctl_dev, STATUS_DISC_REG_ADDR); + if (status_reg1 & WDTE_DISC_BPN_MASK) + write_reg(pbpctl_dev, + status_reg1 & + ~WDTE_DISC_BPN_MASK, + STATUS_DISC_REG_ADDR); + } + if (status_reg & WDTE_TAP_BPN_MASK) + write_reg(pbpctl_dev, + status_reg & ~WDTE_TAP_BPN_MASK, + STATUS_TAP_REG_ADDR); + return BP_OK; + + } else if ((mode == 1) && (pbpctl_dev->bp_caps & TAP_CAP)) { + if (!(status_reg & WDTE_TAP_BPN_MASK)) + write_reg(pbpctl_dev, + status_reg | WDTE_TAP_BPN_MASK, + STATUS_TAP_REG_ADDR); + /*else return BP_NOT_CAP; */ + return BP_OK; + } + + } + return BP_NOT_CAP; +} + +int bypass_fw_ver(bpctl_dev_t *pbpctl_dev) +{ + if (is_bypass_fn(pbpctl_dev)) + return read_reg(pbpctl_dev, VER_REG_ADDR); + else + return BP_NOT_CAP; +} + +int bypass_sign_check(bpctl_dev_t *pbpctl_dev) +{ + + if (is_bypass_fn(pbpctl_dev)) + return (((read_reg(pbpctl_dev, PIC_SIGN_REG_ADDR)) == + PIC_SIGN_VALUE) ? 1 : 0); + else + return BP_NOT_CAP; +} + +static int tx_status(bpctl_dev_t *pbpctl_dev) +{ + uint32_t ctrl = 0; + bpctl_dev_t *pbpctl_dev_m; + if ((is_bypass_fn(pbpctl_dev)) == 1) + pbpctl_dev_m = pbpctl_dev; + else + pbpctl_dev_m = get_master_port_fn(pbpctl_dev); + if (pbpctl_dev_m == NULL) + return BP_NOT_CAP; + if (pbpctl_dev_m->bp_caps_ex & DISC_PORT_CAP_EX) { + + ctrl = BPCTL_READ_REG(pbpctl_dev, CTRL); + if (pbpctl_dev->bp_i80) + return ((ctrl & BPCTLI_CTRL_SWDPIN1) != 0 ? 0 : 1); + if (pbpctl_dev->bp_540) { + ctrl = BP10G_READ_REG(pbpctl_dev, ESDP); + + return ((ctrl & BP10G_SDP1_DATA) != 0 ? 0 : 1); + } + + } + + if (pbpctl_dev->bp_caps & TX_CTL_CAP) { + if (PEG5_IF_SERIES(pbpctl_dev->subdevice)) { + uint16_t mii_reg; + if (! + (bp75_read_phy_reg + (pbpctl_dev, BPCTLI_PHY_CONTROL, &mii_reg))) { + if (mii_reg & BPCTLI_MII_CR_POWER_DOWN) + return 0; + + else + return 1; + } + return -1; + } + + if (pbpctl_dev->bp_10g9) { + return ((BP10G_READ_REG(pbpctl_dev, ESDP) & + BP10G_SDP3_DATA) != 0 ? 0 : 1); + + } else if (pbpctl_dev->bp_fiber5) { + ctrl = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); + if (ctrl & BPCTLI_CTRL_EXT_SDP6_DATA) + return 0; + return 1; + } else if (pbpctl_dev->bp_10gb) { + ctrl = BP10GB_READ_REG(pbpctl_dev, MISC_REG_GPIO); + BP10GB_WRITE_REG(pbpctl_dev, MISC_REG_GPIO, + (ctrl | BP10GB_GPIO0_OE_P1) & + ~(BP10GB_GPIO0_SET_P1 | + BP10GB_GPIO0_CLR_P1)); + + if ((pbpctl_dev->func == 1) || (pbpctl_dev->func == 3)) + return (((BP10GB_READ_REG + (pbpctl_dev, + MISC_REG_GPIO)) & BP10GB_GPIO0_P1) != + 0 ? 0 : 1); + else + return (((BP10GB_READ_REG + (pbpctl_dev, + MISC_REG_GPIO)) & BP10GB_GPIO0_P0) != + 0 ? 0 : 1); + } + + if (!pbpctl_dev->bp_10g) { + + ctrl = BPCTL_READ_REG(pbpctl_dev, CTRL); + if (pbpctl_dev->bp_i80) + return ((ctrl & BPCTLI_CTRL_SWDPIN1) != + 0 ? 0 : 1); + if (pbpctl_dev->bp_540) { + ctrl = BP10G_READ_REG(pbpctl_dev, ESDP); + + return ((ctrl & BP10G_SDP1_DATA) != 0 ? 0 : 1); + } + + return ((ctrl & BPCTLI_CTRL_SWDPIN0) != 0 ? 0 : 1); + } else + return ((BP10G_READ_REG(pbpctl_dev, ESDP) & + BP10G_SDP0_DATA) != 0 ? 0 : 1); + + } + return BP_NOT_CAP; +} + +static int bp_force_link_status(bpctl_dev_t *pbpctl_dev) +{ + + if (DBI_IF_SERIES(pbpctl_dev->subdevice)) { + + if ((pbpctl_dev->bp_10g) || (pbpctl_dev->bp_10g9)) { + return ((BP10G_READ_REG(pbpctl_dev, ESDP) & + BP10G_SDP1_DIR) != 0 ? 1 : 0); + + } + } + return BP_NOT_CAP; +} + +int bypass_from_last_read(bpctl_dev_t *pbpctl_dev) +{ + uint32_t ctrl_ext = 0; + bpctl_dev_t *pbpctl_dev_b = NULL; + + if ((pbpctl_dev->bp_caps & SW_CTL_CAP) + && (pbpctl_dev_b = get_status_port_fn(pbpctl_dev))) { + ctrl_ext = BPCTL_READ_REG(pbpctl_dev_b, CTRL_EXT); + BPCTL_BP_WRITE_REG(pbpctl_dev_b, CTRL_EXT, + (ctrl_ext & ~BPCTLI_CTRL_EXT_SDP7_DIR)); + ctrl_ext = BPCTL_READ_REG(pbpctl_dev_b, CTRL_EXT); + if (ctrl_ext & BPCTLI_CTRL_EXT_SDP7_DATA) + return 0; + return 1; + } else + return BP_NOT_CAP; +} + +int bypass_status_clear(bpctl_dev_t *pbpctl_dev) +{ + bpctl_dev_t *pbpctl_dev_b = NULL; + + if ((pbpctl_dev->bp_caps & SW_CTL_CAP) + && (pbpctl_dev_b = get_status_port_fn(pbpctl_dev))) { + + send_bypass_clear_pulse(pbpctl_dev_b, 1); + return 0; + } else + return BP_NOT_CAP; +} + +int bypass_flag_status(bpctl_dev_t *pbpctl_dev) +{ + + if ((pbpctl_dev->bp_caps & BP_CAP)) { + if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { + return ((((read_reg(pbpctl_dev, STATUS_REG_ADDR)) & + BYPASS_FLAG_MASK) == + BYPASS_FLAG_MASK) ? 1 : 0); + } + } + return BP_NOT_CAP; +} + +int bypass_flag_status_clear(bpctl_dev_t *pbpctl_dev) +{ + + if (pbpctl_dev->bp_caps & BP_CAP) { + if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { + uint32_t status_reg = 0; + status_reg = read_reg(pbpctl_dev, STATUS_REG_ADDR); + write_reg(pbpctl_dev, status_reg & ~BYPASS_FLAG_MASK, + STATUS_REG_ADDR); + return 0; + } + } + return BP_NOT_CAP; +} + +int bypass_change_status(bpctl_dev_t *pbpctl_dev) +{ + int ret = BP_NOT_CAP; + + if (pbpctl_dev->bp_caps & BP_STATUS_CHANGE_CAP) { + if (pbpctl_dev->bp_ext_ver >= 0x8) { + ret = bypass_flag_status(pbpctl_dev); + bypass_flag_status_clear(pbpctl_dev); + } else if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { + ret = bypass_flag_status(pbpctl_dev); + bypass_flag_status_clear(pbpctl_dev); + } else { + ret = bypass_from_last_read(pbpctl_dev); + bypass_status_clear(pbpctl_dev); + } + } + return ret; +} + +int bypass_off_status(bpctl_dev_t *pbpctl_dev) +{ + + if (pbpctl_dev->bp_caps & BP_CAP) { + if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { + return ((((read_reg(pbpctl_dev, STATUS_REG_ADDR)) & + BYPASS_OFF_MASK) == BYPASS_OFF_MASK) ? 1 : 0); + } + } + return BP_NOT_CAP; +} + +static int bypass_status(bpctl_dev_t *pbpctl_dev) +{ + u32 ctrl_ext = 0; + if (pbpctl_dev->bp_caps & BP_CAP) { + + bpctl_dev_t *pbpctl_dev_b = NULL; + + if (!(pbpctl_dev_b = get_status_port_fn(pbpctl_dev))) + return BP_NOT_CAP; + + if (INTEL_IF_SERIES(pbpctl_dev->subdevice)) { + + if (!pbpctl_dev->bp_status_un) + return (((BPCTL_READ_REG + (pbpctl_dev_b, + CTRL_EXT)) & + BPCTLI_CTRL_EXT_SDP7_DATA) != + 0 ? 1 : 0); + else + return BP_NOT_CAP; + } + if (pbpctl_dev->bp_ext_ver >= 0x8) { + + if (pbpctl_dev->bp_10g9) { + ctrl_ext = BP10G_READ_REG(pbpctl_dev_b, I2CCTL); + BP10G_WRITE_REG(pbpctl_dev_b, I2CCTL, + (ctrl_ext | BP10G_I2C_CLK_OUT)); + return ((BP10G_READ_REG(pbpctl_dev_b, I2CCTL) & + BP10G_I2C_CLK_IN) != 0 ? 0 : 1); + + } else if (pbpctl_dev->bp_540) { + return (((BP10G_READ_REG(pbpctl_dev_b, ESDP)) & + BP10G_SDP0_DATA) != 0 ? 0 : 1); + } + + else if ((pbpctl_dev->bp_fiber5) + || (pbpctl_dev->bp_i80)) { + return (((BPCTL_READ_REG(pbpctl_dev_b, CTRL)) & + BPCTLI_CTRL_SWDPIN0) != 0 ? 0 : 1); + } else if (pbpctl_dev->bp_10gb) { + ctrl_ext = + BP10GB_READ_REG(pbpctl_dev, MISC_REG_GPIO); + BP10GB_WRITE_REG(pbpctl_dev, MISC_REG_GPIO, + (ctrl_ext | BP10GB_GPIO3_OE_P0) + & ~(BP10GB_GPIO3_SET_P0 | + BP10GB_GPIO3_CLR_P0)); + + return (((BP10GB_READ_REG + (pbpctl_dev, + MISC_REG_GPIO)) & BP10GB_GPIO3_P0) != + 0 ? 0 : 1); + } + + else if (!pbpctl_dev->bp_10g) + return (((BPCTL_READ_REG + (pbpctl_dev_b, + CTRL_EXT)) & + BPCTLI_CTRL_EXT_SDP7_DATA) != + 0 ? 0 : 1); + + else { + ctrl_ext = BP10G_READ_REG(pbpctl_dev_b, EODSDP); + BP10G_WRITE_REG(pbpctl_dev_b, EODSDP, + (ctrl_ext | + BP10G_SDP7_DATA_OUT)); + return ((BP10G_READ_REG(pbpctl_dev_b, EODSDP) & + BP10G_SDP7_DATA_IN) != 0 ? 0 : 1); + } + + } else if (pbpctl_dev->media_type == bp_copper) { + + return (((BPCTL_READ_REG(pbpctl_dev_b, CTRL)) & + BPCTLI_CTRL_SWDPIN1) != 0 ? 1 : 0); + } else { + if ((bypass_status_clear(pbpctl_dev)) >= 0) + return bypass_from_last_read(pbpctl_dev); + } + + } + return BP_NOT_CAP; +} + +int default_pwron_status(bpctl_dev_t *pbpctl_dev) +{ + + if (pbpctl_dev->bp_caps & SW_CTL_CAP) { + if (pbpctl_dev->bp_caps & BP_PWUP_CTL_CAP) { + if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { + return ((((read_reg + (pbpctl_dev, + STATUS_REG_ADDR)) & DFLT_PWRON_MASK) + == DFLT_PWRON_MASK) ? 0 : 1); + } + } /*else if ((!pbpctl_dev->bp_caps&BP_DIS_CAP)&& + (pbpctl_dev->bp_caps&BP_PWUP_ON_CAP)) + return 1; */ + } + return BP_NOT_CAP; +} + +static int default_pwroff_status(bpctl_dev_t *pbpctl_dev) +{ + + /*if ((!pbpctl_dev->bp_caps&BP_DIS_CAP)&& + (pbpctl_dev->bp_caps&BP_PWOFF_ON_CAP)) + return 1; */ + if ((pbpctl_dev->bp_caps & SW_CTL_CAP) + && (pbpctl_dev->bp_caps & BP_PWOFF_CTL_CAP)) { + return ((((read_reg(pbpctl_dev, STATUS_REG_ADDR)) & + DFLT_PWROFF_MASK) == DFLT_PWROFF_MASK) ? 0 : 1); + } + return BP_NOT_CAP; +} + +int dis_bypass_cap_status(bpctl_dev_t *pbpctl_dev) +{ + + if (pbpctl_dev->bp_caps & BP_DIS_CAP) { + if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { + return ((((read_reg(pbpctl_dev, STATUS_REG_ADDR)) & + DIS_BYPASS_CAP_MASK) == + DIS_BYPASS_CAP_MASK) ? 1 : 0); + } + } + return BP_NOT_CAP; +} + +int cmd_en_status(bpctl_dev_t *pbpctl_dev) +{ + + if (pbpctl_dev->bp_caps & SW_CTL_CAP) { + if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { + return ((((read_reg(pbpctl_dev, STATUS_REG_ADDR)) & + CMND_EN_MASK) == CMND_EN_MASK) ? 1 : 0); + } + } + return BP_NOT_CAP; +} + +int wdt_en_status(bpctl_dev_t *pbpctl_dev) +{ + + if (pbpctl_dev->bp_caps & WD_CTL_CAP) { + if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { + return ((((read_reg(pbpctl_dev, STATUS_REG_ADDR)) & + WDT_EN_MASK) == WDT_EN_MASK) ? 1 : 0); + } + } + return BP_NOT_CAP; +} + +int wdt_programmed(bpctl_dev_t *pbpctl_dev, int *timeout) +{ + int ret = 0; + if (pbpctl_dev->bp_caps & WD_CTL_CAP) { + if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { + if ((read_reg(pbpctl_dev, STATUS_REG_ADDR)) & + WDT_EN_MASK) { + u8 wdt_val; + wdt_val = read_reg(pbpctl_dev, WDT_REG_ADDR); + *timeout = (1 << wdt_val) * 100; + } else + *timeout = 0; + } else { + int curr_wdt_status = pbpctl_dev->wdt_status; + if (curr_wdt_status == WDT_STATUS_UNKNOWN) + *timeout = -1; + else + *timeout = + curr_wdt_status == + 0 ? 0 : pbpctl_dev->bypass_timer_interval; + }; + } else + ret = BP_NOT_CAP; + return ret; +} + +int bypass_support(bpctl_dev_t *pbpctl_dev) +{ + int ret = 0; + + if (pbpctl_dev->bp_caps & SW_CTL_CAP) { + if (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER) { + ret = + ((((read_reg(pbpctl_dev, PRODUCT_CAP_REG_ADDR)) & + BYPASS_SUPPORT_MASK) == + BYPASS_SUPPORT_MASK) ? 1 : 0); + } else if (pbpctl_dev->bp_ext_ver == PXG2BPI_VER) + ret = 1; + } else + ret = BP_NOT_CAP; + return ret; +} + +int tap_support(bpctl_dev_t *pbpctl_dev) +{ + int ret = 0; + + if (pbpctl_dev->bp_caps & SW_CTL_CAP) { + if (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER) { + ret = + ((((read_reg(pbpctl_dev, PRODUCT_CAP_REG_ADDR)) & + TAP_SUPPORT_MASK) == TAP_SUPPORT_MASK) ? 1 : 0); + } else if (pbpctl_dev->bp_ext_ver == PXG2BPI_VER) + ret = 0; + } else + ret = BP_NOT_CAP; + return ret; +} + +int normal_support(bpctl_dev_t *pbpctl_dev) +{ + int ret = BP_NOT_CAP; + + if (pbpctl_dev->bp_caps & SW_CTL_CAP) { + if (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER) { + ret = + ((((read_reg(pbpctl_dev, PRODUCT_CAP_REG_ADDR)) & + NORMAL_UNSUPPORT_MASK) == + NORMAL_UNSUPPORT_MASK) ? 0 : 1); + } else + ret = 1; + }; + return ret; +} + +int get_bp_prod_caps(bpctl_dev_t *pbpctl_dev) +{ + if ((pbpctl_dev->bp_caps & SW_CTL_CAP) && + (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER)) + return read_reg(pbpctl_dev, PRODUCT_CAP_REG_ADDR); + return BP_NOT_CAP; + +} + +int tap_flag_status(bpctl_dev_t *pbpctl_dev) +{ + + if (pbpctl_dev->bp_caps & TAP_STATUS_CAP) { + if (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER) + return ((((read_reg(pbpctl_dev, STATUS_TAP_REG_ADDR)) & + TAP_FLAG_MASK) == TAP_FLAG_MASK) ? 1 : 0); + + } + return BP_NOT_CAP; +} + +int tap_flag_status_clear(bpctl_dev_t *pbpctl_dev) +{ + uint32_t status_reg = 0; + if (pbpctl_dev->bp_caps & TAP_STATUS_CAP) { + if (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER) { + status_reg = read_reg(pbpctl_dev, STATUS_TAP_REG_ADDR); + write_reg(pbpctl_dev, status_reg & ~TAP_FLAG_MASK, + STATUS_TAP_REG_ADDR); + return 0; + } + } + return BP_NOT_CAP; +} + +int tap_change_status(bpctl_dev_t *pbpctl_dev) +{ + int ret = BP_NOT_CAP; + if (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER) { + if (pbpctl_dev->bp_caps & TAP_CAP) { + if (pbpctl_dev->bp_caps & BP_CAP) { + ret = tap_flag_status(pbpctl_dev); + tap_flag_status_clear(pbpctl_dev); + } else { + ret = bypass_from_last_read(pbpctl_dev); + bypass_status_clear(pbpctl_dev); + } + } + } + return ret; +} + +int tap_off_status(bpctl_dev_t *pbpctl_dev) +{ + if (pbpctl_dev->bp_caps & TAP_CAP) { + if (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER) + return ((((read_reg(pbpctl_dev, STATUS_TAP_REG_ADDR)) & + TAP_OFF_MASK) == TAP_OFF_MASK) ? 1 : 0); + } + return BP_NOT_CAP; +} + +int tap_status(bpctl_dev_t *pbpctl_dev) +{ + u32 ctrl_ext = 0; + + if (pbpctl_dev->bp_caps & TAP_CAP) { + bpctl_dev_t *pbpctl_dev_b = NULL; + + if (!(pbpctl_dev_b = get_status_port_fn(pbpctl_dev))) + return BP_NOT_CAP; + + if (pbpctl_dev->bp_ext_ver >= 0x8) { + if (!pbpctl_dev->bp_10g) + return (((BPCTL_READ_REG + (pbpctl_dev_b, + CTRL_EXT)) & + BPCTLI_CTRL_EXT_SDP6_DATA) != + 0 ? 0 : 1); + else { + ctrl_ext = BP10G_READ_REG(pbpctl_dev_b, EODSDP); + BP10G_WRITE_REG(pbpctl_dev_b, EODSDP, + (ctrl_ext | + BP10G_SDP6_DATA_OUT)); + return ((BP10G_READ_REG(pbpctl_dev_b, EODSDP) & + BP10G_SDP6_DATA_IN) != 0 ? 0 : 1); + } + + } else if (pbpctl_dev->media_type == bp_copper) + return (((BPCTL_READ_REG(pbpctl_dev, CTRL)) & + BPCTLI_CTRL_SWDPIN0) != 0 ? 1 : 0); + else { + if ((bypass_status_clear(pbpctl_dev)) >= 0) + return bypass_from_last_read(pbpctl_dev); + } + + } + return BP_NOT_CAP; +} + +int default_pwron_tap_status(bpctl_dev_t *pbpctl_dev) +{ + if (pbpctl_dev->bp_caps & TAP_PWUP_CTL_CAP) { + if (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER) + return ((((read_reg(pbpctl_dev, STATUS_TAP_REG_ADDR)) & + DFLT_PWRON_TAP_MASK) == + DFLT_PWRON_TAP_MASK) ? 1 : 0); + } + return BP_NOT_CAP; +} + +int dis_tap_cap_status(bpctl_dev_t *pbpctl_dev) +{ + if (pbpctl_dev->bp_caps & TAP_PWUP_CTL_CAP) { + if (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER) + return ((((read_reg(pbpctl_dev, STATUS_TAP_REG_ADDR)) & + DIS_TAP_CAP_MASK) == + DIS_TAP_CAP_MASK) ? 1 : 0); + } + return BP_NOT_CAP; +} + +int disc_flag_status(bpctl_dev_t *pbpctl_dev) +{ + + if (pbpctl_dev->bp_caps & DISC_CAP) { + if (pbpctl_dev->bp_ext_ver >= 0x8) + return ((((read_reg(pbpctl_dev, STATUS_DISC_REG_ADDR)) & + DISC_FLAG_MASK) == DISC_FLAG_MASK) ? 1 : 0); + + } + return BP_NOT_CAP; +} + +int disc_flag_status_clear(bpctl_dev_t *pbpctl_dev) +{ + uint32_t status_reg = 0; + if (pbpctl_dev->bp_caps & DISC_CAP) { + if (pbpctl_dev->bp_ext_ver >= 0x8) { + status_reg = read_reg(pbpctl_dev, STATUS_DISC_REG_ADDR); + write_reg(pbpctl_dev, status_reg & ~DISC_FLAG_MASK, + STATUS_DISC_REG_ADDR); + return BP_OK; + } + } + return BP_NOT_CAP; +} + +int disc_change_status(bpctl_dev_t *pbpctl_dev) +{ + int ret = BP_NOT_CAP; + if (pbpctl_dev->bp_caps & DISC_CAP) { + ret = disc_flag_status(pbpctl_dev); + disc_flag_status_clear(pbpctl_dev); + return ret; + } + return BP_NOT_CAP; +} + +int disc_off_status(bpctl_dev_t *pbpctl_dev) +{ + bpctl_dev_t *pbpctl_dev_b = NULL; + u32 ctrl_ext = 0; + + if (pbpctl_dev->bp_caps & DISC_CAP) { + if (!(pbpctl_dev_b = get_status_port_fn(pbpctl_dev))) + return BP_NOT_CAP; + if (DISCF_IF_SERIES(pbpctl_dev->subdevice)) + return ((((read_reg(pbpctl_dev, STATUS_DISC_REG_ADDR)) & + DISC_OFF_MASK) == DISC_OFF_MASK) ? 1 : 0); + + if (pbpctl_dev->bp_i80) { + return (((BPCTL_READ_REG(pbpctl_dev_b, CTRL_EXT)) & + BPCTLI_CTRL_EXT_SDP6_DATA) != 0 ? 1 : 0); + + } + if (pbpctl_dev->bp_540) { + ctrl_ext = BP10G_READ_REG(pbpctl_dev_b, ESDP); + return ((BP10G_READ_REG(pbpctl_dev_b, ESDP) & + BP10G_SDP2_DATA) != 0 ? 1 : 0); + + } + if (pbpctl_dev->media_type == bp_copper) { + +#if 0 + return ((((read_reg(pbpctl_dev, STATUS_DISC_REG_ADDR)) & + DISC_OFF_MASK) == DISC_OFF_MASK) ? 1 : 0); +#endif + if (!pbpctl_dev->bp_10g) + return (((BPCTL_READ_REG(pbpctl_dev_b, CTRL)) & + BPCTLI_CTRL_SWDPIN1) != 0 ? 1 : 0); + else + return ((BP10G_READ_REG(pbpctl_dev_b, ESDP) & + BP10G_SDP1_DATA) != 0 ? 1 : 0); + + } else { + + if (pbpctl_dev->bp_10g9) { + ctrl_ext = BP10G_READ_REG(pbpctl_dev_b, I2CCTL); + BP10G_WRITE_REG(pbpctl_dev_b, I2CCTL, + (ctrl_ext | + BP10G_I2C_DATA_OUT)); + return ((BP10G_READ_REG(pbpctl_dev_b, I2CCTL) & + BP10G_I2C_DATA_IN) != 0 ? 1 : 0); + + } else if (pbpctl_dev->bp_fiber5) { + return (((BPCTL_READ_REG(pbpctl_dev_b, CTRL)) & + BPCTLI_CTRL_SWDPIN1) != 0 ? 1 : 0); + } else if (pbpctl_dev->bp_10gb) { + ctrl_ext = + BP10GB_READ_REG(pbpctl_dev, MISC_REG_GPIO); + BP10GB_WRITE_REG(pbpctl_dev, MISC_REG_GPIO, + (ctrl_ext | BP10GB_GPIO3_OE_P1) + & ~(BP10GB_GPIO3_SET_P1 | + BP10GB_GPIO3_CLR_P1)); + + return (((BP10GB_READ_REG + (pbpctl_dev, + MISC_REG_GPIO)) & BP10GB_GPIO3_P1) != + 0 ? 1 : 0); + } + if (!pbpctl_dev->bp_10g) { + + return (((BPCTL_READ_REG + (pbpctl_dev_b, + CTRL_EXT)) & + BPCTLI_CTRL_EXT_SDP6_DATA) != + 0 ? 1 : 0); + } else { + ctrl_ext = BP10G_READ_REG(pbpctl_dev_b, EODSDP); + BP10G_WRITE_REG(pbpctl_dev_b, EODSDP, + (ctrl_ext | + BP10G_SDP6_DATA_OUT)); + return (((BP10G_READ_REG(pbpctl_dev_b, EODSDP)) + & BP10G_SDP6_DATA_IN) != 0 ? 1 : 0); + } + + } + } + return BP_NOT_CAP; +} + +static int disc_status(bpctl_dev_t *pbpctl_dev) +{ + int ctrl = 0; + if (pbpctl_dev->bp_caps & DISC_CAP) { + + if ((ctrl = disc_off_status(pbpctl_dev)) < 0) + return ctrl; + return ((ctrl == 0) ? 1 : 0); + + } + return BP_NOT_CAP; +} + +int default_pwron_disc_status(bpctl_dev_t *pbpctl_dev) +{ + if (pbpctl_dev->bp_caps & DISC_PWUP_CTL_CAP) { + if (pbpctl_dev->bp_ext_ver >= 0x8) + return ((((read_reg(pbpctl_dev, STATUS_DISC_REG_ADDR)) & + DFLT_PWRON_DISC_MASK) == + DFLT_PWRON_DISC_MASK) ? 1 : 0); + } + return BP_NOT_CAP; +} + +int dis_disc_cap_status(bpctl_dev_t *pbpctl_dev) +{ + if (pbpctl_dev->bp_caps & DIS_DISC_CAP) { + if (pbpctl_dev->bp_ext_ver >= 0x8) + return ((((read_reg(pbpctl_dev, STATUS_DISC_REG_ADDR)) & + DIS_DISC_CAP_MASK) == + DIS_DISC_CAP_MASK) ? 1 : 0); + } + return BP_NOT_CAP; +} + +int disc_port_status(bpctl_dev_t *pbpctl_dev) +{ + int ret = BP_NOT_CAP; + bpctl_dev_t *pbpctl_dev_m; + + if ((is_bypass_fn(pbpctl_dev)) == 1) + pbpctl_dev_m = pbpctl_dev; + else + pbpctl_dev_m = get_master_port_fn(pbpctl_dev); + if (pbpctl_dev_m == NULL) + return BP_NOT_CAP; + + if (pbpctl_dev_m->bp_caps_ex & DISC_PORT_CAP_EX) { + if (is_bypass_fn(pbpctl_dev) == 1) { + return ((((read_reg(pbpctl_dev, STATUS_TAP_REG_ADDR)) & + TX_DISA_MASK) == TX_DISA_MASK) ? 1 : 0); + } else + return ((((read_reg(pbpctl_dev, STATUS_TAP_REG_ADDR)) & + TX_DISB_MASK) == TX_DISB_MASK) ? 1 : 0); + + } + return ret; +} + +int default_pwron_disc_port_status(bpctl_dev_t *pbpctl_dev) +{ + int ret = BP_NOT_CAP; + bpctl_dev_t *pbpctl_dev_m; + + if ((is_bypass_fn(pbpctl_dev)) == 1) + pbpctl_dev_m = pbpctl_dev; + else + pbpctl_dev_m = get_master_port_fn(pbpctl_dev); + if (pbpctl_dev_m == NULL) + return BP_NOT_CAP; + + if (pbpctl_dev_m->bp_caps_ex & DISC_PORT_CAP_EX) { + if (is_bypass_fn(pbpctl_dev) == 1) + return ret; + /* return((((read_reg(pbpctl_dev,STATUS_TAP_REG_ADDR)) & TX_DISA_MASK)==TX_DISA_MASK)?1:0); */ + else + return ret; + /* return((((read_reg(pbpctl_dev,STATUS_TAP_REG_ADDR)) & TX_DISA_MASK)==TX_DISA_MASK)?1:0); */ + + } + return ret; +} + +int wdt_exp_mode_status(bpctl_dev_t *pbpctl_dev) +{ + if (pbpctl_dev->bp_caps & WD_CTL_CAP) { + if (pbpctl_dev->bp_ext_ver <= PXG2BPI_VER) + return 0; /* bypass mode */ + else if (pbpctl_dev->bp_ext_ver == PXG2TBPI_VER) + return 1; /* tap mode */ + else if (pbpctl_dev->bp_ext_ver >= PXE2TBPI_VER) { + if (pbpctl_dev->bp_ext_ver >= 0x8) { + if (((read_reg + (pbpctl_dev, + STATUS_DISC_REG_ADDR)) & + WDTE_DISC_BPN_MASK) == WDTE_DISC_BPN_MASK) + return 2; + } + return ((((read_reg(pbpctl_dev, STATUS_TAP_REG_ADDR)) & + WDTE_TAP_BPN_MASK) == + WDTE_TAP_BPN_MASK) ? 1 : 0); + } + } + return BP_NOT_CAP; +} + +int tpl2_flag_status(bpctl_dev_t *pbpctl_dev) +{ + + if (pbpctl_dev->bp_caps_ex & TPL2_CAP_EX) { + return ((((read_reg(pbpctl_dev, STATUS_DISC_REG_ADDR)) & + TPL2_FLAG_MASK) == TPL2_FLAG_MASK) ? 1 : 0); + + } + return BP_NOT_CAP; +} + +int tpl_hw_status(bpctl_dev_t *pbpctl_dev) +{ + bpctl_dev_t *pbpctl_dev_b = NULL; + + if (!(pbpctl_dev_b = get_status_port_fn(pbpctl_dev))) + return BP_NOT_CAP; + + if (TPL_IF_SERIES(pbpctl_dev->subdevice)) + return (((BPCTL_READ_REG(pbpctl_dev, CTRL)) & + BPCTLI_CTRL_SWDPIN0) != 0 ? 1 : 0); + return BP_NOT_CAP; +} + + +int bp_wait_at_pwup_status(bpctl_dev_t *pbpctl_dev) +{ + if (pbpctl_dev->bp_caps & SW_CTL_CAP) { + if (pbpctl_dev->bp_ext_ver >= 0x8) + return ((((read_reg(pbpctl_dev, CONT_CONFIG_REG_ADDR)) & + WAIT_AT_PWUP_MASK) == + WAIT_AT_PWUP_MASK) ? 1 : 0); + } + return BP_NOT_CAP; +} + +int bp_hw_reset_status(bpctl_dev_t *pbpctl_dev) +{ + + if (pbpctl_dev->bp_caps & SW_CTL_CAP) { + + if (pbpctl_dev->bp_ext_ver >= 0x8) + return ((((read_reg(pbpctl_dev, CONT_CONFIG_REG_ADDR)) & + EN_HW_RESET_MASK) == + EN_HW_RESET_MASK) ? 1 : 0); + } + return BP_NOT_CAP; +} + + +int std_nic_status(bpctl_dev_t *pbpctl_dev) +{ + int status_val = 0; + + if (pbpctl_dev->bp_caps & STD_NIC_CAP) { + if (INTEL_IF_SERIES(pbpctl_dev->subdevice)) + return BP_NOT_CAP; + if (pbpctl_dev->bp_ext_ver >= BP_FW_EXT_VER8) { + return ((((read_reg(pbpctl_dev, STATUS_DISC_REG_ADDR)) & + STD_NIC_ON_MASK) == STD_NIC_ON_MASK) ? 1 : 0); + } + + if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { + if (pbpctl_dev->bp_caps & BP_CAP) { + status_val = + read_reg(pbpctl_dev, STATUS_REG_ADDR); + if (((!(status_val & WDT_EN_MASK)) + && ((status_val & STD_NIC_MASK) == + STD_NIC_MASK))) + status_val = 1; + else + return 0; + } + if (pbpctl_dev->bp_caps & TAP_CAP) { + status_val = + read_reg(pbpctl_dev, STATUS_TAP_REG_ADDR); + if ((status_val & STD_NIC_TAP_MASK) == + STD_NIC_TAP_MASK) + status_val = 1; + else + return 0; + } + if (pbpctl_dev->bp_caps & TAP_CAP) { + if ((disc_off_status(pbpctl_dev))) + status_val = 1; + else + return 0; + } + + return status_val; + } + } + return BP_NOT_CAP; +} + +/******************************************************/ +/**************SW_INIT*********************************/ +/******************************************************/ +void bypass_caps_init(bpctl_dev_t *pbpctl_dev) +{ + u_int32_t ctrl_ext = 0; + bpctl_dev_t *pbpctl_dev_m = NULL; + +#ifdef BYPASS_DEBUG + int ret = 0; + if (!(INTEL_IF_SERIES(adapter->bp_device_block.subdevice))) { + ret = read_reg(pbpctl_dev, VER_REG_ADDR); + printk("VER_REG reg1=%x\n", ret); + ret = read_reg(pbpctl_dev, PRODUCT_CAP_REG_ADDR); + printk("PRODUCT_CAP reg=%x\n", ret); + ret = read_reg(pbpctl_dev, STATUS_TAP_REG_ADDR); + printk("STATUS_TAP reg1=%x\n", ret); + ret = read_reg(pbpctl_dev, 0x7); + printk("SIG_REG reg1=%x\n", ret); + ret = read_reg(pbpctl_dev, STATUS_REG_ADDR); + printk("STATUS_REG_ADDR=%x\n", ret); + ret = read_reg(pbpctl_dev, WDT_REG_ADDR); + printk("WDT_REG_ADDR=%x\n", ret); + ret = read_reg(pbpctl_dev, TMRL_REG_ADDR); + printk("TMRL_REG_ADDR=%x\n", ret); + ret = read_reg(pbpctl_dev, TMRH_REG_ADDR); + printk("TMRH_REG_ADDR=%x\n", ret); + } +#endif + if ((pbpctl_dev->bp_fiber5) || (pbpctl_dev->bp_10g9)) { + pbpctl_dev->media_type = bp_fiber; + } else if (pbpctl_dev->bp_10gb) { + if (BP10GB_CX4_SERIES(pbpctl_dev->subdevice)) + pbpctl_dev->media_type = bp_cx4; + else + pbpctl_dev->media_type = bp_fiber; + + } + + else if (pbpctl_dev->bp_540) + pbpctl_dev->media_type = bp_none; + else if (!pbpctl_dev->bp_10g) { + + ctrl_ext = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); + if ((ctrl_ext & BPCTLI_CTRL_EXT_LINK_MODE_MASK) == 0x0) + pbpctl_dev->media_type = bp_copper; + else + pbpctl_dev->media_type = bp_fiber; + + } else { + if (BP10G_CX4_SERIES(pbpctl_dev->subdevice)) + pbpctl_dev->media_type = bp_cx4; + else + pbpctl_dev->media_type = bp_fiber; + } + + if (is_bypass_fn(pbpctl_dev)) { + + pbpctl_dev->bp_caps |= BP_PWOFF_ON_CAP; + if (pbpctl_dev->media_type == bp_fiber) + pbpctl_dev->bp_caps |= + (TX_CTL_CAP | TX_STATUS_CAP | TPL_CAP); + + if (TPL_IF_SERIES(pbpctl_dev->subdevice)) { + pbpctl_dev->bp_caps |= TPL_CAP; + } + + if (INTEL_IF_SERIES(pbpctl_dev->subdevice)) { + pbpctl_dev->bp_caps |= + (BP_CAP | BP_STATUS_CAP | SW_CTL_CAP | + BP_PWUP_ON_CAP | BP_PWUP_OFF_CAP | BP_PWOFF_OFF_CAP + | WD_CTL_CAP | WD_STATUS_CAP | STD_NIC_CAP | + WD_TIMEOUT_CAP); + + pbpctl_dev->bp_ext_ver = OLD_IF_VER; + return; + } + + if ((pbpctl_dev->bp_fw_ver == 0xff) && + OLD_IF_SERIES(pbpctl_dev->subdevice)) { + + pbpctl_dev->bp_caps |= + (BP_CAP | BP_STATUS_CAP | BP_STATUS_CHANGE_CAP | + SW_CTL_CAP | BP_PWUP_ON_CAP | WD_CTL_CAP | + WD_STATUS_CAP | WD_TIMEOUT_CAP); + + pbpctl_dev->bp_ext_ver = OLD_IF_VER; + return; + } + + else { + switch (pbpctl_dev->bp_fw_ver) { + case BP_FW_VER_A0: + case BP_FW_VER_A1:{ + pbpctl_dev->bp_ext_ver = + (pbpctl_dev-> + bp_fw_ver & EXT_VER_MASK); + break; + } + default:{ + if ((bypass_sign_check(pbpctl_dev)) != + 1) { + pbpctl_dev->bp_caps = 0; + return; + } + pbpctl_dev->bp_ext_ver = + (pbpctl_dev-> + bp_fw_ver & EXT_VER_MASK); + } + } + } + + if (pbpctl_dev->bp_ext_ver == PXG2BPI_VER) + pbpctl_dev->bp_caps |= + (BP_CAP | BP_STATUS_CAP | BP_STATUS_CHANGE_CAP | + SW_CTL_CAP | BP_DIS_CAP | BP_DIS_STATUS_CAP | + BP_PWUP_ON_CAP | BP_PWUP_OFF_CAP | BP_PWUP_CTL_CAP + | WD_CTL_CAP | STD_NIC_CAP | WD_STATUS_CAP | + WD_TIMEOUT_CAP); + else if (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER) { + int cap_reg; + + pbpctl_dev->bp_caps |= + (SW_CTL_CAP | WD_CTL_CAP | WD_STATUS_CAP | + WD_TIMEOUT_CAP); + cap_reg = get_bp_prod_caps(pbpctl_dev); + + if ((cap_reg & NORMAL_UNSUPPORT_MASK) == + NORMAL_UNSUPPORT_MASK) + pbpctl_dev->bp_caps |= NIC_CAP_NEG; + else + pbpctl_dev->bp_caps |= STD_NIC_CAP; + + if ((normal_support(pbpctl_dev)) == 1) + + pbpctl_dev->bp_caps |= STD_NIC_CAP; + + else + pbpctl_dev->bp_caps |= NIC_CAP_NEG; + if ((cap_reg & BYPASS_SUPPORT_MASK) == + BYPASS_SUPPORT_MASK) { + pbpctl_dev->bp_caps |= + (BP_CAP | BP_STATUS_CAP | + BP_STATUS_CHANGE_CAP | BP_DIS_CAP | + BP_DIS_STATUS_CAP | BP_PWUP_ON_CAP | + BP_PWUP_OFF_CAP | BP_PWUP_CTL_CAP); + if (pbpctl_dev->bp_ext_ver >= BP_FW_EXT_VER7) + pbpctl_dev->bp_caps |= + BP_PWOFF_ON_CAP | BP_PWOFF_OFF_CAP | + BP_PWOFF_CTL_CAP; + } + if ((cap_reg & TAP_SUPPORT_MASK) == TAP_SUPPORT_MASK) { + pbpctl_dev->bp_caps |= + (TAP_CAP | TAP_STATUS_CAP | + TAP_STATUS_CHANGE_CAP | TAP_DIS_CAP | + TAP_DIS_STATUS_CAP | TAP_PWUP_ON_CAP | + TAP_PWUP_OFF_CAP | TAP_PWUP_CTL_CAP); + } + if (pbpctl_dev->bp_ext_ver >= BP_FW_EXT_VER8) { + if ((cap_reg & DISC_SUPPORT_MASK) == + DISC_SUPPORT_MASK) + pbpctl_dev->bp_caps |= + (DISC_CAP | DISC_DIS_CAP | + DISC_PWUP_CTL_CAP); + if ((cap_reg & TPL2_SUPPORT_MASK) == + TPL2_SUPPORT_MASK) { + pbpctl_dev->bp_caps_ex |= TPL2_CAP_EX; + pbpctl_dev->bp_caps |= TPL_CAP; + pbpctl_dev->bp_tpl_flag = + tpl2_flag_status(pbpctl_dev); + } + + } + + if (pbpctl_dev->bp_ext_ver >= BP_FW_EXT_VER9) { + if ((cap_reg & DISC_PORT_SUPPORT_MASK) == + DISC_PORT_SUPPORT_MASK) { + pbpctl_dev->bp_caps_ex |= + DISC_PORT_CAP_EX; + pbpctl_dev->bp_caps |= + (TX_CTL_CAP | TX_STATUS_CAP); + } + + } + + } + if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { + if ((read_reg(pbpctl_dev, STATUS_REG_ADDR)) & + WDT_EN_MASK) + pbpctl_dev->wdt_status = WDT_STATUS_EN; + else + pbpctl_dev->wdt_status = WDT_STATUS_DIS; + } + + } else if ((P2BPFI_IF_SERIES(pbpctl_dev->subdevice)) || + (PEGF5_IF_SERIES(pbpctl_dev->subdevice)) || + (PEGF80_IF_SERIES(pbpctl_dev->subdevice)) || + (BP10G9_IF_SERIES(pbpctl_dev->subdevice))) { + pbpctl_dev->bp_caps |= (TX_CTL_CAP | TX_STATUS_CAP); + } + if ((pbpctl_dev->subdevice & 0xa00) == 0xa00) + pbpctl_dev->bp_caps |= (TX_CTL_CAP | TX_STATUS_CAP); + if (PEG5_IF_SERIES(pbpctl_dev->subdevice)) + pbpctl_dev->bp_caps |= (TX_CTL_CAP | TX_STATUS_CAP); + + if (BP10GB_IF_SERIES(pbpctl_dev->subdevice)) { + pbpctl_dev->bp_caps &= ~(TX_CTL_CAP | TX_STATUS_CAP); + } + pbpctl_dev_m = get_master_port_fn(pbpctl_dev); + if (pbpctl_dev_m != NULL) { + int cap_reg = 0; + if (pbpctl_dev_m->bp_ext_ver >= 0x9) { + cap_reg = get_bp_prod_caps(pbpctl_dev_m); + if ((cap_reg & DISC_PORT_SUPPORT_MASK) == + DISC_PORT_SUPPORT_MASK) + pbpctl_dev->bp_caps |= + (TX_CTL_CAP | TX_STATUS_CAP); + pbpctl_dev->bp_caps_ex |= DISC_PORT_CAP_EX; + } + } +} + +int bypass_off_init(bpctl_dev_t *pbpctl_dev) +{ + int ret = 0; + + if ((ret = cmnd_on(pbpctl_dev)) < 0) + return ret; + if (INTEL_IF_SERIES(pbpctl_dev->subdevice)) + return dis_bypass_cap(pbpctl_dev); + wdt_off(pbpctl_dev); + if (pbpctl_dev->bp_caps & BP_CAP) + bypass_off(pbpctl_dev); + if (pbpctl_dev->bp_caps & TAP_CAP) + tap_off(pbpctl_dev); + cmnd_off(pbpctl_dev); + return 0; +} + +void remove_bypass_wd_auto(bpctl_dev_t *pbpctl_dev) +{ +#ifdef BP_SELF_TEST + bpctl_dev_t *pbpctl_dev_sl = NULL; +#endif + + if (pbpctl_dev->bp_caps & WD_CTL_CAP) { + + del_timer_sync(&pbpctl_dev->bp_timer); +#ifdef BP_SELF_TEST + pbpctl_dev_sl = get_status_port_fn(pbpctl_dev); + if (pbpctl_dev_sl && (pbpctl_dev_sl->ndev)) { + if ((pbpctl_dev_sl->ndev->netdev_ops) + && (pbpctl_dev_sl->old_ops)) { + rtnl_lock(); + pbpctl_dev_sl->ndev->netdev_ops = + pbpctl_dev_sl->old_ops; + pbpctl_dev_sl->old_ops = NULL; + + rtnl_unlock(); + + } + + } +#endif + } + +} + +int init_bypass_wd_auto(bpctl_dev_t *pbpctl_dev) +{ + if (pbpctl_dev->bp_caps & WD_CTL_CAP) { + init_timer(&pbpctl_dev->bp_timer); + pbpctl_dev->bp_timer.function = &wd_reset_timer; + pbpctl_dev->bp_timer.data = (unsigned long)pbpctl_dev; + return 1; + } + return BP_NOT_CAP; +} + +#ifdef BP_SELF_TEST +int bp_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) +{ + bpctl_dev_t *pbpctl_dev = NULL, *pbpctl_dev_m = NULL; + int idx_dev = 0; + struct ethhdr *eth = (struct ethhdr *)skb->data; + + for (idx_dev = 0; + ((bpctl_dev_arr[idx_dev].ndev != NULL) && (idx_dev < device_num)); + idx_dev++) { + if (bpctl_dev_arr[idx_dev].ndev == dev) { + pbpctl_dev = &bpctl_dev_arr[idx_dev]; + break; + } + } + if (!pbpctl_dev) + return 1; + if ((htons(ETH_P_BPTEST) == eth->h_proto)) { + + pbpctl_dev_m = get_master_port_fn(pbpctl_dev); + if (pbpctl_dev_m) { + + if (bypass_status(pbpctl_dev_m)) { + cmnd_on(pbpctl_dev_m); + bypass_off(pbpctl_dev_m); + cmnd_off(pbpctl_dev_m); + } + wdt_timer_reload(pbpctl_dev_m); + } + dev_kfree_skb_irq(skb); + return 0; + } + return pbpctl_dev->hard_start_xmit_save(skb, dev); +} +#endif + +int set_bypass_wd_auto(bpctl_dev_t *pbpctl_dev, unsigned int param) +{ + if (pbpctl_dev->bp_caps & WD_CTL_CAP) { + if (pbpctl_dev->reset_time != param) { + if (INTEL_IF_SERIES(pbpctl_dev->subdevice)) + pbpctl_dev->reset_time = + (param < + WDT_AUTO_MIN_INT) ? WDT_AUTO_MIN_INT : + param; + else + pbpctl_dev->reset_time = param; + if (param) + mod_timer(&pbpctl_dev->bp_timer, jiffies); + } + return 0; + } + return BP_NOT_CAP; +} + +int get_bypass_wd_auto(bpctl_dev_t *pbpctl_dev) +{ + + if (pbpctl_dev->bp_caps & WD_CTL_CAP) { + return pbpctl_dev->reset_time; + } + return BP_NOT_CAP; +} + +#ifdef BP_SELF_TEST + +int set_bp_self_test(bpctl_dev_t *pbpctl_dev, unsigned int param) +{ + bpctl_dev_t *pbpctl_dev_sl = NULL; + + if (pbpctl_dev->bp_caps & WD_CTL_CAP) { + pbpctl_dev->bp_self_test_flag = param == 0 ? 0 : 1; + pbpctl_dev_sl = get_status_port_fn(pbpctl_dev); + + if ((pbpctl_dev_sl->ndev) && (pbpctl_dev_sl->ndev->netdev_ops)) { + rtnl_lock(); + if (pbpctl_dev->bp_self_test_flag == 1) { + + pbpctl_dev_sl->old_ops = + pbpctl_dev_sl->ndev->netdev_ops; + pbpctl_dev_sl->new_ops = + *pbpctl_dev_sl->old_ops; + pbpctl_dev_sl->new_ops.ndo_start_xmit = + bp_hard_start_xmit; + pbpctl_dev_sl->ndev->netdev_ops = + &pbpctl_dev_sl->new_ops; + + } else if (pbpctl_dev_sl->old_ops) { + pbpctl_dev_sl->ndev->netdev_ops = + pbpctl_dev_sl->old_ops; + pbpctl_dev_sl->old_ops = NULL; + } + rtnl_unlock(); + } + + set_bypass_wd_auto(pbpctl_dev, param); + return 0; + } + return BP_NOT_CAP; +} + +int get_bp_self_test(bpctl_dev_t *pbpctl_dev) +{ + + if (pbpctl_dev->bp_caps & WD_CTL_CAP) { + if (pbpctl_dev->bp_self_test_flag == 1) + return pbpctl_dev->reset_time; + else + return 0; + } + return BP_NOT_CAP; +} + +#endif + +/**************************************************************/ +/************************* API ********************************/ +/**************************************************************/ + +int is_bypass_fn(bpctl_dev_t *pbpctl_dev) +{ + if (!pbpctl_dev) + return -1; + + return (((pbpctl_dev->func == 0) || (pbpctl_dev->func == 2)) ? 1 : 0); +} + +int set_bypass_fn(bpctl_dev_t *pbpctl_dev, int bypass_mode) +{ + int ret = 0; + + if (!(pbpctl_dev->bp_caps & BP_CAP)) + return BP_NOT_CAP; + if ((ret = cmnd_on(pbpctl_dev)) < 0) + return ret; + if (!bypass_mode) + ret = bypass_off(pbpctl_dev); + else + ret = bypass_on(pbpctl_dev); + cmnd_off(pbpctl_dev); + + return ret; +} + +int get_bypass_fn(bpctl_dev_t *pbpctl_dev) +{ + return bypass_status(pbpctl_dev); +} + +int get_bypass_change_fn(bpctl_dev_t *pbpctl_dev) +{ + if (!pbpctl_dev) + return -1; + + return bypass_change_status(pbpctl_dev); +} + +int set_dis_bypass_fn(bpctl_dev_t *pbpctl_dev, int dis_param) +{ + int ret = 0; + if (!pbpctl_dev) + return -1; + + if (!(pbpctl_dev->bp_caps & BP_DIS_CAP)) + return BP_NOT_CAP; + if ((ret = cmnd_on(pbpctl_dev)) < 0) + return ret; + if (dis_param) + ret = dis_bypass_cap(pbpctl_dev); + else + ret = en_bypass_cap(pbpctl_dev); + cmnd_off(pbpctl_dev); + return ret; +} + +int get_dis_bypass_fn(bpctl_dev_t *pbpctl_dev) +{ + if (!pbpctl_dev) + return -1; + + return dis_bypass_cap_status(pbpctl_dev); +} + +int set_bypass_pwoff_fn(bpctl_dev_t *pbpctl_dev, int bypass_mode) +{ + int ret = 0; + if (!pbpctl_dev) + return -1; + + if (!(pbpctl_dev->bp_caps & BP_PWOFF_CTL_CAP)) + return BP_NOT_CAP; + if ((ret = cmnd_on(pbpctl_dev)) < 0) + return ret; + if (bypass_mode) + ret = bypass_state_pwroff(pbpctl_dev); + else + ret = normal_state_pwroff(pbpctl_dev); + cmnd_off(pbpctl_dev); + return ret; +} + +int get_bypass_pwoff_fn(bpctl_dev_t *pbpctl_dev) +{ + if (!pbpctl_dev) + return -1; + + return default_pwroff_status(pbpctl_dev); +} + +int set_bypass_pwup_fn(bpctl_dev_t *pbpctl_dev, int bypass_mode) +{ + int ret = 0; + if (!pbpctl_dev) + return -1; + + if (!(pbpctl_dev->bp_caps & BP_PWUP_CTL_CAP)) + return BP_NOT_CAP; + if ((ret = cmnd_on(pbpctl_dev)) < 0) + return ret; + if (bypass_mode) + ret = bypass_state_pwron(pbpctl_dev); + else + ret = normal_state_pwron(pbpctl_dev); + cmnd_off(pbpctl_dev); + return ret; +} + +int get_bypass_pwup_fn(bpctl_dev_t *pbpctl_dev) +{ + if (!pbpctl_dev) + return -1; + + return default_pwron_status(pbpctl_dev); +} + +int set_bypass_wd_fn(bpctl_dev_t *pbpctl_dev, int timeout) +{ + int ret = 0; + if (!pbpctl_dev) + return -1; + + if (!(pbpctl_dev->bp_caps & WD_CTL_CAP)) + return BP_NOT_CAP; + + if ((ret = cmnd_on(pbpctl_dev)) < 0) + return ret; + if (!timeout) + ret = wdt_off(pbpctl_dev); + else { + wdt_on(pbpctl_dev, timeout); + ret = pbpctl_dev->bypass_timer_interval; + } + cmnd_off(pbpctl_dev); + return ret; +} + +int get_bypass_wd_fn(bpctl_dev_t *pbpctl_dev, int *timeout) +{ + if (!pbpctl_dev) + return -1; + + return wdt_programmed(pbpctl_dev, timeout); +} + +int get_wd_expire_time_fn(bpctl_dev_t *pbpctl_dev, int *time_left) +{ + if (!pbpctl_dev) + return -1; + + return wdt_timer(pbpctl_dev, time_left); +} + +int reset_bypass_wd_timer_fn(bpctl_dev_t *pbpctl_dev) +{ + if (!pbpctl_dev) + return -1; + + return wdt_timer_reload(pbpctl_dev); +} + +int get_wd_set_caps_fn(bpctl_dev_t *pbpctl_dev) +{ + int bp_status = 0; + + unsigned int step_value = TIMEOUT_MAX_STEP + 1, bit_cnt = 0; + if (!pbpctl_dev) + return -1; + + if (INTEL_IF_SERIES(pbpctl_dev->subdevice)) + return BP_NOT_CAP; + + while ((step_value >>= 1)) + bit_cnt++; + + if (is_bypass_fn(pbpctl_dev)) { + bp_status = + WD_STEP_COUNT_MASK(bit_cnt) | WDT_STEP_TIME | + WD_MIN_TIME_MASK(TIMEOUT_UNIT / 100); + } else + return -1; + + return bp_status; +} + +int set_std_nic_fn(bpctl_dev_t *pbpctl_dev, int nic_mode) +{ + int ret = 0; + if (!pbpctl_dev) + return -1; + + if (!(pbpctl_dev->bp_caps & STD_NIC_CAP)) + return BP_NOT_CAP; + + if ((ret = cmnd_on(pbpctl_dev)) < 0) + return ret; + if (nic_mode) + ret = std_nic_on(pbpctl_dev); + else + ret = std_nic_off(pbpctl_dev); + cmnd_off(pbpctl_dev); + return ret; +} + +int get_std_nic_fn(bpctl_dev_t *pbpctl_dev) +{ + if (!pbpctl_dev) + return -1; + + return std_nic_status(pbpctl_dev); +} + +int set_tap_fn(bpctl_dev_t *pbpctl_dev, int tap_mode) +{ + if (!pbpctl_dev) + return -1; + + if ((pbpctl_dev->bp_caps & TAP_CAP) && ((cmnd_on(pbpctl_dev)) >= 0)) { + if (!tap_mode) + tap_off(pbpctl_dev); + else + tap_on(pbpctl_dev); + cmnd_off(pbpctl_dev); + return 0; + } + return BP_NOT_CAP; +} + +int get_tap_fn(bpctl_dev_t *pbpctl_dev) +{ + if (!pbpctl_dev) + return -1; + + return tap_status(pbpctl_dev); +} + +int set_tap_pwup_fn(bpctl_dev_t *pbpctl_dev, int tap_mode) +{ + int ret = 0; + if (!pbpctl_dev) + return -1; + + if ((pbpctl_dev->bp_caps & TAP_PWUP_CTL_CAP) + && ((cmnd_on(pbpctl_dev)) >= 0)) { + if (tap_mode) + ret = tap_state_pwron(pbpctl_dev); + else + ret = normal_state_pwron(pbpctl_dev); + cmnd_off(pbpctl_dev); + } else + ret = BP_NOT_CAP; + return ret; +} + +int get_tap_pwup_fn(bpctl_dev_t *pbpctl_dev) +{ + int ret = 0; + if (!pbpctl_dev) + return -1; + + if ((ret = default_pwron_tap_status(pbpctl_dev)) < 0) + return ret; + return ((ret == 0) ? 1 : 0); +} + +int get_tap_change_fn(bpctl_dev_t *pbpctl_dev) +{ + if (!pbpctl_dev) + return -1; + + return tap_change_status(pbpctl_dev); +} + +int set_dis_tap_fn(bpctl_dev_t *pbpctl_dev, int dis_param) +{ + int ret = 0; + if (!pbpctl_dev) + return -1; + + if ((pbpctl_dev->bp_caps & TAP_DIS_CAP) && ((cmnd_on(pbpctl_dev)) >= 0)) { + if (dis_param) + ret = dis_tap_cap(pbpctl_dev); + else + ret = en_tap_cap(pbpctl_dev); + cmnd_off(pbpctl_dev); + return ret; + } else + return BP_NOT_CAP; +} + +int get_dis_tap_fn(bpctl_dev_t *pbpctl_dev) +{ + if (!pbpctl_dev) + return -1; + + return dis_tap_cap_status(pbpctl_dev); +} + +int set_disc_fn(bpctl_dev_t *pbpctl_dev, int disc_mode) +{ + if (!pbpctl_dev) + return -1; + + if ((pbpctl_dev->bp_caps & DISC_CAP) && ((cmnd_on(pbpctl_dev)) >= 0)) { + if (!disc_mode) + disc_off(pbpctl_dev); + else + disc_on(pbpctl_dev); + cmnd_off(pbpctl_dev); + + return BP_OK; + } + return BP_NOT_CAP; +} + +int get_disc_fn(bpctl_dev_t *pbpctl_dev) +{ + int ret = 0; + if (!pbpctl_dev) + return -1; + + ret = disc_status(pbpctl_dev); + + return ret; +} + +int set_disc_pwup_fn(bpctl_dev_t *pbpctl_dev, int disc_mode) +{ + int ret = 0; + if (!pbpctl_dev) + return -1; + + if ((pbpctl_dev->bp_caps & DISC_PWUP_CTL_CAP) + && ((cmnd_on(pbpctl_dev)) >= 0)) { + if (disc_mode) + ret = disc_state_pwron(pbpctl_dev); + else + ret = normal_state_pwron(pbpctl_dev); + cmnd_off(pbpctl_dev); + } else + ret = BP_NOT_CAP; + return ret; +} + +int get_disc_pwup_fn(bpctl_dev_t *pbpctl_dev) +{ + int ret = 0; + if (!pbpctl_dev) + return -1; + + ret = default_pwron_disc_status(pbpctl_dev); + return (ret == 0 ? 1 : (ret < 0 ? BP_NOT_CAP : 0)); +} + +int get_disc_change_fn(bpctl_dev_t *pbpctl_dev) +{ + int ret = 0; + if (!pbpctl_dev) + return -1; + + ret = disc_change_status(pbpctl_dev); + return ret; +} + +int set_dis_disc_fn(bpctl_dev_t *pbpctl_dev, int dis_param) +{ + int ret = 0; + if (!pbpctl_dev) + return -1; + + if ((pbpctl_dev->bp_caps & DISC_DIS_CAP) + && ((cmnd_on(pbpctl_dev)) >= 0)) { + if (dis_param) + ret = dis_disc_cap(pbpctl_dev); + else + ret = en_disc_cap(pbpctl_dev); + cmnd_off(pbpctl_dev); + return ret; + } else + return BP_NOT_CAP; +} + +int get_dis_disc_fn(bpctl_dev_t *pbpctl_dev) +{ + int ret = 0; + if (!pbpctl_dev) + return -1; + + ret = dis_disc_cap_status(pbpctl_dev); + + return ret; +} + +int set_disc_port_fn(bpctl_dev_t *pbpctl_dev, int disc_mode) +{ + int ret = BP_NOT_CAP; + if (!pbpctl_dev) + return -1; + + if (!disc_mode) + ret = disc_port_off(pbpctl_dev); + else + ret = disc_port_on(pbpctl_dev); + + return ret; +} + +int get_disc_port_fn(bpctl_dev_t *pbpctl_dev) +{ + if (!pbpctl_dev) + return -1; + + return disc_port_status(pbpctl_dev); +} + +int set_disc_port_pwup_fn(bpctl_dev_t *pbpctl_dev, int disc_mode) +{ + int ret = BP_NOT_CAP; + if (!pbpctl_dev) + return -1; + + if (!disc_mode) + ret = normal_port_state_pwron(pbpctl_dev); + else + ret = disc_port_state_pwron(pbpctl_dev); + + return ret; +} + +int get_disc_port_pwup_fn(bpctl_dev_t *pbpctl_dev) +{ + int ret = 0; + if (!pbpctl_dev) + return -1; + + if ((ret = default_pwron_disc_port_status(pbpctl_dev)) < 0) + return ret; + return ((ret == 0) ? 1 : 0); +} + +int get_wd_exp_mode_fn(bpctl_dev_t *pbpctl_dev) +{ + if (!pbpctl_dev) + return -1; + + return wdt_exp_mode_status(pbpctl_dev); +} + +int set_wd_exp_mode_fn(bpctl_dev_t *pbpctl_dev, int param) +{ + if (!pbpctl_dev) + return -1; + + return wdt_exp_mode(pbpctl_dev, param); +} + +int reset_cont_fn(bpctl_dev_t *pbpctl_dev) +{ + int ret = 0; + if (!pbpctl_dev) + return -1; + + if ((ret = cmnd_on(pbpctl_dev)) < 0) + return ret; + return reset_cont(pbpctl_dev); +} + +int set_tx_fn(bpctl_dev_t *pbpctl_dev, int tx_state) +{ + + bpctl_dev_t *pbpctl_dev_b = NULL; + if (!pbpctl_dev) + return -1; + + if ((pbpctl_dev->bp_caps & TPL_CAP) && + (pbpctl_dev->bp_caps & SW_CTL_CAP)) { + if ((pbpctl_dev->bp_tpl_flag)) + return BP_NOT_CAP; + } else if ((pbpctl_dev_b = get_master_port_fn(pbpctl_dev))) { + if ((pbpctl_dev_b->bp_caps & TPL_CAP) && + (pbpctl_dev_b->bp_tpl_flag)) + return BP_NOT_CAP; + } + return set_tx(pbpctl_dev, tx_state); +} + +int set_bp_force_link_fn(int dev_num, int tx_state) +{ + static bpctl_dev_t *bpctl_dev_curr; + + if ((dev_num < 0) || (dev_num > device_num) + || (bpctl_dev_arr[dev_num].pdev == NULL)) + return -1; + bpctl_dev_curr = &bpctl_dev_arr[dev_num]; + + return set_bp_force_link(bpctl_dev_curr, tx_state); +} + +int set_wd_autoreset_fn(bpctl_dev_t *pbpctl_dev, int param) +{ + if (!pbpctl_dev) + return -1; + + return set_bypass_wd_auto(pbpctl_dev, param); +} + +int get_wd_autoreset_fn(bpctl_dev_t *pbpctl_dev) +{ + if (!pbpctl_dev) + return -1; + + return get_bypass_wd_auto(pbpctl_dev); +} + +#ifdef BP_SELF_TEST +int set_bp_self_test_fn(bpctl_dev_t *pbpctl_dev, int param) +{ + if (!pbpctl_dev) + return -1; + + return set_bp_self_test(pbpctl_dev, param); +} + +int get_bp_self_test_fn(bpctl_dev_t *pbpctl_dev) +{ + if (!pbpctl_dev) + return -1; + + return get_bp_self_test(pbpctl_dev); +} + +#endif + +int get_bypass_caps_fn(bpctl_dev_t *pbpctl_dev) +{ + if (!pbpctl_dev) + return -1; + + return pbpctl_dev->bp_caps; + +} + +int get_bypass_slave_fn(bpctl_dev_t *pbpctl_dev, bpctl_dev_t **pbpctl_dev_out) +{ + int idx_dev = 0; + if (!pbpctl_dev) + return -1; + + 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)) { + if ((pbpctl_dev->func == 0) + && (bpctl_dev_arr[idx_dev].func == 1)) { + *pbpctl_dev_out = + &bpctl_dev_arr[idx_dev]; + return 1; + } + if ((pbpctl_dev->func == 2) && + (bpctl_dev_arr[idx_dev].func == 3)) { + *pbpctl_dev_out = + &bpctl_dev_arr[idx_dev]; + return 1; + } + } + } + return -1; + } else + return 0; +} + +int is_bypass(bpctl_dev_t *pbpctl_dev) +{ + if (!pbpctl_dev) + return -1; + + if ((pbpctl_dev->func == 0) || (pbpctl_dev->func == 2)) + return 1; + else + return 0; +} + +int get_tx_fn(bpctl_dev_t *pbpctl_dev) +{ + bpctl_dev_t *pbpctl_dev_b = NULL; + if (!pbpctl_dev) + return -1; + + if ((pbpctl_dev->bp_caps & TPL_CAP) && + (pbpctl_dev->bp_caps & SW_CTL_CAP)) { + if ((pbpctl_dev->bp_tpl_flag)) + return BP_NOT_CAP; + } else if ((pbpctl_dev_b = get_master_port_fn(pbpctl_dev))) { + if ((pbpctl_dev_b->bp_caps & TPL_CAP) && + (pbpctl_dev_b->bp_tpl_flag)) + return BP_NOT_CAP; + } + return tx_status(pbpctl_dev); +} + +int get_bp_force_link_fn(int dev_num) +{ + static bpctl_dev_t *bpctl_dev_curr; + + if ((dev_num < 0) || (dev_num > device_num) + || (bpctl_dev_arr[dev_num].pdev == NULL)) + return -1; + bpctl_dev_curr = &bpctl_dev_arr[dev_num]; + + return bp_force_link_status(bpctl_dev_curr); +} + +static int get_bypass_link_status(bpctl_dev_t *pbpctl_dev) +{ + if (!pbpctl_dev) + return -1; + + if (pbpctl_dev->media_type == bp_fiber) + return ((BPCTL_READ_REG(pbpctl_dev, CTRL) & + BPCTLI_CTRL_SWDPIN1)); + else + return ((BPCTL_READ_REG(pbpctl_dev, STATUS) & + BPCTLI_STATUS_LU)); + +} + +static void bp_tpl_timer_fn(unsigned long param) +{ + bpctl_dev_t *pbpctl_dev = (bpctl_dev_t *) param; + uint32_t link1, link2; + bpctl_dev_t *pbpctl_dev_b = NULL; + + if (!(pbpctl_dev_b = get_status_port_fn(pbpctl_dev))) + return; + + if (!pbpctl_dev->bp_tpl_flag) { + set_tx(pbpctl_dev_b, 1); + set_tx(pbpctl_dev, 1); + return; + } + link1 = get_bypass_link_status(pbpctl_dev); + + link2 = get_bypass_link_status(pbpctl_dev_b); + if ((link1) && (tx_status(pbpctl_dev))) { + if ((!link2) && (tx_status(pbpctl_dev_b))) { + set_tx(pbpctl_dev, 0); + } else if (!tx_status(pbpctl_dev_b)) { + set_tx(pbpctl_dev_b, 1); + } + } else if ((!link1) && (tx_status(pbpctl_dev))) { + if ((link2) && (tx_status(pbpctl_dev_b))) { + set_tx(pbpctl_dev_b, 0); + } + } else if ((link1) && (!tx_status(pbpctl_dev))) { + if ((link2) && (tx_status(pbpctl_dev_b))) { + set_tx(pbpctl_dev, 1); + } + } else if ((!link1) && (!tx_status(pbpctl_dev))) { + if ((link2) && (tx_status(pbpctl_dev_b))) { + set_tx(pbpctl_dev, 1); + } + } + + mod_timer(&pbpctl_dev->bp_tpl_timer, jiffies + BP_LINK_MON_DELAY * HZ); +} + +void remove_bypass_tpl_auto(bpctl_dev_t *pbpctl_dev) +{ + bpctl_dev_t *pbpctl_dev_b = NULL; + if (!pbpctl_dev) + return; + pbpctl_dev_b = get_status_port_fn(pbpctl_dev); + + if (pbpctl_dev->bp_caps & TPL_CAP) { + del_timer_sync(&pbpctl_dev->bp_tpl_timer); + pbpctl_dev->bp_tpl_flag = 0; + pbpctl_dev_b = get_status_port_fn(pbpctl_dev); + if (pbpctl_dev_b) + set_tx(pbpctl_dev_b, 1); + set_tx(pbpctl_dev, 1); + } + return; +} + +int init_bypass_tpl_auto(bpctl_dev_t *pbpctl_dev) +{ + if (!pbpctl_dev) + return -1; + if (pbpctl_dev->bp_caps & TPL_CAP) { + init_timer(&pbpctl_dev->bp_tpl_timer); + pbpctl_dev->bp_tpl_timer.function = &bp_tpl_timer_fn; + pbpctl_dev->bp_tpl_timer.data = (unsigned long)pbpctl_dev; + return BP_OK; + } + return BP_NOT_CAP; +} + +int set_bypass_tpl_auto(bpctl_dev_t *pbpctl_dev, unsigned int param) +{ + if (!pbpctl_dev) + return -1; + if (pbpctl_dev->bp_caps & TPL_CAP) { + if ((param) && (!pbpctl_dev->bp_tpl_flag)) { + pbpctl_dev->bp_tpl_flag = param; + mod_timer(&pbpctl_dev->bp_tpl_timer, jiffies + 1); + return BP_OK; + }; + if ((!param) && (pbpctl_dev->bp_tpl_flag)) + remove_bypass_tpl_auto(pbpctl_dev); + + return BP_OK; + } + return BP_NOT_CAP; +} + +int get_bypass_tpl_auto(bpctl_dev_t *pbpctl_dev) +{ + if (!pbpctl_dev) + return -1; + if (pbpctl_dev->bp_caps & TPL_CAP) { + return pbpctl_dev->bp_tpl_flag; + } + return BP_NOT_CAP; +} + +int set_tpl_fn(bpctl_dev_t *pbpctl_dev, int tpl_mode) +{ + + bpctl_dev_t *pbpctl_dev_b = NULL; + if (!pbpctl_dev) + return -1; + + pbpctl_dev_b = get_status_port_fn(pbpctl_dev); + + if (pbpctl_dev->bp_caps & TPL_CAP) { + if (tpl_mode) { + if ((pbpctl_dev_b = get_status_port_fn(pbpctl_dev))) + set_tx(pbpctl_dev_b, 1); + set_tx(pbpctl_dev, 1); + } + if ((TPL_IF_SERIES(pbpctl_dev->subdevice)) || + (pbpctl_dev->bp_caps_ex & TPL2_CAP_EX)) { + pbpctl_dev->bp_tpl_flag = tpl_mode; + if (!tpl_mode) + tpl_hw_off(pbpctl_dev); + else + tpl_hw_on(pbpctl_dev); + } else + set_bypass_tpl_auto(pbpctl_dev, tpl_mode); + return 0; + } + return BP_NOT_CAP; +} + +int get_tpl_fn(bpctl_dev_t *pbpctl_dev) +{ + int ret = BP_NOT_CAP; + if (!pbpctl_dev) + return -1; + + if (pbpctl_dev->bp_caps & TPL_CAP) { + if (pbpctl_dev->bp_caps_ex & TPL2_CAP_EX) + return tpl2_flag_status(pbpctl_dev); + ret = pbpctl_dev->bp_tpl_flag; + } + return ret; +} + +int set_bp_wait_at_pwup_fn(bpctl_dev_t *pbpctl_dev, int tap_mode) +{ + if (!pbpctl_dev) + return -1; + + if (pbpctl_dev->bp_caps & SW_CTL_CAP) { + /* bp_lock(pbp_device_block); */ + cmnd_on(pbpctl_dev); + if (!tap_mode) + bp_wait_at_pwup_dis(pbpctl_dev); + else + bp_wait_at_pwup_en(pbpctl_dev); + cmnd_off(pbpctl_dev); + + /* bp_unlock(pbp_device_block); */ + return BP_OK; + } + return BP_NOT_CAP; +} + +int get_bp_wait_at_pwup_fn(bpctl_dev_t *pbpctl_dev) +{ + int ret = 0; + if (!pbpctl_dev) + return -1; + + /* bp_lock(pbp_device_block); */ + ret = bp_wait_at_pwup_status(pbpctl_dev); + /* bp_unlock(pbp_device_block); */ + + return ret; +} + +int set_bp_hw_reset_fn(bpctl_dev_t *pbpctl_dev, int tap_mode) +{ + if (!pbpctl_dev) + return -1; + + if (pbpctl_dev->bp_caps & SW_CTL_CAP) { + /* bp_lock(pbp_device_block); */ + cmnd_on(pbpctl_dev); + + if (!tap_mode) + bp_hw_reset_dis(pbpctl_dev); + else + bp_hw_reset_en(pbpctl_dev); + cmnd_off(pbpctl_dev); + /* bp_unlock(pbp_device_block); */ + return BP_OK; + } + return BP_NOT_CAP; +} + +int get_bp_hw_reset_fn(bpctl_dev_t *pbpctl_dev) +{ + int ret = 0; + if (!pbpctl_dev) + return -1; + + /* bp_lock(pbp_device_block); */ + ret = bp_hw_reset_status(pbpctl_dev); + + /* bp_unlock(pbp_device_block); */ + + return ret; +} + + +int get_bypass_info_fn(bpctl_dev_t *pbpctl_dev, char *dev_name, + char *add_param) +{ + if (!pbpctl_dev) + return -1; + if (!is_bypass_fn(pbpctl_dev)) + return -1; + strcpy(dev_name, pbpctl_dev->name); + *add_param = pbpctl_dev->bp_fw_ver; + return 0; +} + +int get_dev_idx_bsf(int bus, int slot, int func) +{ + int idx_dev = 0; + for (idx_dev = 0; + ((bpctl_dev_arr[idx_dev].pdev != NULL) && (idx_dev < device_num)); + idx_dev++) { + if ((bus == bpctl_dev_arr[idx_dev].bus) + && (slot == bpctl_dev_arr[idx_dev].slot) + && (func == bpctl_dev_arr[idx_dev].func)) + + return idx_dev; + } + return -1; +} + +static void str_low(char *str) +{ + int i; + + for (i = 0; i < strlen(str); i++) + if ((str[i] >= 65) && (str[i] <= 90)) + str[i] += 32; +} + +static unsigned long str_to_hex(char *p) +{ + unsigned long hex = 0; + unsigned long length = strlen(p), shift = 0; + unsigned char dig = 0; + + str_low(p); + length = strlen(p); + + if (length == 0) + return 0; + + do { + dig = p[--length]; + dig = dig < 'a' ? (dig - '0') : (dig - 'a' + 0xa); + hex |= (dig << shift); + shift += 4; + } while (length); + return hex; +} + +static int get_dev_idx(int ifindex) +{ + int idx_dev = 0; + + for (idx_dev = 0; + ((bpctl_dev_arr[idx_dev].pdev != NULL) && (idx_dev < device_num)); + idx_dev++) { + if (ifindex == bpctl_dev_arr[idx_dev].ifindex) + return idx_dev; + } + + return -1; +} + +static bpctl_dev_t *get_dev_idx_p(int ifindex) +{ + int idx_dev = 0; + + for (idx_dev = 0; + ((bpctl_dev_arr[idx_dev].pdev != NULL) && (idx_dev < device_num)); + idx_dev++) { + if (ifindex == bpctl_dev_arr[idx_dev].ifindex) + return &bpctl_dev_arr[idx_dev]; + } + + return NULL; +} + +static void if_scan_init(void) +{ + int idx_dev = 0; + struct net_device *dev; + int ifindex; + /* rcu_read_lock(); */ + /* rtnl_lock(); */ + /* rcu_read_lock(); */ + + for_each_netdev(&init_net, dev) { + + struct ethtool_drvinfo drvinfo; + char cbuf[32]; + char *buf = NULL; + char res[10]; + int i = 0; + int bus = 0, slot = 0, func = 0; + ifindex = dev->ifindex; + + memset(res, 0, 10); + memset(&drvinfo, 0, sizeof(struct ethtool_drvinfo)); + + if (dev->ethtool_ops && dev->ethtool_ops->get_drvinfo) { + memset(&drvinfo, 0, sizeof(drvinfo)); + dev->ethtool_ops->get_drvinfo(dev, &drvinfo); + } else + continue; + if (!strcmp(drvinfo.bus_info, "N/A")) + continue; + memcpy(&cbuf, drvinfo.bus_info, 32); + buf = &cbuf[0]; + + while (*buf++ != ':') ; + for (i = 0; i < 10; i++, buf++) { + if (*buf == ':') + break; + res[i] = *buf; + + } + buf++; + bus = str_to_hex(res); + memset(res, 0, 10); + + for (i = 0; i < 10; i++, buf++) { + if (*buf == '.') + break; + res[i] = *buf; + + } + buf++; + slot = str_to_hex(res); + func = str_to_hex(buf); + idx_dev = get_dev_idx_bsf(bus, slot, func); + + if (idx_dev != -1) { + + bpctl_dev_arr[idx_dev].ifindex = ifindex; + bpctl_dev_arr[idx_dev].ndev = dev; + + } + + } + /* rtnl_unlock(); */ + /* rcu_read_unlock(); */ + +} + +static long device_ioctl(struct file *file, /* see include/linux/fs.h */ + unsigned int ioctl_num, /* number and param for ioctl */ + unsigned long ioctl_param) +{ + struct bpctl_cmd bpctl_cmd; + int dev_idx = 0; + bpctl_dev_t *pbpctl_dev_out; + void __user *argp = (void __user *)ioctl_param; + int ret = 0; + unsigned long flags; + + static bpctl_dev_t *pbpctl_dev; + + /* lock_kernel(); */ + lock_bpctl(); + /* local_irq_save(flags); */ + /* if(!spin_trylock_irqsave(&bpvm_lock)){ + local_irq_restore(flags); + unlock_bpctl(); + unlock_kernel(); + return -1; + } */ + /* spin_lock_irqsave(&bpvm_lock, flags); */ + +/* +* Switch according to the ioctl called +*/ + if (ioctl_num == IOCTL_TX_MSG(IF_SCAN)) { + if_scan_init(); + ret = SUCCESS; + goto bp_exit; + } + if (copy_from_user(&bpctl_cmd, argp, sizeof(struct bpctl_cmd))) { + + ret = -EFAULT; + goto bp_exit; + } + + if (ioctl_num == IOCTL_TX_MSG(GET_DEV_NUM)) { + bpctl_cmd.out_param[0] = device_num; + if (copy_to_user + (argp, (void *)&bpctl_cmd, sizeof(struct bpctl_cmd))) { + ret = -EFAULT; + goto bp_exit; + } + ret = SUCCESS; + goto bp_exit; + + } + /* lock_bpctl(); */ + /* preempt_disable(); */ + local_irq_save(flags); + if (!spin_trylock(&bpvm_lock)) { + local_irq_restore(flags); + unlock_bpctl(); + return -1; + } + +/* preempt_disable(); + rcu_read_lock(); + spin_lock_irqsave(&bpvm_lock, flags); +*/ + if ((bpctl_cmd.in_param[5]) || + (bpctl_cmd.in_param[6]) || (bpctl_cmd.in_param[7])) + dev_idx = get_dev_idx_bsf(bpctl_cmd.in_param[5], + bpctl_cmd.in_param[6], + bpctl_cmd.in_param[7]); + else if (bpctl_cmd.in_param[1] == 0) + dev_idx = bpctl_cmd.in_param[0]; + else + dev_idx = get_dev_idx(bpctl_cmd.in_param[1]); + + if (dev_idx < 0 || dev_idx > device_num) { + /* unlock_bpctl(); + preempt_enable(); */ + ret = -EOPNOTSUPP; + /* preempt_enable(); + rcu_read_unlock(); */ + spin_unlock_irqrestore(&bpvm_lock, flags); + goto bp_exit; + } + + bpctl_cmd.out_param[0] = bpctl_dev_arr[dev_idx].bus; + bpctl_cmd.out_param[1] = bpctl_dev_arr[dev_idx].slot; + bpctl_cmd.out_param[2] = bpctl_dev_arr[dev_idx].func; + bpctl_cmd.out_param[3] = bpctl_dev_arr[dev_idx].ifindex; + + if ((bpctl_dev_arr[dev_idx].bp_10gb) + && (!(bpctl_dev_arr[dev_idx].ifindex))) { + printk("Please load network driver for %s adapter!\n", + bpctl_dev_arr[dev_idx].name); + bpctl_cmd.status = -1; + ret = SUCCESS; + /* preempt_enable(); */ + /* rcu_read_unlock(); */ + spin_unlock_irqrestore(&bpvm_lock, flags); + goto bp_exit; + + } + if ((bpctl_dev_arr[dev_idx].bp_10gb) && (bpctl_dev_arr[dev_idx].ndev)) { + if (!(bpctl_dev_arr[dev_idx].ndev->flags & IFF_UP)) { + if (!(bpctl_dev_arr[dev_idx].ndev->flags & IFF_UP)) { + printk + ("Please bring up network interfaces for %s adapter!\n", + bpctl_dev_arr[dev_idx].name); + bpctl_cmd.status = -1; + ret = SUCCESS; + /* preempt_enable(); */ + /* rcu_read_unlock(); */ + spin_unlock_irqrestore(&bpvm_lock, flags); + goto bp_exit; + } + + } + } + + if ((dev_idx < 0) || (dev_idx > device_num) + || (bpctl_dev_arr[dev_idx].pdev == NULL)) { + bpctl_cmd.status = -1; + goto bpcmd_exit; + } + + pbpctl_dev = &bpctl_dev_arr[dev_idx]; + + switch (ioctl_num) { + case IOCTL_TX_MSG(SET_BYPASS_PWOFF): + bpctl_cmd.status = + set_bypass_pwoff_fn(pbpctl_dev, bpctl_cmd.in_param[2]); + break; + + case IOCTL_TX_MSG(GET_BYPASS_PWOFF): + bpctl_cmd.status = get_bypass_pwoff_fn(pbpctl_dev); + break; + + case IOCTL_TX_MSG(SET_BYPASS_PWUP): + bpctl_cmd.status = + set_bypass_pwup_fn(pbpctl_dev, bpctl_cmd.in_param[2]); + break; + + case IOCTL_TX_MSG(GET_BYPASS_PWUP): + bpctl_cmd.status = get_bypass_pwup_fn(pbpctl_dev); + break; + + case IOCTL_TX_MSG(SET_BYPASS_WD): + bpctl_cmd.status = + set_bypass_wd_fn(pbpctl_dev, bpctl_cmd.in_param[2]); + break; + + case IOCTL_TX_MSG(GET_BYPASS_WD): + bpctl_cmd.status = + get_bypass_wd_fn(pbpctl_dev, (int *)&(bpctl_cmd.data[0])); + break; + + case IOCTL_TX_MSG(GET_WD_EXPIRE_TIME): + bpctl_cmd.status = + get_wd_expire_time_fn(pbpctl_dev, + (int *)&(bpctl_cmd.data[0])); + break; + + case IOCTL_TX_MSG(RESET_BYPASS_WD_TIMER): + bpctl_cmd.status = reset_bypass_wd_timer_fn(pbpctl_dev); + break; + + case IOCTL_TX_MSG(GET_WD_SET_CAPS): + bpctl_cmd.status = get_wd_set_caps_fn(pbpctl_dev); + break; + + case IOCTL_TX_MSG(SET_STD_NIC): + bpctl_cmd.status = + set_std_nic_fn(pbpctl_dev, bpctl_cmd.in_param[2]); + break; + + case IOCTL_TX_MSG(GET_STD_NIC): + bpctl_cmd.status = get_std_nic_fn(pbpctl_dev); + break; + + case IOCTL_TX_MSG(SET_TAP): + bpctl_cmd.status = + set_tap_fn(pbpctl_dev, bpctl_cmd.in_param[2]); + break; + + case IOCTL_TX_MSG(GET_TAP): + bpctl_cmd.status = get_tap_fn(pbpctl_dev); + break; + + case IOCTL_TX_MSG(GET_TAP_CHANGE): + bpctl_cmd.status = get_tap_change_fn(pbpctl_dev); + break; + + case IOCTL_TX_MSG(SET_DIS_TAP): + bpctl_cmd.status = + set_dis_tap_fn(pbpctl_dev, bpctl_cmd.in_param[2]); + break; + + case IOCTL_TX_MSG(GET_DIS_TAP): + bpctl_cmd.status = get_dis_tap_fn(pbpctl_dev); + break; + + case IOCTL_TX_MSG(SET_TAP_PWUP): + bpctl_cmd.status = + set_tap_pwup_fn(pbpctl_dev, bpctl_cmd.in_param[2]); + break; + + case IOCTL_TX_MSG(GET_TAP_PWUP): + bpctl_cmd.status = get_tap_pwup_fn(pbpctl_dev); + break; + + case IOCTL_TX_MSG(SET_WD_EXP_MODE): + bpctl_cmd.status = + set_wd_exp_mode_fn(pbpctl_dev, bpctl_cmd.in_param[2]); + break; + + case IOCTL_TX_MSG(GET_WD_EXP_MODE): + bpctl_cmd.status = get_wd_exp_mode_fn(pbpctl_dev); + break; + + case IOCTL_TX_MSG(GET_DIS_BYPASS): + bpctl_cmd.status = get_dis_bypass_fn(pbpctl_dev); + break; + + case IOCTL_TX_MSG(SET_DIS_BYPASS): + bpctl_cmd.status = + set_dis_bypass_fn(pbpctl_dev, bpctl_cmd.in_param[2]); + break; + + case IOCTL_TX_MSG(GET_BYPASS_CHANGE): + bpctl_cmd.status = get_bypass_change_fn(pbpctl_dev); + break; + + case IOCTL_TX_MSG(GET_BYPASS): + bpctl_cmd.status = get_bypass_fn(pbpctl_dev); + break; + + case IOCTL_TX_MSG(SET_BYPASS): + bpctl_cmd.status = + set_bypass_fn(pbpctl_dev, bpctl_cmd.in_param[2]); + break; + + case IOCTL_TX_MSG(GET_BYPASS_CAPS): + bpctl_cmd.status = get_bypass_caps_fn(pbpctl_dev); + /*preempt_enable(); */ + /*rcu_read_unlock();*/ + spin_unlock_irqrestore(&bpvm_lock, flags); + if (copy_to_user + (argp, (void *)&bpctl_cmd, sizeof(struct bpctl_cmd))) { + /*unlock_bpctl(); */ + /*preempt_enable(); */ + ret = -EFAULT; + goto bp_exit; + } + goto bp_exit; + + case IOCTL_TX_MSG(GET_BYPASS_SLAVE): + bpctl_cmd.status = + get_bypass_slave_fn(pbpctl_dev, &pbpctl_dev_out); + if (bpctl_cmd.status == 1) { + bpctl_cmd.out_param[4] = pbpctl_dev_out->bus; + bpctl_cmd.out_param[5] = pbpctl_dev_out->slot; + bpctl_cmd.out_param[6] = pbpctl_dev_out->func; + bpctl_cmd.out_param[7] = pbpctl_dev_out->ifindex; + } + break; + + case IOCTL_TX_MSG(IS_BYPASS): + bpctl_cmd.status = is_bypass(pbpctl_dev); + break; + case IOCTL_TX_MSG(SET_TX): + bpctl_cmd.status = set_tx_fn(pbpctl_dev, bpctl_cmd.in_param[2]); + break; + case IOCTL_TX_MSG(GET_TX): + bpctl_cmd.status = get_tx_fn(pbpctl_dev); + break; + case IOCTL_TX_MSG(SET_WD_AUTORESET): + bpctl_cmd.status = + set_wd_autoreset_fn(pbpctl_dev, bpctl_cmd.in_param[2]); + + break; + case IOCTL_TX_MSG(GET_WD_AUTORESET): + + bpctl_cmd.status = get_wd_autoreset_fn(pbpctl_dev); + break; + case IOCTL_TX_MSG(SET_DISC): + bpctl_cmd.status = + set_disc_fn(pbpctl_dev, bpctl_cmd.in_param[2]); + break; + case IOCTL_TX_MSG(GET_DISC): + bpctl_cmd.status = get_disc_fn(pbpctl_dev); + break; + case IOCTL_TX_MSG(GET_DISC_CHANGE): + bpctl_cmd.status = get_disc_change_fn(pbpctl_dev); + break; + case IOCTL_TX_MSG(SET_DIS_DISC): + bpctl_cmd.status = + set_dis_disc_fn(pbpctl_dev, bpctl_cmd.in_param[2]); + break; + case IOCTL_TX_MSG(GET_DIS_DISC): + bpctl_cmd.status = get_dis_disc_fn(pbpctl_dev); + break; + case IOCTL_TX_MSG(SET_DISC_PWUP): + bpctl_cmd.status = + set_disc_pwup_fn(pbpctl_dev, bpctl_cmd.in_param[2]); + break; + case IOCTL_TX_MSG(GET_DISC_PWUP): + bpctl_cmd.status = get_disc_pwup_fn(pbpctl_dev); + break; + + case IOCTL_TX_MSG(GET_BYPASS_INFO): + + bpctl_cmd.status = + get_bypass_info_fn(pbpctl_dev, (char *)&bpctl_cmd.data, + (char *)&bpctl_cmd.out_param[4]); + break; + + case IOCTL_TX_MSG(SET_TPL): + bpctl_cmd.status = + set_tpl_fn(pbpctl_dev, bpctl_cmd.in_param[2]); + break; + + case IOCTL_TX_MSG(GET_TPL): + bpctl_cmd.status = get_tpl_fn(pbpctl_dev); + break; + case IOCTL_TX_MSG(SET_BP_WAIT_AT_PWUP): + bpctl_cmd.status = + set_bp_wait_at_pwup_fn(pbpctl_dev, bpctl_cmd.in_param[2]); + break; + + case IOCTL_TX_MSG(GET_BP_WAIT_AT_PWUP): + bpctl_cmd.status = get_bp_wait_at_pwup_fn(pbpctl_dev); + break; + case IOCTL_TX_MSG(SET_BP_HW_RESET): + bpctl_cmd.status = + set_bp_hw_reset_fn(pbpctl_dev, bpctl_cmd.in_param[2]); + break; + + case IOCTL_TX_MSG(GET_BP_HW_RESET): + bpctl_cmd.status = get_bp_hw_reset_fn(pbpctl_dev); + break; +#ifdef BP_SELF_TEST + case IOCTL_TX_MSG(SET_BP_SELF_TEST): + bpctl_cmd.status = + set_bp_self_test_fn(pbpctl_dev, bpctl_cmd.in_param[2]); + + break; + case IOCTL_TX_MSG(GET_BP_SELF_TEST): + bpctl_cmd.status = get_bp_self_test_fn(pbpctl_dev); + break; + +#endif +#if 0 + case IOCTL_TX_MSG(SET_DISC_PORT): + bpctl_cmd.status = + set_disc_port_fn(pbpctl_dev, bpctl_cmd.in_param[2]); + break; + + case IOCTL_TX_MSG(GET_DISC_PORT): + bpctl_cmd.status = get_disc_port_fn(pbpctl_dev); + break; + + case IOCTL_TX_MSG(SET_DISC_PORT_PWUP): + bpctl_cmd.status = + set_disc_port_pwup_fn(pbpctl_dev, bpctl_cmd.in_param[2]); + break; + + case IOCTL_TX_MSG(GET_DISC_PORT_PWUP): + bpctl_cmd.status = get_disc_port_pwup_fn(pbpctl_dev); + break; +#endif + case IOCTL_TX_MSG(SET_BP_FORCE_LINK): + bpctl_cmd.status = + set_bp_force_link_fn(dev_idx, bpctl_cmd.in_param[2]); + break; + + case IOCTL_TX_MSG(GET_BP_FORCE_LINK): + bpctl_cmd.status = get_bp_force_link_fn(dev_idx); + break; + + default: + /* unlock_bpctl(); */ + + ret = -EOPNOTSUPP; + /* preempt_enable(); */ + /* rcu_read_unlock();*/ + spin_unlock_irqrestore(&bpvm_lock, flags); + goto bp_exit; + } + /* unlock_bpctl(); */ + /* preempt_enable(); */ + bpcmd_exit: + /* rcu_read_unlock(); */ + spin_unlock_irqrestore(&bpvm_lock, flags); + if (copy_to_user(argp, (void *)&bpctl_cmd, sizeof(struct bpctl_cmd))) + ret = -EFAULT; + ret = SUCCESS; + bp_exit: + /* unlock_kernel(); */ + /* spin_unlock_irqrestore(&bpvm_lock, flags); */ + unlock_bpctl(); + /* unlock_kernel(); */ + return ret; +} + +struct file_operations Fops = { + .owner = THIS_MODULE, + .unlocked_ioctl = device_ioctl, + .open = device_open, + .release = device_release, /* a.k.a. close */ +}; + +#ifndef PCI_DEVICE +#define PCI_DEVICE(vend,dev) \ + .vendor = (vend), .device = (dev), \ + .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID +#endif + +#define SILICOM_E1000BP_ETHERNET_DEVICE(device_id) {\ + PCI_DEVICE(SILICOM_VID, device_id)} + +typedef enum { + PXG2BPFI, + PXG2BPFIL, + PXG2BPFILX, + PXG2BPFILLX, + PXGBPI, + PXGBPIG, + PXG2TBFI, + PXG4BPI, + PXG4BPFI, + PEG4BPI, + PEG2BPI, + PEG4BPIN, + PEG2BPFI, + PEG2BPFILX, + PMCXG2BPFI, + PMCXG2BPFIN, + PEG4BPII, + PEG4BPFII, + PXG4BPFILX, + PMCXG2BPIN, + PMCXG4BPIN, + PXG2BISC1, + PEG2TBFI, + PXG2TBI, + PXG4BPFID, + PEG4BPFI, + PEG4BPIPT, + PXG6BPI, + PEG4BPIL, + PMCXG2BPIN2, + PMCXG4BPIN2, + PMCX2BPI, + PEG2BPFID, + PEG2BPFIDLX, + PMCX4BPI, + MEG2BPFILN, + MEG2BPFINX, + PEG4BPFILX, + PE10G2BPISR, + PE10G2BPILR, + MHIO8AD, + PE10G2BPICX4, + PEG2BPI5, + PEG6BPI, + PEG4BPFI5, + PEG4BPFI5LX, + MEG2BPFILXLN, + PEG2BPIX1, + MEG2BPFILXNX, + XE10G2BPIT, + XE10G2BPICX4, + XE10G2BPISR, + XE10G2BPILR, + PEG4BPIIO, + XE10G2BPIXR, + PE10GDBISR, + PE10GDBILR, + PEG2BISC6, + PEG6BPIFC, + PE10G2BPTCX4, + PE10G2BPTSR, + PE10G2BPTLR, + PE10G2BPTT, + PEG4BPI6, + PEG4BPFI6, + PEG4BPFI6LX, + PEG4BPFI6ZX, + PEG2BPI6, + PEG2BPFI6, + PEG2BPFI6LX, + PEG2BPFI6ZX, + PEG2BPFI6FLXM, + PEG4BPI6FC, + PEG4BPFI6FC, + PEG4BPFI6FCLX, + PEG4BPFI6FCZX, + PEG6BPI6, + PEG2BPI6SC6, + MEG2BPI6, + XEG2BPI6, + MEG4BPI6, + PEG2BPFI5, + PEG2BPFI5LX, + PXEG4BPFI, + M1EG2BPI6, + M1EG2BPFI6, + M1EG2BPFI6LX, + M1EG2BPFI6ZX, + M1EG4BPI6, + M1EG4BPFI6, + M1EG4BPFI6LX, + M1EG4BPFI6ZX, + M1EG6BPI6, + M1E2G4BPi80, + M1E2G4BPFi80, + M1E2G4BPFi80LX, + M1E2G4BPFi80ZX, + PE210G2SPI9, + M1E10G2BPI9CX4, + M1E10G2BPI9SR, + M1E10G2BPI9LR, + M1E10G2BPI9T, + PE210G2BPI9CX4, + PE210G2BPI9SR, + PE210G2BPI9LR, + PE210G2BPI9T, + M2EG2BPFI6, + M2EG2BPFI6LX, + M2EG2BPFI6ZX, + M2EG4BPI6, + M2EG4BPFI6, + M2EG4BPFI6LX, + M2EG4BPFI6ZX, + M2EG6BPI6, + PEG2DBI6, + PEG2DBFI6, + PEG2DBFI6LX, + PEG2DBFI6ZX, + PE2G4BPi80, + PE2G4BPFi80, + PE2G4BPFi80LX, + PE2G4BPFi80ZX, + PE2G4BPi80L, + M6E2G8BPi80A, + + PE2G2BPi35, + PAC1200BPi35, + PE2G2BPFi35, + PE2G2BPFi35LX, + PE2G2BPFi35ZX, + PE2G4BPi35, + PE2G4BPi35L, + PE2G4BPFi35, + PE2G4BPFi35LX, + PE2G4BPFi35ZX, + + PE2G6BPi35, + PE2G6BPi35CX, + + PE2G2BPi80, + PE2G2BPFi80, + PE2G2BPFi80LX, + PE2G2BPFi80ZX, + M2E10G2BPI9CX4, + M2E10G2BPI9SR, + M2E10G2BPI9LR, + M2E10G2BPI9T, + M6E2G8BPi80, + PE210G2DBi9SR, + PE210G2DBi9SRRB, + PE210G2DBi9LR, + PE210G2DBi9LRRB, + PE310G4DBi940SR, + PE310G4BPi9T, + PE310G4BPi9SR, + PE310G4BPi9LR, + PE210G2BPi40, +} board_t; + +typedef struct _bpmod_info_t { + unsigned int vendor; + unsigned int device; + unsigned int subvendor; + unsigned int subdevice; + unsigned int index; + char *bp_name; + +} bpmod_info_t; + +typedef struct _dev_desc { + char *name; +} dev_desc_t; + +dev_desc_t dev_desc[] = { + {"Silicom Bypass PXG2BPFI-SD series adapter"}, + {"Silicom Bypass PXG2BPFIL-SD series adapter"}, + {"Silicom Bypass PXG2BPFILX-SD series adapter"}, + {"Silicom Bypass PXG2BPFILLX-SD series adapter"}, + {"Silicom Bypass PXG2BPI-SD series adapter"}, + {"Silicom Bypass PXG2BPIG-SD series adapter"}, + {"Silicom Bypass PXG2TBFI-SD series adapter"}, + {"Silicom Bypass PXG4BPI-SD series adapter"}, + {"Silicom Bypass PXG4BPFI-SD series adapter"}, + {"Silicom Bypass PEG4BPI-SD series adapter"}, + {"Silicom Bypass PEG2BPI-SD series adapter"}, + {"Silicom Bypass PEG4BPIN-SD series adapter"}, + {"Silicom Bypass PEG2BPFI-SD series adapter"}, + {"Silicom Bypass PEG2BPFI-LX-SD series adapter"}, + {"Silicom Bypass PMCX2BPFI-SD series adapter"}, + {"Silicom Bypass PMCX2BPFI-N series adapter"}, + {"Intel Bypass PEG2BPII series adapter"}, + {"Intel Bypass PEG2BPFII series adapter"}, + {"Silicom Bypass PXG4BPFILX-SD series adapter"}, + {"Silicom Bypass PMCX2BPI-N series adapter"}, + {"Silicom Bypass PMCX4BPI-N series adapter"}, + {"Silicom Bypass PXG2BISC1-SD series adapter"}, + {"Silicom Bypass PEG2TBFI-SD series adapter"}, + {"Silicom Bypass PXG2TBI-SD series adapter"}, + {"Silicom Bypass PXG4BPFID-SD series adapter"}, + {"Silicom Bypass PEG4BPFI-SD series adapter"}, + {"Silicom Bypass PEG4BPIPT-SD series adapter"}, + {"Silicom Bypass PXG6BPI-SD series adapter"}, + {"Silicom Bypass PEG4BPIL-SD series adapter"}, + {"Silicom Bypass PMCX2BPI-N2 series adapter"}, + {"Silicom Bypass PMCX4BPI-N2 series adapter"}, + {"Silicom Bypass PMCX2BPI-SD series adapter"}, + {"Silicom Bypass PEG2BPFID-SD series adapter"}, + {"Silicom Bypass PEG2BPFIDLX-SD series adapter"}, + {"Silicom Bypass PMCX4BPI-SD series adapter"}, + {"Silicom Bypass MEG2BPFILN-SD series adapter"}, + {"Silicom Bypass MEG2BPFINX-SD series adapter"}, + {"Silicom Bypass PEG4BPFILX-SD series adapter"}, + {"Silicom Bypass PE10G2BPISR-SD series adapter"}, + {"Silicom Bypass PE10G2BPILR-SD series adapter"}, + {"Silicom Bypass MHIO8AD-SD series adapter"}, + {"Silicom Bypass PE10G2BPICX4-SD series adapter"}, + {"Silicom Bypass PEG2BPI5-SD series adapter"}, + {"Silicom Bypass PEG6BPI5-SD series adapter"}, + {"Silicom Bypass PEG4BPFI5-SD series adapter"}, + {"Silicom Bypass PEG4BPFI5LX-SD series adapter"}, + {"Silicom Bypass MEG2BPFILXLN-SD series adapter"}, + {"Silicom Bypass PEG2BPIX1-SD series adapter"}, + {"Silicom Bypass MEG2BPFILXNX-SD series adapter"}, + {"Silicom Bypass XE10G2BPIT-SD series adapter"}, + {"Silicom Bypass XE10G2BPICX4-SD series adapter"}, + {"Silicom Bypass XE10G2BPISR-SD series adapter"}, + {"Silicom Bypass XE10G2BPILR-SD series adapter"}, + {"Intel Bypass PEG2BPFII0 series adapter"}, + {"Silicom Bypass XE10G2BPIXR series adapter"}, + {"Silicom Bypass PE10G2DBISR series adapter"}, + {"Silicom Bypass PEG2BI5SC6 series adapter"}, + {"Silicom Bypass PEG6BPI5FC series adapter"}, + + {"Silicom Bypass PE10G2BPTCX4 series adapter"}, + {"Silicom Bypass PE10G2BPTSR series adapter"}, + {"Silicom Bypass PE10G2BPTLR series adapter"}, + {"Silicom Bypass PE10G2BPTT series adapter"}, + {"Silicom Bypass PEG4BPI6 series adapter"}, + {"Silicom Bypass PEG4BPFI6 series adapter"}, + {"Silicom Bypass PEG4BPFI6LX series adapter"}, + {"Silicom Bypass PEG4BPFI6ZX series adapter"}, + {"Silicom Bypass PEG2BPI6 series adapter"}, + {"Silicom Bypass PEG2BPFI6 series adapter"}, + {"Silicom Bypass PEG2BPFI6LX series adapter"}, + {"Silicom Bypass PEG2BPFI6ZX series adapter"}, + {"Silicom Bypass PEG2BPFI6FLXM series adapter"}, + {"Silicom Bypass PEG4BPI6FC series adapter"}, + {"Silicom Bypass PEG4BPFI6FC series adapter"}, + {"Silicom Bypass PEG4BPFI6FCLX series adapter"}, + {"Silicom Bypass PEG4BPFI6FCZX series adapter"}, + {"Silicom Bypass PEG6BPI6 series adapter"}, + {"Silicom Bypass PEG2BPI6SC6 series adapter"}, + {"Silicom Bypass MEG2BPI6 series adapter"}, + {"Silicom Bypass XEG2BPI6 series adapter"}, + {"Silicom Bypass MEG4BPI6 series adapter"}, + {"Silicom Bypass PEG2BPFI5-SD series adapter"}, + {"Silicom Bypass PEG2BPFI5LX-SD series adapter"}, + {"Silicom Bypass PXEG4BPFI-SD series adapter"}, + {"Silicom Bypass MxEG2BPI6 series adapter"}, + {"Silicom Bypass MxEG2BPFI6 series adapter"}, + {"Silicom Bypass MxEG2BPFI6LX series adapter"}, + {"Silicom Bypass MxEG2BPFI6ZX series adapter"}, + {"Silicom Bypass MxEG4BPI6 series adapter"}, + {"Silicom Bypass MxEG4BPFI6 series adapter"}, + {"Silicom Bypass MxEG4BPFI6LX series adapter"}, + {"Silicom Bypass MxEG4BPFI6ZX series adapter"}, + {"Silicom Bypass MxEG6BPI6 series adapter"}, + {"Silicom Bypass MxE2G4BPi80 series adapter"}, + {"Silicom Bypass MxE2G4BPFi80 series adapter"}, + {"Silicom Bypass MxE2G4BPFi80LX series adapter"}, + {"Silicom Bypass MxE2G4BPFi80ZX series adapter"}, + + {"Silicom Bypass PE210G2SPI9 series adapter"}, + + {"Silicom Bypass MxE210G2BPI9CX4 series adapter"}, + {"Silicom Bypass MxE210G2BPI9SR series adapter"}, + {"Silicom Bypass MxE210G2BPI9LR series adapter"}, + {"Silicom Bypass MxE210G2BPI9T series adapter"}, + + {"Silicom Bypass PE210G2BPI9CX4 series adapter"}, + {"Silicom Bypass PE210G2BPI9SR series adapter"}, + {"Silicom Bypass PE210G2BPI9LR series adapter"}, + {"Silicom Bypass PE210G2BPI9T series adapter"}, + + {"Silicom Bypass M2EG2BPFI6 series adapter"}, + {"Silicom Bypass M2EG2BPFI6LX series adapter"}, + {"Silicom Bypass M2EG2BPFI6ZX series adapter"}, + {"Silicom Bypass M2EG4BPI6 series adapter"}, + {"Silicom Bypass M2EG4BPFI6 series adapter"}, + {"Silicom Bypass M2EG4BPFI6LX series adapter"}, + {"Silicom Bypass M2EG4BPFI6ZX series adapter"}, + {"Silicom Bypass M2EG6BPI6 series adapter"}, + + {"Silicom Bypass PEG2DBI6 series adapter"}, + {"Silicom Bypass PEG2DBFI6 series adapter"}, + {"Silicom Bypass PEG2DBFI6LX series adapter"}, + {"Silicom Bypass PEG2DBFI6ZX series adapter"}, + + {"Silicom Bypass PE2G4BPi80 series adapter"}, + {"Silicom Bypass PE2G4BPFi80 series adapter"}, + {"Silicom Bypass PE2G4BPFi80LX series adapter"}, + {"Silicom Bypass PE2G4BPFi80ZX series adapter"}, + + {"Silicom Bypass PE2G4BPi80L series adapter"}, + {"Silicom Bypass MxE2G8BPi80A series adapter"}, + + {"Silicom Bypass PE2G2BPi35 series adapter"}, + {"Silicom Bypass PAC1200BPi35 series adapter"}, + {"Silicom Bypass PE2G2BPFi35 series adapter"}, + {"Silicom Bypass PE2G2BPFi35LX series adapter"}, + {"Silicom Bypass PE2G2BPFi35ZX series adapter"}, + + {"Silicom Bypass PE2G4BPi35 series adapter"}, + {"Silicom Bypass PE2G4BPi35L series adapter"}, + {"Silicom Bypass PE2G4BPFi35 series adapter"}, + {"Silicom Bypass PE2G4BPFi35LX series adapter"}, + {"Silicom Bypass PE2G4BPFi35ZX series adapter"}, + + {"Silicom Bypass PE2G6BPi35 series adapter"}, + {"Silicom Bypass PE2G6BPi35CX series adapter"}, + + {"Silicom Bypass PE2G2BPi80 series adapter"}, + {"Silicom Bypass PE2G2BPFi80 series adapter"}, + {"Silicom Bypass PE2G2BPFi80LX series adapter"}, + {"Silicom Bypass PE2G2BPFi80ZX series adapter"}, + + {"Silicom Bypass M2E10G2BPI9CX4 series adapter"}, + {"Silicom Bypass M2E10G2BPI9SR series adapter"}, + {"Silicom Bypass M2E10G2BPI9LR series adapter"}, + {"Silicom Bypass M2E10G2BPI9T series adapter"}, + {"Silicom Bypass MxE2G8BPi80 series adapter"}, + {"Silicom Bypass PE210G2DBi9SR series adapter"}, + {"Silicom Bypass PE210G2DBi9SRRB series adapter"}, + {"Silicom Bypass PE210G2DBi9LR series adapter"}, + {"Silicom Bypass PE210G2DBi9LRRB series adapter"}, + {"Silicom Bypass PE310G4DBi9-SR series adapter"}, + {"Silicom Bypass PE310G4BPi9T series adapter"}, + {"Silicom Bypass PE310G4BPi9SR series adapter"}, + {"Silicom Bypass PE310G4BPi9LR series adapter"}, + {"Silicom Bypass PE210G2BPi40T series adapter"}, + {0}, +}; + +static bpmod_info_t tx_ctl_pci_tbl[] = { + {0x8086, 0x107a, SILICOM_SVID, SILICOM_PXG2BPFI_SSID, PXG2BPFI, + "PXG2BPFI-SD"}, + {0x8086, 0x107a, SILICOM_SVID, SILICOM_PXG2BPFIL_SSID, PXG2BPFIL, + "PXG2BPFIL-SD"}, + {0x8086, 0x107a, SILICOM_SVID, SILICOM_PXG2BPFILX_SSID, PXG2BPFILX, + "PXG2BPFILX-SD"}, + {0x8086, 0x107a, SILICOM_SVID, SILICOM_PXG2BPFILLX_SSID, PXG2BPFILLX, + "PXG2BPFILLXSD"}, + {0x8086, 0x1010, SILICOM_SVID, SILICOM_PXGBPI_SSID, PXGBPI, + "PXG2BPI-SD"}, + {0x8086, 0x1079, SILICOM_SVID, SILICOM_PXGBPIG_SSID, PXGBPIG, + "PXG2BPIG-SD"}, + {0x8086, 0x107a, SILICOM_SVID, SILICOM_PXG2TBFI_SSID, PXG2TBFI, + "PXG2TBFI-SD"}, + {0x8086, 0x1079, SILICOM_SVID, SILICOM_PXG4BPI_SSID, PXG4BPI, + "PXG4BPI-SD"}, + {0x8086, 0x107a, SILICOM_SVID, SILICOM_PXG4BPFI_SSID, PXG4BPFI, + "PXG4BPFI-SD"}, + {0x8086, 0x107a, SILICOM_SVID, SILICOM_PXG4BPFILX_SSID, PXG4BPFILX, + "PXG4BPFILX-SD"}, + {0x8086, 0x1079, SILICOM_SVID, SILICOM_PEG4BPI_SSID, PEG4BPI, + "PEXG4BPI-SD"}, + {0x8086, 0x105e, SILICOM_SVID, SILICOM_PEG2BPI_SSID, PEG2BPI, + "PEG2BPI-SD"}, + {0x8086, 0x105e, SILICOM_SVID, SILICOM_PEG4BPIN_SSID, PEG4BPIN, + "PEG4BPI-SD"}, + {0x8086, 0x105f, SILICOM_SVID, SILICOM_PEG2BPFI_SSID, PEG2BPFI, + "PEG2BPFI-SD"}, + {0x8086, 0x105f, SILICOM_SVID, SILICOM_PEG2BPFILX_SSID, PEG2BPFILX, + "PEG2BPFILX-SD"}, + {0x8086, 0x107a, SILICOM_SVID, SILICOM_PMCXG2BPFI_SSID, PMCXG2BPFI, + "PMCX2BPFI-SD"}, + {0x8086, 0x107a, NOKIA_PMCXG2BPFIN_SVID, NOKIA_PMCXG2BPFIN_SSID, + PMCXG2BPFIN, "PMCX2BPFI-N"}, + {0x8086, INTEL_PEG4BPII_PID, 0x8086, INTEL_PEG4BPII_SSID, PEG4BPII, + "PEG4BPII"}, + {0x8086, INTEL_PEG4BPIIO_PID, 0x8086, INTEL_PEG4BPIIO_SSID, PEG4BPIIO, + "PEG4BPII0"}, + {0x8086, INTEL_PEG4BPFII_PID, 0x8086, INTEL_PEG4BPFII_SSID, PEG4BPFII, + "PEG4BPFII"}, + {0x8086, 0x1079, NOKIA_PMCXG2BPFIN_SVID, NOKIA_PMCXG2BPIN_SSID, + PMCXG2BPIN, "PMCX2BPI-N"}, + {0x8086, 0x1079, NOKIA_PMCXG2BPFIN_SVID, NOKIA_PMCXG4BPIN_SSID, + PMCXG4BPIN, "PMCX4BPI-N"}, + {0x8086, 0x1079, SILICOM_SVID, SILICOM_PXG2BISC1_SSID, PXG2BISC1, + "PXG2BISC1-SD"}, + {0x8086, 0x105f, SILICOM_SVID, SILICOM_PEG2TBFI_SSID, PEG2TBFI, + "PEG2TBFI-SD"}, + {0x8086, 0x1079, SILICOM_SVID, SILICOM_PXG2TBI_SSID, PXG2TBI, + "PXG2TBI-SD"}, + {0x8086, 0x107a, SILICOM_SVID, SILICOM_PXG4BPFID_SSID, PXG4BPFID, + "PXG4BPFID-SD"}, + {0x8086, 0x105f, SILICOM_SVID, SILICOM_PEG4BPFI_SSID, PEG4BPFI, + "PEG4BPFI-SD"}, + {0x8086, 0x105e, SILICOM_SVID, SILICOM_PEG4BPIPT_SSID, PEG4BPIPT, + "PEG4BPIPT-SD"}, + {0x8086, 0x1079, SILICOM_SVID, SILICOM_PXG6BPI_SSID, PXG6BPI, + "PXG6BPI-SD"}, + {0x8086, 0x10a7, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PEG4BPIL_SSID /*PCI_ANY_ID */ , PEG4BPIL, "PEG4BPIL-SD"}, + {0x8086, 0x1079, NOKIA_PMCXG2BPFIN_SVID, NOKIA_PMCXG2BPIN2_SSID, + PMCXG2BPIN2, "PMCX2BPI-N2"}, + {0x8086, 0x1079, NOKIA_PMCXG2BPFIN_SVID, NOKIA_PMCXG4BPIN2_SSID, + PMCXG4BPIN2, "PMCX4BPI-N2"}, + {0x8086, 0x1079, SILICOM_SVID, SILICOM_PMCX2BPI_SSID, PMCX2BPI, + "PMCX2BPI-SD"}, + {0x8086, 0x1079, SILICOM_SVID, SILICOM_PMCX4BPI_SSID, PMCX4BPI, + "PMCX4BPI-SD"}, + {0x8086, 0x105f, SILICOM_SVID, SILICOM_PEG2BPFID_SSID, PEG2BPFID, + "PEG2BPFID-SD"}, + {0x8086, 0x105f, SILICOM_SVID, SILICOM_PEG2BPFIDLX_SSID, PEG2BPFIDLX, + "PEG2BPFIDLXSD"}, + {0x8086, 0x105f, SILICOM_SVID, SILICOM_MEG2BPFILN_SSID, MEG2BPFILN, + "MEG2BPFILN-SD"}, + {0x8086, 0x105f, SILICOM_SVID, SILICOM_MEG2BPFINX_SSID, MEG2BPFINX, + "MEG2BPFINX-SD"}, + {0x8086, 0x105f, SILICOM_SVID, SILICOM_PEG4BPFILX_SSID, PEG4BPFILX, + "PEG4BPFILX-SD"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID, SILICOM_PE10G2BPISR_SSID, + PE10G2BPISR, "PE10G2BPISR"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID, SILICOM_PE10G2BPILR_SSID, + PE10G2BPILR, "PE10G2BPILR"}, + {0x8086, 0x10a9, SILICOM_SVID, SILICOM_MHIO8AD_SSID, MHIO8AD, + "MHIO8AD-SD"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID, SILICOM_PE10G2BPICX4_SSID, + PE10G2BPISR, "PE10G2BPICX4"}, + {0x8086, 0x10a7, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PEG2BPI5_SSID /*PCI_ANY_ID */ , PEG2BPI5, "PEG2BPI5-SD"}, + {0x8086, 0x10a7, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PEG6BPI_SSID /*PCI_ANY_ID */ , PEG6BPI, "PEG6BPI5"}, + {0x8086, 0x10a9, SILICOM_SVID /*PCI_ANY_ID */ , SILICOM_PEG4BPFI5_SSID, + PEG4BPFI5, "PEG4BPFI5"}, + {0x8086, 0x10a9, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PEG4BPFI5LX_SSID, PEG4BPFI5LX, "PEG4BPFI5LX"}, + {0x8086, 0x105f, SILICOM_SVID, SILICOM_MEG2BPFILXLN_SSID, MEG2BPFILXLN, + "MEG2BPFILXLN"}, + {0x8086, 0x105e, SILICOM_SVID, SILICOM_PEG2BPIX1_SSID, PEG2BPIX1, + "PEG2BPIX1-SD"}, + {0x8086, 0x105f, SILICOM_SVID, SILICOM_MEG2BPFILXNX_SSID, MEG2BPFILXNX, + "MEG2BPFILXNX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID, SILICOM_XE10G2BPIT_SSID, XE10G2BPIT, + "XE10G2BPIT"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID, SILICOM_XE10G2BPICX4_SSID, + XE10G2BPICX4, "XE10G2BPICX4"}, + {0x8086, 0x10C6, SILICOM_SVID, SILICOM_XE10G2BPISR_SSID, XE10G2BPISR, + "XE10G2BPISR"}, + {0x8086, 0x10C6, SILICOM_SVID, SILICOM_XE10G2BPILR_SSID, XE10G2BPILR, + "XE10G2BPILR"}, + {0x8086, 0x10C6, NOKIA_XE10G2BPIXR_SVID, NOKIA_XE10G2BPIXR_SSID, + XE10G2BPIXR, "XE10G2BPIXR"}, + {0x8086, 0x10C6, SILICOM_SVID, SILICOM_PE10GDBISR_SSID, PE10GDBISR, + "PE10G2DBISR"}, + {0x8086, 0x10C6, SILICOM_SVID, SILICOM_PE10GDBILR_SSID, PE10GDBILR, + "PE10G2DBILR"}, + {0x8086, 0x10a7, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PEG2BISC6_SSID /*PCI_ANY_ID */ , PEG2BISC6, "PEG2BI5SC6"}, + {0x8086, 0x10a7, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PEG6BPIFC_SSID /*PCI_ANY_ID */ , PEG6BPIFC, "PEG6BPI5FC"}, + + {BROADCOM_VID, BROADCOM_PE10G2_PID, SILICOM_SVID, + SILICOM_PE10G2BPTCX4_SSID, PE10G2BPTCX4, "PE10G2BPTCX4"}, + {BROADCOM_VID, BROADCOM_PE10G2_PID, SILICOM_SVID, + SILICOM_PE10G2BPTSR_SSID, PE10G2BPTSR, "PE10G2BPTSR"}, + {BROADCOM_VID, BROADCOM_PE10G2_PID, SILICOM_SVID, + SILICOM_PE10G2BPTLR_SSID, PE10G2BPTLR, "PE10G2BPTLR"}, + {BROADCOM_VID, BROADCOM_PE10G2_PID, SILICOM_SVID, + SILICOM_PE10G2BPTT_SSID, PE10G2BPTT, "PE10G2BPTT"}, + + /* {BROADCOM_VID, BROADCOM_PE10G2_PID, PCI_ANY_ID, PCI_ANY_ID, PE10G2BPTCX4, "PE10G2BPTCX4"}, */ + + {0x8086, 0x10c9, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PEG4BPI6_SSID /*PCI_ANY_ID */ , PEG4BPI6, "PEG4BPI6"}, + {0x8086, 0x10e6, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PEG4BPFI6_SSID /*PCI_ANY_ID */ , PEG4BPFI6, "PEG4BPFI6"}, + {0x8086, 0x10e6, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PEG4BPFI6LX_SSID /*PCI_ANY_ID */ , PEG4BPFI6LX, "PEG4BPFI6LX"}, + {0x8086, 0x10e6, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PEG4BPFI6ZX_SSID /*PCI_ANY_ID */ , PEG4BPFI6ZX, "PEG4BPFI6ZX"}, + {0x8086, 0x10c9, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PEG2BPI6_SSID /*PCI_ANY_ID */ , PEG2BPI6, "PEG2BPI6"}, + {0x8086, 0x10e6, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PEG2BPFI6_SSID /*PCI_ANY_ID */ , PEG2BPFI6, "PEG2BPFI6"}, + {0x8086, 0x10e6, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PEG2BPFI6LX_SSID /*PCI_ANY_ID */ , PEG2BPFI6LX, "PEG2BPFI6LX"}, + {0x8086, 0x10e6, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PEG2BPFI6ZX_SSID /*PCI_ANY_ID */ , PEG2BPFI6ZX, "PEG2BPFI6ZX"}, + {0x8086, 0x10e7, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PEG2BPFI6FLXM_SSID /*PCI_ANY_ID */ , PEG2BPFI6FLXM, + "PEG2BPFI6FLXM"}, + {0x8086, 0x10c9, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PEG4BPI6FC_SSID /*PCI_ANY_ID */ , PEG4BPI6FC, "PEG4BPI6FC"}, + {0x8086, 0x10e6, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PEG4BPFI6FC_SSID /*PCI_ANY_ID */ , PEG4BPFI6FC, "PEG4BPFI6FC"}, + {0x8086, 0x10e6, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PEG4BPFI6FCLX_SSID /*PCI_ANY_ID */ , PEG4BPFI6FCLX, + "PEG4BPFI6FCLX"}, + {0x8086, 0x10e6, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PEG4BPFI6FCZX_SSID /*PCI_ANY_ID */ , PEG4BPFI6FCZX, + "PEG4BPFI6FCZX"}, + {0x8086, 0x10c9, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PEG6BPI6_SSID /*PCI_ANY_ID */ , PEG6BPI6, "PEG6BPI6"}, + {0x8086, 0x10c9, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PEG2BPI6SC6_SSID /*PCI_ANY_ID */ , PEG2BPI6SC6, + "PEG6BPI62SC6"}, + {0x8086, 0x10c9, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_MEG2BPI6_SSID /*PCI_ANY_ID */ , MEG2BPI6, "MEG2BPI6"}, + {0x8086, 0x10c9, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_XEG2BPI6_SSID /*PCI_ANY_ID */ , XEG2BPI6, "XEG2BPI6"}, + {0x8086, 0x10c9, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_MEG4BPI6_SSID /*PCI_ANY_ID */ , MEG4BPI6, "MEG4BPI6"}, + + {0x8086, 0x10a9, SILICOM_SVID /*PCI_ANY_ID */ , SILICOM_PEG2BPFI5_SSID, + PEG2BPFI5, "PEG2BPFI5"}, + {0x8086, 0x10a9, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PEG2BPFI5LX_SSID, PEG2BPFI5LX, "PEG2BPFI5LX"}, + + {0x8086, 0x105f, SILICOM_SVID, SILICOM_PXEG4BPFI_SSID, PXEG4BPFI, + "PXEG4BPFI-SD"}, + + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_M1EG2BPI6_SSID /*PCI_ANY_ID */ , M1EG2BPI6, "MxEG2BPI6"}, + + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_M1EG2BPFI6_SSID /*PCI_ANY_ID */ , M1EG2BPFI6, "MxEG2BPFI6"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_M1EG2BPFI6LX_SSID /*PCI_ANY_ID */ , M1EG2BPFI6LX, + "MxEG2BPFI6LX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_M1EG2BPFI6ZX_SSID /*PCI_ANY_ID */ , M1EG2BPFI6ZX, + "MxEG2BPFI6ZX"}, + + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_M1EG4BPI6_SSID /*PCI_ANY_ID */ , M1EG4BPI6, "MxEG4BPI6"}, + + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_M1EG4BPFI6_SSID /*PCI_ANY_ID */ , M1EG4BPFI6, "MxEG4BPFI6"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_M1EG4BPFI6LX_SSID /*PCI_ANY_ID */ , M1EG4BPFI6LX, + "MxEG4BPFI6LX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_M1EG4BPFI6ZX_SSID /*PCI_ANY_ID */ , M1EG4BPFI6ZX, + "MxEG4BPFI6ZX"}, + + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_M1EG6BPI6_SSID /*PCI_ANY_ID */ , M1EG6BPI6, "MxEG6BPI6"}, + + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_M1E2G4BPi80_SSID /*PCI_ANY_ID */ , M1E2G4BPi80, "MxE2G4BPi80"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_M1E2G4BPFi80_SSID /*PCI_ANY_ID */ , M1E2G4BPFi80, + "MxE2G4BPFi80"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_M1E2G4BPFi80LX_SSID /*PCI_ANY_ID */ , M1E2G4BPFi80LX, + "MxE2G4BPFi80LX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_M1E2G4BPFi80ZX_SSID /*PCI_ANY_ID */ , M1E2G4BPFi80ZX, + "MxE2G4BPFi80ZX"}, + + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_M2EG2BPFI6_SSID /*PCI_ANY_ID */ , M2EG2BPFI6, "M2EG2BPFI6"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_M2EG2BPFI6LX_SSID /*PCI_ANY_ID */ , M2EG2BPFI6LX, + "M2EG2BPFI6LX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_M2EG2BPFI6ZX_SSID /*PCI_ANY_ID */ , M2EG2BPFI6ZX, + "M2EG2BPFI6ZX"}, + + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_M2EG4BPI6_SSID /*PCI_ANY_ID */ , M2EG4BPI6, "M2EG4BPI6"}, + + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_M2EG4BPFI6_SSID /*PCI_ANY_ID */ , M2EG4BPFI6, "M2EG4BPFI6"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_M2EG4BPFI6LX_SSID /*PCI_ANY_ID */ , M2EG4BPFI6LX, + "M2EG4BPFI6LX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_M2EG4BPFI6ZX_SSID /*PCI_ANY_ID */ , M2EG4BPFI6ZX, + "M2EG4BPFI6ZX"}, + + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_M2EG6BPI6_SSID /*PCI_ANY_ID */ , M2EG6BPI6, "M2EG6BPI6"}, + + {0x8086, 0x10c9, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PEG2DBI6_SSID /*PCI_ANY_ID */ , PEG2DBI6, "PEG2DBI6"}, + {0x8086, 0x10e6, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PEG2DBFI6_SSID /*PCI_ANY_ID */ , PEG2DBFI6, "PEG2DBFI6"}, + {0x8086, 0x10e6, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PEG2DBFI6LX_SSID /*PCI_ANY_ID */ , PEG2DBFI6LX, "PEG2DBFI6LX"}, + {0x8086, 0x10e6, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PEG2DBFI6ZX_SSID /*PCI_ANY_ID */ , PEG2DBFI6ZX, "PEG2DBFI6ZX"}, + + {0x8086, 0x10F9, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PE210G2DBi9SR_SSID, PE210G2DBi9SR, "PE210G2DBi9SR"}, + {0x8086, 0x10F9, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PE210G2DBi9LR_SSID, PE210G2DBi9LR, "PE210G2DBi9LR"}, + {0x8086, 0x10F9, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PE310G4DBi940SR_SSID, PE310G4DBi940SR, "PE310G4DBi9SR"}, + + {0x8086, 0x10Fb, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PE310G4BPi9T_SSID, PE310G4BPi9T, "PE310G4BPi9T"}, + {0x8086, 0x10Fb, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PE310G4BPi9SR_SSID, PE310G4BPi9SR, "PE310G4BPi9SR"}, + {0x8086, 0x10Fb, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PE310G4BPi9LR_SSID, PE310G4BPi9LR, "PE310G4BPi9LR"}, + + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PE2G4BPi80_SSID /*PCI_ANY_ID */ , PE2G4BPi80, "PE2G4BPi80"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PE2G4BPFi80_SSID /*PCI_ANY_ID */ , PE2G4BPFi80, "PE2G4BPFi80"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PE2G4BPFi80LX_SSID /*PCI_ANY_ID */ , PE2G4BPFi80LX, + "PE2G4BPFi80LX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PE2G4BPFi80ZX_SSID /*PCI_ANY_ID */ , PE2G4BPFi80ZX, + "PE2G4BPFi80ZX"}, + + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PE2G4BPi80L_SSID /*PCI_ANY_ID */ , PE2G4BPi80L, "PE2G4BPi80L"}, + + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_M6E2G8BPi80A_SSID /*PCI_ANY_ID */ , M6E2G8BPi80A, + "MxE2G8BPi80A"}, + + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PE2G2BPi35_SSID /*PCI_ANY_ID */ , PE2G2BPi35, "PE2G2BPi35"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PAC1200BPi35_SSID /*PCI_ANY_ID */ , PAC1200BPi35, + "PAC1200BPi35"}, + + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PE2G2BPFi35_SSID /*PCI_ANY_ID */ , PE2G2BPFi35, "PE2G2BPFi35"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PE2G2BPFi35LX_SSID /*PCI_ANY_ID */ , PE2G2BPFi35LX, + "PE2G2BPFi35LX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PE2G2BPFi35ZX_SSID /*PCI_ANY_ID */ , PE2G2BPFi35ZX, + "PE2G2BPFi35ZX"}, + + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PE2G4BPi35_SSID /*PCI_ANY_ID */ , PE2G4BPi35, "PE2G4BPi35"}, + + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PE2G4BPi35L_SSID /*PCI_ANY_ID */ , PE2G4BPi35L, "PE2G4BPi35L"}, + + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PE2G4BPFi35_SSID /*PCI_ANY_ID */ , PE2G4BPFi35, "PE2G4BPFi35"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PE2G4BPFi35LX_SSID /*PCI_ANY_ID */ , PE2G4BPFi35LX, + "PE2G4BPFi35LX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PE2G4BPFi35ZX_SSID /*PCI_ANY_ID */ , PE2G4BPFi35ZX, + "PE2G4BPFi35ZX"}, + + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PE2G6BPi35_SSID /*PCI_ANY_ID */ , PE2G6BPi35, "PE2G6BPi35"}, + + + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xaa0, PE2G6BPi35CX, + "PE2G6BPi35CX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xaa1, PE2G6BPi35CX, + "PE2G6BPi35CX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xaa2, PE2G6BPi35CX, + "PE2G6BPi35CX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xaa3, PE2G6BPi35CX, + "PE2G6BPi35CX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xaa4, PE2G6BPi35CX, + "PE2G6BPi35CX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xaa5, PE2G6BPi35CX, + "PE2G6BPi35CX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xaa6, PE2G6BPi35CX, + "PE2G6BPi35CX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xaa7, PE2G6BPi35CX, + "PE2G6BPi35CX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xaa8, PE2G6BPi35CX, + "PE2G6BPi35CX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xaa9, PE2G6BPi35CX, + "PE2G6BPi35CX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xaaa, PE2G6BPi35CX, + "PE2G6BPi35CX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xaab, PE2G6BPi35CX, + "PE2G6BPi35CX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xaac, PE2G6BPi35CX, + "PE2G6BPi35CX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xaad, PE2G6BPi35CX, + "PE2G6BPi35CX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xaae, PE2G6BPi35CX, + "PE2G6BPi35CX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xaaf, PE2G6BPi35CX, + "PE2G6BPi35CX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xab0, PE2G6BPi35CX, + "PE2G6BPi35CX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xab1, PE2G6BPi35CX, + "PE2G6BPi35CX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xab2, PE2G6BPi35CX, + "PE2G6BPi35CX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xab3, PE2G6BPi35CX, + "PE2G6BPi35CX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xab4, PE2G6BPi35CX, + "PE2G6BPi35CX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xab5, PE2G6BPi35CX, + "PE2G6BPi35CX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xab6, PE2G6BPi35CX, + "PE2G6BPi35CX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xab7, PE2G6BPi35CX, + "PE2G6BPi35CX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xab8, PE2G6BPi35CX, + "PE2G6BPi35CX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xab9, PE2G6BPi35CX, + "PE2G6BPi35CX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xaba, PE2G6BPi35CX, + "PE2G6BPi35CX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xabb, PE2G6BPi35CX, + "PE2G6BPi35CX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xabc, PE2G6BPi35CX, + "PE2G6BPi35CX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xabd, PE2G6BPi35CX, + "PE2G6BPi35CX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xabe, PE2G6BPi35CX, + "PE2G6BPi35CX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , 0xabf, PE2G6BPi35CX, + "PE2G6BPi35CX"}, + + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PE2G2BPi80_SSID /*PCI_ANY_ID */ , PE2G2BPi80, "PE2G2BPi80"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PE2G2BPFi80_SSID /*PCI_ANY_ID */ , PE2G2BPFi80, "PE2G2BPFi80"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PE2G2BPFi80LX_SSID /*PCI_ANY_ID */ , PE2G2BPFi80LX, + "PE2G2BPFi80LX"}, + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PE2G2BPFi80ZX_SSID /*PCI_ANY_ID */ , PE2G2BPFi80ZX, + "PE2G2BPFi80ZX"}, + + {0x8086, 0x10c9, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_MEG2BPI6_SSID /*PCI_ANY_ID */ , MEG2BPI6, "MEG2BPI6"}, + {0x8086, 0x10c9, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_XEG2BPI6_SSID /*PCI_ANY_ID */ , XEG2BPI6, "XEG2BPI6"}, + +#if 0 + {0x8086, 0x10fb, 0x8086, INTEL_PE210G2SPI9_SSID, PE210G2SPI9, + "PE210G2SPI9"}, +#endif + {0x8086, 0x10fb, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_M1E10G2BPI9CX4_SSID /*PCI_ANY_ID */ , M1E10G2BPI9CX4, + "MxE210G2BPI9CX4"}, + {0x8086, 0x10fb, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_M1E10G2BPI9SR_SSID /*PCI_ANY_ID */ , M1E10G2BPI9SR, + "MxE210G2BPI9SR"}, + {0x8086, 0x10fb, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_M1E10G2BPI9LR_SSID /*PCI_ANY_ID */ , M1E10G2BPI9LR, + "MxE210G2BPI9LR"}, + {0x8086, 0x10fb, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_M1E10G2BPI9T_SSID /*PCI_ANY_ID */ , M1E10G2BPI9T, + "MxE210G2BPI9T"}, + + {0x8086, 0x10fb, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_M2E10G2BPI9CX4_SSID /*PCI_ANY_ID */ , M2E10G2BPI9CX4, + "M2E10G2BPI9CX4"}, + {0x8086, 0x10fb, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_M2E10G2BPI9SR_SSID /*PCI_ANY_ID */ , M2E10G2BPI9SR, + "M2E10G2BPI9SR"}, + {0x8086, 0x10fb, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_M2E10G2BPI9LR_SSID /*PCI_ANY_ID */ , M2E10G2BPI9LR, + "M2E10G2BPI9LR"}, + {0x8086, 0x10fb, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_M2E10G2BPI9T_SSID /*PCI_ANY_ID */ , M2E10G2BPI9T, + "M2E10G2BPI9T"}, + + {0x8086, 0x10fb, SILICOM_SVID, SILICOM_PE210G2BPI9CX4_SSID, + PE210G2BPI9CX4, "PE210G2BPI9CX4"}, + {0x8086, 0x10fb, SILICOM_SVID, SILICOM_PE210G2BPI9SR_SSID, + PE210G2BPI9SR, "PE210G2BPI9SR"}, + {0x8086, 0x10fb, SILICOM_SVID, SILICOM_PE210G2BPI9LR_SSID, + PE210G2BPI9LR, "PE210G2BPI9LR"}, + {0x8086, 0x10fb, SILICOM_SVID, SILICOM_PE210G2BPI9T_SSID, PE210G2BPI9T, + "PE210G2BPI9T"}, + +#if 0 + {0x1374, 0x2c, SILICOM_SVID, SILICOM_PXG4BPI_SSID, PXG4BPI, + "PXG4BPI-SD"}, + + {0x1374, 0x2d, SILICOM_SVID, SILICOM_PXG4BPFI_SSID, PXG4BPFI, + "PXG4BPFI-SD"}, + + {0x1374, 0x3f, SILICOM_SVID, SILICOM_PXG2TBI_SSID, PXG2TBI, + "PXG2TBI-SD"}, + + {0x1374, 0x3d, SILICOM_SVID, SILICOM_PXG2BISC1_SSID, PXG2BISC1, + "PXG2BISC1-SD"}, + + {0x1374, 0x40, SILICOM_SVID, SILICOM_PEG4BPFI_SSID, PEG4BPFI, + "PEG4BPFI-SD"}, + +#ifdef BP_SELF_TEST + {0x1374, 0x28, SILICOM_SVID, 0x28, PXGBPI, "PXG2BPI-SD"}, +#endif +#endif + {0x8086, PCI_ANY_ID, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_M6E2G8BPi80_SSID /*PCI_ANY_ID */ , M6E2G8BPi80, "MxE2G8BPi80"}, + {0x8086, 0x1528, SILICOM_SVID /*PCI_ANY_ID */ , + SILICOM_PE210G2BPi40_SSID /*PCI_ANY_ID */ , PE210G2BPi40, + "PE210G2BPi40T"}, + + /* required last entry */ + {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 +*/ + +static int __init bypass_init_module(void) +{ + int ret_val, idx, idx_dev = 0; + struct pci_dev *pdev1 = NULL; + bpctl_dev_t *dev; + + printk(BP_MOD_DESCR " v" BP_MOD_VER "\n"); + ret_val = register_chrdev(major_num, DEVICE_NAME, &Fops); + if (ret_val < 0) { + printk("%s failed with %d\n", DEVICE_NAME, ret_val); + return ret_val; + } + major_num = ret_val; /* dynamic */ + 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))) { + + device_num++; + } + } + if (!device_num) { + printk("No such device\n"); + unregister_chrdev(major_num, DEVICE_NAME); + return -1; + } + + bpctl_dev_arr = kmalloc((device_num) * sizeof(bpctl_dev_t), GFP_KERNEL); + + if (!bpctl_dev_arr) { + printk("Allocation error\n"); + unregister_chrdev(major_num, DEVICE_NAME); + return -1; + } + 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))) { + if (init_one(dev, &tx_ctl_pci_tbl[idx], pdev1) < 0) + return -1; + dev++; + } + } + if_scan_init(); + + sema_init(&bpctl_sema, 1); + spin_lock_init(&bpvm_lock); + { + + bpctl_dev_t *pbpctl_dev_c = NULL; + 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, ", + dev->name); + dev->bp_fw_ver = bypass_fw_ver(dev); + printk("firmware version: 0x%x\n", + dev->bp_fw_ver); + } + 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); + + } + + } + } + + register_netdevice_notifier(&bp_notifier_block); +#ifdef BP_PROC_SUPPORT + { + int i = 0; + /* unsigned long flags; */ + /* rcu_read_lock(); */ + bp_proc_create(); + for (i = 0; i < device_num; i++) { + if (bpctl_dev_arr[i].ifindex) { + /* spin_lock_irqsave(&bpvm_lock, flags); */ + bypass_proc_remove_dev_sd(&bpctl_dev_arr[i]); + bypass_proc_create_dev_sd(&bpctl_dev_arr[i]); + /* spin_unlock_irqrestore(&bpvm_lock, flags); */ + } + + } + /* rcu_read_unlock(); */ + } +#endif + + return 0; +} + +/* +* Cleanup - unregister the appropriate file from /proc +*/ +static void __exit bypass_cleanup_module(void) +{ + int i; + unregister_netdevice_notifier(&bp_notifier_block); + + for (i = 0; i < device_num; i++) { + /* unsigned long flags; */ +#ifdef BP_PROC_SUPPORT +/* spin_lock_irqsave(&bpvm_lock, flags); + rcu_read_lock(); */ + bypass_proc_remove_dev_sd(&bpctl_dev_arr[i]); +/* spin_unlock_irqrestore(&bpvm_lock, flags); + rcu_read_unlock(); */ +#endif + remove_bypass_wd_auto(&bpctl_dev_arr[i]); + bpctl_dev_arr[i].reset_time = 0; + + remove_bypass_tpl_auto(&bpctl_dev_arr[i]); + } + + /* unmap all devices */ + for (i = 0; i < device_num; i++) { +#ifdef BP_SELF_TEST + if (bpctl_dev_arr[i].bp_tx_data) + kfree(bpctl_dev_arr[i].bp_tx_data); +#endif + iounmap((void *)(bpctl_dev_arr[i].mem_map)); + } + + /* free all devices space */ + if (bpctl_dev_arr) + kfree(bpctl_dev_arr); + +/* +* Unregister the device +*/ + unregister_chrdev(major_num, DEVICE_NAME); +} + +module_init(bypass_init_module); +module_exit(bypass_cleanup_module); + +int is_bypass_sd(int ifindex) +{ + return is_bypass(get_dev_idx_p(ifindex)); +} + +int set_bypass_sd(int ifindex, int bypass_mode) +{ + + return set_bypass_fn(get_dev_idx_p(ifindex), bypass_mode); +} + +int get_bypass_sd(int ifindex) +{ + + return get_bypass_fn(get_dev_idx_p(ifindex)); +} + +int get_bypass_change_sd(int ifindex) +{ + + return get_bypass_change_fn(get_dev_idx_p(ifindex)); +} + +int set_dis_bypass_sd(int ifindex, int dis_param) +{ + return set_dis_bypass_fn(get_dev_idx_p(ifindex), dis_param); +} + +int get_dis_bypass_sd(int ifindex) +{ + + return get_dis_bypass_fn(get_dev_idx_p(ifindex)); +} + +int set_bypass_pwoff_sd(int ifindex, int bypass_mode) +{ + return set_bypass_pwoff_fn(get_dev_idx_p(ifindex), bypass_mode); + +} + +int get_bypass_pwoff_sd(int ifindex) +{ + return get_bypass_pwoff_fn(get_dev_idx_p(ifindex)); + +} + +int set_bypass_pwup_sd(int ifindex, int bypass_mode) +{ + return set_bypass_pwup_fn(get_dev_idx_p(ifindex), bypass_mode); + +} + +int get_bypass_pwup_sd(int ifindex) +{ + return get_bypass_pwup_fn(get_dev_idx_p(ifindex)); + +} + +int set_bypass_wd_sd(int if_index, int ms_timeout, int *ms_timeout_set) +{ + if ((is_bypass(get_dev_idx_p(if_index))) <= 0) + return BP_NOT_CAP; + *ms_timeout_set = set_bypass_wd_fn(get_dev_idx_p(if_index), ms_timeout); + return 0; +} + +int get_bypass_wd_sd(int ifindex, int *timeout) +{ + return get_bypass_wd_fn(get_dev_idx_p(ifindex), timeout); + +} + +int get_wd_expire_time_sd(int ifindex, int *time_left) +{ + return get_wd_expire_time_fn(get_dev_idx_p(ifindex), time_left); +} + +int reset_bypass_wd_timer_sd(int ifindex) +{ + return reset_bypass_wd_timer_fn(get_dev_idx_p(ifindex)); + +} + +int get_wd_set_caps_sd(int ifindex) +{ + return get_wd_set_caps_fn(get_dev_idx_p(ifindex)); + +} + +int set_std_nic_sd(int ifindex, int nic_mode) +{ + return set_std_nic_fn(get_dev_idx_p(ifindex), nic_mode); + +} + +int get_std_nic_sd(int ifindex) +{ + return get_std_nic_fn(get_dev_idx_p(ifindex)); + +} + +int set_tap_sd(int ifindex, int tap_mode) +{ + return set_tap_fn(get_dev_idx_p(ifindex), tap_mode); + +} + +int get_tap_sd(int ifindex) +{ + return get_tap_fn(get_dev_idx_p(ifindex)); + +} + +int set_tap_pwup_sd(int ifindex, int tap_mode) +{ + return set_tap_pwup_fn(get_dev_idx_p(ifindex), tap_mode); + +} + +int get_tap_pwup_sd(int ifindex) +{ + return get_tap_pwup_fn(get_dev_idx_p(ifindex)); + +} + +int get_tap_change_sd(int ifindex) +{ + return get_tap_change_fn(get_dev_idx_p(ifindex)); + +} + +int set_dis_tap_sd(int ifindex, int dis_param) +{ + return set_dis_tap_fn(get_dev_idx_p(ifindex), dis_param); + +} + +int get_dis_tap_sd(int ifindex) +{ + return get_dis_tap_fn(get_dev_idx_p(ifindex)); + +} + +int set_bp_disc_sd(int ifindex, int disc_mode) +{ + return set_disc_fn(get_dev_idx_p(ifindex), disc_mode); + +} + +int get_bp_disc_sd(int ifindex) +{ + return get_disc_fn(get_dev_idx_p(ifindex)); + +} + +int set_bp_disc_pwup_sd(int ifindex, int disc_mode) +{ + return set_disc_pwup_fn(get_dev_idx_p(ifindex), disc_mode); + +} + +int get_bp_disc_pwup_sd(int ifindex) +{ + return get_disc_pwup_fn(get_dev_idx_p(ifindex)); + +} + +int get_bp_disc_change_sd(int ifindex) +{ + return get_disc_change_fn(get_dev_idx_p(ifindex)); + +} + +int set_bp_dis_disc_sd(int ifindex, int dis_param) +{ + return set_dis_disc_fn(get_dev_idx_p(ifindex), dis_param); + +} + +int get_bp_dis_disc_sd(int ifindex) +{ + return get_dis_disc_fn(get_dev_idx_p(ifindex)); + +} + +int get_wd_exp_mode_sd(int ifindex) +{ + return get_wd_exp_mode_fn(get_dev_idx_p(ifindex)); +} + +int set_wd_exp_mode_sd(int ifindex, int param) +{ + return set_wd_exp_mode_fn(get_dev_idx_p(ifindex), param); + +} + +int reset_cont_sd(int ifindex) +{ + return reset_cont_fn(get_dev_idx_p(ifindex)); + +} + +int set_tx_sd(int ifindex, int tx_state) +{ + return set_tx_fn(get_dev_idx_p(ifindex), tx_state); + +} + +int set_tpl_sd(int ifindex, int tpl_state) +{ + return set_tpl_fn(get_dev_idx_p(ifindex), tpl_state); + +} + +int set_bp_hw_reset_sd(int ifindex, int status) +{ + return set_bp_hw_reset_fn(get_dev_idx_p(ifindex), status); + +} + +int set_wd_autoreset_sd(int ifindex, int param) +{ + return set_wd_autoreset_fn(get_dev_idx_p(ifindex), param); + +} + +int get_wd_autoreset_sd(int ifindex) +{ + return get_wd_autoreset_fn(get_dev_idx_p(ifindex)); + +} + +int get_bypass_caps_sd(int ifindex) +{ + return get_bypass_caps_fn(get_dev_idx_p(ifindex)); +} + +int get_bypass_slave_sd(int ifindex) +{ + bpctl_dev_t *pbpctl_dev_out; + int ret = get_bypass_slave_fn(get_dev_idx_p(ifindex), &pbpctl_dev_out); + if (ret == 1) + return pbpctl_dev_out->ifindex; + return -1; + +} + +int get_tx_sd(int ifindex) +{ + return get_tx_fn(get_dev_idx_p(ifindex)); + +} + +int get_tpl_sd(int ifindex) +{ + return get_tpl_fn(get_dev_idx_p(ifindex)); + +} + +int get_bp_hw_reset_sd(int ifindex) +{ + return get_bp_hw_reset_fn(get_dev_idx_p(ifindex)); + +} + +int get_bypass_info_sd(int ifindex, struct bp_info *bp_info) +{ + return get_bypass_info_fn(get_dev_idx_p(ifindex), bp_info->prod_name, &bp_info->fw_ver); +} + +int bp_if_scan_sd(void) +{ + if_scan_init(); + return 0; +} + +EXPORT_SYMBOL_NOVERS(is_bypass_sd); +EXPORT_SYMBOL_NOVERS(get_bypass_slave_sd); +EXPORT_SYMBOL_NOVERS(get_bypass_caps_sd); +EXPORT_SYMBOL_NOVERS(get_wd_set_caps_sd); +EXPORT_SYMBOL_NOVERS(set_bypass_sd); +EXPORT_SYMBOL_NOVERS(get_bypass_sd); +EXPORT_SYMBOL_NOVERS(get_bypass_change_sd); +EXPORT_SYMBOL_NOVERS(set_dis_bypass_sd); +EXPORT_SYMBOL_NOVERS(get_dis_bypass_sd); +EXPORT_SYMBOL_NOVERS(set_bypass_pwoff_sd); +EXPORT_SYMBOL_NOVERS(get_bypass_pwoff_sd); +EXPORT_SYMBOL_NOVERS(set_bypass_pwup_sd); +EXPORT_SYMBOL_NOVERS(get_bypass_pwup_sd); +EXPORT_SYMBOL_NOVERS(set_bypass_wd_sd); +EXPORT_SYMBOL_NOVERS(get_bypass_wd_sd); +EXPORT_SYMBOL_NOVERS(get_wd_expire_time_sd); +EXPORT_SYMBOL_NOVERS(reset_bypass_wd_timer_sd); +EXPORT_SYMBOL_NOVERS(set_std_nic_sd); +EXPORT_SYMBOL_NOVERS(get_std_nic_sd); +EXPORT_SYMBOL_NOVERS(set_tx_sd); +EXPORT_SYMBOL_NOVERS(get_tx_sd); +EXPORT_SYMBOL_NOVERS(set_tpl_sd); +EXPORT_SYMBOL_NOVERS(get_tpl_sd); +EXPORT_SYMBOL_NOVERS(set_bp_hw_reset_sd); +EXPORT_SYMBOL_NOVERS(get_bp_hw_reset_sd); +EXPORT_SYMBOL_NOVERS(set_tap_sd); +EXPORT_SYMBOL_NOVERS(get_tap_sd); +EXPORT_SYMBOL_NOVERS(get_tap_change_sd); +EXPORT_SYMBOL_NOVERS(set_dis_tap_sd); +EXPORT_SYMBOL_NOVERS(get_dis_tap_sd); +EXPORT_SYMBOL_NOVERS(set_tap_pwup_sd); +EXPORT_SYMBOL_NOVERS(get_tap_pwup_sd); +EXPORT_SYMBOL_NOVERS(set_wd_exp_mode_sd); +EXPORT_SYMBOL_NOVERS(get_wd_exp_mode_sd); +EXPORT_SYMBOL_NOVERS(set_wd_autoreset_sd); +EXPORT_SYMBOL_NOVERS(get_wd_autoreset_sd); +EXPORT_SYMBOL_NOVERS(set_bp_disc_sd); +EXPORT_SYMBOL_NOVERS(get_bp_disc_sd); +EXPORT_SYMBOL_NOVERS(get_bp_disc_change_sd); +EXPORT_SYMBOL_NOVERS(set_bp_dis_disc_sd); +EXPORT_SYMBOL_NOVERS(get_bp_dis_disc_sd); +EXPORT_SYMBOL_NOVERS(set_bp_disc_pwup_sd); +EXPORT_SYMBOL_NOVERS(get_bp_disc_pwup_sd); +EXPORT_SYMBOL_NOVERS(get_bypass_info_sd); +EXPORT_SYMBOL_NOVERS(bp_if_scan_sd); + +#define BP_PROC_DIR "bypass" + +static struct proc_dir_entry *bp_procfs_dir; + +int bp_proc_create(void) +{ + 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", + BP_PROC_DIR); + return -1; + } + return 0; +} + +static int procfs_add(char *proc_name, const struct file_operations *fops, + bpctl_dev_t *dev) +{ + struct bypass_pfs_sd *pfs = &dev->bypass_pfs_set; + if (!proc_create_data(proc_name, 0644, pfs->bypass_entry, fops, dev)) + return -1; + return 0; +} + +#define RO_FOPS(name) \ +static int name##_open(struct inode *inode, struct file *file) \ +{ \ + return single_open(file, show_##name, PDE(inode)->data);\ +} \ +static const struct file_operations name##_ops = { \ + .open = name##_open, \ + .read = seq_read, \ + .llseek = seq_lseek, \ + .release = single_release, \ +}; + +#define RW_FOPS(name) \ +static int name##_open(struct inode *inode, struct file *file) \ +{ \ + return single_open(file, show_##name, PDE(inode)->data);\ +} \ +static const struct file_operations name##_ops = { \ + .open = name##_open, \ + .read = seq_read, \ + .write = name##_write, \ + .llseek = seq_lseek, \ + .release = single_release, \ +}; + +static int show_bypass_info(struct seq_file *m, void *v) +{ + bpctl_dev_t *dev = m->private; + + 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) + +static int show_bypass_slave(struct seq_file *m, void *v) +{ + 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) + +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) + seq_printf(m, "-1\n"); + else + seq_printf(m, "0x%x\n", ret); + return 0; +} +RO_FOPS(bypass_caps) + +static int show_wd_set_caps(struct seq_file *m, void *v) +{ + bpctl_dev_t *dev = m->private; + int ret = get_wd_set_caps_fn(dev); + if (ret == BP_NOT_CAP) + seq_printf(m, "-1\n"); + else + seq_printf(m, "0x%x\n", ret); + return 0; +} +RO_FOPS(wd_set_caps) + +static int user_on_off(const void __user *buffer, size_t count) +{ + + char kbuf[256]; + int 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) + return 1; + if (strcmp(kbuf, "off") == 0) + return 0; + return 0; +} + +static ssize_t bypass_write(struct file *file, const char __user *buffer, + size_t count, loff_t *pos) +{ + int bypass_param = user_on_off(buffer, count); + if (bypass_param < 0) + return -1; + + set_bypass_fn(PDE(file_inode(file))->data, bypass_param); + return count; +} +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) + +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; + + set_tap_fn(PDE(file_inode(file))->data, tap_param); + return count; +} +static int show_tap(struct seq_file *m, void *v) +{ + bpctl_dev_t *dev = m->private; + int ret = get_tap_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(tap) + +static ssize_t disc_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; + + set_disc_fn(PDE(file_inode(file))->data, tap_param); + return count; +} +static int show_disc(struct seq_file *m, void *v) +{ + bpctl_dev_t *dev = m->private; + int ret = get_disc_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(disc) + +static int show_bypass_change(struct seq_file *m, void *v) +{ + bpctl_dev_t *dev = m->private; + int ret = get_bypass_change_fn(dev); + if (ret == 1) + seq_printf(m, "on\n"); + else if (ret == 0) + seq_printf(m, "off\n"); + else + seq_printf(m, "fail\n"); + return 0; +} +RO_FOPS(bypass_change) + +static int show_tap_change(struct seq_file *m, void *v) +{ + bpctl_dev_t *dev = m->private; + int ret = get_tap_change_fn(dev); + if (ret == 1) + seq_printf(m, "on\n"); + else if (ret == 0) + seq_printf(m, "off\n"); + else + seq_printf(m, "fail\n"); + return 0; +} +RO_FOPS(tap_change) + +static int show_disc_change(struct seq_file *m, void *v) +{ + bpctl_dev_t *dev = m->private; + int ret = get_disc_change_fn(dev); + if (ret == 1) + seq_printf(m, "on\n"); + else if (ret == 0) + seq_printf(m, "off\n"); + else + seq_printf(m, "fail\n"); + return 0; +} +RO_FOPS(disc_change) + +static ssize_t bypass_wd_write(struct file *file, const char __user *buffer, + size_t count, loff_t *pos) +{ + bpctl_dev_t *dev = PDE(file_inode(file))->data; + int timeout; + int ret = kstrtoint_from_user(buffer, count, 10, &timeout); + if (ret) + return ret; + set_bypass_wd_fn(dev, timeout); + return count; +} +static int show_bypass_wd(struct seq_file *m, void *v) +{ + bpctl_dev_t *dev = m->private; + int ret = 0, timeout = 0; + + ret = get_bypass_wd_fn(dev, &timeout); + if (ret == BP_NOT_CAP) + seq_printf(m, "fail\n"); + else if (timeout == -1) + seq_printf(m, "unknown\n"); + else if (timeout == 0) + seq_printf(m, "disable\n"); + else + seq_printf(m, "%d\n", timeout); + return 0; +} +RW_FOPS(bypass_wd) + +static int show_wd_expire_time(struct seq_file *m, void *v) +{ + bpctl_dev_t *dev = m->private; + int ret = 0, timeout = 0; + ret = get_wd_expire_time_fn(dev, &timeout); + if (ret == BP_NOT_CAP) + seq_printf(m, "fail\n"); + else if (timeout == -1) + seq_printf(m, "expire\n"); + else if (timeout == 0) + seq_printf(m, "disable\n"); + else + seq_printf(m, "%d\n", timeout); + return 0; +} +RO_FOPS(wd_expire_time) + +static ssize_t tpl_write(struct file *file, const char __user *buffer, + size_t count, loff_t *pos) +{ + bpctl_dev_t *dev = PDE(file_inode(file))->data; + int tpl_param = user_on_off(buffer, count); + if (tpl_param < 0) + return -1; + + 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) + 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(tpl) + +#ifdef PMC_FIX_FLAG +static ssize_t wait_at_pwup_write(struct file *file, const char __user *buffer, + size_t count, loff_t *pos) +{ + bpctl_dev_t *dev = PDE(file_inode(file))->data; + int tpl_param = user_on_off(buffer, count); + if (tpl_param < 0) + return -1; + + 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) + 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(wait_at_pwup) + +static ssize_t hw_reset_write(struct file *file, const char __user *buffer, + size_t count, loff_t *pos) +{ + bpctl_dev_t *dev = PDE(file_inode(file))->data; + int tpl_param = user_on_off(buffer, count); + if (tpl_param < 0) + return -1; + + 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) + 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(hw_reset) + +#endif /*PMC_WAIT_FLAG */ + +static int show_reset_bypass_wd(struct seq_file *m, void *v) +{ + bpctl_dev_t *dev = m->private; + int ret = reset_bypass_wd_timer_fn(dev); + if (ret == BP_NOT_CAP) + seq_printf(m, "fail\n"); + else if (ret == 0) + seq_printf(m, "disable\n"); + else if (ret == 1) + seq_printf(m, "success\n"); + return 0; +} +RO_FOPS(reset_bypass_wd) + +static ssize_t dis_bypass_write(struct file *file, const char __user *buffer, + size_t count, loff_t *pos) +{ + int bypass_param = user_on_off(buffer, count); + if (bypass_param < 0) + return -EINVAL; + + set_dis_bypass_fn(PDE(file_inode(file))->data, bypass_param); + return count; +} +static int show_dis_bypass(struct seq_file *m, void *v) +{ + 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) + +static ssize_t dis_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 -EINVAL; + + set_dis_tap_fn(PDE(file_inode(file))->data, tap_param); + return count; +} +static int show_dis_tap(struct seq_file *m, void *v) +{ + bpctl_dev_t *dev = m->private; + int ret = get_dis_tap_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_tap) + +static ssize_t dis_disc_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 -EINVAL; + + set_dis_disc_fn(PDE(file_inode(file))->data, tap_param); + return count; +} +static int show_dis_disc(struct seq_file *m, void *v) +{ + bpctl_dev_t *dev = m->private; + int ret = get_dis_disc_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_disc) + +static ssize_t bypass_pwup_write(struct file *file, const char __user *buffer, + size_t count, loff_t *pos) +{ + int bypass_param = user_on_off(buffer, count); + if (bypass_param < 0) + return -EINVAL; + + set_bypass_pwup_fn(PDE(file_inode(file))->data, bypass_param); + return count; +} +static int show_bypass_pwup(struct seq_file *m, void *v) +{ + 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) + +static ssize_t bypass_pwoff_write(struct file *file, const char __user *buffer, + size_t count, loff_t *pos) +{ + int bypass_param = user_on_off(buffer, count); + if (bypass_param < 0) + return -EINVAL; + + set_bypass_pwoff_fn(PDE(file_inode(file))->data, bypass_param); + return count; +} +static int show_bypass_pwoff(struct seq_file *m, void *v) +{ + bpctl_dev_t *dev = m->private; + int ret = get_bypass_pwoff_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_pwoff) + +static ssize_t tap_pwup_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 -EINVAL; + + set_tap_pwup_fn(PDE(file_inode(file))->data, tap_param); + return count; +} +static int show_tap_pwup(struct seq_file *m, void *v) +{ + bpctl_dev_t *dev = m->private; + int ret = get_tap_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(tap_pwup) + +static ssize_t disc_pwup_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 -EINVAL; + + set_disc_pwup_fn(PDE(file_inode(file))->data, 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) + seq_printf(m, "fail\n"); + else if (ret == 0) + seq_printf(m, "off\n"); + else + seq_printf(m, "on\n"); + return 0; +} +RW_FOPS(disc_pwup) + +static ssize_t std_nic_write(struct file *file, const char __user *buffer, + size_t count, loff_t *pos) +{ + int bypass_param = user_on_off(buffer, count); + if (bypass_param < 0) + return -EINVAL; + + set_std_nic_fn(PDE(file_inode(file))->data, bypass_param); + return count; +} +static int show_std_nic(struct seq_file *m, void *v) +{ + bpctl_dev_t *dev = m->private; + int ret = get_std_nic_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(std_nic) + +static ssize_t wd_exp_mode_write(struct file *file, const char __user *buffer, + size_t count, loff_t *pos) +{ + char kbuf[256]; + 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(PDE(file_inode(file))->data, bypass_param); + + return count; +} +static int show_wd_exp_mode(struct seq_file *m, void *v) +{ + 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 + seq_printf(m, "fail\n"); + return 0; +} +RW_FOPS(wd_exp_mode) + +static ssize_t wd_autoreset_write(struct file *file, const char __user *buffer, + size_t count, loff_t *pos) +{ + int timeout; + int ret = kstrtoint_from_user(buffer, count, 10, &timeout); + if (ret) + return ret; + set_wd_autoreset_fn(PDE(file_inode(file))->data, timeout); + return count; +} +static int show_wd_autoreset(struct seq_file *m, void *v) +{ + 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; +} +RW_FOPS(wd_autoreset) + +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 = NULL; + int ret = 0; + + if (!pbp_device_block->ndev) + return -1; + sprintf(current_pfs->dir_name, "bypass_%s", + pbp_device_block->ndev->name); + + if (!bp_procfs_dir) + return -1; + + /* create device proc dir */ + 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; + +#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 */ + 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) { + ENTRY(bypass); + ENTRY(dis_bypass); + ENTRY(bypass_pwup); + ENTRY(bypass_pwoff); + ENTRY(bypass_change); + } + if (pbp_device_block->bp_caps & TAP_CAP) { + ENTRY(tap); + ENTRY(dis_tap); + ENTRY(tap_pwup); + ENTRY(tap_change); + } + if (pbp_device_block->bp_caps & DISC_CAP) { + ENTRY(disc); + ENTRY(dis_disc); + ENTRY(disc_pwup); + ENTRY(disc_change); + } + + ENTRY(wd_exp_mode); + ENTRY(wd_autoreset); + ENTRY(tpl); +#ifdef PMC_FIX_FLAG + ENTRY(wait_at_pwup); + ENTRY(hw_reset); +#endif + } +#undef ENTRY + 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; + remove_proc_subtree(current_pfs->dir_name, bp_procfs_dir); + current_pfs->bypass_entry = NULL; + return 0; +} -- cgit v1.2.3 From 21ba37c9cf2f2dcadaabd79dff384537124d216c Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 30 Mar 2013 20:34:21 -0400 Subject: i2o: use proc_remove_subtree() Signed-off-by: Al Viro --- drivers/message/i2o/i2o_proc.c | 51 +----------------------------------------- 1 file changed, 1 insertion(+), 50 deletions(-) (limited to 'drivers') diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c index 8001aa6bfb4..15c1e480c0d 100644 --- a/drivers/message/i2o/i2o_proc.c +++ b/drivers/message/i2o/i2o_proc.c @@ -1894,25 +1894,6 @@ static int i2o_proc_create_entries(struct proc_dir_entry *dir, return 0; } -/** - * i2o_proc_subdir_remove - Remove child entries from a proc entry - * @dir: proc dir entry from which the childs should be removed - * - * Iterate over each i2o proc entry under dir and remove it. If the child - * also has entries, remove them too. - */ -static void i2o_proc_subdir_remove(struct proc_dir_entry *dir) -{ - struct proc_dir_entry *pe, *tmp; - pe = dir->subdir; - while (pe) { - tmp = pe->next; - i2o_proc_subdir_remove(pe); - remove_proc_entry(pe->name, dir); - pe = tmp; - } -}; - /** * i2o_proc_device_add - Add an I2O device to the proc dir * @dir: proc dir entry to which the device should be added @@ -1987,31 +1968,6 @@ static int i2o_proc_iop_add(struct proc_dir_entry *dir, return 0; } -/** - * i2o_proc_iop_remove - Removes an I2O controller from the i2o proc tree - * @dir: parent proc dir entry - * @c: I2O controller which should be removed - * - * Iterate over each i2o proc entry and search controller c. If it is found - * remove it from the tree. - */ -static void i2o_proc_iop_remove(struct proc_dir_entry *dir, - struct i2o_controller *c) -{ - struct proc_dir_entry *pe, *tmp; - - pe = dir->subdir; - while (pe) { - tmp = pe->next; - if (pe->data == c) { - i2o_proc_subdir_remove(pe); - remove_proc_entry(pe->name, dir); - } - osm_debug("removing IOP /proc/i2o/%s\n", c->name); - pe = tmp; - } -} - /** * i2o_proc_fs_create - Create the i2o proc fs. * @@ -2042,12 +1998,7 @@ static int __init i2o_proc_fs_create(void) */ static int __exit i2o_proc_fs_destroy(void) { - struct i2o_controller *c; - - list_for_each_entry(c, &i2o_controllers, list) - i2o_proc_iop_remove(i2o_proc_dir_root, c); - - remove_proc_entry("i2o", NULL); + remove_proc_subtree("i2o", NULL); return 0; }; -- cgit v1.2.3 From 0ffddfbb834557b8babc7f050b83d11dbcbb1008 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 30 Mar 2013 23:58:05 -0400 Subject: scsi: saner replacements for ->proc_info() It's still an obsolete interface; don't introduce those in new drivers. However, it's saner than the ->proc_info() and commits after this one will convert the existing ->proc_info() users to it. The read side is ->show_info(seq_file *, struct Scsi_Host *); use seq_... for generating contents. The write side is ->write_info(struct Scsi_Host *, char *, int). Again, this is driven by procfs needs; we are going to kill ->write_proc() and ->read_proc() and this is the main obstacle to burying that piece of shit. Signed-off-by: Al Viro --- drivers/scsi/scsi_proc.c | 68 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 59 insertions(+), 9 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/scsi_proc.c b/drivers/scsi/scsi_proc.c index ad747dc337d..6f4c3cff03b 100644 --- a/drivers/scsi/scsi_proc.c +++ b/drivers/scsi/scsi_proc.c @@ -97,6 +97,49 @@ out: return ret; } +static ssize_t proc_scsi_host_write(struct file *file, const char __user *buf, + size_t count, loff_t *ppos) +{ + struct Scsi_Host *shost = PDE(file_inode(file))->data; + ssize_t ret = -ENOMEM; + char *page; + + if (count > PROC_BLOCK_SIZE) + return -EOVERFLOW; + + if (!shost->hostt->write_info) + return -EINVAL; + + page = (char *)__get_free_page(GFP_KERNEL); + if (page) { + ret = -EFAULT; + if (copy_from_user(page, buf, count)) + goto out; + ret = shost->hostt->write_info(shost, page, count); + } +out: + free_page((unsigned long)page); + return ret; +} + +static int proc_scsi_show(struct seq_file *m, void *v) +{ + struct Scsi_Host *shost = m->private; + return shost->hostt->show_info(m, shost); +} + +static int proc_scsi_host_open(struct inode *inode, struct file *file) +{ + return single_open(file, proc_scsi_show, PDE(inode)->data); +} + +static const struct file_operations proc_scsi_fops = { + .open = proc_scsi_host_open, + .read = seq_read, + .llseek = seq_lseek, + .write = proc_scsi_host_write +}; + /** * scsi_proc_hostdir_add - Create directory in /proc for a scsi host * @sht: owner of this directory @@ -106,7 +149,7 @@ out: void scsi_proc_hostdir_add(struct scsi_host_template *sht) { - if (!sht->proc_info) + if (!sht->proc_info && !sht->show_info) return; mutex_lock(&global_host_template_mutex); @@ -125,7 +168,7 @@ void scsi_proc_hostdir_add(struct scsi_host_template *sht) */ void scsi_proc_hostdir_rm(struct scsi_host_template *sht) { - if (!sht->proc_info) + if (!sht->proc_info && !sht->show_info) return; mutex_lock(&global_host_template_mutex); @@ -151,16 +194,23 @@ void scsi_proc_host_add(struct Scsi_Host *shost) return; sprintf(name,"%d", shost->host_no); + if (sht->show_info) { + p = proc_create_data(name, S_IRUGO | S_IWUSR, + sht->proc_dir, &proc_scsi_fops, shost); + if (!p) + goto Fail; + return; + } p = create_proc_read_entry(name, S_IFREG | S_IRUGO | S_IWUSR, sht->proc_dir, proc_scsi_read, shost); - if (!p) { - printk(KERN_ERR "%s: Failed to register host %d in" - "%s\n", __func__, shost->host_no, - sht->proc_name); + if (p) { + p->write_proc = proc_scsi_write_proc; return; - } - - p->write_proc = proc_scsi_write_proc; + } +Fail: + printk(KERN_ERR "%s: Failed to register host %d in" + "%s\n", __func__, shost->host_no, + sht->proc_name); } /** -- cgit v1.2.3 From ee127fec448bb066b549d516af5fe5a596b6ad6c Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 00:10:16 -0400 Subject: sym53c8xx_2: switch to ->show_info() Signed-off-by: Al Viro --- drivers/scsi/sym53c8xx_2/sym_glue.c | 115 +++++++----------------------------- 1 file changed, 21 insertions(+), 94 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c index 599568299fb..bac55f7f69f 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.c +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c @@ -1171,112 +1171,36 @@ printk("sym_user_command: data=%ld\n", uc->data); #endif /* SYM_LINUX_USER_COMMAND_SUPPORT */ -#ifdef SYM_LINUX_USER_INFO_SUPPORT -/* - * Informations through the proc file system. - */ -struct info_str { - char *buffer; - int length; - int offset; - int pos; -}; - -static void copy_mem_info(struct info_str *info, char *data, int len) -{ - if (info->pos + len > info->length) - len = info->length - info->pos; - - if (info->pos + len < info->offset) { - info->pos += len; - return; - } - if (info->pos < info->offset) { - data += (info->offset - info->pos); - len -= (info->offset - info->pos); - } - - if (len > 0) { - memcpy(info->buffer + info->pos, data, len); - info->pos += len; - } -} - -static int copy_info(struct info_str *info, char *fmt, ...) -{ - va_list args; - char buf[81]; - int len; - - va_start(args, fmt); - len = vsprintf(buf, fmt, args); - va_end(args); - - copy_mem_info(info, buf, len); - return len; -} - /* * Copy formatted information into the input buffer. */ -static int sym_host_info(struct Scsi_Host *shost, char *ptr, off_t offset, int len) +static int sym_show_info(struct seq_file *m, struct Scsi_Host *shost) { +#ifdef SYM_LINUX_USER_INFO_SUPPORT struct sym_data *sym_data = shost_priv(shost); struct pci_dev *pdev = sym_data->pdev; struct sym_hcb *np = sym_data->ncb; - struct info_str info; - - info.buffer = ptr; - info.length = len; - info.offset = offset; - info.pos = 0; - copy_info(&info, "Chip " NAME53C "%s, device id 0x%x, " - "revision id 0x%x\n", np->s.chip_name, - pdev->device, pdev->revision); - copy_info(&info, "At PCI address %s, IRQ %u\n", + seq_printf(m, "Chip " NAME53C "%s, device id 0x%x, " + "revision id 0x%x\n", np->s.chip_name, + pdev->device, pdev->revision); + seq_printf(m, "At PCI address %s, IRQ %u\n", pci_name(pdev), pdev->irq); - copy_info(&info, "Min. period factor %d, %s SCSI BUS%s\n", - (int) (np->minsync_dt ? np->minsync_dt : np->minsync), - np->maxwide ? "Wide" : "Narrow", - np->minsync_dt ? ", DT capable" : ""); + seq_printf(m, "Min. period factor %d, %s SCSI BUS%s\n", + (int) (np->minsync_dt ? np->minsync_dt : np->minsync), + np->maxwide ? "Wide" : "Narrow", + np->minsync_dt ? ", DT capable" : ""); - copy_info(&info, "Max. started commands %d, " - "max. commands per LUN %d\n", - SYM_CONF_MAX_START, SYM_CONF_MAX_TAG); + seq_printf(m, "Max. started commands %d, " + "max. commands per LUN %d\n", + SYM_CONF_MAX_START, SYM_CONF_MAX_TAG); - return info.pos > info.offset? info.pos - info.offset : 0; -} -#endif /* SYM_LINUX_USER_INFO_SUPPORT */ - -/* - * Entry point of the scsi proc fs of the driver. - * - func = 0 means read (returns adapter infos) - * - func = 1 means write (not yet merget from sym53c8xx) - */ -static int sym53c8xx_proc_info(struct Scsi_Host *shost, char *buffer, - char **start, off_t offset, int length, int func) -{ - int retv; - - if (func) { -#ifdef SYM_LINUX_USER_COMMAND_SUPPORT - retv = sym_user_command(shost, buffer, length); -#else - retv = -EINVAL; -#endif - } else { - if (start) - *start = buffer; -#ifdef SYM_LINUX_USER_INFO_SUPPORT - retv = sym_host_info(shost, buffer, offset, length); + return 0; #else - retv = -EINVAL; -#endif - } - - return retv; + return -EINVAL; +#endif /* SYM_LINUX_USER_INFO_SUPPORT */ } + #endif /* SYM_LINUX_PROC_INFO_SUPPORT */ /* @@ -1742,7 +1666,10 @@ static struct scsi_host_template sym2_template = { .use_clustering = ENABLE_CLUSTERING, .max_sectors = 0xFFFF, #ifdef SYM_LINUX_PROC_INFO_SUPPORT - .proc_info = sym53c8xx_proc_info, + .show_info = sym_show_info, +#ifdef SYM_LINUX_USER_COMMAND_SUPPORT + .write_info = sym_user_command, +#endif .proc_name = NAME53C8XX, #endif }; -- cgit v1.2.3 From cab29b99dfaa6065e3b576e54d7f6cfa60fa2faf Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 00:17:00 -0400 Subject: wd7000: switch to ->show_info() Signed-off-by: Al Viro --- drivers/scsi/wd7000.c | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/wd7000.c b/drivers/scsi/wd7000.c index d89a5dfd3ad..f9a6e4b0aff 100644 --- a/drivers/scsi/wd7000.c +++ b/drivers/scsi/wd7000.c @@ -1296,9 +1296,9 @@ static void wd7000_revision(Adapter * host) #undef SPRINTF -#define SPRINTF(args...) { if (pos < (buffer + length)) pos += sprintf (pos, ## args); } +#define SPRINTF(args...) { seq_printf(m, ## args); } -static int wd7000_set_info(char *buffer, int length, struct Scsi_Host *host) +static int wd7000_set_info(struct Scsi_Host *host, char *buffer, int length) { dprintk("Buffer = <%.*s>, length = %d\n", length, buffer, length); @@ -1310,22 +1310,15 @@ static int wd7000_set_info(char *buffer, int length, struct Scsi_Host *host) } -static int wd7000_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, int length, int inout) +static int wd7000_show_info(struct seq_file *m, struct Scsi_Host *host) { Adapter *adapter = (Adapter *)host->hostdata; unsigned long flags; - char *pos = buffer; #ifdef WD7000_DEBUG Mailbox *ogmbs, *icmbs; short count; #endif - /* - * Has data been written to the file ? - */ - if (inout) - return (wd7000_set_info(buffer, length, host)); - spin_lock_irqsave(host->host_lock, flags); SPRINTF("Host scsi%d: Western Digital WD-7000 (rev %d.%d)\n", host->host_no, adapter->rev1, adapter->rev2); SPRINTF(" IO base: 0x%x\n", adapter->iobase); @@ -1368,17 +1361,7 @@ static int wd7000_proc_info(struct Scsi_Host *host, char *buffer, char **start, spin_unlock_irqrestore(host->host_lock, flags); - /* - * 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; } @@ -1413,7 +1396,8 @@ static __init int wd7000_detect(struct scsi_host_template *tpnt) for (i = 0; i < NUM_CONFIGS; biosptr[i++] = -1); tpnt->proc_name = "wd7000"; - tpnt->proc_info = &wd7000_proc_info; + tpnt->show_info = &wd7000_show_info; + tpnt->write_info = wd7000_set_info; /* * Set up SCB free list, which is shared by all adapters @@ -1658,7 +1642,8 @@ MODULE_LICENSE("GPL"); static struct scsi_host_template driver_template = { .proc_name = "wd7000", - .proc_info = wd7000_proc_info, + .show_info = wd7000_show_info, + .write_info = wd7000_set_info, .name = "Western Digital WD-7000", .detect = wd7000_detect, .release = wd7000_release, -- cgit v1.2.3 From 408bb25ba50c6abaf516d844fd62556ec89a0af2 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 00:30:35 -0400 Subject: switch wd33c93 to ->show_info() Signed-off-by: Al Viro --- drivers/scsi/a2091.c | 3 +- drivers/scsi/a3000.c | 3 +- drivers/scsi/gvp11.c | 3 +- drivers/scsi/mvme147.c | 3 +- drivers/scsi/wd33c93.c | 194 +++++++++++++++++++++---------------------------- drivers/scsi/wd33c93.h | 3 +- 6 files changed, 94 insertions(+), 115 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/a2091.c b/drivers/scsi/a2091.c index 3e09aa21c1c..30fa38a0ad3 100644 --- a/drivers/scsi/a2091.c +++ b/drivers/scsi/a2091.c @@ -166,7 +166,8 @@ static int a2091_bus_reset(struct scsi_cmnd *cmd) static struct scsi_host_template a2091_scsi_template = { .module = THIS_MODULE, .name = "Commodore A2091/A590 SCSI", - .proc_info = wd33c93_proc_info, + .show_info = wd33c93_show_info, + .write_info = wd33c93_write_info, .proc_name = "A2901", .queuecommand = wd33c93_queuecommand, .eh_abort_handler = wd33c93_abort, diff --git a/drivers/scsi/a3000.c b/drivers/scsi/a3000.c index e29fe0e708f..c487916a9d4 100644 --- a/drivers/scsi/a3000.c +++ b/drivers/scsi/a3000.c @@ -181,7 +181,8 @@ static int a3000_bus_reset(struct scsi_cmnd *cmd) static struct scsi_host_template amiga_a3000_scsi_template = { .module = THIS_MODULE, .name = "Amiga 3000 built-in SCSI", - .proc_info = wd33c93_proc_info, + .show_info = wd33c93_show_info, + .write_info = wd33c93_write_info, .proc_name = "A3000", .queuecommand = wd33c93_queuecommand, .eh_abort_handler = wd33c93_abort, diff --git a/drivers/scsi/gvp11.c b/drivers/scsi/gvp11.c index dbe4cc6b9f8..2203ac28110 100644 --- a/drivers/scsi/gvp11.c +++ b/drivers/scsi/gvp11.c @@ -191,7 +191,8 @@ static int gvp11_bus_reset(struct scsi_cmnd *cmd) static struct scsi_host_template gvp11_scsi_template = { .module = THIS_MODULE, .name = "GVP Series II SCSI", - .proc_info = wd33c93_proc_info, + .show_info = wd33c93_show_info, + .write_info = wd33c93_write_info, .proc_name = "GVP11", .queuecommand = wd33c93_queuecommand, .eh_abort_handler = wd33c93_abort, diff --git a/drivers/scsi/mvme147.c b/drivers/scsi/mvme147.c index c29d0dbb966..e7f6661a886 100644 --- a/drivers/scsi/mvme147.c +++ b/drivers/scsi/mvme147.c @@ -76,7 +76,8 @@ int mvme147_detect(struct scsi_host_template *tpnt) called++; tpnt->proc_name = "MVME147"; - tpnt->proc_info = &wd33c93_proc_info; + tpnt->show_info = wd33c93_show_info, + tpnt->write_info = wd33c93_write_info, instance = scsi_register(tpnt, sizeof(struct WD33C93_hostdata)); if (!instance) diff --git a/drivers/scsi/wd33c93.c b/drivers/scsi/wd33c93.c index c0ee4ea28a1..41883a87931 100644 --- a/drivers/scsi/wd33c93.c +++ b/drivers/scsi/wd33c93.c @@ -2054,22 +2054,16 @@ wd33c93_init(struct Scsi_Host *instance, const wd33c93_regs regs, printk(" Version %s - %s\n", WD33C93_VERSION, WD33C93_DATE); } -int -wd33c93_proc_info(struct Scsi_Host *instance, char *buf, char **start, off_t off, int len, int in) +int wd33c93_write_info(struct Scsi_Host *instance, char *buf, int len) { - #ifdef PROC_INTERFACE - char *bp; - char tbuf[128]; struct WD33C93_hostdata *hd; - struct scsi_cmnd *cmd; int x; - static int stop = 0; hd = (struct WD33C93_hostdata *) instance->hostdata; -/* If 'in' is TRUE we need to _read_ the proc file. We accept the following +/* We accept the following * keywords (same format as command-line, but arguments are not optional): * debug * disconnect @@ -2083,145 +2077,124 @@ wd33c93_proc_info(struct Scsi_Host *instance, char *buf, char **start, off_t off * nosync */ - if (in) { - buf[len] = '\0'; - for (bp = buf; *bp; ) { - while (',' == *bp || ' ' == *bp) - ++bp; - if (!strncmp(bp, "debug:", 6)) { - hd->args = simple_strtoul(bp+6, &bp, 0) & DB_MASK; - } else if (!strncmp(bp, "disconnect:", 11)) { - x = simple_strtoul(bp+11, &bp, 0); - if (x < DIS_NEVER || x > DIS_ALWAYS) - x = DIS_ADAPTIVE; - hd->disconnect = x; - } else if (!strncmp(bp, "period:", 7)) { + buf[len] = '\0'; + for (bp = buf; *bp; ) { + while (',' == *bp || ' ' == *bp) + ++bp; + if (!strncmp(bp, "debug:", 6)) { + hd->args = simple_strtoul(bp+6, &bp, 0) & DB_MASK; + } else if (!strncmp(bp, "disconnect:", 11)) { + x = simple_strtoul(bp+11, &bp, 0); + if (x < DIS_NEVER || x > DIS_ALWAYS) + x = DIS_ADAPTIVE; + hd->disconnect = x; + } else if (!strncmp(bp, "period:", 7)) { + x = simple_strtoul(bp+7, &bp, 0); + hd->default_sx_per = + hd->sx_table[round_period((unsigned int) x, + hd->sx_table)].period_ns; + } else if (!strncmp(bp, "resync:", 7)) { + set_resync(hd, (int)simple_strtoul(bp+7, &bp, 0)); + } else if (!strncmp(bp, "proc:", 5)) { + hd->proc = simple_strtoul(bp+5, &bp, 0); + } else if (!strncmp(bp, "nodma:", 6)) { + hd->no_dma = simple_strtoul(bp+6, &bp, 0); + } else if (!strncmp(bp, "level2:", 7)) { + hd->level2 = simple_strtoul(bp+7, &bp, 0); + } else if (!strncmp(bp, "burst:", 6)) { + hd->dma_mode = + simple_strtol(bp+6, &bp, 0) ? CTRL_BURST:CTRL_DMA; + } else if (!strncmp(bp, "fast:", 5)) { + x = !!simple_strtol(bp+5, &bp, 0); + if (x != hd->fast) + set_resync(hd, 0xff); + hd->fast = x; + } else if (!strncmp(bp, "nosync:", 7)) { x = simple_strtoul(bp+7, &bp, 0); - hd->default_sx_per = - hd->sx_table[round_period((unsigned int) x, - hd->sx_table)].period_ns; - } else if (!strncmp(bp, "resync:", 7)) { - set_resync(hd, (int)simple_strtoul(bp+7, &bp, 0)); - } else if (!strncmp(bp, "proc:", 5)) { - hd->proc = simple_strtoul(bp+5, &bp, 0); - } else if (!strncmp(bp, "nodma:", 6)) { - hd->no_dma = simple_strtoul(bp+6, &bp, 0); - } else if (!strncmp(bp, "level2:", 7)) { - hd->level2 = simple_strtoul(bp+7, &bp, 0); - } else if (!strncmp(bp, "burst:", 6)) { - hd->dma_mode = - simple_strtol(bp+6, &bp, 0) ? CTRL_BURST:CTRL_DMA; - } else if (!strncmp(bp, "fast:", 5)) { - x = !!simple_strtol(bp+5, &bp, 0); - if (x != hd->fast) - set_resync(hd, 0xff); - hd->fast = x; - } else if (!strncmp(bp, "nosync:", 7)) { - x = simple_strtoul(bp+7, &bp, 0); - set_resync(hd, x ^ hd->no_sync); - hd->no_sync = x; - } else { - break; /* unknown keyword,syntax-error,... */ - } + set_resync(hd, x ^ hd->no_sync); + hd->no_sync = x; + } else { + break; /* unknown keyword,syntax-error,... */ } - return len; } + return len; +#else + return 0; +#endif +} + +int +wd33c93_show_info(struct seq_file *m, struct Scsi_Host *instance) +{ +#ifdef PROC_INTERFACE + struct WD33C93_hostdata *hd; + struct scsi_cmnd *cmd; + int x; + + hd = (struct WD33C93_hostdata *) instance->hostdata; spin_lock_irq(&hd->lock); - bp = buf; - *bp = '\0'; - if (hd->proc & PR_VERSION) { - sprintf(tbuf, "\nVersion %s - %s.", + if (hd->proc & PR_VERSION) + seq_printf(m, "\nVersion %s - %s.", WD33C93_VERSION, WD33C93_DATE); - strcat(bp, tbuf); - } + if (hd->proc & PR_INFO) { - sprintf(tbuf, "\nclock_freq=%02x no_sync=%02x no_dma=%d" + seq_printf(m, "\nclock_freq=%02x no_sync=%02x no_dma=%d" " dma_mode=%02x fast=%d", hd->clock_freq, hd->no_sync, hd->no_dma, hd->dma_mode, hd->fast); - strcat(bp, tbuf); - strcat(bp, "\nsync_xfer[] = "); - for (x = 0; x < 7; x++) { - sprintf(tbuf, "\t%02x", hd->sync_xfer[x]); - strcat(bp, tbuf); - } - strcat(bp, "\nsync_stat[] = "); - for (x = 0; x < 7; x++) { - sprintf(tbuf, "\t%02x", hd->sync_stat[x]); - strcat(bp, tbuf); - } + seq_printf(m, "\nsync_xfer[] = "); + for (x = 0; x < 7; x++) + seq_printf(m, "\t%02x", hd->sync_xfer[x]); + seq_printf(m, "\nsync_stat[] = "); + for (x = 0; x < 7; x++) + seq_printf(m, "\t%02x", hd->sync_stat[x]); } #ifdef PROC_STATISTICS if (hd->proc & PR_STATISTICS) { - strcat(bp, "\ncommands issued: "); - for (x = 0; x < 7; x++) { - sprintf(tbuf, "\t%ld", hd->cmd_cnt[x]); - strcat(bp, tbuf); - } - strcat(bp, "\ndisconnects allowed:"); - for (x = 0; x < 7; x++) { - sprintf(tbuf, "\t%ld", hd->disc_allowed_cnt[x]); - strcat(bp, tbuf); - } - strcat(bp, "\ndisconnects done: "); - for (x = 0; x < 7; x++) { - sprintf(tbuf, "\t%ld", hd->disc_done_cnt[x]); - strcat(bp, tbuf); - } - sprintf(tbuf, + seq_printf(m, "\ncommands issued: "); + for (x = 0; x < 7; x++) + seq_printf(m, "\t%ld", hd->cmd_cnt[x]); + seq_printf(m, "\ndisconnects allowed:"); + for (x = 0; x < 7; x++) + seq_printf(m, "\t%ld", hd->disc_allowed_cnt[x]); + seq_printf(m, "\ndisconnects done: "); + for (x = 0; x < 7; x++) + seq_printf(m, "\t%ld", hd->disc_done_cnt[x]); + seq_printf(m, "\ninterrupts: %ld, DATA_PHASE ints: %ld DMA, %ld PIO", hd->int_cnt, hd->dma_cnt, hd->pio_cnt); - strcat(bp, tbuf); } #endif if (hd->proc & PR_CONNECTED) { - strcat(bp, "\nconnected: "); + seq_printf(m, "\nconnected: "); if (hd->connected) { cmd = (struct scsi_cmnd *) hd->connected; - sprintf(tbuf, " %d:%d(%02x)", + seq_printf(m, " %d:%d(%02x)", cmd->device->id, cmd->device->lun, cmd->cmnd[0]); - strcat(bp, tbuf); } } if (hd->proc & PR_INPUTQ) { - strcat(bp, "\ninput_Q: "); + seq_printf(m, "\ninput_Q: "); cmd = (struct scsi_cmnd *) hd->input_Q; while (cmd) { - sprintf(tbuf, " %d:%d(%02x)", + seq_printf(m, " %d:%d(%02x)", cmd->device->id, cmd->device->lun, cmd->cmnd[0]); - strcat(bp, tbuf); cmd = (struct scsi_cmnd *) cmd->host_scribble; } } if (hd->proc & PR_DISCQ) { - strcat(bp, "\ndisconnected_Q:"); + seq_printf(m, "\ndisconnected_Q:"); cmd = (struct scsi_cmnd *) hd->disconnected_Q; while (cmd) { - sprintf(tbuf, " %d:%d(%02x)", + seq_printf(m, " %d:%d(%02x)", cmd->device->id, cmd->device->lun, cmd->cmnd[0]); - strcat(bp, tbuf); cmd = (struct scsi_cmnd *) cmd->host_scribble; } } - strcat(bp, "\n"); + seq_printf(m, "\n"); spin_unlock_irq(&hd->lock); - *start = buf; - if (stop) { - stop = 0; - return 0; - } - if (off > 0x40000) /* ALWAYS stop after 256k bytes have been read */ - stop = 1; - if (hd->proc & PR_STOP) /* stop every other time */ - stop = 1; - return strlen(bp); - -#else /* PROC_INTERFACE */ - - return 0; - #endif /* PROC_INTERFACE */ - + return 0; } EXPORT_SYMBOL(wd33c93_host_reset); @@ -2229,4 +2202,5 @@ EXPORT_SYMBOL(wd33c93_init); EXPORT_SYMBOL(wd33c93_abort); EXPORT_SYMBOL(wd33c93_queuecommand); EXPORT_SYMBOL(wd33c93_intr); -EXPORT_SYMBOL(wd33c93_proc_info); +EXPORT_SYMBOL(wd33c93_show_info); +EXPORT_SYMBOL(wd33c93_write_info); diff --git a/drivers/scsi/wd33c93.h b/drivers/scsi/wd33c93.h index 3b463d7304d..08abe508e9a 100644 --- a/drivers/scsi/wd33c93.h +++ b/drivers/scsi/wd33c93.h @@ -345,7 +345,8 @@ void wd33c93_init (struct Scsi_Host *instance, const wd33c93_regs regs, int wd33c93_abort (struct scsi_cmnd *cmd); int wd33c93_queuecommand (struct Scsi_Host *h, struct scsi_cmnd *cmd); void wd33c93_intr (struct Scsi_Host *instance); -int wd33c93_proc_info(struct Scsi_Host *, char *, char **, off_t, int, int); +int wd33c93_show_info(struct seq_file *, struct Scsi_Host *); +int wd33c93_write_info(struct Scsi_Host *, char *, int); int wd33c93_host_reset (struct scsi_cmnd *); #endif /* WD33C93_H */ -- cgit v1.2.3 From 3e0552eebdf621504eaec7786613ef94a63463a0 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 00:52:08 -0400 Subject: gdth: switch to ->show_info() Signed-off-by: Al Viro --- drivers/scsi/gdth.c | 3 +- drivers/scsi/gdth.h | 3 +- drivers/scsi/gdth_proc.c | 211 +++++++++++------------------------------------ drivers/scsi/gdth_proc.h | 5 -- 4 files changed, 52 insertions(+), 170 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c index 59bceac51a4..6d55b4e7e79 100644 --- a/drivers/scsi/gdth.c +++ b/drivers/scsi/gdth.c @@ -4676,7 +4676,8 @@ static struct scsi_host_template gdth_template = { .eh_bus_reset_handler = gdth_eh_bus_reset, .slave_configure = gdth_slave_configure, .bios_param = gdth_bios_param, - .proc_info = gdth_proc_info, + .show_info = gdth_show_info, + .write_info = gdth_set_info, .eh_timed_out = gdth_timed_out, .proc_name = "gdth", .can_queue = GDTH_MAXCMDS, diff --git a/drivers/scsi/gdth.h b/drivers/scsi/gdth.h index fbf6f0f4b0d..3fd8b83ffbf 100644 --- a/drivers/scsi/gdth.h +++ b/drivers/scsi/gdth.h @@ -1007,6 +1007,7 @@ typedef struct { /* function prototyping */ -int gdth_proc_info(struct Scsi_Host *, char *,char **,off_t,int,int); +int gdth_show_info(struct seq_file *, struct Scsi_Host *); +int gdth_set_info(struct Scsi_Host *, char *, int); #endif diff --git a/drivers/scsi/gdth_proc.c b/drivers/scsi/gdth_proc.c index 652754319a4..9fb63268486 100644 --- a/drivers/scsi/gdth_proc.c +++ b/drivers/scsi/gdth_proc.c @@ -5,23 +5,9 @@ #include #include -int gdth_proc_info(struct Scsi_Host *host, char *buffer,char **start,off_t offset,int length, - int inout) +int gdth_set_info(struct Scsi_Host *host, char *buffer, int length) { gdth_ha_str *ha = shost_priv(host); - - TRACE2(("gdth_proc_info() length %d offs %d inout %d\n", - length,(int)offset,inout)); - - if (inout) - return(gdth_set_info(buffer,length,host,ha)); - else - return(gdth_get_info(buffer,start,offset,length,host,ha)); -} - -static int gdth_set_info(char *buffer,int length,struct Scsi_Host *host, - gdth_ha_str *ha) -{ int ret_val = -EINVAL; TRACE2(("gdth_set_info() ha %d\n",ha->hanum,)); @@ -149,12 +135,10 @@ static int gdth_set_asc_info(struct Scsi_Host *host, char *buffer, return(-EINVAL); } -static int gdth_get_info(char *buffer,char **start,off_t offset,int length, - struct Scsi_Host *host, gdth_ha_str *ha) +int gdth_show_info(struct seq_file *m, struct Scsi_Host *host) { - int size = 0,len = 0; + gdth_ha_str *ha = shost_priv(host); int hlen; - off_t begin = 0,pos = 0; int id, i, j, k, sec, flag; int no_mdrv = 0, drv_no, is_mirr; u32 cnt; @@ -189,8 +173,7 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length, /* request is i.e. "cat /proc/scsi/gdth/0" */ /* format: %-15s\t%-10s\t%-15s\t%s */ /* driver parameters */ - size = sprintf(buffer+len,"Driver Parameters:\n"); - len += size; pos = begin + len; + seq_printf(m, "Driver Parameters:\n"); if (reserve_list[0] == 0xff) strcpy(hrec, "--"); else { @@ -201,69 +184,50 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length, hlen += snprintf(hrec + hlen , 161 - hlen, ",%d", reserve_list[i]); } } - size = sprintf(buffer+len, + seq_printf(m, " reserve_mode: \t%d \treserve_list: \t%s\n", reserve_mode, hrec); - len += size; pos = begin + len; - size = sprintf(buffer+len, + seq_printf(m, " max_ids: \t%-3d \thdr_channel: \t%d\n", max_ids, hdr_channel); - len += size; pos = begin + len; /* controller information */ - size = sprintf(buffer+len,"\nDisk Array Controller Information:\n"); - len += size; pos = begin + len; - strcpy(hrec, ha->binfo.type_string); - size = sprintf(buffer+len, + seq_printf(m,"\nDisk Array Controller Information:\n"); + seq_printf(m, " Number: \t%d \tName: \t%s\n", - ha->hanum, hrec); - len += size; pos = begin + len; + ha->hanum, ha->binfo.type_string); + seq_printf(m, + " Driver Ver.: \t%-10s\tFirmware Ver.: \t", + GDTH_VERSION_STR); if (ha->more_proc) - sprintf(hrec, "%d.%02d.%02d-%c%03X", + seq_printf(m, "%d.%02d.%02d-%c%03X\n", (u8)(ha->binfo.upd_fw_ver>>24), (u8)(ha->binfo.upd_fw_ver>>16), (u8)(ha->binfo.upd_fw_ver), ha->bfeat.raid ? 'R':'N', ha->binfo.upd_revision); else - sprintf(hrec, "%d.%02d", (u8)(ha->cpar.version>>8), + seq_printf(m, "%d.%02d\n", (u8)(ha->cpar.version>>8), (u8)(ha->cpar.version)); - - size = sprintf(buffer+len, - " Driver Ver.: \t%-10s\tFirmware Ver.: \t%s\n", - GDTH_VERSION_STR, hrec); - len += size; pos = begin + len; - if (ha->more_proc) { + if (ha->more_proc) /* more information: 1. about controller */ - size = sprintf(buffer+len, + seq_printf(m, " Serial No.: \t0x%8X\tCache RAM size:\t%d KB\n", ha->binfo.ser_no, ha->binfo.memsize / 1024); - len += size; pos = begin + len; - } #ifdef GDTH_DMA_STATISTICS /* controller statistics */ - size = sprintf(buffer+len,"\nController Statistics:\n"); - len += size; pos = begin + len; - size = sprintf(buffer+len, + seq_printf(m,"\nController Statistics:\n"); + seq_printf(m, " 32-bit DMA buffer:\t%lu\t64-bit DMA buffer:\t%lu\n", ha->dma32_cnt, ha->dma64_cnt); - len += size; pos = begin + len; #endif - if (pos < offset) { - len = 0; - begin = pos; - } - if (pos > offset + length) - goto stop_output; - if (ha->more_proc) { /* more information: 2. about physical devices */ - size = sprintf(buffer+len,"\nPhysical Devices:"); - len += size; pos = begin + len; + seq_printf(m, "\nPhysical Devices:"); flag = FALSE; buf = gdth_ioctl_alloc(ha, GDTH_SCRATCH, FALSE, &paddr); @@ -309,21 +273,19 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length, strncpy(hrec+8,pdi->product,16); strncpy(hrec+24,pdi->revision,4); hrec[28] = 0; - size = sprintf(buffer+len, + seq_printf(m, "\n Chn/ID/LUN: \t%c/%02d/%d \tName: \t%s\n", 'A'+i,pdi->target_id,pdi->lun,hrec); - len += size; pos = begin + len; flag = TRUE; pdi->no_ldrive &= 0xffff; if (pdi->no_ldrive == 0xffff) strcpy(hrec,"--"); else sprintf(hrec,"%d",pdi->no_ldrive); - size = sprintf(buffer+len, + seq_printf(m, " Capacity [MB]:\t%-6d \tTo Log. Drive: \t%s\n", pdi->blkcnt/(1024*1024/pdi->blksize), hrec); - len += size; pos = begin + len; } else { pdi->devtype = 0xff; } @@ -333,11 +295,10 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length, for (k = 0; k < pds->count; ++k) { if (pds->list[k].tid == pdi->target_id && pds->list[k].lun == pdi->lun) { - size = sprintf(buffer+len, + seq_printf(m, " Retries: \t%-6d \tReassigns: \t%d\n", pds->list[k].retries, pds->list[k].reassigns); - len += size; pos = begin + len; break; } } @@ -355,32 +316,20 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length, pdef->sddc_type = 0x08; if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) == S_OK) { - size = sprintf(buffer+len, + seq_printf(m, " Grown Defects:\t%d\n", pdef->sddc_cnt); - len += size; pos = begin + len; } } - if (pos < offset) { - len = 0; - begin = pos; - } - if (pos > offset + length) { - gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr); - goto stop_output; - } } } gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr); - if (!flag) { - size = sprintf(buffer+len, "\n --\n"); - len += size; pos = begin + len; - } + if (!flag) + seq_printf(m, "\n --\n"); /* 3. about logical drives */ - size = sprintf(buffer+len,"\nLogical Drives:"); - len += size; pos = begin + len; + seq_printf(m,"\nLogical Drives:"); flag = FALSE; buf = gdth_ioctl_alloc(ha, GDTH_SCRATCH, FALSE, &paddr); @@ -418,10 +367,9 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length, } if (drv_no == i) { - size = sprintf(buffer+len, + seq_printf(m, "\n Number: \t%-2d \tStatus: \t%s\n", drv_no, hrec); - len += size; pos = begin + len; flag = TRUE; no_mdrv = pcdi->cd_ldcnt; if (no_mdrv > 1 || pcdi->ld_slave != -1) { @@ -436,61 +384,37 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length, } else { strcpy(hrec, "???"); } - size = sprintf(buffer+len, + seq_printf(m, " Capacity [MB]:\t%-6d \tType: \t%s\n", pcdi->ld_blkcnt/(1024*1024/pcdi->ld_blksize), hrec); - len += size; pos = begin + len; } else { - size = sprintf(buffer+len, + seq_printf(m, " Slave Number: \t%-2d \tStatus: \t%s\n", drv_no & 0x7fff, hrec); - len += size; pos = begin + len; } drv_no = pcdi->ld_slave; - if (pos < offset) { - len = 0; - begin = pos; - } - if (pos > offset + length) { - gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr); - goto stop_output; - } } while (drv_no != -1); - if (is_mirr) { - size = sprintf(buffer+len, + if (is_mirr) + seq_printf(m, " Missing Drv.: \t%-2d \tInvalid Drv.: \t%d\n", no_mdrv - j - k, k); - len += size; pos = begin + len; - } - + if (!ha->hdr[i].is_arraydrv) strcpy(hrec, "--"); else sprintf(hrec, "%d", ha->hdr[i].master_no); - size = sprintf(buffer+len, + seq_printf(m, " To Array Drv.:\t%s\n", hrec); - len += size; pos = begin + len; - if (pos < offset) { - len = 0; - begin = pos; - } - if (pos > offset + length) { - gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr); - goto stop_output; - } } gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr); - if (!flag) { - size = sprintf(buffer+len, "\n --\n"); - len += size; pos = begin + len; - } + if (!flag) + seq_printf(m, "\n --\n"); /* 4. about array drives */ - size = sprintf(buffer+len,"\nArray Drives:"); - len += size; pos = begin + len; + seq_printf(m,"\nArray Drives:"); flag = FALSE; buf = gdth_ioctl_alloc(ha, GDTH_SCRATCH, FALSE, &paddr); @@ -525,10 +449,9 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length, strcat(hrec, "/expand"); else if (pai->ai_ext_state & 0x1) strcat(hrec, "/patch"); - size = sprintf(buffer+len, + seq_printf(m, "\n Number: \t%-2d \tStatus: \t%s\n", i,hrec); - len += size; pos = begin + len; flag = TRUE; if (pai->ai_type == 0) @@ -539,31 +462,19 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length, strcpy(hrec, "RAID-5"); else strcpy(hrec, "RAID-10"); - size = sprintf(buffer+len, + seq_printf(m, " Capacity [MB]:\t%-6d \tType: \t%s\n", pai->ai_size/(1024*1024/pai->ai_secsize), hrec); - len += size; pos = begin + len; - if (pos < offset) { - len = 0; - begin = pos; - } - if (pos > offset + length) { - gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr); - goto stop_output; - } } } gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr); - if (!flag) { - size = sprintf(buffer+len, "\n --\n"); - len += size; pos = begin + len; - } + if (!flag) + seq_printf(m, "\n --\n"); /* 5. about host drives */ - size = sprintf(buffer+len,"\nHost Drives:"); - len += size; pos = begin + len; + seq_printf(m,"\nHost Drives:"); flag = FALSE; buf = gdth_ioctl_alloc(ha, sizeof(gdth_hget_str), FALSE, &paddr); @@ -605,33 +516,22 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length, if (!(ha->hdr[i].present)) continue; - size = sprintf(buffer+len, + seq_printf(m, "\n Number: \t%-2d \tArr/Log. Drive:\t%d\n", i, ha->hdr[i].ldr_no); - len += size; pos = begin + len; flag = TRUE; - size = sprintf(buffer+len, + seq_printf(m, " Capacity [MB]:\t%-6d \tStart Sector: \t%d\n", (u32)(ha->hdr[i].size/2048), ha->hdr[i].start_sec); - len += size; pos = begin + len; - if (pos < offset) { - len = 0; - begin = pos; - } - if (pos > offset + length) - goto stop_output; } - if (!flag) { - size = sprintf(buffer+len, "\n --\n"); - len += size; pos = begin + len; - } + if (!flag) + seq_printf(m, "\n --\n"); } /* controller events */ - size = sprintf(buffer+len,"\nController Events:\n"); - len += size; pos = begin + len; + seq_printf(m,"\nController Events:\n"); for (id = -1;;) { id = gdth_read_event(ha, id, estr); @@ -643,29 +543,14 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length, do_gettimeofday(&tv); sec = (int)(tv.tv_sec - estr->first_stamp); if (sec < 0) sec = 0; - size = sprintf(buffer+len," date- %02d:%02d:%02d\t%s\n", + seq_printf(m," date- %02d:%02d:%02d\t%s\n", sec/3600, sec%3600/60, sec%60, hrec); - len += size; pos = begin + len; - if (pos < offset) { - len = 0; - begin = pos; - } - if (pos > offset + length) - goto stop_output; } if (id == -1) break; } - stop_output: - *start = buffer +(offset-begin); - len -= (offset-begin); - if (len > length) - len = length; - TRACE2(("get_info() len %d pos %d begin %d offset %d length %d size %d\n", - len,(int)pos,(int)begin,(int)offset,length,size)); - rc = len; - + rc = 0; free_fail: kfree(gdtcmd); kfree(estr); diff --git a/drivers/scsi/gdth_proc.h b/drivers/scsi/gdth_proc.h index dab15f59f2c..aaa61819897 100644 --- a/drivers/scsi/gdth_proc.h +++ b/drivers/scsi/gdth_proc.h @@ -8,11 +8,6 @@ int gdth_execute(struct Scsi_Host *shost, gdth_cmd_str *gdtcmd, char *cmnd, int timeout, u32 *info); -static int gdth_set_info(char *buffer,int length,struct Scsi_Host *host, - gdth_ha_str *ha); -static int gdth_get_info(char *buffer,char **start,off_t offset,int length, - struct Scsi_Host *host, gdth_ha_str *ha); - static int gdth_set_asc_info(struct Scsi_Host *host, char *buffer, int length, gdth_ha_str *ha); -- cgit v1.2.3 From fa5fd36820efdc82fc9ac8ac9bd47ddc2fee3d37 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 00:55:40 -0400 Subject: imm: switch to ->show_info() Signed-off-by: Al Viro --- drivers/scsi/imm.c | 40 +++++++++++----------------------------- 1 file changed, 11 insertions(+), 29 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/imm.c b/drivers/scsi/imm.c index 26cd9d1d757..89a8266560d 100644 --- a/drivers/scsi/imm.c +++ b/drivers/scsi/imm.c @@ -121,45 +121,26 @@ static inline void imm_pb_release(imm_struct *dev) * testing... * Also gives a method to use a script to obtain optimum timings (TODO) */ -static inline int imm_proc_write(imm_struct *dev, char *buffer, int length) +static int imm_write_info(struct Scsi_Host *host, char *buffer, int length) { - unsigned long x; + imm_struct *dev = imm_dev(host); if ((length > 5) && (strncmp(buffer, "mode=", 5) == 0)) { - x = simple_strtoul(buffer + 5, NULL, 0); - dev->mode = x; + dev->mode = simple_strtoul(buffer + 5, NULL, 0); return length; } printk("imm /proc: invalid variable\n"); - return (-EINVAL); + return -EINVAL; } -static int imm_proc_info(struct Scsi_Host *host, char *buffer, char **start, - off_t offset, int length, int inout) +static int imm_show_info(struct seq_file *m, struct Scsi_Host *host) { imm_struct *dev = imm_dev(host); - int len = 0; - - if (inout) - return imm_proc_write(dev, buffer, length); - - len += sprintf(buffer + len, "Version : %s\n", IMM_VERSION); - len += - sprintf(buffer + len, "Parport : %s\n", - dev->dev->port->name); - len += - sprintf(buffer + len, "Mode : %s\n", - IMM_MODE_STRING[dev->mode]); - /* Request for beyond end of buffer */ - if (offset > len) - return 0; - - *start = buffer + offset; - len -= offset; - if (len > length) - len = length; - return len; + seq_printf(m, "Version : %s\n", IMM_VERSION); + seq_printf(m, "Parport : %s\n", dev->dev->port->name); + seq_printf(m, "Mode : %s\n", IMM_MODE_STRING[dev->mode]); + return 0; } #if IMM_DEBUG > 0 @@ -1118,7 +1099,8 @@ static int imm_adjust_queue(struct scsi_device *device) static struct scsi_host_template imm_template = { .module = THIS_MODULE, .proc_name = "imm", - .proc_info = imm_proc_info, + .show_info = imm_show_info, + .write_info = imm_write_info, .name = "Iomega VPI2 (imm) interface", .queuecommand = imm_queuecommand, .eh_abort_handler = imm_abort, -- cgit v1.2.3 From b7654914bb8059a9817f32f4c4d0e7f75a08b78a Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 00:58:31 -0400 Subject: ppa: switch to ->show_info() Signed-off-by: Al Viro --- drivers/scsi/ppa.c | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/ppa.c b/drivers/scsi/ppa.c index d164c963936..1db8b26063b 100644 --- a/drivers/scsi/ppa.c +++ b/drivers/scsi/ppa.c @@ -118,8 +118,9 @@ static inline void ppa_pb_release(ppa_struct *dev) * Also gives a method to use a script to obtain optimum timings (TODO) */ -static inline int ppa_proc_write(ppa_struct *dev, char *buffer, int length) +static inline int ppa_write_info(struct Scsi_Host *host, char *buffer, int length) { + ppa_struct *dev = ppa_dev(host); unsigned long x; if ((length > 5) && (strncmp(buffer, "mode=", 5) == 0)) { @@ -137,35 +138,17 @@ static inline int ppa_proc_write(ppa_struct *dev, char *buffer, int length) return -EINVAL; } -static int ppa_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, int length, int inout) +static int ppa_show_info(struct seq_file *m, struct Scsi_Host *host) { - int len = 0; ppa_struct *dev = ppa_dev(host); - if (inout) - return ppa_proc_write(dev, buffer, length); - - len += sprintf(buffer + len, "Version : %s\n", PPA_VERSION); - len += - sprintf(buffer + len, "Parport : %s\n", - dev->dev->port->name); - len += - sprintf(buffer + len, "Mode : %s\n", - PPA_MODE_STRING[dev->mode]); + seq_printf(m, "Version : %s\n", PPA_VERSION); + seq_printf(m, "Parport : %s\n", dev->dev->port->name); + seq_printf(m, "Mode : %s\n", PPA_MODE_STRING[dev->mode]); #if PPA_DEBUG > 0 - len += - sprintf(buffer + len, "recon_tmo : %lu\n", dev->recon_tmo); + seq_printf(m, "recon_tmo : %lu\n", dev->recon_tmo); #endif - - /* Request for beyond end of buffer */ - if (offset > length) - return 0; - - *start = buffer + offset; - len -= offset; - if (len > length) - len = length; - return len; + return 0; } static int device_check(ppa_struct *dev); @@ -981,7 +964,8 @@ static int ppa_adjust_queue(struct scsi_device *device) static struct scsi_host_template ppa_template = { .module = THIS_MODULE, .proc_name = "ppa", - .proc_info = ppa_proc_info, + .show_info = ppa_show_info, + .write_info = ppa_write_info, .name = "Iomega VPI0 (ppa) interface", .queuecommand = ppa_queuecommand, .eh_abort_handler = ppa_abort, -- cgit v1.2.3 From dd7ab71bb3b4dad7fa1c4fd89706d6870991cfe6 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 01:15:54 -0400 Subject: NCR5830: switch to ->show_info() Signed-off-by: Al Viro --- drivers/scsi/NCR5380.c | 61 ++++++++++++++++++++------------------------- drivers/scsi/NCR5380.h | 6 +++-- drivers/scsi/arm/cumana_1.c | 1 - drivers/scsi/arm/oak.c | 6 +++-- drivers/scsi/dtc.c | 3 ++- drivers/scsi/dtc.h | 3 ++- drivers/scsi/g_NCR5380.c | 51 +++++++++++++++---------------------- drivers/scsi/mac_scsi.c | 3 ++- drivers/scsi/mac_scsi.h | 3 ++- drivers/scsi/pas16.c | 3 ++- drivers/scsi/pas16.h | 3 ++- drivers/scsi/t128.c | 3 ++- drivers/scsi/t128.h | 3 ++- 13 files changed, 71 insertions(+), 78 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c index 450353e04dd..1e9d6ad9302 100644 --- a/drivers/scsi/NCR5380.c +++ b/drivers/scsi/NCR5380.c @@ -695,33 +695,35 @@ static void NCR5380_print_status(struct Scsi_Host *instance) * Return the number of bytes read from or written */ +static int __maybe_unused NCR5380_write_info(struct Scsi_Host *instance, + char *buffer, int length) +{ +#ifdef DTC_PUBLIC_RELEASE + dtc_wmaxi = dtc_maxi = 0; +#endif +#ifdef PAS16_PUBLIC_RELEASE + pas_wmaxi = pas_maxi = 0; +#endif + return (-ENOSYS); /* Currently this is a no-op */ +} + #undef SPRINTF -#define SPRINTF(args...) do { if(pos < buffer + length-80) pos += sprintf(pos, ## args); } while(0) +#define SPRINTF(args...) seq_printf(m, ## args) static -char *lprint_Scsi_Cmnd(Scsi_Cmnd * cmd, char *pos, char *buffer, int length); +void lprint_Scsi_Cmnd(Scsi_Cmnd * cmd, struct seq_file *m); static -char *lprint_command(unsigned char *cmd, char *pos, char *buffer, int len); +void lprint_command(unsigned char *cmd, struct seq_file *m); static -char *lprint_opcode(int opcode, char *pos, char *buffer, int length); +void lprint_opcode(int opcode, struct seq_file *m); -static int __maybe_unused NCR5380_proc_info(struct Scsi_Host *instance, - char *buffer, char **start, off_t offset, int length, int inout) +static int __maybe_unused NCR5380_show_info(struct seq_file *m, + struct Scsi_Host *instance) { - char *pos = buffer; struct NCR5380_hostdata *hostdata; Scsi_Cmnd *ptr; hostdata = (struct NCR5380_hostdata *) instance->hostdata; - if (inout) { /* Has data been written to the file ? */ -#ifdef DTC_PUBLIC_RELEASE - dtc_wmaxi = dtc_maxi = 0; -#endif -#ifdef PAS16_PUBLIC_RELEASE - pas_wmaxi = pas_maxi = 0; -#endif - return (-ENOSYS); /* Currently this is a no-op */ - } SPRINTF("NCR5380 core release=%d. ", NCR5380_PUBLIC_RELEASE); if (((struct NCR5380_hostdata *) instance->hostdata)->flags & FLAG_NCR53C400) SPRINTF("ncr53c400 release=%d. ", NCR53C400_PUBLIC_RELEASE); @@ -755,46 +757,37 @@ static int __maybe_unused NCR5380_proc_info(struct Scsi_Host *instance, if (!hostdata->connected) SPRINTF("scsi%d: no currently connected command\n", instance->host_no); else - pos = lprint_Scsi_Cmnd((Scsi_Cmnd *) hostdata->connected, pos, buffer, length); + lprint_Scsi_Cmnd((Scsi_Cmnd *) hostdata->connected, m); SPRINTF("scsi%d: issue_queue\n", instance->host_no); for (ptr = (Scsi_Cmnd *) hostdata->issue_queue; ptr; ptr = (Scsi_Cmnd *) ptr->host_scribble) - pos = lprint_Scsi_Cmnd(ptr, pos, buffer, length); + lprint_Scsi_Cmnd(ptr, m); SPRINTF("scsi%d: disconnected_queue\n", instance->host_no); for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr; ptr = (Scsi_Cmnd *) ptr->host_scribble) - pos = lprint_Scsi_Cmnd(ptr, pos, buffer, length); + lprint_Scsi_Cmnd(ptr, m); spin_unlock_irq(instance->host_lock); - - *start = buffer; - if (pos - buffer < offset) - return 0; - else if (pos - buffer - offset < length) - return pos - buffer - offset; - return length; + return 0; } -static char *lprint_Scsi_Cmnd(Scsi_Cmnd * cmd, char *pos, char *buffer, int length) +static void lprint_Scsi_Cmnd(Scsi_Cmnd * cmd, struct seq_file *m) { SPRINTF("scsi%d : destination target %d, lun %d\n", cmd->device->host->host_no, cmd->device->id, cmd->device->lun); SPRINTF(" command = "); - pos = lprint_command(cmd->cmnd, pos, buffer, length); - return (pos); + lprint_command(cmd->cmnd, m); } -static char *lprint_command(unsigned char *command, char *pos, char *buffer, int length) +static void lprint_command(unsigned char *command, struct seq_file *m) { int i, s; - pos = lprint_opcode(command[0], pos, buffer, length); + lprint_opcode(command[0], m); for (i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i) SPRINTF("%02x ", command[i]); SPRINTF("\n"); - return (pos); } -static char *lprint_opcode(int opcode, char *pos, char *buffer, int length) +static void lprint_opcode(int opcode, struct seq_file *m) { SPRINTF("%2d (0x%02x)", opcode, opcode); - return (pos); } diff --git a/drivers/scsi/NCR5380.h b/drivers/scsi/NCR5380.h index fd40a32b1f6..14964d0a0e9 100644 --- a/drivers/scsi/NCR5380.h +++ b/drivers/scsi/NCR5380.h @@ -314,8 +314,10 @@ static void NCR5380_print(struct Scsi_Host *instance); static int NCR5380_abort(Scsi_Cmnd * cmd); static int NCR5380_bus_reset(Scsi_Cmnd * cmd); static int NCR5380_queue_command(struct Scsi_Host *, struct scsi_cmnd *); -static int __maybe_unused NCR5380_proc_info(struct Scsi_Host *instance, - char *buffer, char **start, off_t offset, int length, int inout); +static int __maybe_unused NCR5380_show_info(struct seq_file *, + struct Scsi_Host *); +static int __maybe_unused NCR5380_write_info(struct Scsi_Host *instance, + char *buffer, int length); static void NCR5380_reselect(struct Scsi_Host *instance); static int NCR5380_select(struct Scsi_Host *instance, Scsi_Cmnd * cmd, int tag); diff --git a/drivers/scsi/arm/cumana_1.c b/drivers/scsi/arm/cumana_1.c index c93938b246d..b679778376c 100644 --- a/drivers/scsi/arm/cumana_1.c +++ b/drivers/scsi/arm/cumana_1.c @@ -30,7 +30,6 @@ #define NCR5380_write(reg, value) cumanascsi_write(_instance, reg, value) #define NCR5380_intr cumanascsi_intr #define NCR5380_queue_command cumanascsi_queue_command -#define NCR5380_proc_info cumanascsi_proc_info #define NCR5380_implementation_fields \ unsigned ctrl; \ diff --git a/drivers/scsi/arm/oak.c b/drivers/scsi/arm/oak.c index 48facdc1800..4266eef8aca 100644 --- a/drivers/scsi/arm/oak.c +++ b/drivers/scsi/arm/oak.c @@ -31,7 +31,8 @@ #define NCR5380_write(reg, value) writeb(value, _base + ((reg) << 2)) #define NCR5380_intr oakscsi_intr #define NCR5380_queue_command oakscsi_queue_command -#define NCR5380_proc_info oakscsi_proc_info +#define NCR5380_show_info oakscsi_show_info +#define NCR5380_write_info oakscsi_write_info #define NCR5380_implementation_fields \ void __iomem *base @@ -115,7 +116,8 @@ printk("reading %p len %d\n", addr, len); static struct scsi_host_template oakscsi_template = { .module = THIS_MODULE, - .proc_info = oakscsi_proc_info, + .show_info = oakscsi_show_info, + .write_info = oakscsi_write_info, .name = "Oak 16-bit SCSI", .info = oakscsi_info, .queuecommand = oakscsi_queue_command, diff --git a/drivers/scsi/dtc.c b/drivers/scsi/dtc.c index 4b11bb04f5c..d01f0160414 100644 --- a/drivers/scsi/dtc.c +++ b/drivers/scsi/dtc.c @@ -216,7 +216,8 @@ static int __init dtc_detect(struct scsi_host_template * tpnt) int sig, count; tpnt->proc_name = "dtc3x80"; - tpnt->proc_info = &dtc_proc_info; + tpnt->show_info = dtc_show_info; + tpnt->write_info = dtc_write_info; for (count = 0; current_override < NO_OVERRIDES; ++current_override) { addr = 0; diff --git a/drivers/scsi/dtc.h b/drivers/scsi/dtc.h index cdc621204b6..92d7cfc3f4f 100644 --- a/drivers/scsi/dtc.h +++ b/drivers/scsi/dtc.h @@ -88,7 +88,8 @@ static int dtc_bus_reset(Scsi_Cmnd *); #define NCR5380_queue_command dtc_queue_command #define NCR5380_abort dtc_abort #define NCR5380_bus_reset dtc_bus_reset -#define NCR5380_proc_info dtc_proc_info +#define NCR5380_show_info dtc_show_info +#define NCR5380_write_info dtc_write_info /* 15 12 11 10 1001 1100 0000 0000 */ diff --git a/drivers/scsi/g_NCR5380.c b/drivers/scsi/g_NCR5380.c index 5041f925c19..5cec6c60ca2 100644 --- a/drivers/scsi/g_NCR5380.c +++ b/drivers/scsi/g_NCR5380.c @@ -745,42 +745,36 @@ static inline int NCR5380_pwrite(struct Scsi_Host *instance, unsigned char *src, #include "NCR5380.c" -#define PRINTP(x) len += sprintf(buffer+len, x) +#define PRINTP(x) seq_printf(m, x) #define ANDP , -static int sprint_opcode(char *buffer, int len, int opcode) +static void sprint_opcode(struct seq_file *m, int opcode) { - int start = len; PRINTP("0x%02x " ANDP opcode); - return len - start; } -static int sprint_command(char *buffer, int len, unsigned char *command) +static void sprint_command(struct seq_file *m, unsigned char *command) { - int i, s, start = len; - len += sprint_opcode(buffer, len, command[0]); + int i, s; + sprint_opcode(m, command[0]); for (i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i) PRINTP("%02x " ANDP command[i]); PRINTP("\n"); - return len - start; } /** * sprintf_Scsi_Cmnd - print a scsi command - * @buffer: buffr to print into - * @len: buffer length + * @m: seq_fil to print into * @cmd: SCSI command block * * Print out the target and command data in hex */ -static int sprint_Scsi_Cmnd(char *buffer, int len, Scsi_Cmnd * cmd) +static void sprint_Scsi_Cmnd(struct seq_file *m, Scsi_Cmnd * cmd) { - int start = len; PRINTP("host number %d destination target %d, lun %d\n" ANDP cmd->device->host->host_no ANDP cmd->device->id ANDP cmd->device->lun); PRINTP(" command = "); - len += sprint_command(buffer, len, cmd->cmnd); - return len - start; + sprint_command(m, cmd->cmnd); } /** @@ -800,9 +794,8 @@ static int sprint_Scsi_Cmnd(char *buffer, int len, Scsi_Cmnd * cmd) * Locks: global cli/lock for queue walk */ -static int generic_NCR5380_proc_info(struct Scsi_Host *scsi_ptr, char *buffer, char **start, off_t offset, int length, int inout) +static int generic_NCR5380_show_info(struct seq_file *m, struct Scsi_Host *scsi_ptr) { - int len = 0; NCR5380_local_declare(); unsigned long flags; unsigned char status; @@ -853,16 +846,16 @@ static int generic_NCR5380_proc_info(struct Scsi_Host *scsi_ptr, char *buffer, c PRINTP(" T:%d %s " ANDP dev->id ANDP scsi_device_type(dev->type)); for (i = 0; i < 8; i++) if (dev->vendor[i] >= 0x20) - *(buffer + (len++)) = dev->vendor[i]; - *(buffer + (len++)) = ' '; + seq_putc(m, dev->vendor[i]); + seq_putc(m, ' '); for (i = 0; i < 16; i++) if (dev->model[i] >= 0x20) - *(buffer + (len++)) = dev->model[i]; - *(buffer + (len++)) = ' '; + seq_putc(m, dev->model[i]); + seq_putc(m, ' '); for (i = 0; i < 4; i++) if (dev->rev[i] >= 0x20) - *(buffer + (len++)) = dev->rev[i]; - *(buffer + (len++)) = ' '; + seq_putc(m, dev->rev[i]); + seq_putc(m, ' '); PRINTP("\n%10ld kb read in %5ld secs" ANDP br / 1024 ANDP tr); if (tr) @@ -886,32 +879,28 @@ static int generic_NCR5380_proc_info(struct Scsi_Host *scsi_ptr, char *buffer, c if (!hostdata->connected) { PRINTP("No currently connected command\n"); } else { - len += sprint_Scsi_Cmnd(buffer, len, (Scsi_Cmnd *) hostdata->connected); + sprint_Scsi_Cmnd(m, (Scsi_Cmnd *) hostdata->connected); } PRINTP("issue_queue\n"); for (ptr = (Scsi_Cmnd *) hostdata->issue_queue; ptr; ptr = (Scsi_Cmnd *) ptr->host_scribble) - len += sprint_Scsi_Cmnd(buffer, len, ptr); + sprint_Scsi_Cmnd(m, ptr); PRINTP("disconnected_queue\n"); for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr; ptr = (Scsi_Cmnd *) ptr->host_scribble) - len += sprint_Scsi_Cmnd(buffer, len, ptr); + sprint_Scsi_Cmnd(m, ptr); - *start = buffer + offset; - len -= offset; - if (len > length) - len = length; spin_unlock_irqrestore(scsi_ptr->host_lock, flags); - return len; + return 0; } #undef PRINTP #undef ANDP static struct scsi_host_template driver_template = { - .proc_info = generic_NCR5380_proc_info, + .show_info = generic_NCR5380_show_info, .name = "Generic NCR5380/NCR53C400 Scsi Driver", .detect = generic_NCR5380_detect, .release = generic_NCR5380_release_resources, diff --git a/drivers/scsi/mac_scsi.c b/drivers/scsi/mac_scsi.c index 24828b54773..858075723c8 100644 --- a/drivers/scsi/mac_scsi.c +++ b/drivers/scsi/mac_scsi.c @@ -561,7 +561,8 @@ static int macscsi_pwrite (struct Scsi_Host *instance, static struct scsi_host_template driver_template = { .proc_name = "Mac5380", - .proc_info = macscsi_proc_info, + .show_info = macscsi_show_info, + .write_info = macscsi_write_info, .name = "Macintosh NCR5380 SCSI", .detect = macscsi_detect, .release = macscsi_release, diff --git a/drivers/scsi/mac_scsi.h b/drivers/scsi/mac_scsi.h index d26e331c6c1..7dc62fce1c4 100644 --- a/drivers/scsi/mac_scsi.h +++ b/drivers/scsi/mac_scsi.h @@ -72,7 +72,8 @@ #define NCR5380_queue_command macscsi_queue_command #define NCR5380_abort macscsi_abort #define NCR5380_bus_reset macscsi_bus_reset -#define NCR5380_proc_info macscsi_proc_info +#define NCR5380_show_info macscsi_show_info +#define NCR5380_write_info macscsi_write_info #define BOARD_NORMAL 0 #define BOARD_NCR53C400 1 diff --git a/drivers/scsi/pas16.c b/drivers/scsi/pas16.c index 2f72c9807b1..62f1a603176 100644 --- a/drivers/scsi/pas16.c +++ b/drivers/scsi/pas16.c @@ -388,7 +388,8 @@ int __init pas16_detect(struct scsi_host_template * tpnt) int count; tpnt->proc_name = "pas16"; - tpnt->proc_info = &pas16_proc_info; + tpnt->show_info = pas16_show_info; + tpnt->write_info = pas16_write_info; if (pas16_addr != 0) { overrides[0].io_port = pas16_addr; diff --git a/drivers/scsi/pas16.h b/drivers/scsi/pas16.h index a04281cace2..3721342835e 100644 --- a/drivers/scsi/pas16.h +++ b/drivers/scsi/pas16.h @@ -163,7 +163,8 @@ static int pas16_bus_reset(Scsi_Cmnd *); #define NCR5380_queue_command pas16_queue_command #define NCR5380_abort pas16_abort #define NCR5380_bus_reset pas16_bus_reset -#define NCR5380_proc_info pas16_proc_info +#define NCR5380_show_info pas16_show_info +#define NCR5380_write_info pas16_write_info /* 15 14 12 10 7 5 3 1101 0100 1010 1000 */ diff --git a/drivers/scsi/t128.c b/drivers/scsi/t128.c index d672d97fb84..f1e4b4148c7 100644 --- a/drivers/scsi/t128.c +++ b/drivers/scsi/t128.c @@ -201,7 +201,8 @@ int __init t128_detect(struct scsi_host_template * tpnt){ int sig, count; tpnt->proc_name = "t128"; - tpnt->proc_info = &t128_proc_info; + tpnt->show_info = t128_show_info; + tpnt->write_info = t128_write_info; for (count = 0; current_override < NO_OVERRIDES; ++current_override) { base = 0; diff --git a/drivers/scsi/t128.h b/drivers/scsi/t128.h index ada1115079c..1df82c28e56 100644 --- a/drivers/scsi/t128.h +++ b/drivers/scsi/t128.h @@ -140,7 +140,8 @@ static int t128_bus_reset(struct scsi_cmnd *); #define NCR5380_queue_command t128_queue_command #define NCR5380_abort t128_abort #define NCR5380_bus_reset t128_bus_reset -#define NCR5380_proc_info t128_proc_info +#define NCR5380_show_info t128_show_info +#define NCR5380_write_info t128_write_info /* 15 14 12 10 7 5 3 1101 0100 1010 1000 */ -- cgit v1.2.3 From 09dae7fc57a010288875ef46a44e30d16cedd232 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 01:37:13 -0400 Subject: usb-storage: switch to ->show_info() Signed-off-by: Al Viro --- drivers/usb/storage/scsiglue.c | 42 ++++++++++++++---------------------------- 1 file changed, 14 insertions(+), 28 deletions(-) (limited to 'drivers') diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c index 92f35abee92..615c66eaede 100644 --- a/drivers/usb/storage/scsiglue.c +++ b/drivers/usb/storage/scsiglue.c @@ -438,22 +438,21 @@ void usb_stor_report_bus_reset(struct us_data *us) * /proc/scsi/ functions ***********************************************************************/ +static int write_info(struct Scsi_Host *host, char *buffer, int length) +{ + /* if someone is sending us data, just throw it away */ + return length; +} + /* 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) -static int proc_info (struct Scsi_Host *host, char *buffer, - char **start, off_t offset, int length, int inout) +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; - /* if someone is sending us data, just throw it away */ - if (inout) - return length; - /* print the controller name */ SPRINTF(" Host scsi%d: usb-storage\n", host->host_no); @@ -483,28 +482,14 @@ static int proc_info (struct Scsi_Host *host, char *buffer, 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) \ - if (us->fflags & value) pos += sprintf(pos, " " #name); + if (us->fflags & value) seq_printf(m, " " #name); 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; } /*********************************************************************** @@ -549,7 +534,8 @@ struct scsi_host_template usb_stor_host_template = { /* basic userland interface stuff */ .name = "usb-storage", .proc_name = "usb-storage", - .proc_info = proc_info, + .show_info = show_info, + .write_info = write_info, .info = host_info, /* command interface -- queued only */ -- cgit v1.2.3 From cac197031ce274efff8a5abea811b9d69ae3d740 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 01:42:38 -0400 Subject: fusion: switch to ->show_info() Signed-off-by: Al Viro --- drivers/message/fusion/mptfc.c | 2 +- drivers/message/fusion/mptsas.c | 2 +- drivers/message/fusion/mptscsih.c | 98 +++------------------------------------ drivers/message/fusion/mptscsih.h | 2 +- drivers/message/fusion/mptspi.c | 2 +- 5 files changed, 11 insertions(+), 95 deletions(-) (limited to 'drivers') diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c index c13cd9bc590..fd75108c355 100644 --- a/drivers/message/fusion/mptfc.c +++ b/drivers/message/fusion/mptfc.c @@ -109,7 +109,7 @@ static int mptfc_host_reset(struct scsi_cmnd *SCpnt); static struct scsi_host_template mptfc_driver_template = { .module = THIS_MODULE, .proc_name = "mptfc", - .proc_info = mptscsih_proc_info, + .show_info = mptscsih_show_info, .name = "MPT FC Host", .info = mptscsih_info, .queuecommand = mptfc_qcmd, diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c index fa43c391c8e..ffee6f781e3 100644 --- a/drivers/message/fusion/mptsas.c +++ b/drivers/message/fusion/mptsas.c @@ -1977,7 +1977,7 @@ done: static struct scsi_host_template mptsas_driver_template = { .module = THIS_MODULE, .proc_name = "mptsas", - .proc_info = mptscsih_proc_info, + .show_info = mptscsih_show_info, .name = "MPT SAS Host", .info = mptscsih_info, .queuecommand = mptsas_qcmd, diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c index 164afa71bba..727819cc703 100644 --- a/drivers/message/fusion/mptscsih.c +++ b/drivers/message/fusion/mptscsih.c @@ -1284,101 +1284,17 @@ mptscsih_info(struct Scsi_Host *SChost) return h->info_kbuf; } -struct info_str { - char *buffer; - int length; - int offset; - int pos; -}; - -static void -mptscsih_copy_mem_info(struct info_str *info, char *data, int len) -{ - if (info->pos + len > info->length) - len = info->length - info->pos; - - if (info->pos + len < info->offset) { - info->pos += len; - return; - } - - if (info->pos < info->offset) { - data += (info->offset - info->pos); - len -= (info->offset - info->pos); - } - - if (len > 0) { - memcpy(info->buffer + info->pos, data, len); - info->pos += len; - } -} - -static int -mptscsih_copy_info(struct info_str *info, char *fmt, ...) -{ - va_list args; - char buf[81]; - int len; - - va_start(args, fmt); - len = vsprintf(buf, fmt, args); - va_end(args); - - mptscsih_copy_mem_info(info, buf, len); - return len; -} - -static int -mptscsih_host_info(MPT_ADAPTER *ioc, char *pbuf, off_t offset, int len) -{ - struct info_str info; - - info.buffer = pbuf; - info.length = len; - info.offset = offset; - info.pos = 0; - - mptscsih_copy_info(&info, "%s: %s, ", ioc->name, ioc->prod_name); - mptscsih_copy_info(&info, "%s%08xh, ", MPT_FW_REV_MAGIC_ID_STRING, ioc->facts.FWVersion.Word); - mptscsih_copy_info(&info, "Ports=%d, ", ioc->facts.NumberOfPorts); - mptscsih_copy_info(&info, "MaxQ=%d\n", ioc->req_depth); - - return ((info.pos > info.offset) ? info.pos - info.offset : 0); -} - -/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ -/** - * mptscsih_proc_info - Return information about MPT adapter - * @host: scsi host struct - * @buffer: if write, user data; if read, buffer for user - * @start: returns the buffer address - * @offset: if write, 0; if read, the current offset into the buffer from - * the previous read. - * @length: if write, return length; - * @func: write = 1; read = 0 - * - * (linux scsi_host_template.info routine) - */ -int -mptscsih_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, - int length, int func) +int mptscsih_show_info(struct seq_file *m, struct Scsi_Host *host) { MPT_SCSI_HOST *hd = shost_priv(host); MPT_ADAPTER *ioc = hd->ioc; - int size = 0; - if (func) { - /* - * write is not supported - */ - } else { - if (start) - *start = buffer; - - size = mptscsih_host_info(ioc, buffer, offset, length); - } + seq_printf(m, "%s: %s, ", ioc->name, ioc->prod_name); + seq_printf(m, "%s%08xh, ", MPT_FW_REV_MAGIC_ID_STRING, ioc->facts.FWVersion.Word); + seq_printf(m, "Ports=%d, ", ioc->facts.NumberOfPorts); + seq_printf(m, "MaxQ=%d\n", ioc->req_depth); - return size; + return 0; } /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ @@ -3348,7 +3264,7 @@ EXPORT_SYMBOL(mptscsih_shutdown); EXPORT_SYMBOL(mptscsih_suspend); EXPORT_SYMBOL(mptscsih_resume); #endif -EXPORT_SYMBOL(mptscsih_proc_info); +EXPORT_SYMBOL(mptscsih_show_info); EXPORT_SYMBOL(mptscsih_info); EXPORT_SYMBOL(mptscsih_qcmd); EXPORT_SYMBOL(mptscsih_slave_destroy); diff --git a/drivers/message/fusion/mptscsih.h b/drivers/message/fusion/mptscsih.h index 43e75ff3992..83f503162f7 100644 --- a/drivers/message/fusion/mptscsih.h +++ b/drivers/message/fusion/mptscsih.h @@ -111,7 +111,7 @@ extern void mptscsih_shutdown(struct pci_dev *); extern int mptscsih_suspend(struct pci_dev *pdev, pm_message_t state); extern int mptscsih_resume(struct pci_dev *pdev); #endif -extern int mptscsih_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, int length, int func); +extern int mptscsih_show_info(struct seq_file *, struct Scsi_Host *); extern const char * mptscsih_info(struct Scsi_Host *SChost); extern int mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)); extern int mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c index c3aabde2dc4..5653e505f91 100644 --- a/drivers/message/fusion/mptspi.c +++ b/drivers/message/fusion/mptspi.c @@ -831,7 +831,7 @@ static void mptspi_slave_destroy(struct scsi_device *sdev) static struct scsi_host_template mptspi_driver_template = { .module = THIS_MODULE, .proc_name = "mptspi", - .proc_info = mptscsih_proc_info, + .show_info = mptscsih_show_info, .name = "MPT SPI Host", .info = mptscsih_info, .queuecommand = mptspi_qcmd, -- cgit v1.2.3 From c8ed555aba11236ff973fa937f38d5af87bfb18e Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 01:46:06 -0400 Subject: scsi_debug: switch to ->show_info() Signed-off-by: Al Viro --- drivers/scsi/scsi_debug.c | 53 +++++++++++++++++++---------------------------- 1 file changed, 21 insertions(+), 32 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 5cda11c07c6..5add6f4e792 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -2823,31 +2823,27 @@ static const char * scsi_debug_info(struct Scsi_Host * shp) /* scsi_debug_proc_info * Used if the driver currently has no own support for /proc/scsi */ -static int scsi_debug_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, - int length, int inout) +static int scsi_debug_write_info(struct Scsi_Host *host, char *buffer, int length) { - int len, pos, begin; - int orig_length; + char arr[16]; + int opts; + int minLen = length > 15 ? 15 : length; - orig_length = length; - - if (inout == 1) { - char arr[16]; - int minLen = length > 15 ? 15 : length; + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) + return -EACCES; + memcpy(arr, buffer, minLen); + arr[minLen] = '\0'; + if (1 != sscanf(arr, "%d", &opts)) + return -EINVAL; + scsi_debug_opts = opts; + if (scsi_debug_every_nth != 0) + scsi_debug_cmnd_count = 0; + return length; +} - if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) - return -EACCES; - memcpy(arr, buffer, minLen); - arr[minLen] = '\0'; - if (1 != sscanf(arr, "%d", &pos)) - return -EINVAL; - scsi_debug_opts = pos; - if (scsi_debug_every_nth != 0) - scsi_debug_cmnd_count = 0; - return length; - } - begin = 0; - pos = len = sprintf(buffer, "scsi_debug adapter driver, version " +static int scsi_debug_show_info(struct seq_file *m, struct Scsi_Host *host) +{ + seq_printf(m, "scsi_debug adapter driver, version " "%s [%s]\n" "num_tgts=%d, shared (ram) size=%d MB, opts=0x%x, " "every_nth=%d(curr:%d)\n" @@ -2862,15 +2858,7 @@ static int scsi_debug_proc_info(struct Scsi_Host *host, char *buffer, char **sta scsi_debug_sector_size, sdebug_cylinders_per, sdebug_heads, sdebug_sectors_per, num_aborts, num_dev_resets, num_bus_resets, num_host_resets, dix_reads, dix_writes, dif_errors); - if (pos < offset) { - len = 0; - begin = pos; - } - *start = buffer + (offset - begin); /* Start of wanted data */ - len -= (offset - begin); - if (len > length) - len = length; - return len; + return 0; } static ssize_t sdebug_delay_show(struct device_driver * ddp, char * buf) @@ -3957,7 +3945,8 @@ write: static DEF_SCSI_QCMD(scsi_debug_queuecommand) static struct scsi_host_template sdebug_driver_template = { - .proc_info = scsi_debug_proc_info, + .show_info = scsi_debug_show_info, + .write_info = scsi_debug_write_info, .proc_name = sdebug_proc_name, .name = "SCSI DEBUG", .info = scsi_debug_info, -- cgit v1.2.3 From 25daa96f2bf72901c3abe664e5b461f29bbf3282 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 01:52:13 -0400 Subject: BusLogic: switch to ->show_info() Signed-off-by: Al Viro --- drivers/scsi/BusLogic.c | 83 ++++++++++++++++++++++--------------------------- drivers/scsi/BusLogic.h | 1 - 2 files changed, 38 insertions(+), 46 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c index d7ca247efa3..344d87599cd 100644 --- a/drivers/scsi/BusLogic.c +++ b/drivers/scsi/BusLogic.c @@ -3201,26 +3201,30 @@ static int BusLogic_BIOSDiskParameters(struct scsi_device *sdev, struct block_de BugLogic_ProcDirectoryInfo implements /proc/scsi/BusLogic/. */ -static int BusLogic_ProcDirectoryInfo(struct Scsi_Host *shost, char *ProcBuffer, char **StartPointer, off_t Offset, int BytesAvailable, int WriteFlag) +static int BusLogic_write_info(struct Scsi_Host *shost, char *ProcBuffer, int BytesAvailable) { struct BusLogic_HostAdapter *HostAdapter = (struct BusLogic_HostAdapter *) shost->hostdata; struct BusLogic_TargetStatistics *TargetStatistics; - int TargetID, Length; - char *Buffer; TargetStatistics = HostAdapter->TargetStatistics; - if (WriteFlag) { - HostAdapter->ExternalHostAdapterResets = 0; - HostAdapter->HostAdapterInternalErrors = 0; - memset(TargetStatistics, 0, BusLogic_MaxTargetDevices * sizeof(struct BusLogic_TargetStatistics)); - return 0; - } - Buffer = HostAdapter->MessageBuffer; - Length = HostAdapter->MessageBufferLength; - Length += sprintf(&Buffer[Length], "\n\ + HostAdapter->ExternalHostAdapterResets = 0; + HostAdapter->HostAdapterInternalErrors = 0; + memset(TargetStatistics, 0, BusLogic_MaxTargetDevices * sizeof(struct BusLogic_TargetStatistics)); + return 0; +} + +static int BusLogic_show_info(struct seq_file *m, struct Scsi_Host *shost) +{ + struct BusLogic_HostAdapter *HostAdapter = (struct BusLogic_HostAdapter *) shost->hostdata; + struct BusLogic_TargetStatistics *TargetStatistics; + int TargetID; + + TargetStatistics = HostAdapter->TargetStatistics; + seq_write(m, HostAdapter->MessageBuffer, HostAdapter->MessageBufferLength); + seq_printf(m, "\n\ Current Driver Queue Depth: %d\n\ Currently Allocated CCBs: %d\n", HostAdapter->DriverQueueDepth, HostAdapter->AllocatedCCBs); - Length += sprintf(&Buffer[Length], "\n\n\ + seq_printf(m, "\n\n\ DATA TRANSFER STATISTICS\n\ \n\ Target Tagged Queuing Queue Depth Active Attempted Completed\n\ @@ -3229,66 +3233,62 @@ Target Tagged Queuing Queue Depth Active Attempted Completed\n\ struct BusLogic_TargetFlags *TargetFlags = &HostAdapter->TargetFlags[TargetID]; if (!TargetFlags->TargetExists) continue; - Length += sprintf(&Buffer[Length], " %2d %s", TargetID, (TargetFlags->TaggedQueuingSupported ? (TargetFlags->TaggedQueuingActive ? " Active" : (HostAdapter->TaggedQueuingPermitted & (1 << TargetID) + seq_printf(m, " %2d %s", TargetID, (TargetFlags->TaggedQueuingSupported ? (TargetFlags->TaggedQueuingActive ? " Active" : (HostAdapter->TaggedQueuingPermitted & (1 << TargetID) ? " Permitted" : " Disabled")) : "Not Supported")); - Length += sprintf(&Buffer[Length], + seq_printf(m, " %3d %3u %9u %9u\n", HostAdapter->QueueDepth[TargetID], HostAdapter->ActiveCommands[TargetID], TargetStatistics[TargetID].CommandsAttempted, TargetStatistics[TargetID].CommandsCompleted); } - Length += sprintf(&Buffer[Length], "\n\ + seq_printf(m, "\n\ Target Read Commands Write Commands Total Bytes Read Total Bytes Written\n\ ====== ============= ============== =================== ===================\n"); for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++) { struct BusLogic_TargetFlags *TargetFlags = &HostAdapter->TargetFlags[TargetID]; if (!TargetFlags->TargetExists) continue; - Length += sprintf(&Buffer[Length], " %2d %9u %9u", TargetID, TargetStatistics[TargetID].ReadCommands, TargetStatistics[TargetID].WriteCommands); + seq_printf(m, " %2d %9u %9u", TargetID, TargetStatistics[TargetID].ReadCommands, TargetStatistics[TargetID].WriteCommands); if (TargetStatistics[TargetID].TotalBytesRead.Billions > 0) - Length += sprintf(&Buffer[Length], " %9u%09u", TargetStatistics[TargetID].TotalBytesRead.Billions, TargetStatistics[TargetID].TotalBytesRead.Units); + seq_printf(m, " %9u%09u", TargetStatistics[TargetID].TotalBytesRead.Billions, TargetStatistics[TargetID].TotalBytesRead.Units); else - Length += sprintf(&Buffer[Length], " %9u", TargetStatistics[TargetID].TotalBytesRead.Units); + seq_printf(m, " %9u", TargetStatistics[TargetID].TotalBytesRead.Units); if (TargetStatistics[TargetID].TotalBytesWritten.Billions > 0) - Length += sprintf(&Buffer[Length], " %9u%09u\n", TargetStatistics[TargetID].TotalBytesWritten.Billions, TargetStatistics[TargetID].TotalBytesWritten.Units); + seq_printf(m, " %9u%09u\n", TargetStatistics[TargetID].TotalBytesWritten.Billions, TargetStatistics[TargetID].TotalBytesWritten.Units); else - Length += sprintf(&Buffer[Length], " %9u\n", TargetStatistics[TargetID].TotalBytesWritten.Units); + seq_printf(m, " %9u\n", TargetStatistics[TargetID].TotalBytesWritten.Units); } - Length += sprintf(&Buffer[Length], "\n\ + seq_printf(m, "\n\ Target Command 0-1KB 1-2KB 2-4KB 4-8KB 8-16KB\n\ ====== ======= ========= ========= ========= ========= =========\n"); for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++) { struct BusLogic_TargetFlags *TargetFlags = &HostAdapter->TargetFlags[TargetID]; if (!TargetFlags->TargetExists) continue; - Length += - sprintf(&Buffer[Length], + seq_printf(m, " %2d Read %9u %9u %9u %9u %9u\n", TargetID, TargetStatistics[TargetID].ReadCommandSizeBuckets[0], TargetStatistics[TargetID].ReadCommandSizeBuckets[1], TargetStatistics[TargetID].ReadCommandSizeBuckets[2], TargetStatistics[TargetID].ReadCommandSizeBuckets[3], TargetStatistics[TargetID].ReadCommandSizeBuckets[4]); - Length += - sprintf(&Buffer[Length], + seq_printf(m, " %2d Write %9u %9u %9u %9u %9u\n", TargetID, TargetStatistics[TargetID].WriteCommandSizeBuckets[0], TargetStatistics[TargetID].WriteCommandSizeBuckets[1], TargetStatistics[TargetID].WriteCommandSizeBuckets[2], TargetStatistics[TargetID].WriteCommandSizeBuckets[3], TargetStatistics[TargetID].WriteCommandSizeBuckets[4]); } - Length += sprintf(&Buffer[Length], "\n\ + seq_printf(m, "\n\ Target Command 16-32KB 32-64KB 64-128KB 128-256KB 256KB+\n\ ====== ======= ========= ========= ========= ========= =========\n"); for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++) { struct BusLogic_TargetFlags *TargetFlags = &HostAdapter->TargetFlags[TargetID]; if (!TargetFlags->TargetExists) continue; - Length += - sprintf(&Buffer[Length], + seq_printf(m, " %2d Read %9u %9u %9u %9u %9u\n", TargetID, TargetStatistics[TargetID].ReadCommandSizeBuckets[5], TargetStatistics[TargetID].ReadCommandSizeBuckets[6], TargetStatistics[TargetID].ReadCommandSizeBuckets[7], TargetStatistics[TargetID].ReadCommandSizeBuckets[8], TargetStatistics[TargetID].ReadCommandSizeBuckets[9]); - Length += - sprintf(&Buffer[Length], + seq_printf(m, " %2d Write %9u %9u %9u %9u %9u\n", TargetID, TargetStatistics[TargetID].WriteCommandSizeBuckets[5], TargetStatistics[TargetID].WriteCommandSizeBuckets[6], TargetStatistics[TargetID].WriteCommandSizeBuckets[7], TargetStatistics[TargetID].WriteCommandSizeBuckets[8], TargetStatistics[TargetID].WriteCommandSizeBuckets[9]); } - Length += sprintf(&Buffer[Length], "\n\n\ + seq_printf(m, "\n\n\ ERROR RECOVERY STATISTICS\n\ \n\ Command Aborts Bus Device Resets Host Adapter Resets\n\ @@ -3299,20 +3299,12 @@ Target Requested Completed Requested Completed Requested Completed\n\ struct BusLogic_TargetFlags *TargetFlags = &HostAdapter->TargetFlags[TargetID]; if (!TargetFlags->TargetExists) continue; - Length += sprintf(&Buffer[Length], "\ + seq_printf(m, "\ %2d %5d %5d %5d %5d %5d %5d %5d %5d %5d\n", TargetID, TargetStatistics[TargetID].CommandAbortsRequested, TargetStatistics[TargetID].CommandAbortsAttempted, TargetStatistics[TargetID].CommandAbortsCompleted, TargetStatistics[TargetID].BusDeviceResetsRequested, TargetStatistics[TargetID].BusDeviceResetsAttempted, TargetStatistics[TargetID].BusDeviceResetsCompleted, TargetStatistics[TargetID].HostAdapterResetsRequested, TargetStatistics[TargetID].HostAdapterResetsAttempted, TargetStatistics[TargetID].HostAdapterResetsCompleted); } - Length += sprintf(&Buffer[Length], "\nExternal Host Adapter Resets: %d\n", HostAdapter->ExternalHostAdapterResets); - Length += sprintf(&Buffer[Length], "Host Adapter Internal Errors: %d\n", HostAdapter->HostAdapterInternalErrors); - if (Length >= BusLogic_MessageBufferSize) - BusLogic_Error("Message Buffer length %d exceeds size %d\n", HostAdapter, Length, BusLogic_MessageBufferSize); - if ((Length -= Offset) <= 0) - return 0; - if (Length >= BytesAvailable) - Length = BytesAvailable; - memcpy(ProcBuffer, HostAdapter->MessageBuffer + Offset, Length); - *StartPointer = ProcBuffer; - return Length; + seq_printf(m, "\nExternal Host Adapter Resets: %d\n", HostAdapter->ExternalHostAdapterResets); + seq_printf(m, "Host Adapter Internal Errors: %d\n", HostAdapter->HostAdapterInternalErrors); + return 0; } @@ -3566,7 +3558,8 @@ static int __init BusLogic_ParseDriverOptions(char *OptionsString) static struct scsi_host_template Bus_Logic_template = { .module = THIS_MODULE, .proc_name = "BusLogic", - .proc_info = BusLogic_ProcDirectoryInfo, + .write_info = BusLogic_write_info, + .show_info = BusLogic_show_info, .name = "BusLogic", .info = BusLogic_DriverInfo, .queuecommand = BusLogic_QueueCommand, diff --git a/drivers/scsi/BusLogic.h b/drivers/scsi/BusLogic.h index 649fcb31f26..6c6c13c3be1 100644 --- a/drivers/scsi/BusLogic.h +++ b/drivers/scsi/BusLogic.h @@ -1321,7 +1321,6 @@ static inline void BusLogic_IncrementSizeBucket(BusLogic_CommandSizeBuckets_T Co static const char *BusLogic_DriverInfo(struct Scsi_Host *); static int BusLogic_QueueCommand(struct Scsi_Host *h, struct scsi_cmnd *); static int BusLogic_BIOSDiskParameters(struct scsi_device *, struct block_device *, sector_t, int *); -static int BusLogic_ProcDirectoryInfo(struct Scsi_Host *, char *, char **, off_t, int, int); static int BusLogic_SlaveConfigure(struct scsi_device *); static void BusLogic_QueueCompletedCCB(struct BusLogic_CCB *); static irqreturn_t BusLogic_InterruptHandler(int, void *); -- cgit v1.2.3 From e88b7bb002e8f53a02fcdf8aab9915ce1ec22940 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 02:00:06 -0400 Subject: cciss: switch to ->show_info() Signed-off-by: Al Viro --- drivers/block/cciss_scsi.c | 96 ++++++++++++++++++++++------------------------ 1 file changed, 45 insertions(+), 51 deletions(-) (limited to 'drivers') diff --git a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c index da3311129a0..ecd845cd28d 100644 --- a/drivers/block/cciss_scsi.c +++ b/drivers/block/cciss_scsi.c @@ -54,13 +54,11 @@ static CommandList_struct *cmd_special_alloc(ctlr_info_t *h); static void cmd_free(ctlr_info_t *h, CommandList_struct *c); static void cmd_special_free(ctlr_info_t *h, CommandList_struct *c); -static int cciss_scsi_proc_info( - struct Scsi_Host *sh, +static int cciss_scsi_write_info(struct Scsi_Host *sh, char *buffer, /* data buffer */ - char **start, /* where data in buffer starts */ - off_t offset, /* offset from start of imaginary file */ - int length, /* length of data in buffer */ - int func); /* 0 == read, 1 == write */ + int length); /* length of data in buffer */ +static int cciss_scsi_show_info(struct seq_file *m, + struct Scsi_Host *sh); static int cciss_scsi_queue_command (struct Scsi_Host *h, struct scsi_cmnd *cmd); @@ -82,7 +80,8 @@ static struct scsi_host_template cciss_driver_template = { .module = THIS_MODULE, .name = "cciss", .proc_name = "cciss", - .proc_info = cciss_scsi_proc_info, + .write_info = cciss_scsi_write_info, + .show_info = cciss_scsi_show_info, .queuecommand = cciss_scsi_queue_command, .this_id = 7, .cmd_per_lun = 1, @@ -1302,59 +1301,54 @@ cciss_scsi_user_command(ctlr_info_t *h, int hostno, char *buffer, int length) return length; } - static int -cciss_scsi_proc_info(struct Scsi_Host *sh, +cciss_scsi_write_info(struct Scsi_Host *sh, char *buffer, /* data buffer */ - char **start, /* where data in buffer starts */ - off_t offset, /* offset from start of imaginary file */ - int length, /* length of data in buffer */ - int func) /* 0 == read, 1 == write */ + int length) /* length of data in buffer */ { + ctlr_info_t *h = (ctlr_info_t *) sh->hostdata[0]; + if (h == NULL) /* This really shouldn't ever happen. */ + return -EINVAL; - int buflen, datalen; - ctlr_info_t *h; + return cciss_scsi_user_command(h, sh->host_no, + buffer, length); +} + +static int +cciss_scsi_show_info(struct seq_file *m, struct Scsi_Host *sh) +{ + + ctlr_info_t *h = (ctlr_info_t *) sh->hostdata[0]; int i; - h = (ctlr_info_t *) sh->hostdata[0]; if (h == NULL) /* This really shouldn't ever happen. */ return -EINVAL; - if (func == 0) { /* User is reading from /proc/scsi/ciss*?/?* */ - buflen = sprintf(buffer, "cciss%d: SCSI host: %d\n", - h->ctlr, sh->host_no); - - /* this information is needed by apps to know which cciss - device corresponds to which scsi host number without - having to open a scsi target device node. The device - information is not a duplicate of /proc/scsi/scsi because - the two may be out of sync due to scsi hotplug, rather - this info is for an app to be able to use to know how to - get them back in sync. */ - - for (i = 0; i < ccissscsi[h->ctlr].ndevices; i++) { - struct cciss_scsi_dev_t *sd = - &ccissscsi[h->ctlr].dev[i]; - buflen += sprintf(&buffer[buflen], "c%db%dt%dl%d %02d " - "0x%02x%02x%02x%02x%02x%02x%02x%02x\n", - sh->host_no, sd->bus, sd->target, sd->lun, - sd->devtype, - sd->scsi3addr[0], sd->scsi3addr[1], - sd->scsi3addr[2], sd->scsi3addr[3], - sd->scsi3addr[4], sd->scsi3addr[5], - sd->scsi3addr[6], sd->scsi3addr[7]); - } - datalen = buflen - offset; - if (datalen < 0) { /* they're reading past EOF. */ - datalen = 0; - *start = buffer+buflen; - } else - *start = buffer + offset; - return(datalen); - } else /* User is writing to /proc/scsi/cciss*?/?* ... */ - return cciss_scsi_user_command(h, sh->host_no, - buffer, length); -} + seq_printf(m, "cciss%d: SCSI host: %d\n", + h->ctlr, sh->host_no); + + /* this information is needed by apps to know which cciss + device corresponds to which scsi host number without + having to open a scsi target device node. The device + information is not a duplicate of /proc/scsi/scsi because + the two may be out of sync due to scsi hotplug, rather + this info is for an app to be able to use to know how to + get them back in sync. */ + + for (i = 0; i < ccissscsi[h->ctlr].ndevices; i++) { + struct cciss_scsi_dev_t *sd = + &ccissscsi[h->ctlr].dev[i]; + seq_printf(m, "c%db%dt%dl%d %02d " + "0x%02x%02x%02x%02x%02x%02x%02x%02x\n", + sh->host_no, sd->bus, sd->target, sd->lun, + sd->devtype, + sd->scsi3addr[0], sd->scsi3addr[1], + sd->scsi3addr[2], sd->scsi3addr[3], + sd->scsi3addr[4], sd->scsi3addr[5], + sd->scsi3addr[6], sd->scsi3addr[7]); + } + return 0; +} /* cciss_scatter_gather takes a struct scsi_cmnd, (cmd), and does the pci dma mapping and fills in the scatter gather entries of the -- cgit v1.2.3 From 8946b077ca385a6f93b32d9a5aa6b5bb966b475d Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 02:01:55 -0400 Subject: tcm: switch to ->show_info() Signed-off-by: Al Viro --- drivers/target/loopback/tcm_loop.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c index 2d444b1ccd3..7c908141cc8 100644 --- a/drivers/target/loopback/tcm_loop.c +++ b/drivers/target/loopback/tcm_loop.c @@ -79,11 +79,10 @@ static void tcm_loop_release_cmd(struct se_cmd *se_cmd) kmem_cache_free(tcm_loop_cmd_cache, tl_cmd); } -static int tcm_loop_proc_info(struct Scsi_Host *host, char *buffer, - char **start, off_t offset, - int length, int inout) +static int tcm_loop_show_info(struct seq_file *m, struct Scsi_Host *host) { - return sprintf(buffer, "tcm_loop_proc_info()\n"); + seq_printf(m, "tcm_loop_proc_info()\n"); + return 0; } static int tcm_loop_driver_probe(struct device *); @@ -336,7 +335,7 @@ static int tcm_loop_slave_configure(struct scsi_device *sd) } static struct scsi_host_template tcm_loop_driver_template = { - .proc_info = tcm_loop_proc_info, + .show_info = tcm_loop_show_info, .proc_name = "tcm_loopback", .name = "TCM_Loopback", .queuecommand = tcm_loop_queuecommand, -- cgit v1.2.3 From 38c19ec9f7b28c8d5034daf28e4cc1b24e23ac49 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 02:04:33 -0400 Subject: rts5139: switch to ->show_info() Signed-off-by: Al Viro --- drivers/staging/rts5139/rts51x_scsi.c | 30 +++++++++--------------------- drivers/staging/rts5139/rts51x_scsi.h | 2 -- 2 files changed, 9 insertions(+), 23 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/rts5139/rts51x_scsi.c b/drivers/staging/rts5139/rts51x_scsi.c index 052911c9310..2ac3fe647ee 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 cdfe550371c..c2446d02d32 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 device_reset(struct scsi_cmnd *srb); -- cgit v1.2.3 From 60e8b807a6fb989de5fc195a92cfab4fd890b3c9 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 02:08:31 -0400 Subject: keucr: switch to ->show_info() Signed-off-by: Al Viro --- drivers/staging/keucr/scsiglue.c | 45 ++++++++++++---------------------------- 1 file changed, 13 insertions(+), 32 deletions(-) (limited to 'drivers') 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 */ -- cgit v1.2.3 From 35c6e0e512910a246e9063a2ddce85741747f0d7 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 02:11:39 -0400 Subject: nsp32: switch to ->show_info() Signed-off-by: Al Viro --- drivers/scsi/nsp32.c | 39 ++++++--------------------------------- 1 file changed, 6 insertions(+), 33 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/nsp32.c b/drivers/scsi/nsp32.c index 1cc0c1c69c8..1e3879dcbdc 100644 --- a/drivers/scsi/nsp32.c +++ b/drivers/scsi/nsp32.c @@ -192,7 +192,7 @@ static int __init init_nsp32 (void); static void __exit exit_nsp32 (void); /* struct struct scsi_host_template */ -static int nsp32_proc_info (struct Scsi_Host *, char *, char **, off_t, int, int); +static int nsp32_show_info (struct seq_file *, struct Scsi_Host *); static int nsp32_detect (struct pci_dev *pdev); static int nsp32_queuecommand(struct Scsi_Host *, struct scsi_cmnd *); @@ -268,7 +268,7 @@ static void nsp32_dmessage(const char *, int, int, char *, ...); static struct scsi_host_template nsp32_template = { .proc_name = "nsp32", .name = "Workbit NinjaSCSI-32Bi/UDE", - .proc_info = nsp32_proc_info, + .show_info = nsp32_show_info, .info = nsp32_info, .queuecommand = nsp32_queuecommand, .can_queue = 1, @@ -1442,19 +1442,10 @@ static irqreturn_t do_nsp32_isr(int irq, void *dev_id) } #undef SPRINTF -#define SPRINTF(args...) \ - do { \ - if(length > (pos - buffer)) { \ - pos += snprintf(pos, length - (pos - buffer) + 1, ## args); \ - nsp32_dbg(NSP32_DEBUG_PROC, "buffer=0x%p pos=0x%p length=%d %d\n", buffer, pos, length, length - (pos - buffer));\ - } \ - } while(0) - -static int nsp32_proc_info(struct Scsi_Host *host, char *buffer, char **start, - off_t offset, int length, int inout) +#define SPRINTF(args...) seq_printf(m, ##args) + +static int nsp32_show_info(struct seq_file *m, struct Scsi_Host *host) { - char *pos = buffer; - int thislength; unsigned long flags; nsp32_hw_data *data; int hostno; @@ -1463,11 +1454,6 @@ static int nsp32_proc_info(struct Scsi_Host *host, char *buffer, char **start, int id, speed; long model; - /* Write is not supported, just return. */ - if (inout == TRUE) { - return -EINVAL; - } - hostno = host->host_no; data = (nsp32_hw_data *)host->hostdata; base = host->io_port; @@ -1527,20 +1513,7 @@ static int nsp32_proc_info(struct Scsi_Host *host, char *buffer, char **start, } SPRINTF("\n"); } - - - thislength = pos - (buffer + offset); - - if(thislength < 0) { - *start = NULL; - return 0; - } - - - thislength = min(thislength, length); - *start = buffer + offset; - - return thislength; + return 0; } #undef SPRINTF -- cgit v1.2.3 From 63fd57cb5c21b7b914b13be0b225829c0f5dba10 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 02:14:18 -0400 Subject: nsp_cs: switch to ->show_info() Signed-off-by: Al Viro --- drivers/scsi/pcmcia/nsp_cs.c | 36 +++++------------------------------- drivers/scsi/pcmcia/nsp_cs.h | 9 ++------- 2 files changed, 7 insertions(+), 38 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c index b61a753eb89..987fbb1b244 100644 --- a/drivers/scsi/pcmcia/nsp_cs.c +++ b/drivers/scsi/pcmcia/nsp_cs.c @@ -76,7 +76,7 @@ MODULE_PARM_DESC(free_ports, "Release IO ports after configuration? (default: 0 static struct scsi_host_template nsp_driver_template = { .proc_name = "nsp_cs", - .proc_info = nsp_proc_info, + .show_info = nsp_show_info, .name = "WorkBit NinjaSCSI-3/32Bi(16bit)", .info = nsp_info, .queuecommand = nsp_queuecommand, @@ -1365,33 +1365,19 @@ static const char *nsp_info(struct Scsi_Host *shpnt) } #undef SPRINTF -#define SPRINTF(args...) \ - do { \ - if(length > (pos - buffer)) { \ - pos += snprintf(pos, length - (pos - buffer) + 1, ## args); \ - nsp_dbg(NSP_DEBUG_PROC, "buffer=0x%p pos=0x%p length=%d %d\n", buffer, pos, length, length - (pos - buffer));\ - } \ - } while(0) - -static int nsp_proc_info(struct Scsi_Host *host, char *buffer, char **start, - off_t offset, int length, int inout) +#define SPRINTF(args...) seq_printf(m, ##args) + +static int nsp_show_info(struct seq_file *m, struct Scsi_Host *host) { int id; - char *pos = buffer; - int thislength; int speed; unsigned long flags; nsp_hw_data *data; int hostno; - if (inout) { - return -EINVAL; - } - hostno = host->host_no; data = (nsp_hw_data *)host->hostdata; - SPRINTF("NinjaSCSI status\n\n"); SPRINTF("Driver version: $Revision: 1.23 $\n"); SPRINTF("SCSI host No.: %d\n", hostno); @@ -1458,19 +1444,7 @@ static int nsp_proc_info(struct Scsi_Host *host, char *buffer, char **start, } SPRINTF("\n"); } - - thislength = pos - (buffer + offset); - - if(thislength < 0) { - *start = NULL; - return 0; - } - - - thislength = min(thislength, length); - *start = buffer + offset; - - return thislength; + return 0; } #undef SPRINTF diff --git a/drivers/scsi/pcmcia/nsp_cs.h b/drivers/scsi/pcmcia/nsp_cs.h index 7fc9a9d0a44..afd64f0adc4 100644 --- a/drivers/scsi/pcmcia/nsp_cs.h +++ b/drivers/scsi/pcmcia/nsp_cs.h @@ -292,13 +292,8 @@ static int nsp_cs_config (struct pcmcia_device *link); /* Linux SCSI subsystem specific functions */ static struct Scsi_Host *nsp_detect (struct scsi_host_template *sht); static const char *nsp_info (struct Scsi_Host *shpnt); -static int nsp_proc_info ( - struct Scsi_Host *host, - char *buffer, - char **start, - off_t offset, - int length, - int inout); +static int nsp_show_info (struct seq_file *m, + struct Scsi_Host *host); static int nsp_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *SCpnt); /* Error handler */ -- cgit v1.2.3 From b59fb6fdce14bbec226cc4a4b5a4511a715ea6c2 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 02:59:55 -0400 Subject: advansys: switch to ->show_info() Signed-off-by: Al Viro --- drivers/scsi/advansys.c | 1164 +++++++++++++---------------------------------- 1 file changed, 327 insertions(+), 837 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c index dcfaee66a8b..9029a208b9c 100644 --- a/drivers/scsi/advansys.c +++ b/drivers/scsi/advansys.c @@ -2178,22 +2178,6 @@ do { \ #define ASC_INFO_SIZE 128 /* advansys_info() line size */ -#ifdef CONFIG_PROC_FS -/* /proc/scsi/advansys/[0...] related definitions */ -#define ASC_PRTBUF_SIZE 2048 -#define ASC_PRTLINE_SIZE 160 - -#define ASC_PRT_NEXT() \ - if (cp) { \ - totlen += len; \ - leftlen -= len; \ - if (leftlen == 0) { \ - return totlen; \ - } \ - cp += len; \ - } -#endif /* CONFIG_PROC_FS */ - /* Asc Library return codes */ #define ASC_TRUE 1 #define ASC_FALSE 0 @@ -2384,7 +2368,6 @@ struct asc_board { } eep_config; ulong last_reset; /* Saved last reset time */ /* /proc/scsi/advansys/[0...] */ - char *prtbuf; /* /proc print buffer */ #ifdef ADVANSYS_STATS struct asc_stats asc_stats; /* Board statistics */ #endif /* ADVANSYS_STATS */ @@ -2875,64 +2858,21 @@ static const char *advansys_info(struct Scsi_Host *shost) } #ifdef CONFIG_PROC_FS -/* - * asc_prt_line() - * - * If 'cp' is NULL print to the console, otherwise print to a buffer. - * - * Return 0 if printing to the console, otherwise return the number of - * bytes written to the buffer. - * - * Note: If any single line is greater than ASC_PRTLINE_SIZE bytes the stack - * will be corrupted. 's[]' is defined to be ASC_PRTLINE_SIZE bytes. - */ -static int asc_prt_line(char *buf, int buflen, char *fmt, ...) -{ - va_list args; - int ret; - char s[ASC_PRTLINE_SIZE]; - - va_start(args, fmt); - ret = vsprintf(s, fmt, args); - BUG_ON(ret >= ASC_PRTLINE_SIZE); - if (buf == NULL) { - (void)printk(s); - ret = 0; - } else { - ret = min(buflen, ret); - memcpy(buf, s, ret); - } - va_end(args); - return ret; -} /* * asc_prt_board_devices() * * Print driver information for devices attached to the board. - * - * Note: no single line should be greater than ASC_PRTLINE_SIZE, - * cf. asc_prt_line(). - * - * Return the number of characters copied into 'cp'. No more than - * 'cplen' characters will be copied to 'cp'. */ -static int asc_prt_board_devices(struct Scsi_Host *shost, char *cp, int cplen) +static void asc_prt_board_devices(struct seq_file *m, struct Scsi_Host *shost) { struct asc_board *boardp = shost_priv(shost); - int leftlen; - int totlen; - int len; int chip_scsi_id; int i; - leftlen = cplen; - totlen = len = 0; - - len = asc_prt_line(cp, leftlen, - "\nDevice Information for AdvanSys SCSI Host %d:\n", - shost->host_no); - ASC_PRT_NEXT(); + seq_printf(m, + "\nDevice Information for AdvanSys SCSI Host %d:\n", + shost->host_no); if (ASC_NARROW_BOARD(boardp)) { chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id; @@ -2940,60 +2880,42 @@ static int asc_prt_board_devices(struct Scsi_Host *shost, char *cp, int cplen) chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id; } - len = asc_prt_line(cp, leftlen, "Target IDs Detected:"); - ASC_PRT_NEXT(); + seq_printf(m, "Target IDs Detected:"); for (i = 0; i <= ADV_MAX_TID; i++) { - if (boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) { - len = asc_prt_line(cp, leftlen, " %X,", i); - ASC_PRT_NEXT(); - } + if (boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) + seq_printf(m, " %X,", i); } - len = asc_prt_line(cp, leftlen, " (%X=Host Adapter)\n", chip_scsi_id); - ASC_PRT_NEXT(); - - return totlen; + seq_printf(m, " (%X=Host Adapter)\n", chip_scsi_id); } /* * Display Wide Board BIOS Information. */ -static int asc_prt_adv_bios(struct Scsi_Host *shost, char *cp, int cplen) +static void asc_prt_adv_bios(struct seq_file *m, struct Scsi_Host *shost) { struct asc_board *boardp = shost_priv(shost); - int leftlen; - int totlen; - int len; ushort major, minor, letter; - leftlen = cplen; - totlen = len = 0; - - len = asc_prt_line(cp, leftlen, "\nROM BIOS Version: "); - ASC_PRT_NEXT(); + seq_printf(m, "\nROM BIOS Version: "); /* * If the BIOS saved a valid signature, then fill in * the BIOS code segment base address. */ if (boardp->bios_signature != 0x55AA) { - len = asc_prt_line(cp, leftlen, "Disabled or Pre-3.1\n"); - ASC_PRT_NEXT(); - len = asc_prt_line(cp, leftlen, - "BIOS either disabled or Pre-3.1. If it is pre-3.1, then a newer version\n"); - ASC_PRT_NEXT(); - len = asc_prt_line(cp, leftlen, - "can be found at the ConnectCom FTP site: ftp://ftp.connectcom.net/pub\n"); - ASC_PRT_NEXT(); + seq_printf(m, "Disabled or Pre-3.1\n"); + seq_printf(m, + "BIOS either disabled or Pre-3.1. If it is pre-3.1, then a newer version\n"); + seq_printf(m, + "can be found at the ConnectCom FTP site: ftp://ftp.connectcom.net/pub\n"); } else { major = (boardp->bios_version >> 12) & 0xF; minor = (boardp->bios_version >> 8) & 0xF; letter = (boardp->bios_version & 0xFF); - len = asc_prt_line(cp, leftlen, "%d.%d%c\n", + seq_printf(m, "%d.%d%c\n", major, minor, letter >= 26 ? '?' : letter + 'A'); - ASC_PRT_NEXT(); - /* * Current available ROM BIOS release is 3.1I for UW * and 3.2I for U2W. This code doesn't differentiate @@ -3001,16 +2923,12 @@ static int asc_prt_adv_bios(struct Scsi_Host *shost, char *cp, int cplen) */ if (major < 3 || (major <= 3 && minor < 1) || (major <= 3 && minor <= 1 && letter < ('I' - 'A'))) { - len = asc_prt_line(cp, leftlen, - "Newer version of ROM BIOS is available at the ConnectCom FTP site:\n"); - ASC_PRT_NEXT(); - len = asc_prt_line(cp, leftlen, - "ftp://ftp.connectcom.net/pub\n"); - ASC_PRT_NEXT(); + seq_printf(m, + "Newer version of ROM BIOS is available at the ConnectCom FTP site:\n"); + seq_printf(m, + "ftp://ftp.connectcom.net/pub\n"); } } - - return totlen; } /* @@ -3115,20 +3033,11 @@ static int asc_get_eeprom_string(ushort *serialnum, uchar *cp) * asc_prt_asc_board_eeprom() * * Print board EEPROM configuration. - * - * Note: no single line should be greater than ASC_PRTLINE_SIZE, - * cf. asc_prt_line(). - * - * Return the number of characters copied into 'cp'. No more than - * 'cplen' characters will be copied to 'cp'. */ -static int asc_prt_asc_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen) +static void asc_prt_asc_board_eeprom(struct seq_file *m, struct Scsi_Host *shost) { struct asc_board *boardp = shost_priv(shost); ASC_DVC_VAR *asc_dvc_varp; - int leftlen; - int totlen; - int len; ASCEEP_CONFIG *ep; int i; #ifdef CONFIG_ISA @@ -3139,129 +3048,75 @@ static int asc_prt_asc_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen asc_dvc_varp = &boardp->dvc_var.asc_dvc_var; ep = &boardp->eep_config.asc_eep; - leftlen = cplen; - totlen = len = 0; - - len = asc_prt_line(cp, leftlen, - "\nEEPROM Settings for AdvanSys SCSI Host %d:\n", - shost->host_no); - ASC_PRT_NEXT(); + seq_printf(m, + "\nEEPROM Settings for AdvanSys SCSI Host %d:\n", + shost->host_no); if (asc_get_eeprom_string((ushort *)&ep->adapter_info[0], serialstr) - == ASC_TRUE) { - len = - asc_prt_line(cp, leftlen, " Serial Number: %s\n", - serialstr); - ASC_PRT_NEXT(); - } else { - if (ep->adapter_info[5] == 0xBB) { - len = asc_prt_line(cp, leftlen, - " Default Settings Used for EEPROM-less Adapter.\n"); - ASC_PRT_NEXT(); - } else { - len = asc_prt_line(cp, leftlen, - " Serial Number Signature Not Present.\n"); - ASC_PRT_NEXT(); - } - } - - len = asc_prt_line(cp, leftlen, - " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n", - ASC_EEP_GET_CHIP_ID(ep), ep->max_total_qng, - ep->max_tag_qng); - ASC_PRT_NEXT(); - - len = asc_prt_line(cp, leftlen, - " cntl 0x%x, no_scam 0x%x\n", ep->cntl, ep->no_scam); - ASC_PRT_NEXT(); - - len = asc_prt_line(cp, leftlen, " Target ID: "); - ASC_PRT_NEXT(); - for (i = 0; i <= ASC_MAX_TID; i++) { - len = asc_prt_line(cp, leftlen, " %d", i); - ASC_PRT_NEXT(); - } - len = asc_prt_line(cp, leftlen, "\n"); - ASC_PRT_NEXT(); - - len = asc_prt_line(cp, leftlen, " Disconnects: "); - ASC_PRT_NEXT(); - for (i = 0; i <= ASC_MAX_TID; i++) { - len = asc_prt_line(cp, leftlen, " %c", - (ep-> - disc_enable & ADV_TID_TO_TIDMASK(i)) ? 'Y' : - 'N'); - ASC_PRT_NEXT(); - } - len = asc_prt_line(cp, leftlen, "\n"); - ASC_PRT_NEXT(); - - len = asc_prt_line(cp, leftlen, " Command Queuing: "); - ASC_PRT_NEXT(); - for (i = 0; i <= ASC_MAX_TID; i++) { - len = asc_prt_line(cp, leftlen, " %c", - (ep-> - use_cmd_qng & ADV_TID_TO_TIDMASK(i)) ? 'Y' : - 'N'); - ASC_PRT_NEXT(); - } - len = asc_prt_line(cp, leftlen, "\n"); - ASC_PRT_NEXT(); - - len = asc_prt_line(cp, leftlen, " Start Motor: "); - ASC_PRT_NEXT(); - for (i = 0; i <= ASC_MAX_TID; i++) { - len = asc_prt_line(cp, leftlen, " %c", - (ep-> - start_motor & ADV_TID_TO_TIDMASK(i)) ? 'Y' : - 'N'); - ASC_PRT_NEXT(); - } - len = asc_prt_line(cp, leftlen, "\n"); - ASC_PRT_NEXT(); - - len = asc_prt_line(cp, leftlen, " Synchronous Transfer:"); - ASC_PRT_NEXT(); - for (i = 0; i <= ASC_MAX_TID; i++) { - len = asc_prt_line(cp, leftlen, " %c", - (ep-> - init_sdtr & ADV_TID_TO_TIDMASK(i)) ? 'Y' : - 'N'); - ASC_PRT_NEXT(); - } - len = asc_prt_line(cp, leftlen, "\n"); - ASC_PRT_NEXT(); + == ASC_TRUE) + seq_printf(m, " Serial Number: %s\n", serialstr); + else if (ep->adapter_info[5] == 0xBB) + seq_printf(m, + " Default Settings Used for EEPROM-less Adapter.\n"); + else + seq_printf(m, + " Serial Number Signature Not Present.\n"); + + seq_printf(m, + " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n", + ASC_EEP_GET_CHIP_ID(ep), ep->max_total_qng, + ep->max_tag_qng); + + seq_printf(m, + " cntl 0x%x, no_scam 0x%x\n", ep->cntl, ep->no_scam); + + seq_printf(m, " Target ID: "); + for (i = 0; i <= ASC_MAX_TID; i++) + seq_printf(m, " %d", i); + seq_printf(m, "\n"); + + seq_printf(m, " Disconnects: "); + for (i = 0; i <= ASC_MAX_TID; i++) + seq_printf(m, " %c", + (ep->disc_enable & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); + seq_printf(m, "\n"); + + seq_printf(m, " Command Queuing: "); + for (i = 0; i <= ASC_MAX_TID; i++) + seq_printf(m, " %c", + (ep->use_cmd_qng & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); + seq_printf(m, "\n"); + + seq_printf(m, " Start Motor: "); + for (i = 0; i <= ASC_MAX_TID; i++) + seq_printf(m, " %c", + (ep->start_motor & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); + seq_printf(m, "\n"); + + seq_printf(m, " Synchronous Transfer:"); + for (i = 0; i <= ASC_MAX_TID; i++) + seq_printf(m, " %c", + (ep->init_sdtr & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); + seq_printf(m, "\n"); #ifdef CONFIG_ISA if (asc_dvc_varp->bus_type & ASC_IS_ISA) { - len = asc_prt_line(cp, leftlen, - " Host ISA DMA speed: %d MB/S\n", - isa_dma_speed[ASC_EEP_GET_DMA_SPD(ep)]); - ASC_PRT_NEXT(); + seq_printf(m, + " Host ISA DMA speed: %d MB/S\n", + isa_dma_speed[ASC_EEP_GET_DMA_SPD(ep)]); } #endif /* CONFIG_ISA */ - - return totlen; } /* * asc_prt_adv_board_eeprom() * * Print board EEPROM configuration. - * - * Note: no single line should be greater than ASC_PRTLINE_SIZE, - * cf. asc_prt_line(). - * - * Return the number of characters copied into 'cp'. No more than - * 'cplen' characters will be copied to 'cp'. */ -static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen) +static void asc_prt_adv_board_eeprom(struct seq_file *m, struct Scsi_Host *shost) { struct asc_board *boardp = shost_priv(shost); ADV_DVC_VAR *adv_dvc_varp; - int leftlen; - int totlen; - int len; int i; char *termstr; uchar serialstr[13]; @@ -3281,13 +3136,9 @@ static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen ep_38C1600 = &boardp->eep_config.adv_38C1600_eep; } - leftlen = cplen; - totlen = len = 0; - - len = asc_prt_line(cp, leftlen, - "\nEEPROM Settings for AdvanSys SCSI Host %d:\n", - shost->host_no); - ASC_PRT_NEXT(); + seq_printf(m, + "\nEEPROM Settings for AdvanSys SCSI Host %d:\n", + shost->host_no); if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { wordp = &ep_3550->serial_number_word1; @@ -3297,38 +3148,28 @@ static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen wordp = &ep_38C1600->serial_number_word1; } - if (asc_get_eeprom_string(wordp, serialstr) == ASC_TRUE) { - len = - asc_prt_line(cp, leftlen, " Serial Number: %s\n", - serialstr); - ASC_PRT_NEXT(); - } else { - len = asc_prt_line(cp, leftlen, - " Serial Number Signature Not Present.\n"); - ASC_PRT_NEXT(); - } + if (asc_get_eeprom_string(wordp, serialstr) == ASC_TRUE) + seq_printf(m, " Serial Number: %s\n", serialstr); + else + seq_printf(m, " Serial Number Signature Not Present.\n"); - if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { - len = asc_prt_line(cp, leftlen, - " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n", - ep_3550->adapter_scsi_id, - ep_3550->max_host_qng, ep_3550->max_dvc_qng); - ASC_PRT_NEXT(); - } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) { - len = asc_prt_line(cp, leftlen, - " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n", - ep_38C0800->adapter_scsi_id, - ep_38C0800->max_host_qng, - ep_38C0800->max_dvc_qng); - ASC_PRT_NEXT(); - } else { - len = asc_prt_line(cp, leftlen, - " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n", - ep_38C1600->adapter_scsi_id, - ep_38C1600->max_host_qng, - ep_38C1600->max_dvc_qng); - ASC_PRT_NEXT(); - } + if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) + seq_printf(m, + " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n", + ep_3550->adapter_scsi_id, + ep_3550->max_host_qng, ep_3550->max_dvc_qng); + else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) + seq_printf(m, + " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n", + ep_38C0800->adapter_scsi_id, + ep_38C0800->max_host_qng, + ep_38C0800->max_dvc_qng); + else + seq_printf(m, + " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n", + ep_38C1600->adapter_scsi_id, + ep_38C1600->max_host_qng, + ep_38C1600->max_dvc_qng); if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { word = ep_3550->termination; } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) { @@ -3352,34 +3193,26 @@ static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen break; } - if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { - len = asc_prt_line(cp, leftlen, - " termination: %u (%s), bios_ctrl: 0x%x\n", - ep_3550->termination, termstr, - ep_3550->bios_ctrl); - ASC_PRT_NEXT(); - } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) { - len = asc_prt_line(cp, leftlen, - " termination: %u (%s), bios_ctrl: 0x%x\n", - ep_38C0800->termination_lvd, termstr, - ep_38C0800->bios_ctrl); - ASC_PRT_NEXT(); - } else { - len = asc_prt_line(cp, leftlen, - " termination: %u (%s), bios_ctrl: 0x%x\n", - ep_38C1600->termination_lvd, termstr, - ep_38C1600->bios_ctrl); - ASC_PRT_NEXT(); - } + if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) + seq_printf(m, + " termination: %u (%s), bios_ctrl: 0x%x\n", + ep_3550->termination, termstr, + ep_3550->bios_ctrl); + else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) + seq_printf(m, + " termination: %u (%s), bios_ctrl: 0x%x\n", + ep_38C0800->termination_lvd, termstr, + ep_38C0800->bios_ctrl); + else + seq_printf(m, + " termination: %u (%s), bios_ctrl: 0x%x\n", + ep_38C1600->termination_lvd, termstr, + ep_38C1600->bios_ctrl); - len = asc_prt_line(cp, leftlen, " Target ID: "); - ASC_PRT_NEXT(); - for (i = 0; i <= ADV_MAX_TID; i++) { - len = asc_prt_line(cp, leftlen, " %X", i); - ASC_PRT_NEXT(); - } - len = asc_prt_line(cp, leftlen, "\n"); - ASC_PRT_NEXT(); + seq_printf(m, " Target ID: "); + for (i = 0; i <= ADV_MAX_TID; i++) + seq_printf(m, " %X", i); + seq_printf(m, "\n"); if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { word = ep_3550->disc_enable; @@ -3388,15 +3221,11 @@ static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen } else { word = ep_38C1600->disc_enable; } - len = asc_prt_line(cp, leftlen, " Disconnects: "); - ASC_PRT_NEXT(); - for (i = 0; i <= ADV_MAX_TID; i++) { - len = asc_prt_line(cp, leftlen, " %c", - (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); - ASC_PRT_NEXT(); - } - len = asc_prt_line(cp, leftlen, "\n"); - ASC_PRT_NEXT(); + seq_printf(m, " Disconnects: "); + for (i = 0; i <= ADV_MAX_TID; i++) + seq_printf(m, " %c", + (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); + seq_printf(m, "\n"); if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { word = ep_3550->tagqng_able; @@ -3405,15 +3234,11 @@ static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen } else { word = ep_38C1600->tagqng_able; } - len = asc_prt_line(cp, leftlen, " Command Queuing: "); - ASC_PRT_NEXT(); - for (i = 0; i <= ADV_MAX_TID; i++) { - len = asc_prt_line(cp, leftlen, " %c", - (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); - ASC_PRT_NEXT(); - } - len = asc_prt_line(cp, leftlen, "\n"); - ASC_PRT_NEXT(); + seq_printf(m, " Command Queuing: "); + for (i = 0; i <= ADV_MAX_TID; i++) + seq_printf(m, " %c", + (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); + seq_printf(m, "\n"); if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { word = ep_3550->start_motor; @@ -3422,42 +3247,28 @@ static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen } else { word = ep_38C1600->start_motor; } - len = asc_prt_line(cp, leftlen, " Start Motor: "); - ASC_PRT_NEXT(); - for (i = 0; i <= ADV_MAX_TID; i++) { - len = asc_prt_line(cp, leftlen, " %c", - (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); - ASC_PRT_NEXT(); - } - len = asc_prt_line(cp, leftlen, "\n"); - ASC_PRT_NEXT(); + seq_printf(m, " Start Motor: "); + for (i = 0; i <= ADV_MAX_TID; i++) + seq_printf(m, " %c", + (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); + seq_printf(m, "\n"); if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { - len = asc_prt_line(cp, leftlen, " Synchronous Transfer:"); - ASC_PRT_NEXT(); - for (i = 0; i <= ADV_MAX_TID; i++) { - len = asc_prt_line(cp, leftlen, " %c", - (ep_3550-> - sdtr_able & ADV_TID_TO_TIDMASK(i)) ? - 'Y' : 'N'); - ASC_PRT_NEXT(); - } - len = asc_prt_line(cp, leftlen, "\n"); - ASC_PRT_NEXT(); + seq_printf(m, " Synchronous Transfer:"); + for (i = 0; i <= ADV_MAX_TID; i++) + seq_printf(m, " %c", + (ep_3550->sdtr_able & ADV_TID_TO_TIDMASK(i)) ? + 'Y' : 'N'); + seq_printf(m, "\n"); } if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { - len = asc_prt_line(cp, leftlen, " Ultra Transfer: "); - ASC_PRT_NEXT(); - for (i = 0; i <= ADV_MAX_TID; i++) { - len = asc_prt_line(cp, leftlen, " %c", - (ep_3550-> - ultra_able & ADV_TID_TO_TIDMASK(i)) - ? 'Y' : 'N'); - ASC_PRT_NEXT(); - } - len = asc_prt_line(cp, leftlen, "\n"); - ASC_PRT_NEXT(); + seq_printf(m, " Ultra Transfer: "); + for (i = 0; i <= ADV_MAX_TID; i++) + seq_printf(m, " %c", + (ep_3550->ultra_able & ADV_TID_TO_TIDMASK(i)) + ? 'Y' : 'N'); + seq_printf(m, "\n"); } if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { @@ -3467,21 +3278,16 @@ static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen } else { word = ep_38C1600->wdtr_able; } - len = asc_prt_line(cp, leftlen, " Wide Transfer: "); - ASC_PRT_NEXT(); - for (i = 0; i <= ADV_MAX_TID; i++) { - len = asc_prt_line(cp, leftlen, " %c", - (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); - ASC_PRT_NEXT(); - } - len = asc_prt_line(cp, leftlen, "\n"); - ASC_PRT_NEXT(); + seq_printf(m, " Wide Transfer: "); + for (i = 0; i <= ADV_MAX_TID; i++) + seq_printf(m, " %c", + (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); + seq_printf(m, "\n"); if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800 || adv_dvc_varp->chip_type == ADV_CHIP_ASC38C1600) { - len = asc_prt_line(cp, leftlen, - " Synchronous Transfer Speed (Mhz):\n "); - ASC_PRT_NEXT(); + seq_printf(m, + " Synchronous Transfer Speed (Mhz):\n "); for (i = 0; i <= ADV_MAX_TID; i++) { char *speed_str; @@ -3517,99 +3323,64 @@ static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen speed_str = "Unk"; break; } - len = asc_prt_line(cp, leftlen, "%X:%s ", i, speed_str); - ASC_PRT_NEXT(); - if (i == 7) { - len = asc_prt_line(cp, leftlen, "\n "); - ASC_PRT_NEXT(); - } + seq_printf(m, "%X:%s ", i, speed_str); + if (i == 7) + seq_printf(m, "\n "); sdtr_speed >>= 4; } - len = asc_prt_line(cp, leftlen, "\n"); - ASC_PRT_NEXT(); + seq_printf(m, "\n"); } - - return totlen; } /* * asc_prt_driver_conf() - * - * Note: no single line should be greater than ASC_PRTLINE_SIZE, - * cf. asc_prt_line(). - * - * Return the number of characters copied into 'cp'. No more than - * 'cplen' characters will be copied to 'cp'. */ -static int asc_prt_driver_conf(struct Scsi_Host *shost, char *cp, int cplen) +static void asc_prt_driver_conf(struct seq_file *m, struct Scsi_Host *shost) { struct asc_board *boardp = shost_priv(shost); - int leftlen; - int totlen; - int len; int chip_scsi_id; - leftlen = cplen; - totlen = len = 0; + seq_printf(m, + "\nLinux Driver Configuration and Information for AdvanSys SCSI Host %d:\n", + shost->host_no); - len = asc_prt_line(cp, leftlen, - "\nLinux Driver Configuration and Information for AdvanSys SCSI Host %d:\n", - shost->host_no); - ASC_PRT_NEXT(); + seq_printf(m, + " host_busy %u, last_reset %u, max_id %u, max_lun %u, max_channel %u\n", + shost->host_busy, shost->last_reset, shost->max_id, + shost->max_lun, shost->max_channel); - len = asc_prt_line(cp, leftlen, - " host_busy %u, last_reset %u, max_id %u, max_lun %u, max_channel %u\n", - shost->host_busy, shost->last_reset, shost->max_id, - shost->max_lun, shost->max_channel); - ASC_PRT_NEXT(); + seq_printf(m, + " unique_id %d, can_queue %d, this_id %d, sg_tablesize %u, cmd_per_lun %u\n", + shost->unique_id, shost->can_queue, shost->this_id, + shost->sg_tablesize, shost->cmd_per_lun); - len = asc_prt_line(cp, leftlen, - " unique_id %d, can_queue %d, this_id %d, sg_tablesize %u, cmd_per_lun %u\n", - shost->unique_id, shost->can_queue, shost->this_id, - shost->sg_tablesize, shost->cmd_per_lun); - ASC_PRT_NEXT(); + seq_printf(m, + " unchecked_isa_dma %d, use_clustering %d\n", + shost->unchecked_isa_dma, shost->use_clustering); - len = asc_prt_line(cp, leftlen, - " unchecked_isa_dma %d, use_clustering %d\n", - shost->unchecked_isa_dma, shost->use_clustering); - ASC_PRT_NEXT(); + seq_printf(m, + " flags 0x%x, last_reset 0x%x, jiffies 0x%x, asc_n_io_port 0x%x\n", + boardp->flags, boardp->last_reset, jiffies, + boardp->asc_n_io_port); - len = asc_prt_line(cp, leftlen, - " flags 0x%x, last_reset 0x%x, jiffies 0x%x, asc_n_io_port 0x%x\n", - boardp->flags, boardp->last_reset, jiffies, - boardp->asc_n_io_port); - ASC_PRT_NEXT(); - - len = asc_prt_line(cp, leftlen, " io_port 0x%x\n", shost->io_port); - ASC_PRT_NEXT(); + seq_printf(m, " io_port 0x%x\n", shost->io_port); if (ASC_NARROW_BOARD(boardp)) { chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id; } else { chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id; } - - return totlen; } /* * asc_prt_asc_board_info() * * Print dynamic board configuration information. - * - * Note: no single line should be greater than ASC_PRTLINE_SIZE, - * cf. asc_prt_line(). - * - * Return the number of characters copied into 'cp'. No more than - * 'cplen' characters will be copied to 'cp'. */ -static int asc_prt_asc_board_info(struct Scsi_Host *shost, char *cp, int cplen) +static void asc_prt_asc_board_info(struct seq_file *m, struct Scsi_Host *shost) { struct asc_board *boardp = shost_priv(shost); int chip_scsi_id; - int leftlen; - int totlen; - int len; ASC_DVC_VAR *v; ASC_DVC_CFG *c; int i; @@ -3619,105 +3390,79 @@ static int asc_prt_asc_board_info(struct Scsi_Host *shost, char *cp, int cplen) c = &boardp->dvc_cfg.asc_dvc_cfg; chip_scsi_id = c->chip_scsi_id; - leftlen = cplen; - totlen = len = 0; + seq_printf(m, + "\nAsc Library Configuration and Statistics for AdvanSys SCSI Host %d:\n", + shost->host_no); - len = asc_prt_line(cp, leftlen, - "\nAsc Library Configuration and Statistics for AdvanSys SCSI Host %d:\n", - shost->host_no); - ASC_PRT_NEXT(); - - len = asc_prt_line(cp, leftlen, " chip_version %u, mcode_date 0x%x, " - "mcode_version 0x%x, err_code %u\n", - c->chip_version, c->mcode_date, c->mcode_version, - v->err_code); - ASC_PRT_NEXT(); + seq_printf(m, " chip_version %u, mcode_date 0x%x, " + "mcode_version 0x%x, err_code %u\n", + c->chip_version, c->mcode_date, c->mcode_version, + v->err_code); /* Current number of commands waiting for the host. */ - len = asc_prt_line(cp, leftlen, - " Total Command Pending: %d\n", v->cur_total_qng); - ASC_PRT_NEXT(); + seq_printf(m, + " Total Command Pending: %d\n", v->cur_total_qng); - len = asc_prt_line(cp, leftlen, " Command Queuing:"); - ASC_PRT_NEXT(); + seq_printf(m, " Command Queuing:"); for (i = 0; i <= ASC_MAX_TID; i++) { if ((chip_scsi_id == i) || ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { continue; } - len = asc_prt_line(cp, leftlen, " %X:%c", - i, - (v-> - use_tagged_qng & ADV_TID_TO_TIDMASK(i)) ? - 'Y' : 'N'); - ASC_PRT_NEXT(); + seq_printf(m, " %X:%c", + i, + (v->use_tagged_qng & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); } - len = asc_prt_line(cp, leftlen, "\n"); - ASC_PRT_NEXT(); + seq_printf(m, "\n"); /* Current number of commands waiting for a device. */ - len = asc_prt_line(cp, leftlen, " Command Queue Pending:"); - ASC_PRT_NEXT(); + seq_printf(m, " Command Queue Pending:"); for (i = 0; i <= ASC_MAX_TID; i++) { if ((chip_scsi_id == i) || ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { continue; } - len = asc_prt_line(cp, leftlen, " %X:%u", i, v->cur_dvc_qng[i]); - ASC_PRT_NEXT(); + seq_printf(m, " %X:%u", i, v->cur_dvc_qng[i]); } - len = asc_prt_line(cp, leftlen, "\n"); - ASC_PRT_NEXT(); + seq_printf(m, "\n"); /* Current limit on number of commands that can be sent to a device. */ - len = asc_prt_line(cp, leftlen, " Command Queue Limit:"); - ASC_PRT_NEXT(); + seq_printf(m, " Command Queue Limit:"); for (i = 0; i <= ASC_MAX_TID; i++) { if ((chip_scsi_id == i) || ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { continue; } - len = asc_prt_line(cp, leftlen, " %X:%u", i, v->max_dvc_qng[i]); - ASC_PRT_NEXT(); + seq_printf(m, " %X:%u", i, v->max_dvc_qng[i]); } - len = asc_prt_line(cp, leftlen, "\n"); - ASC_PRT_NEXT(); + seq_printf(m, "\n"); /* Indicate whether the device has returned queue full status. */ - len = asc_prt_line(cp, leftlen, " Command Queue Full:"); - ASC_PRT_NEXT(); + seq_printf(m, " Command Queue Full:"); for (i = 0; i <= ASC_MAX_TID; i++) { if ((chip_scsi_id == i) || ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { continue; } - if (boardp->queue_full & ADV_TID_TO_TIDMASK(i)) { - len = asc_prt_line(cp, leftlen, " %X:Y-%d", - i, boardp->queue_full_cnt[i]); - } else { - len = asc_prt_line(cp, leftlen, " %X:N", i); - } - ASC_PRT_NEXT(); + if (boardp->queue_full & ADV_TID_TO_TIDMASK(i)) + seq_printf(m, " %X:Y-%d", + i, boardp->queue_full_cnt[i]); + else + seq_printf(m, " %X:N", i); } - len = asc_prt_line(cp, leftlen, "\n"); - ASC_PRT_NEXT(); + seq_printf(m, "\n"); - len = asc_prt_line(cp, leftlen, " Synchronous Transfer:"); - ASC_PRT_NEXT(); + seq_printf(m, " Synchronous Transfer:"); for (i = 0; i <= ASC_MAX_TID; i++) { if ((chip_scsi_id == i) || ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { continue; } - len = asc_prt_line(cp, leftlen, " %X:%c", - i, - (v-> - sdtr_done & ADV_TID_TO_TIDMASK(i)) ? 'Y' : - 'N'); - ASC_PRT_NEXT(); + seq_printf(m, " %X:%c", + i, + (v->sdtr_done & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); } - len = asc_prt_line(cp, leftlen, "\n"); - ASC_PRT_NEXT(); + seq_printf(m, "\n"); for (i = 0; i <= ASC_MAX_TID; i++) { uchar syn_period_ix; @@ -3728,69 +3473,48 @@ static int asc_prt_asc_board_info(struct Scsi_Host *shost, char *cp, int cplen) continue; } - len = asc_prt_line(cp, leftlen, " %X:", i); - ASC_PRT_NEXT(); + seq_printf(m, " %X:", i); if ((boardp->sdtr_data[i] & ASC_SYN_MAX_OFFSET) == 0) { - len = asc_prt_line(cp, leftlen, " Asynchronous"); - ASC_PRT_NEXT(); + seq_printf(m, " Asynchronous"); } else { syn_period_ix = (boardp->sdtr_data[i] >> 4) & (v->max_sdtr_index - 1); - len = asc_prt_line(cp, leftlen, - " Transfer Period Factor: %d (%d.%d Mhz),", - v->sdtr_period_tbl[syn_period_ix], - 250 / - v->sdtr_period_tbl[syn_period_ix], - ASC_TENTHS(250, - v-> - sdtr_period_tbl - [syn_period_ix])); - ASC_PRT_NEXT(); + seq_printf(m, + " Transfer Period Factor: %d (%d.%d Mhz),", + v->sdtr_period_tbl[syn_period_ix], + 250 / v->sdtr_period_tbl[syn_period_ix], + ASC_TENTHS(250, + v->sdtr_period_tbl[syn_period_ix])); - len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d", - boardp-> - sdtr_data[i] & ASC_SYN_MAX_OFFSET); - ASC_PRT_NEXT(); + seq_printf(m, " REQ/ACK Offset: %d", + boardp->sdtr_data[i] & ASC_SYN_MAX_OFFSET); } if ((v->sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) { - len = asc_prt_line(cp, leftlen, "*\n"); + seq_printf(m, "*\n"); renegotiate = 1; } else { - len = asc_prt_line(cp, leftlen, "\n"); + seq_printf(m, "\n"); } - ASC_PRT_NEXT(); } if (renegotiate) { - len = asc_prt_line(cp, leftlen, - " * = Re-negotiation pending before next command.\n"); - ASC_PRT_NEXT(); + seq_printf(m, + " * = Re-negotiation pending before next command.\n"); } - - return totlen; } /* * asc_prt_adv_board_info() * * Print dynamic board configuration information. - * - * Note: no single line should be greater than ASC_PRTLINE_SIZE, - * cf. asc_prt_line(). - * - * Return the number of characters copied into 'cp'. No more than - * 'cplen' characters will be copied to 'cp'. */ -static int asc_prt_adv_board_info(struct Scsi_Host *shost, char *cp, int cplen) +static void asc_prt_adv_board_info(struct seq_file *m, struct Scsi_Host *shost) { struct asc_board *boardp = shost_priv(shost); - int leftlen; - int totlen; - int len; int i; ADV_DVC_VAR *v; ADV_DVC_CFG *c; @@ -3809,47 +3533,35 @@ static int asc_prt_adv_board_info(struct Scsi_Host *shost, char *cp, int cplen) iop_base = v->iop_base; chip_scsi_id = v->chip_scsi_id; - leftlen = cplen; - totlen = len = 0; - - len = asc_prt_line(cp, leftlen, - "\nAdv Library Configuration and Statistics for AdvanSys SCSI Host %d:\n", - shost->host_no); - ASC_PRT_NEXT(); + seq_printf(m, + "\nAdv Library Configuration and Statistics for AdvanSys SCSI Host %d:\n", + shost->host_no); - len = asc_prt_line(cp, leftlen, - " iop_base 0x%lx, cable_detect: %X, err_code %u\n", - v->iop_base, - AdvReadWordRegister(iop_base, - IOPW_SCSI_CFG1) & CABLE_DETECT, - v->err_code); - ASC_PRT_NEXT(); + seq_printf(m, + " iop_base 0x%lx, cable_detect: %X, err_code %u\n", + v->iop_base, + AdvReadWordRegister(iop_base,IOPW_SCSI_CFG1) & CABLE_DETECT, + v->err_code); - len = asc_prt_line(cp, leftlen, " chip_version %u, mcode_date 0x%x, " - "mcode_version 0x%x\n", c->chip_version, - c->mcode_date, c->mcode_version); - ASC_PRT_NEXT(); + seq_printf(m, " chip_version %u, mcode_date 0x%x, " + "mcode_version 0x%x\n", c->chip_version, + c->mcode_date, c->mcode_version); AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able); - len = asc_prt_line(cp, leftlen, " Queuing Enabled:"); - ASC_PRT_NEXT(); + seq_printf(m, " Queuing Enabled:"); for (i = 0; i <= ADV_MAX_TID; i++) { if ((chip_scsi_id == i) || ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { continue; } - len = asc_prt_line(cp, leftlen, " %X:%c", - i, - (tagqng_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' : - 'N'); - ASC_PRT_NEXT(); + seq_printf(m, " %X:%c", + i, + (tagqng_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); } - len = asc_prt_line(cp, leftlen, "\n"); - ASC_PRT_NEXT(); + seq_printf(m, "\n"); - len = asc_prt_line(cp, leftlen, " Queue Limit:"); - ASC_PRT_NEXT(); + seq_printf(m, " Queue Limit:"); for (i = 0; i <= ADV_MAX_TID; i++) { if ((chip_scsi_id == i) || ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { @@ -3859,14 +3571,11 @@ static int asc_prt_adv_board_info(struct Scsi_Host *shost, char *cp, int cplen) AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + i, lrambyte); - len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte); - ASC_PRT_NEXT(); + seq_printf(m, " %X:%d", i, lrambyte); } - len = asc_prt_line(cp, leftlen, "\n"); - ASC_PRT_NEXT(); + seq_printf(m, "\n"); - len = asc_prt_line(cp, leftlen, " Command Pending:"); - ASC_PRT_NEXT(); + seq_printf(m, " Command Pending:"); for (i = 0; i <= ADV_MAX_TID; i++) { if ((chip_scsi_id == i) || ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { @@ -3876,33 +3585,26 @@ static int asc_prt_adv_board_info(struct Scsi_Host *shost, char *cp, int cplen) AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_QUEUED_CMD + i, lrambyte); - len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte); - ASC_PRT_NEXT(); + seq_printf(m, " %X:%d", i, lrambyte); } - len = asc_prt_line(cp, leftlen, "\n"); - ASC_PRT_NEXT(); + seq_printf(m, "\n"); AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able); - len = asc_prt_line(cp, leftlen, " Wide Enabled:"); - ASC_PRT_NEXT(); + seq_printf(m, " Wide Enabled:"); for (i = 0; i <= ADV_MAX_TID; i++) { if ((chip_scsi_id == i) || ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { continue; } - len = asc_prt_line(cp, leftlen, " %X:%c", - i, - (wdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' : - 'N'); - ASC_PRT_NEXT(); + seq_printf(m, " %X:%c", + i, + (wdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); } - len = asc_prt_line(cp, leftlen, "\n"); - ASC_PRT_NEXT(); + seq_printf(m, "\n"); AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, wdtr_done); - len = asc_prt_line(cp, leftlen, " Transfer Bit Width:"); - ASC_PRT_NEXT(); + seq_printf(m, " Transfer Bit Width:"); for (i = 0; i <= ADV_MAX_TID; i++) { if ((chip_scsi_id == i) || ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { @@ -3913,37 +3615,30 @@ static int asc_prt_adv_board_info(struct Scsi_Host *shost, char *cp, int cplen) ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i), lramword); - len = asc_prt_line(cp, leftlen, " %X:%d", - i, (lramword & 0x8000) ? 16 : 8); - ASC_PRT_NEXT(); + seq_printf(m, " %X:%d", + i, (lramword & 0x8000) ? 16 : 8); if ((wdtr_able & ADV_TID_TO_TIDMASK(i)) && (wdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) { - len = asc_prt_line(cp, leftlen, "*"); - ASC_PRT_NEXT(); + seq_printf(m, "*"); renegotiate = 1; } } - len = asc_prt_line(cp, leftlen, "\n"); - ASC_PRT_NEXT(); + seq_printf(m, "\n"); AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able); - len = asc_prt_line(cp, leftlen, " Synchronous Enabled:"); - ASC_PRT_NEXT(); + seq_printf(m, " Synchronous Enabled:"); for (i = 0; i <= ADV_MAX_TID; i++) { if ((chip_scsi_id == i) || ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { continue; } - len = asc_prt_line(cp, leftlen, " %X:%c", - i, - (sdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' : - 'N'); - ASC_PRT_NEXT(); + seq_printf(m, " %X:%c", + i, + (sdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); } - len = asc_prt_line(cp, leftlen, "\n"); - ASC_PRT_NEXT(); + seq_printf(m, "\n"); AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, sdtr_done); for (i = 0; i <= ADV_MAX_TID; i++) { @@ -3959,358 +3654,170 @@ static int asc_prt_adv_board_info(struct Scsi_Host *shost, char *cp, int cplen) continue; } - len = asc_prt_line(cp, leftlen, " %X:", i); - ASC_PRT_NEXT(); + seq_printf(m, " %X:", i); if ((lramword & 0x1F) == 0) { /* Check for REQ/ACK Offset 0. */ - len = asc_prt_line(cp, leftlen, " Asynchronous"); - ASC_PRT_NEXT(); + seq_printf(m, " Asynchronous"); } else { - len = - asc_prt_line(cp, leftlen, - " Transfer Period Factor: "); - ASC_PRT_NEXT(); + seq_printf(m, " Transfer Period Factor: "); if ((lramword & 0x1F00) == 0x1100) { /* 80 Mhz */ - len = - asc_prt_line(cp, leftlen, "9 (80.0 Mhz),"); - ASC_PRT_NEXT(); + seq_printf(m, "9 (80.0 Mhz),"); } else if ((lramword & 0x1F00) == 0x1000) { /* 40 Mhz */ - len = - asc_prt_line(cp, leftlen, "10 (40.0 Mhz),"); - ASC_PRT_NEXT(); + seq_printf(m, "10 (40.0 Mhz),"); } else { /* 20 Mhz or below. */ period = (((lramword >> 8) * 25) + 50) / 4; if (period == 0) { /* Should never happen. */ - len = - asc_prt_line(cp, leftlen, - "%d (? Mhz), "); - ASC_PRT_NEXT(); + seq_printf(m, "%d (? Mhz), "); } else { - len = asc_prt_line(cp, leftlen, - "%d (%d.%d Mhz),", - period, 250 / period, - ASC_TENTHS(250, - period)); - ASC_PRT_NEXT(); + seq_printf(m, + "%d (%d.%d Mhz),", + period, 250 / period, + ASC_TENTHS(250, period)); } } - len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d", - lramword & 0x1F); - ASC_PRT_NEXT(); + seq_printf(m, " REQ/ACK Offset: %d", + lramword & 0x1F); } if ((sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) { - len = asc_prt_line(cp, leftlen, "*\n"); + seq_printf(m, "*\n"); renegotiate = 1; } else { - len = asc_prt_line(cp, leftlen, "\n"); + seq_printf(m, "\n"); } - ASC_PRT_NEXT(); } if (renegotiate) { - len = asc_prt_line(cp, leftlen, - " * = Re-negotiation pending before next command.\n"); - ASC_PRT_NEXT(); + seq_printf(m, + " * = Re-negotiation pending before next command.\n"); } - - return totlen; -} - -/* - * asc_proc_copy() - * - * Copy proc information to a read buffer taking into account the current - * read offset in the file and the remaining space in the read buffer. - */ -static int -asc_proc_copy(off_t advoffset, off_t offset, char *curbuf, int leftlen, - char *cp, int cplen) -{ - int cnt = 0; - - ASC_DBG(2, "offset %d, advoffset %d, cplen %d\n", - (unsigned)offset, (unsigned)advoffset, cplen); - if (offset <= advoffset) { - /* Read offset below current offset, copy everything. */ - cnt = min(cplen, leftlen); - ASC_DBG(2, "curbuf 0x%lx, cp 0x%lx, cnt %d\n", - (ulong)curbuf, (ulong)cp, cnt); - memcpy(curbuf, cp, cnt); - } else if (offset < advoffset + cplen) { - /* Read offset within current range, partial copy. */ - cnt = (advoffset + cplen) - offset; - cp = (cp + cplen) - cnt; - cnt = min(cnt, leftlen); - ASC_DBG(2, "curbuf 0x%lx, cp 0x%lx, cnt %d\n", - (ulong)curbuf, (ulong)cp, cnt); - memcpy(curbuf, cp, cnt); - } - return cnt; } #ifdef ADVANSYS_STATS /* * asc_prt_board_stats() - * - * Note: no single line should be greater than ASC_PRTLINE_SIZE, - * cf. asc_prt_line(). - * - * Return the number of characters copied into 'cp'. No more than - * 'cplen' characters will be copied to 'cp'. */ -static int asc_prt_board_stats(struct Scsi_Host *shost, char *cp, int cplen) +static void asc_prt_board_stats(struct seq_file *m, struct Scsi_Host *shost) { struct asc_board *boardp = shost_priv(shost); struct asc_stats *s = &boardp->asc_stats; - int leftlen = cplen; - int len, totlen = 0; + seq_printf(m, + "\nLinux Driver Statistics for AdvanSys SCSI Host %d:\n", + shost->host_no); - len = asc_prt_line(cp, leftlen, - "\nLinux Driver Statistics for AdvanSys SCSI Host %d:\n", - shost->host_no); - ASC_PRT_NEXT(); + seq_printf(m, + " queuecommand %lu, reset %lu, biosparam %lu, interrupt %lu\n", + s->queuecommand, s->reset, s->biosparam, + s->interrupt); - len = asc_prt_line(cp, leftlen, - " queuecommand %lu, reset %lu, biosparam %lu, interrupt %lu\n", - s->queuecommand, s->reset, s->biosparam, - s->interrupt); - ASC_PRT_NEXT(); + seq_printf(m, + " callback %lu, done %lu, build_error %lu, build_noreq %lu, build_nosg %lu\n", + s->callback, s->done, s->build_error, + s->adv_build_noreq, s->adv_build_nosg); - len = asc_prt_line(cp, leftlen, - " callback %lu, done %lu, build_error %lu, build_noreq %lu, build_nosg %lu\n", - s->callback, s->done, s->build_error, - s->adv_build_noreq, s->adv_build_nosg); - ASC_PRT_NEXT(); - - len = asc_prt_line(cp, leftlen, - " exe_noerror %lu, exe_busy %lu, exe_error %lu, exe_unknown %lu\n", - s->exe_noerror, s->exe_busy, s->exe_error, - s->exe_unknown); - ASC_PRT_NEXT(); + seq_printf(m, + " exe_noerror %lu, exe_busy %lu, exe_error %lu, exe_unknown %lu\n", + s->exe_noerror, s->exe_busy, s->exe_error, + s->exe_unknown); /* * Display data transfer statistics. */ if (s->xfer_cnt > 0) { - len = asc_prt_line(cp, leftlen, " xfer_cnt %lu, xfer_elem %lu, ", - s->xfer_cnt, s->xfer_elem); - ASC_PRT_NEXT(); + seq_printf(m, " xfer_cnt %lu, xfer_elem %lu, ", + s->xfer_cnt, s->xfer_elem); - len = asc_prt_line(cp, leftlen, "xfer_bytes %lu.%01lu kb\n", - s->xfer_sect / 2, ASC_TENTHS(s->xfer_sect, 2)); - ASC_PRT_NEXT(); + seq_printf(m, "xfer_bytes %lu.%01lu kb\n", + s->xfer_sect / 2, ASC_TENTHS(s->xfer_sect, 2)); /* Scatter gather transfer statistics */ - len = asc_prt_line(cp, leftlen, " avg_num_elem %lu.%01lu, ", - s->xfer_elem / s->xfer_cnt, - ASC_TENTHS(s->xfer_elem, s->xfer_cnt)); - ASC_PRT_NEXT(); + seq_printf(m, " avg_num_elem %lu.%01lu, ", + s->xfer_elem / s->xfer_cnt, + ASC_TENTHS(s->xfer_elem, s->xfer_cnt)); - len = asc_prt_line(cp, leftlen, "avg_elem_size %lu.%01lu kb, ", - (s->xfer_sect / 2) / s->xfer_elem, - ASC_TENTHS((s->xfer_sect / 2), s->xfer_elem)); - ASC_PRT_NEXT(); + seq_printf(m, "avg_elem_size %lu.%01lu kb, ", + (s->xfer_sect / 2) / s->xfer_elem, + ASC_TENTHS((s->xfer_sect / 2), s->xfer_elem)); - len = asc_prt_line(cp, leftlen, "avg_xfer_size %lu.%01lu kb\n", - (s->xfer_sect / 2) / s->xfer_cnt, - ASC_TENTHS((s->xfer_sect / 2), s->xfer_cnt)); - ASC_PRT_NEXT(); + seq_printf(m, "avg_xfer_size %lu.%01lu kb\n", + (s->xfer_sect / 2) / s->xfer_cnt, + ASC_TENTHS((s->xfer_sect / 2), s->xfer_cnt)); } - - return totlen; } #endif /* ADVANSYS_STATS */ /* - * advansys_proc_info() - /proc/scsi/advansys/{0,1,2,3,...} + * advansys_show_info() - /proc/scsi/advansys/{0,1,2,3,...} * - * *buffer: I/O buffer - * **start: if inout == FALSE pointer into buffer where user read should start - * offset: current offset into a /proc/scsi/advansys/[0...] file - * length: length of buffer - * hostno: Scsi_Host host_no - * inout: TRUE - user is writing; FALSE - user is reading + * m: seq_file to print into + * shost: Scsi_Host * * Return the number of bytes read from or written to a * /proc/scsi/advansys/[0...] file. - * - * Note: This function uses the per board buffer 'prtbuf' which is - * allocated when the board is initialized in advansys_detect(). The - * buffer is ASC_PRTBUF_SIZE bytes. The function asc_proc_copy() is - * used to write to the buffer. The way asc_proc_copy() is written - * if 'prtbuf' is too small it will not be overwritten. Instead the - * user just won't get all the available statistics. */ static int -advansys_proc_info(struct Scsi_Host *shost, char *buffer, char **start, - off_t offset, int length, int inout) +advansys_show_info(struct seq_file *m, struct Scsi_Host *shost) { struct asc_board *boardp = shost_priv(shost); - char *cp; - int cplen; - int cnt; - int totcnt; - int leftlen; - char *curbuf; - off_t advoffset; ASC_DBG(1, "begin\n"); - /* - * User write not supported. - */ - if (inout == TRUE) - return -ENOSYS; - /* * User read of /proc/scsi/advansys/[0...] file. */ - /* Copy read data starting at the beginning of the buffer. */ - *start = buffer; - curbuf = buffer; - advoffset = 0; - totcnt = 0; - leftlen = length; - /* * Get board configuration information. * * advansys_info() returns the board string from its own static buffer. */ - cp = (char *)advansys_info(shost); - strcat(cp, "\n"); - cplen = strlen(cp); /* Copy board information. */ - cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen); - totcnt += cnt; - leftlen -= cnt; - if (leftlen == 0) { - ASC_DBG(1, "totcnt %d\n", totcnt); - return totcnt; - } - advoffset += cplen; - curbuf += cnt; - + seq_printf(m, "%s\n", (char *)advansys_info(shost)); /* * Display Wide Board BIOS Information. */ - if (!ASC_NARROW_BOARD(boardp)) { - cp = boardp->prtbuf; - cplen = asc_prt_adv_bios(shost, cp, ASC_PRTBUF_SIZE); - BUG_ON(cplen >= ASC_PRTBUF_SIZE); - cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, - cplen); - totcnt += cnt; - leftlen -= cnt; - if (leftlen == 0) { - ASC_DBG(1, "totcnt %d\n", totcnt); - return totcnt; - } - advoffset += cplen; - curbuf += cnt; - } + if (!ASC_NARROW_BOARD(boardp)) + asc_prt_adv_bios(m, shost); /* * Display driver information for each device attached to the board. */ - cp = boardp->prtbuf; - cplen = asc_prt_board_devices(shost, cp, ASC_PRTBUF_SIZE); - BUG_ON(cplen >= ASC_PRTBUF_SIZE); - cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen); - totcnt += cnt; - leftlen -= cnt; - if (leftlen == 0) { - ASC_DBG(1, "totcnt %d\n", totcnt); - return totcnt; - } - advoffset += cplen; - curbuf += cnt; + asc_prt_board_devices(m, shost); /* * Display EEPROM configuration for the board. */ - cp = boardp->prtbuf; - if (ASC_NARROW_BOARD(boardp)) { - cplen = asc_prt_asc_board_eeprom(shost, cp, ASC_PRTBUF_SIZE); - } else { - cplen = asc_prt_adv_board_eeprom(shost, cp, ASC_PRTBUF_SIZE); - } - BUG_ON(cplen >= ASC_PRTBUF_SIZE); - cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen); - totcnt += cnt; - leftlen -= cnt; - if (leftlen == 0) { - ASC_DBG(1, "totcnt %d\n", totcnt); - return totcnt; - } - advoffset += cplen; - curbuf += cnt; + if (ASC_NARROW_BOARD(boardp)) + asc_prt_asc_board_eeprom(m, shost); + else + asc_prt_adv_board_eeprom(m, shost); /* * Display driver configuration and information for the board. */ - cp = boardp->prtbuf; - cplen = asc_prt_driver_conf(shost, cp, ASC_PRTBUF_SIZE); - BUG_ON(cplen >= ASC_PRTBUF_SIZE); - cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen); - totcnt += cnt; - leftlen -= cnt; - if (leftlen == 0) { - ASC_DBG(1, "totcnt %d\n", totcnt); - return totcnt; - } - advoffset += cplen; - curbuf += cnt; + asc_prt_driver_conf(m, shost); #ifdef ADVANSYS_STATS /* * Display driver statistics for the board. */ - cp = boardp->prtbuf; - cplen = asc_prt_board_stats(shost, cp, ASC_PRTBUF_SIZE); - BUG_ON(cplen >= ASC_PRTBUF_SIZE); - cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen); - totcnt += cnt; - leftlen -= cnt; - if (leftlen == 0) { - ASC_DBG(1, "totcnt %d\n", totcnt); - return totcnt; - } - advoffset += cplen; - curbuf += cnt; + asc_prt_board_stats(m, shost); #endif /* ADVANSYS_STATS */ /* * Display Asc Library dynamic configuration information * for the board. */ - cp = boardp->prtbuf; - if (ASC_NARROW_BOARD(boardp)) { - cplen = asc_prt_asc_board_info(shost, cp, ASC_PRTBUF_SIZE); - } else { - cplen = asc_prt_adv_board_info(shost, cp, ASC_PRTBUF_SIZE); - } - BUG_ON(cplen >= ASC_PRTBUF_SIZE); - cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen); - totcnt += cnt; - leftlen -= cnt; - if (leftlen == 0) { - ASC_DBG(1, "totcnt %d\n", totcnt); - return totcnt; - } - advoffset += cplen; - curbuf += cnt; - - ASC_DBG(1, "totcnt %d\n", totcnt); - - return totcnt; + if (ASC_NARROW_BOARD(boardp)) + asc_prt_asc_board_info(m, shost); + else + asc_prt_adv_board_info(m, shost); + return 0; } #endif /* CONFIG_PROC_FS */ @@ -11743,7 +11250,7 @@ static int AdvInitGetConfig(struct pci_dev *pdev, struct Scsi_Host *shost) static struct scsi_host_template advansys_template = { .proc_name = DRV_NAME, #ifdef CONFIG_PROC_FS - .proc_info = advansys_proc_info, + .show_info = advansys_show_info, #endif .name = DRV_NAME, .info = advansys_info, @@ -11939,20 +11446,6 @@ static int advansys_board_found(struct Scsi_Host *shost, unsigned int iop, #endif /* CONFIG_PCI */ } -#ifdef CONFIG_PROC_FS - /* - * Allocate buffer for printing information from - * /proc/scsi/advansys/[0...]. - */ - boardp->prtbuf = kmalloc(ASC_PRTBUF_SIZE, GFP_KERNEL); - if (!boardp->prtbuf) { - shost_printk(KERN_ERR, shost, "kmalloc(%d) returned NULL\n", - ASC_PRTBUF_SIZE); - ret = -ENOMEM; - goto err_unmap; - } -#endif /* CONFIG_PROC_FS */ - if (ASC_NARROW_BOARD(boardp)) { /* * Set the board bus type and PCI IRQ before @@ -12010,7 +11503,7 @@ static int advansys_board_found(struct Scsi_Host *shost, unsigned int iop, } if (ret) - goto err_free_proc; + goto err_unmap; /* * Save the EEPROM configuration so that it can be displayed @@ -12055,7 +11548,7 @@ static int advansys_board_found(struct Scsi_Host *shost, unsigned int iop, ASC_DBG(2, "AscInitSetConfig()\n"); ret = AscInitSetConfig(pdev, shost) ? -ENODEV : 0; if (ret) - goto err_free_proc; + goto err_unmap; } else { ADVEEP_3550_CONFIG *ep_3550; ADVEEP_38C0800_CONFIG *ep_38C0800; @@ -12290,7 +11783,7 @@ static int advansys_board_found(struct Scsi_Host *shost, unsigned int iop, shost_printk(KERN_ERR, shost, "request_dma() " "%d failed %d\n", shost->dma_channel, ret); - goto err_free_proc; + goto err_unmap; } AscEnableIsaDma(shost->dma_channel); } @@ -12371,8 +11864,6 @@ static int advansys_board_found(struct Scsi_Host *shost, unsigned int iop, if (shost->dma_channel != NO_ISA_DMA) free_dma(shost->dma_channel); #endif - err_free_proc: - kfree(boardp->prtbuf); err_unmap: if (boardp->ioremap_addr) iounmap(boardp->ioremap_addr); @@ -12406,7 +11897,6 @@ static int advansys_release(struct Scsi_Host *shost) iounmap(board->ioremap_addr); advansys_wide_free_mem(board); } - kfree(board->prtbuf); scsi_host_put(shost); ASC_DBG(1, "end\n"); return 0; -- cgit v1.2.3 From 31491e1ac425edc6b80a670a71ac8d2dfdd78417 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 03:04:13 -0400 Subject: advansys: fix buggered formats - unsigned long != u32 on 64bit asc_prt_line() had been hiding several places where formats had not matched the argument types. The previous commit has finally made them visible... Signed-off-by: Al Viro --- drivers/scsi/advansys.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c index 9029a208b9c..c67e401954c 100644 --- a/drivers/scsi/advansys.c +++ b/drivers/scsi/advansys.c @@ -3345,7 +3345,7 @@ static void asc_prt_driver_conf(struct seq_file *m, struct Scsi_Host *shost) shost->host_no); seq_printf(m, - " host_busy %u, last_reset %u, max_id %u, max_lun %u, max_channel %u\n", + " host_busy %u, last_reset %lu, max_id %u, max_lun %u, max_channel %u\n", shost->host_busy, shost->last_reset, shost->max_id, shost->max_lun, shost->max_channel); @@ -3359,11 +3359,11 @@ static void asc_prt_driver_conf(struct seq_file *m, struct Scsi_Host *shost) shost->unchecked_isa_dma, shost->use_clustering); seq_printf(m, - " flags 0x%x, last_reset 0x%x, jiffies 0x%x, asc_n_io_port 0x%x\n", + " flags 0x%x, last_reset 0x%lx, jiffies 0x%lx, asc_n_io_port 0x%x\n", boardp->flags, boardp->last_reset, jiffies, boardp->asc_n_io_port); - seq_printf(m, " io_port 0x%x\n", shost->io_port); + seq_printf(m, " io_port 0x%lx\n", shost->io_port); if (ASC_NARROW_BOARD(boardp)) { chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id; @@ -3539,7 +3539,7 @@ static void asc_prt_adv_board_info(struct seq_file *m, struct Scsi_Host *shost) seq_printf(m, " iop_base 0x%lx, cable_detect: %X, err_code %u\n", - v->iop_base, + (unsigned long)v->iop_base, AdvReadWordRegister(iop_base,IOPW_SCSI_CFG1) & CABLE_DETECT, v->err_code); @@ -3670,7 +3670,7 @@ static void asc_prt_adv_board_info(struct seq_file *m, struct Scsi_Host *shost) period = (((lramword >> 8) * 25) + 50) / 4; if (period == 0) { /* Should never happen. */ - seq_printf(m, "%d (? Mhz), "); + seq_printf(m, "%d (? Mhz), ", period); } else { seq_printf(m, "%d (%d.%d Mhz),", @@ -3711,17 +3711,17 @@ static void asc_prt_board_stats(struct seq_file *m, struct Scsi_Host *shost) shost->host_no); seq_printf(m, - " queuecommand %lu, reset %lu, biosparam %lu, interrupt %lu\n", + " queuecommand %u, reset %u, biosparam %u, interrupt %u\n", s->queuecommand, s->reset, s->biosparam, s->interrupt); seq_printf(m, - " callback %lu, done %lu, build_error %lu, build_noreq %lu, build_nosg %lu\n", + " callback %u, done %u, build_error %u, build_noreq %u, build_nosg %u\n", s->callback, s->done, s->build_error, s->adv_build_noreq, s->adv_build_nosg); seq_printf(m, - " exe_noerror %lu, exe_busy %lu, exe_error %lu, exe_unknown %lu\n", + " exe_noerror %u, exe_busy %u, exe_error %u, exe_unknown %u\n", s->exe_noerror, s->exe_busy, s->exe_error, s->exe_unknown); @@ -3729,22 +3729,22 @@ static void asc_prt_board_stats(struct seq_file *m, struct Scsi_Host *shost) * Display data transfer statistics. */ if (s->xfer_cnt > 0) { - seq_printf(m, " xfer_cnt %lu, xfer_elem %lu, ", + seq_printf(m, " xfer_cnt %u, xfer_elem %u, ", s->xfer_cnt, s->xfer_elem); - seq_printf(m, "xfer_bytes %lu.%01lu kb\n", + seq_printf(m, "xfer_bytes %u.%01u kb\n", s->xfer_sect / 2, ASC_TENTHS(s->xfer_sect, 2)); /* Scatter gather transfer statistics */ - seq_printf(m, " avg_num_elem %lu.%01lu, ", + seq_printf(m, " avg_num_elem %u.%01u, ", s->xfer_elem / s->xfer_cnt, ASC_TENTHS(s->xfer_elem, s->xfer_cnt)); - seq_printf(m, "avg_elem_size %lu.%01lu kb, ", + seq_printf(m, "avg_elem_size %u.%01u kb, ", (s->xfer_sect / 2) / s->xfer_elem, ASC_TENTHS((s->xfer_sect / 2), s->xfer_elem)); - seq_printf(m, "avg_xfer_size %lu.%01lu kb\n", + seq_printf(m, "avg_xfer_size %u.%01u kb\n", (s->xfer_sect / 2) / s->xfer_cnt, ASC_TENTHS((s->xfer_sect / 2), s->xfer_cnt)); } -- cgit v1.2.3 From 275084cbff47f8a3f4b6f86464d08da6691424db Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 03:12:15 -0400 Subject: aha152x: switch to ->show_info() Signed-off-by: Al Viro --- drivers/scsi/aha152x.c | 61 ++++++++++---------------------------------------- 1 file changed, 12 insertions(+), 49 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c index a284be17699..3f7b6fee0a7 100644 --- a/drivers/scsi/aha152x.c +++ b/drivers/scsi/aha152x.c @@ -2977,11 +2977,10 @@ static void show_queues(struct Scsi_Host *shpnt) } #undef SPRINTF -#define SPRINTF(args...) pos += sprintf(pos, ## args) +#define SPRINTF(args...) seq_printf(m, ##args) -static int get_command(char *pos, Scsi_Cmnd * ptr) +static void get_command(struct seq_file *m, Scsi_Cmnd * ptr) { - char *start = pos; int i; SPRINTF("%p: target=%d; lun=%d; cmnd=( ", @@ -3011,13 +3010,10 @@ static int get_command(char *pos, Scsi_Cmnd * ptr) if (ptr->SCp.phase & syncneg) SPRINTF("syncneg|"); SPRINTF("; next=0x%p\n", SCNEXT(ptr)); - - return (pos - start); } -static int get_ports(struct Scsi_Host *shpnt, char *pos) +static void get_ports(struct seq_file *m, struct Scsi_Host *shpnt) { - char *start = pos; int s; SPRINTF("\n%s: %s(%s) ", CURRENT_SC ? "on bus" : "waiting", states[STATE].name, states[PREVSTATE].name); @@ -3273,11 +3269,9 @@ static int get_ports(struct Scsi_Host *shpnt, char *pos) if (s & ENREQINIT) SPRINTF("ENREQINIT "); SPRINTF(")\n"); - - return (pos - start); } -static int aha152x_set_info(char *buffer, int length, struct Scsi_Host *shpnt) +static int aha152x_set_info(struct Scsi_Host *shpnt, char *buffer, int length) { if(!shpnt || !buffer || length<8 || strncmp("aha152x ", buffer, 8)!=0) return -EINVAL; @@ -3320,26 +3314,11 @@ static int aha152x_set_info(char *buffer, int length, struct Scsi_Host *shpnt) return length; } -#undef SPRINTF -#define SPRINTF(args...) \ - do { if(pos < buffer + length) pos += sprintf(pos, ## args); } while(0) - -static int aha152x_proc_info(struct Scsi_Host *shpnt, char *buffer, char **start, - off_t offset, int length, int inout) +static int aha152x_show_info(struct seq_file *m, struct Scsi_Host *shpnt) { int i; - char *pos = buffer; Scsi_Cmnd *ptr; unsigned long flags; - int thislength; - - DPRINTK(debug_procinfo, - KERN_DEBUG "aha152x_proc_info: buffer=%p offset=%ld length=%d hostno=%d inout=%d\n", - buffer, offset, length, shpnt->host_no, inout); - - - if (inout) - return aha152x_set_info(buffer, length, shpnt); SPRINTF(AHA152X_REVID "\n"); @@ -3392,25 +3371,25 @@ static int aha152x_proc_info(struct Scsi_Host *shpnt, char *buffer, char **start if (ISSUE_SC) { SPRINTF("not yet issued commands:\n"); for (ptr = ISSUE_SC; ptr; ptr = SCNEXT(ptr)) - pos += get_command(pos, ptr); + get_command(m, ptr); } else SPRINTF("no not yet issued commands\n"); DO_UNLOCK(flags); if (CURRENT_SC) { SPRINTF("current command:\n"); - pos += get_command(pos, CURRENT_SC); + get_command(m, CURRENT_SC); } else SPRINTF("no current command\n"); if (DISCONNECTED_SC) { SPRINTF("disconnected commands:\n"); for (ptr = DISCONNECTED_SC; ptr; ptr = SCNEXT(ptr)) - pos += get_command(pos, ptr); + get_command(m, ptr); } else SPRINTF("no disconnected commands\n"); - pos += get_ports(shpnt, pos); + get_ports(m, shpnt); #if defined(AHA152X_STAT) SPRINTF("statistics:\n" @@ -3440,24 +3419,7 @@ static int aha152x_proc_info(struct Scsi_Host *shpnt, char *buffer, char **start HOSTDATA(shpnt)->time[i]); } #endif - - DPRINTK(debug_procinfo, KERN_DEBUG "aha152x_proc_info: pos=%p\n", pos); - - thislength = pos - (buffer + offset); - DPRINTK(debug_procinfo, KERN_DEBUG "aha152x_proc_info: length=%d thislength=%d\n", length, thislength); - - if(thislength<0) { - DPRINTK(debug_procinfo, KERN_DEBUG "aha152x_proc_info: output too short\n"); - *start = NULL; - return 0; - } - - thislength = thislength Date: Sun, 31 Mar 2013 03:15:00 -0400 Subject: aha1740: switch to ->show_info() Signed-off-by: Al Viro --- drivers/scsi/aha1740.c | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/aha1740.c b/drivers/scsi/aha1740.c index df775e6ba57..5f3101797c9 100644 --- a/drivers/scsi/aha1740.c +++ b/drivers/scsi/aha1740.c @@ -106,33 +106,14 @@ static inline dma_addr_t ecb_cpu_to_dma (struct Scsi_Host *host, void *cpu) return hdata->ecb_dma_addr + offset; } -static int aha1740_proc_info(struct Scsi_Host *shpnt, char *buffer, - char **start, off_t offset, - int length, int inout) +static int aha1740_show_info(struct seq_file *m, struct Scsi_Host *shpnt) { - int len; - struct aha1740_hostdata *host; - - if (inout) - return-ENOSYS; - - host = HOSTDATA(shpnt); - - len = sprintf(buffer, "aha174x at IO:%lx, IRQ %d, SLOT %d.\n" + struct aha1740_hostdata *host = HOSTDATA(shpnt); + seq_printf(m, "aha174x at IO:%lx, IRQ %d, SLOT %d.\n" "Extended translation %sabled.\n", shpnt->io_port, shpnt->irq, host->edev->slot, host->translation ? "en" : "dis"); - - if (offset > len) { - *start = buffer; - return 0; - } - - *start = buffer + offset; - len -= offset; - if (len > length) - len = length; - return len; + return 0; } static int aha1740_makecode(unchar *sense, unchar *status) @@ -556,7 +537,7 @@ static int aha1740_eh_abort_handler (Scsi_Cmnd *dummy) static struct scsi_host_template aha1740_template = { .module = THIS_MODULE, .proc_name = "aha1740", - .proc_info = aha1740_proc_info, + .show_info = aha1740_show_info, .name = "Adaptec 174x (EISA)", .queuecommand = aha1740_queuecommand, .bios_param = aha1740_biosparam, -- cgit v1.2.3 From 8c986544562b667766f42e08a206f6c2e21d272c Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 03:18:35 -0400 Subject: eata_pio: switch to ->show_info() Signed-off-by: Al Viro --- drivers/scsi/eata_pio.c | 56 +++++++++---------------------------------------- 1 file changed, 10 insertions(+), 46 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/eata_pio.c b/drivers/scsi/eata_pio.c index d5f8362335d..356def44ce5 100644 --- a/drivers/scsi/eata_pio.c +++ b/drivers/scsi/eata_pio.c @@ -92,58 +92,22 @@ static unsigned long queue_counter; static struct scsi_host_template driver_template; -/* - * eata_proc_info - * inout : decides on the direction of the dataflow and the meaning of the - * variables - * buffer: If inout==FALSE data is being written to it else read from it - * *start: If inout==FALSE start of the valid data in the buffer - * offset: If inout==FALSE offset from the beginning of the imaginary file - * from which we start writing into the buffer - * length: If inout==FALSE max number of bytes to be written into the buffer - * else number of bytes in the buffer - */ -static int eata_pio_proc_info(struct Scsi_Host *shost, char *buffer, char **start, off_t offset, - int length, int rw) +static int eata_pio_show_info(struct seq_file *m, struct Scsi_Host *shost) { - int len = 0; - off_t begin = 0, pos = 0; - - if (rw) - return -ENOSYS; - - len += sprintf(buffer+len, "EATA (Extended Attachment) PIO driver version: " + seq_printf(m, "EATA (Extended Attachment) PIO driver version: " "%d.%d%s\n",VER_MAJOR, VER_MINOR, VER_SUB); - len += sprintf(buffer + len, "queued commands: %10ld\n" + seq_printf(m, "queued commands: %10ld\n" "processed interrupts:%10ld\n", queue_counter, int_counter); - len += sprintf(buffer + len, "\nscsi%-2d: HBA %.10s\n", + seq_printf(m, "\nscsi%-2d: HBA %.10s\n", shost->host_no, SD(shost)->name); - len += sprintf(buffer + len, "Firmware revision: v%s\n", + seq_printf(m, "Firmware revision: v%s\n", SD(shost)->revision); - len += sprintf(buffer + len, "IO: PIO\n"); - len += sprintf(buffer + len, "Base IO : %#.4x\n", (u32) shost->base); - len += sprintf(buffer + len, "Host Bus: %s\n", + seq_printf(m, "IO: PIO\n"); + seq_printf(m, "Base IO : %#.4x\n", (u32) shost->base); + seq_printf(m, "Host Bus: %s\n", (SD(shost)->bustype == 'P')?"PCI ": (SD(shost)->bustype == 'E')?"EISA":"ISA "); - - pos = begin + len; - - if (pos < offset) { - len = 0; - begin = pos; - } - if (pos > offset + length) - goto stop_output; - -stop_output: - DBG(DBG_PROC, printk("2pos: %ld offset: %ld len: %d\n", pos, offset, len)); - *start = buffer + (offset - begin); /* Start of wanted data */ - len -= (offset - begin); /* Start slop */ - if (len > length) - len = length; /* Ending slop */ - DBG(DBG_PROC, printk("3pos: %ld offset: %ld len: %d\n", pos, offset, len)); - - return len; + return 0; } static int eata_pio_release(struct Scsi_Host *sh) @@ -985,7 +949,7 @@ static int eata_pio_detect(struct scsi_host_template *tpnt) static struct scsi_host_template driver_template = { .proc_name = "eata_pio", .name = "EATA (Extended Attachment) PIO driver", - .proc_info = eata_pio_proc_info, + .show_info = eata_pio_show_info, .detect = eata_pio_detect, .release = eata_pio_release, .queuecommand = eata_pio_queue, -- cgit v1.2.3 From ff98f7ce0ec89a3de50a1920eb8a223bf0a3a6f2 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 03:21:50 -0400 Subject: dpt_i2o: switch to ->show_info() Signed-off-by: Al Viro --- drivers/scsi/dpt_i2o.c | 102 ++++++------------------------------------------- 1 file changed, 12 insertions(+), 90 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c index b6e2700ec1c..19e1b422260 100644 --- a/drivers/scsi/dpt_i2o.c +++ b/drivers/scsi/dpt_i2o.c @@ -553,36 +553,14 @@ static const char *adpt_info(struct Scsi_Host *host) return (char *) (pHba->detail); } -static int adpt_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, - int length, int inout) +static int adpt_show_info(struct seq_file *m, struct Scsi_Host *host) { struct adpt_device* d; int id; int chan; - int len = 0; - int begin = 0; - int pos = 0; adpt_hba* pHba; int unit; - *start = buffer; - if (inout == TRUE) { - /* - * The user has done a write and wants us to take the - * data in the buffer and do something with it. - * proc_scsiwrite calls us with inout = 1 - * - * Read data from buffer (writing to us) - NOT SUPPORTED - */ - return -EINVAL; - } - - /* - * inout = 0 means the user has done a read and wants information - * returned, so we write information about the cards into the buffer - * proc_scsiread() calls us with inout = 0 - */ - // Find HBA (host bus adapter) we are looking for mutex_lock(&adpt_configuration_lock); for (pHba = hba_chain; pHba; pHba = pHba->next) { @@ -596,86 +574,30 @@ static int adpt_proc_info(struct Scsi_Host *host, char *buffer, char **start, of } host = pHba->host; - len = sprintf(buffer , "Adaptec I2O RAID Driver Version: %s\n\n", DPT_I2O_VERSION); - len += sprintf(buffer+len, "%s\n", pHba->detail); - len += sprintf(buffer+len, "SCSI Host=scsi%d Control Node=/dev/%s irq=%d\n", + seq_printf(m, "Adaptec I2O RAID Driver Version: %s\n\n", DPT_I2O_VERSION); + seq_printf(m, "%s\n", pHba->detail); + seq_printf(m, "SCSI Host=scsi%d Control Node=/dev/%s irq=%d\n", pHba->host->host_no, pHba->name, host->irq); - len += sprintf(buffer+len, "\tpost fifo size = %d\n\treply fifo size = %d\n\tsg table size = %d\n\n", + seq_printf(m, "\tpost fifo size = %d\n\treply fifo size = %d\n\tsg table size = %d\n\n", host->can_queue, (int) pHba->reply_fifo_size , host->sg_tablesize); - pos = begin + len; - - /* CHECKPOINT */ - if(pos > offset + length) { - goto stop_output; - } - if(pos <= offset) { - /* - * If we haven't even written to where we last left - * off (the last time we were called), reset the - * beginning pointer. - */ - len = 0; - begin = pos; - } - len += sprintf(buffer+len, "Devices:\n"); + seq_printf(m, "Devices:\n"); for(chan = 0; chan < MAX_CHANNEL; chan++) { for(id = 0; id < MAX_ID; id++) { d = pHba->channel[chan].device[id]; - while(d){ - len += sprintf(buffer+len,"\t%-24.24s", d->pScsi_dev->vendor); - len += sprintf(buffer+len," Rev: %-8.8s\n", d->pScsi_dev->rev); - pos = begin + len; - - - /* CHECKPOINT */ - if(pos > offset + length) { - goto stop_output; - } - if(pos <= offset) { - len = 0; - begin = pos; - } + while(d) { + seq_printf(m,"\t%-24.24s", d->pScsi_dev->vendor); + seq_printf(m," Rev: %-8.8s\n", d->pScsi_dev->rev); unit = d->pI2o_dev->lct_data.tid; - len += sprintf(buffer+len, "\tTID=%d, (Channel=%d, Target=%d, Lun=%d) (%s)\n\n", + seq_printf(m, "\tTID=%d, (Channel=%d, Target=%d, Lun=%d) (%s)\n\n", unit, (int)d->scsi_channel, (int)d->scsi_id, (int)d->scsi_lun, scsi_device_online(d->pScsi_dev)? "online":"offline"); - pos = begin + len; - - /* CHECKPOINT */ - if(pos > offset + length) { - goto stop_output; - } - if(pos <= offset) { - len = 0; - begin = pos; - } - d = d->next_lun; } } } - - /* - * begin is where we last checked our position with regards to offset - * begin is always less than offset. len is relative to begin. It - * is the number of bytes written past begin - * - */ -stop_output: - /* stop the output and calculate the correct length */ - *(buffer + len) = '\0'; - - *start = buffer + (offset - begin); /* Start of wanted data */ - len -= (offset - begin); - if(len > length) { - len = length; - } else if(len < 0){ - len = 0; - **start = '\0'; - } - return len; + return 0; } /* @@ -3639,7 +3561,7 @@ static struct scsi_host_template driver_template = { .module = THIS_MODULE, .name = "dpt_i2o", .proc_name = "dpt_i2o", - .proc_info = adpt_proc_info, + .show_info = adpt_show_info, .info = adpt_info, .queuecommand = adpt_queue, .eh_abort_handler = adpt_abort, -- cgit v1.2.3 From d32812ae4b94a306e84cfbfbfeecda4ba3d1ba0f Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 03:24:12 -0400 Subject: dc395x: switch to ->show_info() Signed-off-by: Al Viro --- drivers/scsi/dc395x.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c index fed486bfd3f..694e13c45df 100644 --- a/drivers/scsi/dc395x.c +++ b/drivers/scsi/dc395x.c @@ -4616,26 +4616,21 @@ static void adapter_uninit(struct AdapterCtlBlk *acb) #undef SPRINTF -#define SPRINTF(args...) pos += sprintf(pos, args) +#define SPRINTF(args...) seq_printf(m,##args) #undef YESNO #define YESNO(YN) \ if (YN) SPRINTF(" Yes ");\ else SPRINTF(" No ") -static int dc395x_proc_info(struct Scsi_Host *host, char *buffer, - char **start, off_t offset, int length, int inout) +static int dc395x_show_info(struct seq_file *m, struct Scsi_Host *host) { struct AdapterCtlBlk *acb = (struct AdapterCtlBlk *)host->hostdata; int spd, spd1; - char *pos = buffer; struct DeviceCtlBlk *dcb; unsigned long flags; int dev; - if (inout) /* Has data been written to the file ? */ - return -EPERM; - SPRINTF(DC395X_BANNER " PCI SCSI Host Adapter\n"); SPRINTF(" Driver Version " DC395X_VERSION "\n"); @@ -4735,22 +4730,15 @@ static int dc395x_proc_info(struct Scsi_Host *host, char *buffer, SPRINTF("END\n"); } - *start = buffer + offset; DC395x_UNLOCK_IO(acb->scsi_host, flags); - - if (pos - buffer < offset) - return 0; - else if (pos - buffer - offset < length) - return pos - buffer - offset; - else - return length; + return 0; } static struct scsi_host_template dc395x_driver_template = { .module = THIS_MODULE, .proc_name = DC395X_NAME, - .proc_info = dc395x_proc_info, + .show_info = dc395x_show_info, .name = DC395X_BANNER " " DC395X_VERSION, .queuecommand = dc395x_queue_command, .bios_param = dc395x_bios_param, -- cgit v1.2.3 From d773e42213bcec26400732e494e2d8e37dc08c92 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 03:26:26 -0400 Subject: atp870u: switch to ->show_info() Signed-off-by: Al Viro --- drivers/scsi/atp870u.c | 40 ++++++++-------------------------------- 1 file changed, 8 insertions(+), 32 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/atp870u.c b/drivers/scsi/atp870u.c index cfc73041f10..15a629d8ed0 100644 --- a/drivers/scsi/atp870u.c +++ b/drivers/scsi/atp870u.c @@ -3099,38 +3099,14 @@ static const char *atp870u_info(struct Scsi_Host *notused) return buffer; } -#define BLS buffer + len + size -static int atp870u_proc_info(struct Scsi_Host *HBAptr, char *buffer, - char **start, off_t offset, int length, int inout) +static int atp870u_show_info(struct seq_file *m, struct Scsi_Host *HBAptr) { - static u8 buff[512]; - int size = 0; - int len = 0; - off_t begin = 0; - off_t pos = 0; - - if (inout) - return -EINVAL; - if (offset == 0) - memset(buff, 0, sizeof(buff)); - size += sprintf(BLS, "ACARD AEC-671X Driver Version: 2.6+ac\n"); - len += size; - pos = begin + len; - size = 0; - - size += sprintf(BLS, "\n"); - size += sprintf(BLS, "Adapter Configuration:\n"); - size += sprintf(BLS, " Base IO: %#.4lx\n", HBAptr->io_port); - size += sprintf(BLS, " IRQ: %d\n", HBAptr->irq); - len += size; - pos = begin + len; - - *start = buffer + (offset - begin); /* Start of wanted data */ - len -= (offset - begin); /* Start slop */ - if (len > length) { - len = length; /* Ending slop */ - } - return (len); + seq_printf(m, "ACARD AEC-671X Driver Version: 2.6+ac\n"); + seq_printf(m, "\n"); + seq_printf(m, "Adapter Configuration:\n"); + seq_printf(m, " Base IO: %#.4lx\n", HBAptr->io_port); + seq_printf(m, " IRQ: %d\n", HBAptr->irq); + return 0; } @@ -3177,7 +3153,7 @@ static struct scsi_host_template atp870u_template = { .module = THIS_MODULE, .name = "atp870u" /* name */, .proc_name = "atp870u", - .proc_info = atp870u_proc_info, + .show_info = atp870u_show_info, .info = atp870u_info /* info */, .queuecommand = atp870u_queuecommand /* queuecommand */, .eh_abort_handler = atp870u_abort /* abort */, -- cgit v1.2.3 From 887fc88e63139810cbde5bf41aa11a749b2b776b Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 03:32:45 -0400 Subject: in2000: switch to ->show_info() Signed-off-by: Al Viro --- drivers/scsi/in2000.c | 178 ++++++++++++++++++++------------------------------ 1 file changed, 72 insertions(+), 106 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/in2000.c b/drivers/scsi/in2000.c index deb5b6d8398..bf028218ac3 100644 --- a/drivers/scsi/in2000.c +++ b/drivers/scsi/in2000.c @@ -2166,152 +2166,117 @@ static int in2000_biosparam(struct scsi_device *sdev, struct block_device *bdev, } -static int in2000_proc_info(struct Scsi_Host *instance, char *buf, char **start, off_t off, int len, int in) +static int in2000_write_info(struct Scsi_Host *instance, char *buf, int len) { #ifdef PROC_INTERFACE char *bp; - char tbuf[128]; - unsigned long flags; struct IN2000_hostdata *hd; - Scsi_Cmnd *cmd; int x, i; - static int stop = 0; hd = (struct IN2000_hostdata *) instance->hostdata; -/* If 'in' is TRUE we need to _read_ the proc file. We accept the following - * keywords (same format as command-line, but only ONE per read): - * debug - * disconnect - * period - * resync - * proc - */ - - if (in) { - buf[len] = '\0'; - bp = buf; - if (!strncmp(bp, "debug:", 6)) { - bp += 6; - hd->args = simple_strtoul(bp, NULL, 0) & DB_MASK; - } else if (!strncmp(bp, "disconnect:", 11)) { - bp += 11; - x = simple_strtoul(bp, NULL, 0); - if (x < DIS_NEVER || x > DIS_ALWAYS) - x = DIS_ADAPTIVE; - hd->disconnect = x; - } else if (!strncmp(bp, "period:", 7)) { - bp += 7; - x = simple_strtoul(bp, NULL, 0); - hd->default_sx_per = sx_table[round_period((unsigned int) x)].period_ns; - } else if (!strncmp(bp, "resync:", 7)) { - bp += 7; - x = simple_strtoul(bp, NULL, 0); - for (i = 0; i < 7; i++) - if (x & (1 << i)) - hd->sync_stat[i] = SS_UNSET; - } else if (!strncmp(bp, "proc:", 5)) { - bp += 5; - hd->proc = simple_strtoul(bp, NULL, 0); - } else if (!strncmp(bp, "level2:", 7)) { - bp += 7; - hd->level2 = simple_strtoul(bp, NULL, 0); - } - return len; + buf[len] = '\0'; + bp = buf; + if (!strncmp(bp, "debug:", 6)) { + bp += 6; + hd->args = simple_strtoul(bp, NULL, 0) & DB_MASK; + } else if (!strncmp(bp, "disconnect:", 11)) { + bp += 11; + x = simple_strtoul(bp, NULL, 0); + if (x < DIS_NEVER || x > DIS_ALWAYS) + x = DIS_ADAPTIVE; + hd->disconnect = x; + } else if (!strncmp(bp, "period:", 7)) { + bp += 7; + x = simple_strtoul(bp, NULL, 0); + hd->default_sx_per = sx_table[round_period((unsigned int) x)].period_ns; + } else if (!strncmp(bp, "resync:", 7)) { + bp += 7; + x = simple_strtoul(bp, NULL, 0); + for (i = 0; i < 7; i++) + if (x & (1 << i)) + hd->sync_stat[i] = SS_UNSET; + } else if (!strncmp(bp, "proc:", 5)) { + bp += 5; + hd->proc = simple_strtoul(bp, NULL, 0); + } else if (!strncmp(bp, "level2:", 7)) { + bp += 7; + hd->level2 = simple_strtoul(bp, NULL, 0); } +#endif + return len; +} + +static int in2000_show_info(struct seq_file *m, struct Scsi_Host *instance) +{ + +#ifdef PROC_INTERFACE + unsigned long flags; + struct IN2000_hostdata *hd; + Scsi_Cmnd *cmd; + int x; + + hd = (struct IN2000_hostdata *) instance->hostdata; spin_lock_irqsave(instance->host_lock, flags); - bp = buf; - *bp = '\0'; - if (hd->proc & PR_VERSION) { - sprintf(tbuf, "\nVersion %s - %s.", IN2000_VERSION, IN2000_DATE); - strcat(bp, tbuf); - } + if (hd->proc & PR_VERSION) + seq_printf(m, "\nVersion %s - %s.", IN2000_VERSION, IN2000_DATE); + if (hd->proc & PR_INFO) { - sprintf(tbuf, "\ndip_switch=%02x: irq=%d io=%02x floppy=%s sync/DOS5=%s", (hd->dip_switch & 0x7f), instance->irq, hd->io_base, (hd->dip_switch & 0x40) ? "Yes" : "No", (hd->dip_switch & 0x20) ? "Yes" : "No"); - strcat(bp, tbuf); - strcat(bp, "\nsync_xfer[] = "); - for (x = 0; x < 7; x++) { - sprintf(tbuf, "\t%02x", hd->sync_xfer[x]); - strcat(bp, tbuf); - } - strcat(bp, "\nsync_stat[] = "); - for (x = 0; x < 7; x++) { - sprintf(tbuf, "\t%02x", hd->sync_stat[x]); - strcat(bp, tbuf); - } + seq_printf(m, "\ndip_switch=%02x: irq=%d io=%02x floppy=%s sync/DOS5=%s", (hd->dip_switch & 0x7f), instance->irq, hd->io_base, (hd->dip_switch & 0x40) ? "Yes" : "No", (hd->dip_switch & 0x20) ? "Yes" : "No"); + seq_printf(m, "\nsync_xfer[] = "); + for (x = 0; x < 7; x++) + seq_printf(m, "\t%02x", hd->sync_xfer[x]); + seq_printf(m, "\nsync_stat[] = "); + for (x = 0; x < 7; x++) + seq_printf(m, "\t%02x", hd->sync_stat[x]); } #ifdef PROC_STATISTICS if (hd->proc & PR_STATISTICS) { - strcat(bp, "\ncommands issued: "); - for (x = 0; x < 7; x++) { - sprintf(tbuf, "\t%ld", hd->cmd_cnt[x]); - strcat(bp, tbuf); - } - strcat(bp, "\ndisconnects allowed:"); - for (x = 0; x < 7; x++) { - sprintf(tbuf, "\t%ld", hd->disc_allowed_cnt[x]); - strcat(bp, tbuf); - } - strcat(bp, "\ndisconnects done: "); - for (x = 0; x < 7; x++) { - sprintf(tbuf, "\t%ld", hd->disc_done_cnt[x]); - strcat(bp, tbuf); - } - sprintf(tbuf, "\ninterrupts: \t%ld", hd->int_cnt); - strcat(bp, tbuf); + seq_printf(m, "\ncommands issued: "); + for (x = 0; x < 7; x++) + seq_printf(m, "\t%ld", hd->cmd_cnt[x]); + seq_printf(m, "\ndisconnects allowed:"); + for (x = 0; x < 7; x++) + seq_printf(m, "\t%ld", hd->disc_allowed_cnt[x]); + seq_printf(m, "\ndisconnects done: "); + for (x = 0; x < 7; x++) + seq_printf(m, "\t%ld", hd->disc_done_cnt[x]); + seq_printf(m, "\ninterrupts: \t%ld", hd->int_cnt); } #endif if (hd->proc & PR_CONNECTED) { - strcat(bp, "\nconnected: "); + seq_printf(m, "\nconnected: "); if (hd->connected) { cmd = (Scsi_Cmnd *) hd->connected; - sprintf(tbuf, " %d:%d(%02x)", cmd->device->id, cmd->device->lun, cmd->cmnd[0]); - strcat(bp, tbuf); + seq_printf(m, " %d:%d(%02x)", cmd->device->id, cmd->device->lun, cmd->cmnd[0]); } } if (hd->proc & PR_INPUTQ) { - strcat(bp, "\ninput_Q: "); + seq_printf(m, "\ninput_Q: "); cmd = (Scsi_Cmnd *) hd->input_Q; while (cmd) { - sprintf(tbuf, " %d:%d(%02x)", cmd->device->id, cmd->device->lun, cmd->cmnd[0]); - strcat(bp, tbuf); + seq_printf(m, " %d:%d(%02x)", cmd->device->id, cmd->device->lun, cmd->cmnd[0]); cmd = (Scsi_Cmnd *) cmd->host_scribble; } } if (hd->proc & PR_DISCQ) { - strcat(bp, "\ndisconnected_Q:"); + seq_printf(m, "\ndisconnected_Q:"); cmd = (Scsi_Cmnd *) hd->disconnected_Q; while (cmd) { - sprintf(tbuf, " %d:%d(%02x)", cmd->device->id, cmd->device->lun, cmd->cmnd[0]); - strcat(bp, tbuf); + seq_printf(m, " %d:%d(%02x)", cmd->device->id, cmd->device->lun, cmd->cmnd[0]); cmd = (Scsi_Cmnd *) cmd->host_scribble; } } if (hd->proc & PR_TEST) { ; /* insert your own custom function here */ } - strcat(bp, "\n"); + seq_printf(m, "\n"); spin_unlock_irqrestore(instance->host_lock, flags); - *start = buf; - if (stop) { - stop = 0; - return 0; /* return 0 to signal end-of-file */ - } - if (off > 0x40000) /* ALWAYS stop after 256k bytes have been read */ - stop = 1; - if (hd->proc & PR_STOP) /* stop every other time */ - stop = 1; - return strlen(bp); - -#else /* PROC_INTERFACE */ - - return 0; - #endif /* PROC_INTERFACE */ - + return 0; } MODULE_LICENSE("GPL"); @@ -2319,7 +2284,8 @@ MODULE_LICENSE("GPL"); static struct scsi_host_template driver_template = { .proc_name = "in2000", - .proc_info = in2000_proc_info, + .write_info = in2000_write_info, + .show_info = in2000_show_info, .name = "Always IN2000", .detect = in2000_detect, .release = in2000_release, -- cgit v1.2.3 From f6f83a6c9210725c730b64ba4b1db74641fab023 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 03:59:17 -0400 Subject: aic79xx: switch to ->show_info() Signed-off-by: Al Viro --- drivers/scsi/aic7xxx/aic79xx_osm.c | 9 +- drivers/scsi/aic7xxx/aic79xx_osm.h | 12 +-- drivers/scsi/aic7xxx/aic79xx_proc.c | 163 +++++++++++------------------------- 3 files changed, 53 insertions(+), 131 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c index 9328121804b..69d5c43a65e 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm.c +++ b/drivers/scsi/aic7xxx/aic79xx_osm.c @@ -906,7 +906,8 @@ struct scsi_host_template aic79xx_driver_template = { .module = THIS_MODULE, .name = "aic79xx", .proc_name = "aic79xx", - .proc_info = ahd_linux_proc_info, + .show_info = ahd_linux_show_info, + .write_info = ahd_proc_write_seeprom, .info = ahd_linux_info, .queuecommand = ahd_linux_queue, .eh_abort_handler = ahd_linux_abort, @@ -1702,19 +1703,13 @@ ahd_send_async(struct ahd_softc *ahd, char channel, switch (code) { case AC_TRANSFER_NEG: { - char buf[80]; struct scsi_target *starget; - struct info_str info; struct ahd_initiator_tinfo *tinfo; struct ahd_tmode_tstate *tstate; unsigned int target_ppr_options; BUG_ON(target == CAM_TARGET_WILDCARD); - info.buffer = buf; - info.length = sizeof(buf); - info.offset = 0; - info.pos = 0; tinfo = ahd_fetch_transinfo(ahd, channel, ahd->our_id, target, &tstate); diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.h b/drivers/scsi/aic7xxx/aic79xx_osm.h index 28e43498cdf..c58fa33c659 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm.h +++ b/drivers/scsi/aic7xxx/aic79xx_osm.h @@ -379,14 +379,6 @@ void ahd_insb(struct ahd_softc * ahd, long port, int ahd_linux_register_host(struct ahd_softc *, struct scsi_host_template *); -/*************************** Pretty Printing **********************************/ -struct info_str { - char *buffer; - int length; - off_t offset; - int pos; -}; - /******************************** Locking *************************************/ static inline void ahd_lockinit(struct ahd_softc *ahd) @@ -513,8 +505,8 @@ ahd_flush_device_writes(struct ahd_softc *ahd) } /**************************** Proc FS Support *********************************/ -int ahd_linux_proc_info(struct Scsi_Host *, char *, char **, - off_t, int, int); +int ahd_proc_write_seeprom(struct Scsi_Host *, char *, int); +int ahd_linux_show_info(struct seq_file *,struct Scsi_Host *); /*********************** Transaction Access Wrappers **************************/ static inline void ahd_cmd_set_transaction_status(struct scsi_cmnd *, uint32_t); diff --git a/drivers/scsi/aic7xxx/aic79xx_proc.c b/drivers/scsi/aic7xxx/aic79xx_proc.c index 59c85d5a153..e9778b4f7e3 100644 --- a/drivers/scsi/aic7xxx/aic79xx_proc.c +++ b/drivers/scsi/aic7xxx/aic79xx_proc.c @@ -42,16 +42,12 @@ #include "aic79xx_osm.h" #include "aic79xx_inline.h" -static void copy_mem_info(struct info_str *info, char *data, int len); -static int copy_info(struct info_str *info, char *fmt, ...); static void ahd_dump_target_state(struct ahd_softc *ahd, - struct info_str *info, + struct seq_file *m, u_int our_id, char channel, u_int target_id); -static void ahd_dump_device_state(struct info_str *info, +static void ahd_dump_device_state(struct seq_file *m, struct scsi_device *sdev); -static int ahd_proc_write_seeprom(struct ahd_softc *ahd, - char *buffer, int length); /* * Table of syncrates that don't follow the "divisible by 4" @@ -93,58 +89,15 @@ ahd_calc_syncsrate(u_int period_factor) return (10000000 / (period_factor * 4 * 10)); } - -static void -copy_mem_info(struct info_str *info, char *data, int len) -{ - if (info->pos + len > info->offset + info->length) - len = info->offset + info->length - info->pos; - - if (info->pos + len < info->offset) { - info->pos += len; - return; - } - - if (info->pos < info->offset) { - off_t partial; - - partial = info->offset - info->pos; - data += partial; - info->pos += partial; - len -= partial; - } - - if (len > 0) { - memcpy(info->buffer, data, len); - info->pos += len; - info->buffer += len; - } -} - -static int -copy_info(struct info_str *info, char *fmt, ...) -{ - va_list args; - char buf[256]; - int len; - - va_start(args, fmt); - len = vsprintf(buf, fmt, args); - va_end(args); - - copy_mem_info(info, buf, len); - return (len); -} - static void -ahd_format_transinfo(struct info_str *info, struct ahd_transinfo *tinfo) +ahd_format_transinfo(struct seq_file *m, struct ahd_transinfo *tinfo) { u_int speed; u_int freq; u_int mb; if (tinfo->period == AHD_PERIOD_UNKNOWN) { - copy_info(info, "Renegotiation Pending\n"); + seq_printf(m, "Renegotiation Pending\n"); return; } speed = 3300; @@ -156,34 +109,34 @@ ahd_format_transinfo(struct info_str *info, struct ahd_transinfo *tinfo) speed *= (0x01 << tinfo->width); mb = speed / 1000; if (mb > 0) - copy_info(info, "%d.%03dMB/s transfers", mb, speed % 1000); + seq_printf(m, "%d.%03dMB/s transfers", mb, speed % 1000); else - copy_info(info, "%dKB/s transfers", speed); + seq_printf(m, "%dKB/s transfers", speed); if (freq != 0) { int printed_options; printed_options = 0; - copy_info(info, " (%d.%03dMHz", freq / 1000, freq % 1000); + seq_printf(m, " (%d.%03dMHz", freq / 1000, freq % 1000); if ((tinfo->ppr_options & MSG_EXT_PPR_RD_STRM) != 0) { - copy_info(info, " RDSTRM"); + seq_printf(m, " RDSTRM"); printed_options++; } if ((tinfo->ppr_options & MSG_EXT_PPR_DT_REQ) != 0) { - copy_info(info, "%s", printed_options ? "|DT" : " DT"); + seq_printf(m, "%s", printed_options ? "|DT" : " DT"); printed_options++; } if ((tinfo->ppr_options & MSG_EXT_PPR_IU_REQ) != 0) { - copy_info(info, "%s", printed_options ? "|IU" : " IU"); + seq_printf(m, "%s", printed_options ? "|IU" : " IU"); printed_options++; } if ((tinfo->ppr_options & MSG_EXT_PPR_RTI) != 0) { - copy_info(info, "%s", + seq_printf(m, "%s", printed_options ? "|RTI" : " RTI"); printed_options++; } if ((tinfo->ppr_options & MSG_EXT_PPR_QAS_REQ) != 0) { - copy_info(info, "%s", + seq_printf(m, "%s", printed_options ? "|QAS" : " QAS"); printed_options++; } @@ -191,19 +144,19 @@ ahd_format_transinfo(struct info_str *info, struct ahd_transinfo *tinfo) if (tinfo->width > 0) { if (freq != 0) { - copy_info(info, ", "); + seq_printf(m, ", "); } else { - copy_info(info, " ("); + seq_printf(m, " ("); } - copy_info(info, "%dbit)", 8 * (0x01 << tinfo->width)); + seq_printf(m, "%dbit)", 8 * (0x01 << tinfo->width)); } else if (freq != 0) { - copy_info(info, ")"); + seq_printf(m, ")"); } - copy_info(info, "\n"); + seq_printf(m, "\n"); } static void -ahd_dump_target_state(struct ahd_softc *ahd, struct info_str *info, +ahd_dump_target_state(struct ahd_softc *ahd, struct seq_file *m, u_int our_id, char channel, u_int target_id) { struct scsi_target *starget; @@ -213,17 +166,17 @@ ahd_dump_target_state(struct ahd_softc *ahd, struct info_str *info, tinfo = ahd_fetch_transinfo(ahd, channel, our_id, target_id, &tstate); - copy_info(info, "Target %d Negotiation Settings\n", target_id); - copy_info(info, "\tUser: "); - ahd_format_transinfo(info, &tinfo->user); + seq_printf(m, "Target %d Negotiation Settings\n", target_id); + seq_printf(m, "\tUser: "); + ahd_format_transinfo(m, &tinfo->user); starget = ahd->platform_data->starget[target_id]; if (starget == NULL) return; - copy_info(info, "\tGoal: "); - ahd_format_transinfo(info, &tinfo->goal); - copy_info(info, "\tCurr: "); - ahd_format_transinfo(info, &tinfo->curr); + seq_printf(m, "\tGoal: "); + ahd_format_transinfo(m, &tinfo->goal); + seq_printf(m, "\tCurr: "); + ahd_format_transinfo(m, &tinfo->curr); for (lun = 0; lun < AHD_NUM_LUNS; lun++) { struct scsi_device *dev; @@ -233,29 +186,30 @@ ahd_dump_target_state(struct ahd_softc *ahd, struct info_str *info, if (dev == NULL) continue; - ahd_dump_device_state(info, dev); + ahd_dump_device_state(m, dev); } } static void -ahd_dump_device_state(struct info_str *info, struct scsi_device *sdev) +ahd_dump_device_state(struct seq_file *m, struct scsi_device *sdev) { struct ahd_linux_device *dev = scsi_transport_device_data(sdev); - copy_info(info, "\tChannel %c Target %d Lun %d Settings\n", + seq_printf(m, "\tChannel %c Target %d Lun %d Settings\n", sdev->sdev_target->channel + 'A', sdev->sdev_target->id, sdev->lun); - copy_info(info, "\t\tCommands Queued %ld\n", dev->commands_issued); - copy_info(info, "\t\tCommands Active %d\n", dev->active); - copy_info(info, "\t\tCommand Openings %d\n", dev->openings); - copy_info(info, "\t\tMax Tagged Openings %d\n", dev->maxtags); - copy_info(info, "\t\tDevice Queue Frozen Count %d\n", dev->qfrozen); + seq_printf(m, "\t\tCommands Queued %ld\n", dev->commands_issued); + seq_printf(m, "\t\tCommands Active %d\n", dev->active); + seq_printf(m, "\t\tCommand Openings %d\n", dev->openings); + seq_printf(m, "\t\tMax Tagged Openings %d\n", dev->maxtags); + seq_printf(m, "\t\tDevice Queue Frozen Count %d\n", dev->qfrozen); } -static int -ahd_proc_write_seeprom(struct ahd_softc *ahd, char *buffer, int length) +int +ahd_proc_write_seeprom(struct Scsi_Host *shost, char *buffer, int length) { + struct ahd_softc *ahd = *(struct ahd_softc **)shost->hostdata; ahd_mode_state saved_modes; int have_seeprom; u_long s; @@ -319,64 +273,45 @@ done: * Return information to handle /proc support for the driver. */ int -ahd_linux_proc_info(struct Scsi_Host *shost, char *buffer, char **start, - off_t offset, int length, int inout) +ahd_linux_show_info(struct seq_file *m, struct Scsi_Host *shost) { struct ahd_softc *ahd = *(struct ahd_softc **)shost->hostdata; - struct info_str info; char ahd_info[256]; u_int max_targ; u_int i; - int retval; - /* Has data been written to the file? */ - if (inout == TRUE) { - retval = ahd_proc_write_seeprom(ahd, buffer, length); - goto done; - } - - if (start) - *start = buffer; - - info.buffer = buffer; - info.length = length; - info.offset = offset; - info.pos = 0; - - copy_info(&info, "Adaptec AIC79xx driver version: %s\n", + seq_printf(m, "Adaptec AIC79xx driver version: %s\n", AIC79XX_DRIVER_VERSION); - copy_info(&info, "%s\n", ahd->description); + seq_printf(m, "%s\n", ahd->description); ahd_controller_info(ahd, ahd_info); - copy_info(&info, "%s\n", ahd_info); - copy_info(&info, "Allocated SCBs: %d, SG List Length: %d\n\n", + seq_printf(m, "%s\n", ahd_info); + seq_printf(m, "Allocated SCBs: %d, SG List Length: %d\n\n", ahd->scb_data.numscbs, AHD_NSEG); max_targ = 16; if (ahd->seep_config == NULL) - copy_info(&info, "No Serial EEPROM\n"); + seq_printf(m, "No Serial EEPROM\n"); else { - copy_info(&info, "Serial EEPROM:\n"); + seq_printf(m, "Serial EEPROM:\n"); for (i = 0; i < sizeof(*ahd->seep_config)/2; i++) { if (((i % 8) == 0) && (i != 0)) { - copy_info(&info, "\n"); + seq_printf(m, "\n"); } - copy_info(&info, "0x%.4x ", + seq_printf(m, "0x%.4x ", ((uint16_t*)ahd->seep_config)[i]); } - copy_info(&info, "\n"); + seq_printf(m, "\n"); } - copy_info(&info, "\n"); + seq_printf(m, "\n"); if ((ahd->features & AHD_WIDE) == 0) max_targ = 8; for (i = 0; i < max_targ; i++) { - ahd_dump_target_state(ahd, &info, ahd->our_id, 'A', + ahd_dump_target_state(ahd, m, ahd->our_id, 'A', /*target_id*/i); } - retval = info.pos > info.offset ? info.pos - info.offset : 0; -done: - return (retval); + return 0; } -- cgit v1.2.3 From 6b3a8bbfd15ca86da496845890a48bee27b423e4 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 04:07:31 -0400 Subject: aic7xxx: switch to ->show_info() Signed-off-by: Al Viro --- drivers/scsi/aic7xxx/aic7xxx_osm.c | 9 +-- drivers/scsi/aic7xxx/aic7xxx_osm.h | 12 +-- drivers/scsi/aic7xxx/aic7xxx_proc.c | 153 +++++++++++------------------------- 3 files changed, 48 insertions(+), 126 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c index 5a477cdc780..c0c62583b54 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_osm.c +++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c @@ -803,7 +803,8 @@ struct scsi_host_template aic7xxx_driver_template = { .module = THIS_MODULE, .name = "aic7xxx", .proc_name = "aic7xxx", - .proc_info = ahc_linux_proc_info, + .show_info = ahc_linux_show_info, + .write_info = ahc_proc_write_seeprom, .info = ahc_linux_info, .queuecommand = ahc_linux_queue, .eh_abort_handler = ahc_linux_abort, @@ -1631,10 +1632,8 @@ ahc_send_async(struct ahc_softc *ahc, char channel, switch (code) { case AC_TRANSFER_NEG: { - char buf[80]; struct scsi_target *starget; struct ahc_linux_target *targ; - struct info_str info; struct ahc_initiator_tinfo *tinfo; struct ahc_tmode_tstate *tstate; int target_offset; @@ -1642,10 +1641,6 @@ ahc_send_async(struct ahc_softc *ahc, char channel, BUG_ON(target == CAM_TARGET_WILDCARD); - info.buffer = buf; - info.length = sizeof(buf); - info.offset = 0; - info.pos = 0; tinfo = ahc_fetch_transinfo(ahc, channel, channel == 'A' ? ahc->our_id : ahc->our_id_b, diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.h b/drivers/scsi/aic7xxx/aic7xxx_osm.h index bca0fb83f55..bc4cca92ff0 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_osm.h +++ b/drivers/scsi/aic7xxx/aic7xxx_osm.h @@ -383,14 +383,6 @@ void ahc_insb(struct ahc_softc * ahc, long port, int ahc_linux_register_host(struct ahc_softc *, struct scsi_host_template *); -/*************************** Pretty Printing **********************************/ -struct info_str { - char *buffer; - int length; - off_t offset; - int pos; -}; - /******************************** Locking *************************************/ /* Lock protecting internal data structures */ @@ -523,8 +515,8 @@ ahc_flush_device_writes(struct ahc_softc *ahc) } /**************************** Proc FS Support *********************************/ -int ahc_linux_proc_info(struct Scsi_Host *, char *, char **, - off_t, int, int); +int ahc_proc_write_seeprom(struct Scsi_Host *, char *, int); +int ahc_linux_show_info(struct seq_file *, struct Scsi_Host *); /*************************** Domain Validation ********************************/ /*********************** Transaction Access Wrappers *************************/ diff --git a/drivers/scsi/aic7xxx/aic7xxx_proc.c b/drivers/scsi/aic7xxx/aic7xxx_proc.c index f2525f8ed1c..383a3d11652 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_proc.c +++ b/drivers/scsi/aic7xxx/aic7xxx_proc.c @@ -43,16 +43,12 @@ #include "aic7xxx_inline.h" #include "aic7xxx_93cx6.h" -static void copy_mem_info(struct info_str *info, char *data, int len); -static int copy_info(struct info_str *info, char *fmt, ...); static void ahc_dump_target_state(struct ahc_softc *ahc, - struct info_str *info, + struct seq_file *m, u_int our_id, char channel, u_int target_id, u_int target_offset); -static void ahc_dump_device_state(struct info_str *info, +static void ahc_dump_device_state(struct seq_file *m, struct scsi_device *dev); -static int ahc_proc_write_seeprom(struct ahc_softc *ahc, - char *buffer, int length); /* * Table of syncrates that don't follow the "divisible by 4" @@ -94,51 +90,8 @@ ahc_calc_syncsrate(u_int period_factor) return (10000000 / (period_factor * 4 * 10)); } - -static void -copy_mem_info(struct info_str *info, char *data, int len) -{ - if (info->pos + len > info->offset + info->length) - len = info->offset + info->length - info->pos; - - if (info->pos + len < info->offset) { - info->pos += len; - return; - } - - if (info->pos < info->offset) { - off_t partial; - - partial = info->offset - info->pos; - data += partial; - info->pos += partial; - len -= partial; - } - - if (len > 0) { - memcpy(info->buffer, data, len); - info->pos += len; - info->buffer += len; - } -} - -static int -copy_info(struct info_str *info, char *fmt, ...) -{ - va_list args; - char buf[256]; - int len; - - va_start(args, fmt); - len = vsprintf(buf, fmt, args); - va_end(args); - - copy_mem_info(info, buf, len); - return (len); -} - static void -ahc_format_transinfo(struct info_str *info, struct ahc_transinfo *tinfo) +ahc_format_transinfo(struct seq_file *m, struct ahc_transinfo *tinfo) { u_int speed; u_int freq; @@ -153,12 +106,12 @@ ahc_format_transinfo(struct info_str *info, struct ahc_transinfo *tinfo) speed *= (0x01 << tinfo->width); mb = speed / 1000; if (mb > 0) - copy_info(info, "%d.%03dMB/s transfers", mb, speed % 1000); + seq_printf(m, "%d.%03dMB/s transfers", mb, speed % 1000); else - copy_info(info, "%dKB/s transfers", speed); + seq_printf(m, "%dKB/s transfers", speed); if (freq != 0) { - copy_info(info, " (%d.%03dMHz%s, offset %d", + seq_printf(m, " (%d.%03dMHz%s, offset %d", freq / 1000, freq % 1000, (tinfo->ppr_options & MSG_EXT_PPR_DT_REQ) != 0 ? " DT" : "", tinfo->offset); @@ -166,19 +119,19 @@ ahc_format_transinfo(struct info_str *info, struct ahc_transinfo *tinfo) if (tinfo->width > 0) { if (freq != 0) { - copy_info(info, ", "); + seq_printf(m, ", "); } else { - copy_info(info, " ("); + seq_printf(m, " ("); } - copy_info(info, "%dbit)", 8 * (0x01 << tinfo->width)); + seq_printf(m, "%dbit)", 8 * (0x01 << tinfo->width)); } else if (freq != 0) { - copy_info(info, ")"); + seq_printf(m, ")"); } - copy_info(info, "\n"); + seq_printf(m, "\n"); } static void -ahc_dump_target_state(struct ahc_softc *ahc, struct info_str *info, +ahc_dump_target_state(struct ahc_softc *ahc, struct seq_file *m, u_int our_id, char channel, u_int target_id, u_int target_offset) { @@ -190,18 +143,18 @@ ahc_dump_target_state(struct ahc_softc *ahc, struct info_str *info, tinfo = ahc_fetch_transinfo(ahc, channel, our_id, target_id, &tstate); if ((ahc->features & AHC_TWIN) != 0) - copy_info(info, "Channel %c ", channel); - copy_info(info, "Target %d Negotiation Settings\n", target_id); - copy_info(info, "\tUser: "); - ahc_format_transinfo(info, &tinfo->user); + seq_printf(m, "Channel %c ", channel); + seq_printf(m, "Target %d Negotiation Settings\n", target_id); + seq_printf(m, "\tUser: "); + ahc_format_transinfo(m, &tinfo->user); starget = ahc->platform_data->starget[target_offset]; if (!starget) return; - copy_info(info, "\tGoal: "); - ahc_format_transinfo(info, &tinfo->goal); - copy_info(info, "\tCurr: "); - ahc_format_transinfo(info, &tinfo->curr); + seq_printf(m, "\tGoal: "); + ahc_format_transinfo(m, &tinfo->goal); + seq_printf(m, "\tCurr: "); + ahc_format_transinfo(m, &tinfo->curr); for (lun = 0; lun < AHC_NUM_LUNS; lun++) { struct scsi_device *sdev; @@ -211,29 +164,30 @@ ahc_dump_target_state(struct ahc_softc *ahc, struct info_str *info, if (sdev == NULL) continue; - ahc_dump_device_state(info, sdev); + ahc_dump_device_state(m, sdev); } } static void -ahc_dump_device_state(struct info_str *info, struct scsi_device *sdev) +ahc_dump_device_state(struct seq_file *m, struct scsi_device *sdev) { struct ahc_linux_device *dev = scsi_transport_device_data(sdev); - copy_info(info, "\tChannel %c Target %d Lun %d Settings\n", + seq_printf(m, "\tChannel %c Target %d Lun %d Settings\n", sdev->sdev_target->channel + 'A', sdev->sdev_target->id, sdev->lun); - copy_info(info, "\t\tCommands Queued %ld\n", dev->commands_issued); - copy_info(info, "\t\tCommands Active %d\n", dev->active); - copy_info(info, "\t\tCommand Openings %d\n", dev->openings); - copy_info(info, "\t\tMax Tagged Openings %d\n", dev->maxtags); - copy_info(info, "\t\tDevice Queue Frozen Count %d\n", dev->qfrozen); + seq_printf(m, "\t\tCommands Queued %ld\n", dev->commands_issued); + seq_printf(m, "\t\tCommands Active %d\n", dev->active); + seq_printf(m, "\t\tCommand Openings %d\n", dev->openings); + seq_printf(m, "\t\tMax Tagged Openings %d\n", dev->maxtags); + seq_printf(m, "\t\tDevice Queue Frozen Count %d\n", dev->qfrozen); } -static int -ahc_proc_write_seeprom(struct ahc_softc *ahc, char *buffer, int length) +int +ahc_proc_write_seeprom(struct Scsi_Host *shost, char *buffer, int length) { + struct ahc_softc *ahc = *(struct ahc_softc **)shost->hostdata; struct seeprom_descriptor sd; int have_seeprom; u_long s; @@ -332,53 +286,36 @@ done: * Return information to handle /proc support for the driver. */ int -ahc_linux_proc_info(struct Scsi_Host *shost, char *buffer, char **start, - off_t offset, int length, int inout) +ahc_linux_show_info(struct seq_file *m, struct Scsi_Host *shost) { struct ahc_softc *ahc = *(struct ahc_softc **)shost->hostdata; - struct info_str info; char ahc_info[256]; u_int max_targ; u_int i; - int retval; - /* Has data been written to the file? */ - if (inout == TRUE) { - retval = ahc_proc_write_seeprom(ahc, buffer, length); - goto done; - } - - if (start) - *start = buffer; - - info.buffer = buffer; - info.length = length; - info.offset = offset; - info.pos = 0; - - copy_info(&info, "Adaptec AIC7xxx driver version: %s\n", + seq_printf(m, "Adaptec AIC7xxx driver version: %s\n", AIC7XXX_DRIVER_VERSION); - copy_info(&info, "%s\n", ahc->description); + seq_printf(m, "%s\n", ahc->description); ahc_controller_info(ahc, ahc_info); - copy_info(&info, "%s\n", ahc_info); - copy_info(&info, "Allocated SCBs: %d, SG List Length: %d\n\n", + seq_printf(m, "%s\n", ahc_info); + seq_printf(m, "Allocated SCBs: %d, SG List Length: %d\n\n", ahc->scb_data->numscbs, AHC_NSEG); if (ahc->seep_config == NULL) - copy_info(&info, "No Serial EEPROM\n"); + seq_printf(m, "No Serial EEPROM\n"); else { - copy_info(&info, "Serial EEPROM:\n"); + seq_printf(m, "Serial EEPROM:\n"); for (i = 0; i < sizeof(*ahc->seep_config)/2; i++) { if (((i % 8) == 0) && (i != 0)) { - copy_info(&info, "\n"); + seq_printf(m, "\n"); } - copy_info(&info, "0x%.4x ", + seq_printf(m, "0x%.4x ", ((uint16_t*)ahc->seep_config)[i]); } - copy_info(&info, "\n"); + seq_printf(m, "\n"); } - copy_info(&info, "\n"); + seq_printf(m, "\n"); max_targ = 16; if ((ahc->features & (AHC_WIDE|AHC_TWIN)) == 0) @@ -398,10 +335,8 @@ ahc_linux_proc_info(struct Scsi_Host *shost, char *buffer, char **start, target_id = i % 8; } - ahc_dump_target_state(ahc, &info, our_id, + ahc_dump_target_state(ahc, m, our_id, channel, target_id, i); } - retval = info.pos > info.offset ? info.pos - info.offset : 0; -done: - return (retval); + return 0; } -- cgit v1.2.3 From 9d4e5c54a3b67cc0246afe0274ba028a85e79a10 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 04:42:22 -0400 Subject: fas216: switch to ->show_info() Signed-off-by: Al Viro --- drivers/scsi/arm/arxescsi.c | 40 +++++++--------------------------------- drivers/scsi/arm/cumana_2.c | 43 +++++++++---------------------------------- drivers/scsi/arm/eesox.c | 42 +++++++++--------------------------------- drivers/scsi/arm/fas216.c | 31 ++++++++++++------------------- drivers/scsi/arm/fas216.h | 6 +++--- drivers/scsi/arm/powertec.c | 29 +++++++++-------------------- 6 files changed, 49 insertions(+), 142 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/arm/arxescsi.c b/drivers/scsi/arm/arxescsi.c index 9274510294a..32d23212de4 100644 --- a/drivers/scsi/arm/arxescsi.c +++ b/drivers/scsi/arm/arxescsi.c @@ -220,47 +220,21 @@ static const char *arxescsi_info(struct Scsi_Host *host) return string; } -/* - * Function: int arxescsi_proc_info(char *buffer, char **start, off_t offset, - * int length, int host_no, int inout) - * Purpose : Return information about the driver to a user process accessing - * the /proc filesystem. - * Params : buffer - a buffer to write information to - * start - a pointer into this buffer set by this routine to the start - * of the required information. - * offset - offset into information that we have read up to. - * length - length of buffer - * host_no - host number to return information for - * inout - 0 for reading, 1 for writing. - * Returns : length of data written to buffer. - */ static int -arxescsi_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, int length, - int inout) +arxescsi_show_info(struct seq_file *m, struct Scsi_Host *host) { struct arxescsi_info *info; - char *p = buffer; - int pos; - info = (struct arxescsi_info *)host->hostdata; - if (inout == 1) - return -EINVAL; - - p += sprintf(p, "ARXE 16-bit SCSI driver v%s\n", VERSION); - p += fas216_print_host(&info->info, p); - p += fas216_print_stats(&info->info, p); - p += fas216_print_devices(&info->info, p); - - *start = buffer + offset; - pos = p - buffer - offset; - if (pos > length) - pos = length; - return pos; + seq_printf(m, "ARXE 16-bit SCSI driver v%s\n", VERSION); + fas216_print_host(&info->info, m); + fas216_print_stats(&info->info, m); + fas216_print_devices(&info->info, m); + return 0; } static struct scsi_host_template arxescsi_template = { - .proc_info = arxescsi_proc_info, + .show_info = arxescsi_show_info, .name = "ARXE SCSI card", .info = arxescsi_info, .queuecommand = fas216_noqueue_command, diff --git a/drivers/scsi/arm/cumana_2.c b/drivers/scsi/arm/cumana_2.c index e3bae93c3c2..58915f29055 100644 --- a/drivers/scsi/arm/cumana_2.c +++ b/drivers/scsi/arm/cumana_2.c @@ -337,50 +337,25 @@ cumanascsi_2_set_proc_info(struct Scsi_Host *host, char *buffer, int length) return ret; } -/* Prototype: int cumanascsi_2_proc_info(char *buffer, char **start, off_t offset, - * int length, int host_no, int inout) - * Purpose : Return information about the driver to a user process accessing - * the /proc filesystem. - * Params : buffer - a buffer to write information to - * start - a pointer into this buffer set by this routine to the start - * of the required information. - * offset - offset into information that we have read up to. - * length - length of buffer - * host_no - host number to return information for - * inout - 0 for reading, 1 for writing. - * Returns : length of data written to buffer. - */ -int cumanascsi_2_proc_info (struct Scsi_Host *host, char *buffer, char **start, off_t offset, - int length, int inout) +static int cumanascsi_2_show_info(struct seq_file *m, struct Scsi_Host *host) { struct cumanascsi2_info *info; - char *p = buffer; - int pos; - - if (inout == 1) - return cumanascsi_2_set_proc_info(host, buffer, length); - info = (struct cumanascsi2_info *)host->hostdata; - p += sprintf(p, "Cumana SCSI II driver v%s\n", VERSION); - p += fas216_print_host(&info->info, p); - p += sprintf(p, "Term : o%s\n", + seq_printf(m, "Cumana SCSI II driver v%s\n", VERSION); + fas216_print_host(&info->info, m); + seq_printf(m, "Term : o%s\n", info->terms ? "n" : "ff"); - p += fas216_print_stats(&info->info, p); - p += fas216_print_devices(&info->info, p); - - *start = buffer + offset; - pos = p - buffer - offset; - if (pos > length) - pos = length; - - return pos; + fas216_print_stats(&info->info, m); + fas216_print_devices(&info->info, m); + return 0; } static struct scsi_host_template cumanascsi2_template = { .module = THIS_MODULE, - .proc_info = cumanascsi_2_proc_info, + .show_info = cumanascsi_2_show_info, + .write_info = cumanascsi_2_set_proc_info, .name = "Cumana SCSI II", .info = cumanascsi_2_info, .queuecommand = fas216_queue_command, diff --git a/drivers/scsi/arm/eesox.c b/drivers/scsi/arm/eesox.c index 8e36908415e..5bf3c0d134b 100644 --- a/drivers/scsi/arm/eesox.c +++ b/drivers/scsi/arm/eesox.c @@ -422,45 +422,20 @@ eesoxscsi_set_proc_info(struct Scsi_Host *host, char *buffer, int length) return ret; } -/* Prototype: int eesoxscsi_proc_info(char *buffer, char **start, off_t offset, - * int length, int host_no, int inout) - * Purpose : Return information about the driver to a user process accessing - * the /proc filesystem. - * Params : buffer - a buffer to write information to - * start - a pointer into this buffer set by this routine to the start - * of the required information. - * offset - offset into information that we have read up to. - * length - length of buffer - * host_no - host number to return information for - * inout - 0 for reading, 1 for writing. - * Returns : length of data written to buffer. - */ -int eesoxscsi_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, - int length, int inout) +static int eesoxscsi_show_info(struct seq_file *m, struct Scsi_Host *host) { struct eesoxscsi_info *info; - char *p = buffer; - int pos; - - if (inout == 1) - return eesoxscsi_set_proc_info(host, buffer, length); info = (struct eesoxscsi_info *)host->hostdata; - p += sprintf(p, "EESOX SCSI driver v%s\n", VERSION); - p += fas216_print_host(&info->info, p); - p += sprintf(p, "Term : o%s\n", + seq_printf(m, "EESOX SCSI driver v%s\n", VERSION); + fas216_print_host(&info->info, m); + seq_printf(m, "Term : o%s\n", info->control & EESOX_TERM_ENABLE ? "n" : "ff"); - p += fas216_print_stats(&info->info, p); - p += fas216_print_devices(&info->info, p); - - *start = buffer + offset; - pos = p - buffer - offset; - if (pos > length) - pos = length; - - return pos; + fas216_print_stats(&info->info, m); + fas216_print_devices(&info->info, m); + return 0; } static ssize_t eesoxscsi_show_term(struct device *dev, struct device_attribute *attr, char *buf) @@ -498,7 +473,8 @@ static DEVICE_ATTR(bus_term, S_IRUGO | S_IWUSR, static struct scsi_host_template eesox_template = { .module = THIS_MODULE, - .proc_info = eesoxscsi_proc_info, + .show_info = eesoxscsi_show_info, + .write_info = eesoxscsi_set_proc_info, .name = "EESOX SCSI", .info = eesoxscsi_info, .queuecommand = fas216_queue_command, diff --git a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c index 737554c37d9..b46a6f6c0eb 100644 --- a/drivers/scsi/arm/fas216.c +++ b/drivers/scsi/arm/fas216.c @@ -2958,9 +2958,9 @@ void fas216_release(struct Scsi_Host *host) queue_free(&info->queues.issue); } -int fas216_print_host(FAS216_Info *info, char *buffer) +void fas216_print_host(FAS216_Info *info, struct seq_file *m) { - return sprintf(buffer, + seq_printf(m, "\n" "Chip : %s\n" " Address: 0x%p\n" @@ -2970,11 +2970,9 @@ int fas216_print_host(FAS216_Info *info, char *buffer) info->scsi.irq, info->scsi.dma); } -int fas216_print_stats(FAS216_Info *info, char *buffer) +void fas216_print_stats(FAS216_Info *info, struct seq_file *m) { - char *p = buffer; - - p += sprintf(p, "\n" + seq_printf(m, "\n" "Command Statistics:\n" " Queued : %u\n" " Issued : %u\n" @@ -2991,38 +2989,33 @@ int fas216_print_stats(FAS216_Info *info, char *buffer) info->stats.writes, info->stats.miscs, info->stats.disconnects, info->stats.aborts, info->stats.bus_resets, info->stats.host_resets); - - return p - buffer; } -int fas216_print_devices(FAS216_Info *info, char *buffer) +void fas216_print_devices(FAS216_Info *info, struct seq_file *m) { struct fas216_device *dev; struct scsi_device *scd; - char *p = buffer; - p += sprintf(p, "Device/Lun TaggedQ Parity Sync\n"); + seq_printf(m, "Device/Lun TaggedQ Parity Sync\n"); shost_for_each_device(scd, info->host) { dev = &info->device[scd->id]; - p += sprintf(p, " %d/%d ", scd->id, scd->lun); + seq_printf(m, " %d/%d ", scd->id, scd->lun); if (scd->tagged_supported) - p += sprintf(p, "%3sabled(%3d) ", + seq_printf(m, "%3sabled(%3d) ", scd->simple_tags ? "en" : "dis", scd->current_tag); else - p += sprintf(p, "unsupported "); + seq_printf(m, "unsupported "); - p += sprintf(p, "%3sabled ", dev->parity_enabled ? "en" : "dis"); + seq_printf(m, "%3sabled ", dev->parity_enabled ? "en" : "dis"); if (dev->sof) - p += sprintf(p, "offset %d, %d ns\n", + seq_printf(m, "offset %d, %d ns\n", dev->sof, dev->period * 4); else - p += sprintf(p, "async\n"); + seq_printf(m, "async\n"); } - - return p - buffer; } EXPORT_SYMBOL(fas216_init); diff --git a/drivers/scsi/arm/fas216.h b/drivers/scsi/arm/fas216.h index df2e1b3ddfe..c57c16ef819 100644 --- a/drivers/scsi/arm/fas216.h +++ b/drivers/scsi/arm/fas216.h @@ -358,9 +358,9 @@ extern void fas216_remove (struct Scsi_Host *instance); */ extern void fas216_release (struct Scsi_Host *instance); -extern int fas216_print_host(FAS216_Info *info, char *buffer); -extern int fas216_print_stats(FAS216_Info *info, char *buffer); -extern int fas216_print_devices(FAS216_Info *info, char *buffer); +extern void fas216_print_host(FAS216_Info *info, struct seq_file *m); +extern void fas216_print_stats(FAS216_Info *info, struct seq_file *m); +extern void fas216_print_devices(FAS216_Info *info, struct seq_file *m); /* Function: int fas216_eh_abort(struct scsi_cmnd *SCpnt) * Purpose : abort this command diff --git a/drivers/scsi/arm/powertec.c b/drivers/scsi/arm/powertec.c index 246600b9355..abc9593615e 100644 --- a/drivers/scsi/arm/powertec.c +++ b/drivers/scsi/arm/powertec.c @@ -237,32 +237,20 @@ powertecscsi_set_proc_info(struct Scsi_Host *host, char *buffer, int length) * inout - 0 for reading, 1 for writing. * Returns : length of data written to buffer. */ -int powertecscsi_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, - int length, int inout) +static int powertecscsi_show_info(struct seq_file *m, struct Scsi_Host *host) { struct powertec_info *info; - char *p = buffer; - int pos; - - if (inout == 1) - return powertecscsi_set_proc_info(host, buffer, length); info = (struct powertec_info *)host->hostdata; - p += sprintf(p, "PowerTec SCSI driver v%s\n", VERSION); - p += fas216_print_host(&info->info, p); - p += sprintf(p, "Term : o%s\n", + seq_printf(m, "PowerTec SCSI driver v%s\n", VERSION); + fas216_print_host(&info->info, m); + seq_printf(m, "Term : o%s\n", info->term_ctl ? "n" : "ff"); - p += fas216_print_stats(&info->info, p); - p += fas216_print_devices(&info->info, p); - - *start = buffer + offset; - pos = p - buffer - offset; - if (pos > length) - pos = length; - - return pos; + fas216_print_stats(&info->info, m); + fas216_print_devices(&info->info, m); + return 0; } static ssize_t powertecscsi_show_term(struct device *dev, struct device_attribute *attr, char *buf) @@ -291,7 +279,8 @@ static DEVICE_ATTR(bus_term, S_IRUGO | S_IWUSR, static struct scsi_host_template powertecscsi_template = { .module = THIS_MODULE, - .proc_info = powertecscsi_proc_info, + .show_info = powertecscsi_show_info, + .write_info = powertecscsi_set_proc_info, .name = "PowerTec SCSI", .info = powertecscsi_info, .queuecommand = fas216_queue_command, -- cgit v1.2.3 From 56b8e8e53523c9a3e1ffacadf35c389fdb427a34 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 12:02:39 -0400 Subject: acornscsi: switch to ->show_info() Signed-off-by: Al Viro --- drivers/scsi/arm/acornscsi.c | 58 +++++++++++++------------------------------- 1 file changed, 17 insertions(+), 41 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/arm/acornscsi.c b/drivers/scsi/arm/acornscsi.c index 3e1172adb37..09ba1869d36 100644 --- a/drivers/scsi/arm/acornscsi.c +++ b/drivers/scsi/arm/acornscsi.c @@ -2836,20 +2836,15 @@ char *acornscsi_info(struct Scsi_Host *host) return string; } -int acornscsi_proc_info(struct Scsi_Host *instance, char *buffer, char **start, off_t offset, - int length, int inout) +static int acornscsi_show_info(struct seq_file *m, struct Scsi_Host *instance) { - int pos, begin = 0, devidx; + int devidx; struct scsi_device *scd; AS_Host *host; - char *p = buffer; - - if (inout == 1) - return -EINVAL; host = (AS_Host *)instance->hostdata; - p += sprintf(p, "AcornSCSI driver v%d.%d.%d" + seq_printf(m, "AcornSCSI driver v%d.%d.%d" #ifdef CONFIG_SCSI_ACORNSCSI_SYNC " SYNC" #endif @@ -2864,14 +2859,14 @@ int acornscsi_proc_info(struct Scsi_Host *instance, char *buffer, char **start, #endif "\n\n", VER_MAJOR, VER_MINOR, VER_PATCH); - p += sprintf(p, "SBIC: WD33C93A Address: %p IRQ : %d\n", + seq_printf(m, "SBIC: WD33C93A Address: %p IRQ : %d\n", host->base + SBIC_REGIDX, host->scsi.irq); #ifdef USE_DMAC - p += sprintf(p, "DMAC: uPC71071 Address: %p IRQ : %d\n\n", + seq_printf(m, "DMAC: uPC71071 Address: %p IRQ : %d\n\n", host->base + DMAC_OFFSET, host->scsi.irq); #endif - p += sprintf(p, "Statistics:\n" + seq_printf(m, "Statistics:\n" "Queued commands: %-10u Issued commands: %-10u\n" "Done commands : %-10u Reads : %-10u\n" "Writes : %-10u Others : %-10u\n" @@ -2886,7 +2881,7 @@ int acornscsi_proc_info(struct Scsi_Host *instance, char *buffer, char **start, for (devidx = 0; devidx < 9; devidx ++) { unsigned int statptr, prev; - p += sprintf(p, "\n%c:", devidx == 8 ? 'H' : ('0' + devidx)); + seq_printf(m, "\n%c:", devidx == 8 ? 'H' : ('0' + devidx)); statptr = host->status_ptr[devidx] - 10; if ((signed int)statptr < 0) @@ -2896,7 +2891,7 @@ int acornscsi_proc_info(struct Scsi_Host *instance, char *buffer, char **start, for (; statptr != host->status_ptr[devidx]; statptr = (statptr + 1) & (STATUS_BUFFER_SIZE - 1)) { if (host->status[devidx][statptr].when) { - p += sprintf(p, "%c%02X:%02X+%2ld", + seq_printf(m, "%c%02X:%02X+%2ld", host->status[devidx][statptr].irq ? '-' : ' ', host->status[devidx][statptr].ph, host->status[devidx][statptr].ssr, @@ -2907,51 +2902,32 @@ int acornscsi_proc_info(struct Scsi_Host *instance, char *buffer, char **start, } } - p += sprintf(p, "\nAttached devices:\n"); + seq_printf(m, "\nAttached devices:\n"); shost_for_each_device(scd, instance) { - p += sprintf(p, "Device/Lun TaggedQ Sync\n"); - p += sprintf(p, " %d/%d ", scd->id, scd->lun); + seq_printf(m, "Device/Lun TaggedQ Sync\n"); + seq_printf(m, " %d/%d ", scd->id, scd->lun); if (scd->tagged_supported) - p += sprintf(p, "%3sabled(%3d) ", + seq_printf(m, "%3sabled(%3d) ", scd->simple_tags ? "en" : "dis", scd->current_tag); else - p += sprintf(p, "unsupported "); + seq_printf(m, "unsupported "); if (host->device[scd->id].sync_xfer & 15) - p += sprintf(p, "offset %d, %d ns\n", + seq_printf(m, "offset %d, %d ns\n", host->device[scd->id].sync_xfer & 15, acornscsi_getperiod(host->device[scd->id].sync_xfer)); else - p += sprintf(p, "async\n"); + seq_printf(m, "async\n"); - pos = p - buffer; - if (pos + begin < offset) { - begin += pos; - p = buffer; - } - pos = p - buffer; - if (pos + begin > offset + length) { - scsi_device_put(scd); - break; - } } - - pos = p - buffer; - - *start = buffer + (offset - begin); - pos -= offset - begin; - - if (pos > length) - pos = length; - - return pos; + return 0; } static struct scsi_host_template acornscsi_template = { .module = THIS_MODULE, - .proc_info = acornscsi_proc_info, + .show_info = acornscsi_show_info, .name = "AcornSCSI", .info = acornscsi_info, .queuecommand = acornscsi_queuecmd, -- cgit v1.2.3 From aacce706fae01dbef03a0c2ca40a363bcb88b24a Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 12:15:44 -0400 Subject: ips: switch to ->show_info() Signed-off-by: Al Viro --- drivers/scsi/ips.c | 232 ++++++++++++++++++----------------------------------- drivers/scsi/ips.h | 9 --- 2 files changed, 80 insertions(+), 161 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c index 9aa86a315a0..3f9b335292d 100644 --- a/drivers/scsi/ips.c +++ b/drivers/scsi/ips.c @@ -326,10 +326,9 @@ static void ips_scmd_buf_write(struct scsi_cmnd * scmd, void *data, static void ips_scmd_buf_read(struct scsi_cmnd * scmd, void *data, unsigned int count); -static int ips_proc_info(struct Scsi_Host *, char *, char **, off_t, int, int); -static int ips_host_info(ips_ha_t *, char *, off_t, int); -static void copy_mem_info(IPS_INFOSTR *, char *, int); -static int copy_info(IPS_INFOSTR *, char *, ...); +static int ips_write_info(struct Scsi_Host *, char *, int); +static int ips_show_info(struct seq_file *, struct Scsi_Host *); +static int ips_host_info(ips_ha_t *, struct seq_file *); static int ips_abort_init(ips_ha_t * ha, int index); static int ips_init_phase2(int index); @@ -367,7 +366,8 @@ static struct scsi_host_template ips_driver_template = { .eh_abort_handler = ips_eh_abort, .eh_host_reset_handler = ips_eh_reset, .proc_name = "ips", - .proc_info = ips_proc_info, + .show_info = ips_show_info, + .write_info = ips_write_info, .slave_configure = ips_slave_configure, .bios_param = ips_biosparam, .this_id = -1, @@ -1433,25 +1433,12 @@ ips_info(struct Scsi_Host *SH) return (bp); } -/****************************************************************************/ -/* */ -/* Routine Name: ips_proc_info */ -/* */ -/* Routine Description: */ -/* */ -/* The passthru interface for the driver */ -/* */ -/****************************************************************************/ static int -ips_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, - int length, int func) +ips_write_info(struct Scsi_Host *host, char *buffer, int length) { int i; - int ret; ips_ha_t *ha = NULL; - METHOD_TRACE("ips_proc_info", 1); - /* Find our host structure */ for (i = 0; i < ips_next_controller; i++) { if (ips_sh[i]) { @@ -1465,18 +1452,29 @@ ips_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, if (!ha) return (-EINVAL); - if (func) { - /* write */ - return (0); - } else { - /* read */ - if (start) - *start = buffer; + return 0; +} - ret = ips_host_info(ha, buffer, offset, length); +static int +ips_show_info(struct seq_file *m, struct Scsi_Host *host) +{ + int i; + ips_ha_t *ha = NULL; - return (ret); + /* Find our host structure */ + for (i = 0; i < ips_next_controller; i++) { + if (ips_sh[i]) { + if (ips_sh[i] == host) { + ha = (ips_ha_t *) ips_sh[i]->hostdata; + break; + } + } } + + if (!ha) + return (-EINVAL); + + return ips_host_info(ha, m); } /*--------------------------------------------------------------------------*/ @@ -2035,183 +2033,113 @@ ips_cleanup_passthru(ips_ha_t * ha, ips_scb_t * scb) /* */ /****************************************************************************/ static int -ips_host_info(ips_ha_t * ha, char *ptr, off_t offset, int len) +ips_host_info(ips_ha_t *ha, struct seq_file *m) { - IPS_INFOSTR info; - METHOD_TRACE("ips_host_info", 1); - info.buffer = ptr; - info.length = len; - info.offset = offset; - info.pos = 0; - info.localpos = 0; - - copy_info(&info, "\nIBM ServeRAID General Information:\n\n"); + seq_printf(m, "\nIBM ServeRAID General Information:\n\n"); if ((le32_to_cpu(ha->nvram->signature) == IPS_NVRAM_P5_SIG) && (le16_to_cpu(ha->nvram->adapter_type) != 0)) - copy_info(&info, "\tController Type : %s\n", + seq_printf(m, "\tController Type : %s\n", ips_adapter_name[ha->ad_type - 1]); else - copy_info(&info, + seq_printf(m, "\tController Type : Unknown\n"); if (ha->io_addr) - copy_info(&info, + seq_printf(m, "\tIO region : 0x%lx (%d bytes)\n", ha->io_addr, ha->io_len); if (ha->mem_addr) { - copy_info(&info, + seq_printf(m, "\tMemory region : 0x%lx (%d bytes)\n", ha->mem_addr, ha->mem_len); - copy_info(&info, + seq_printf(m, "\tShared memory address : 0x%lx\n", ha->mem_ptr); } - copy_info(&info, "\tIRQ number : %d\n", ha->pcidev->irq); + seq_printf(m, "\tIRQ number : %d\n", ha->pcidev->irq); /* For the Next 3 lines Check for Binary 0 at the end and don't include it if it's there. */ /* That keeps everything happy for "text" operations on the proc file. */ if (le32_to_cpu(ha->nvram->signature) == IPS_NVRAM_P5_SIG) { if (ha->nvram->bios_low[3] == 0) { - copy_info(&info, - "\tBIOS Version : %c%c%c%c%c%c%c\n", - ha->nvram->bios_high[0], ha->nvram->bios_high[1], - ha->nvram->bios_high[2], ha->nvram->bios_high[3], - ha->nvram->bios_low[0], ha->nvram->bios_low[1], - ha->nvram->bios_low[2]); + seq_printf(m, + "\tBIOS Version : %c%c%c%c%c%c%c\n", + ha->nvram->bios_high[0], ha->nvram->bios_high[1], + ha->nvram->bios_high[2], ha->nvram->bios_high[3], + ha->nvram->bios_low[0], ha->nvram->bios_low[1], + ha->nvram->bios_low[2]); } else { - copy_info(&info, - "\tBIOS Version : %c%c%c%c%c%c%c%c\n", - ha->nvram->bios_high[0], ha->nvram->bios_high[1], - ha->nvram->bios_high[2], ha->nvram->bios_high[3], - ha->nvram->bios_low[0], ha->nvram->bios_low[1], - ha->nvram->bios_low[2], ha->nvram->bios_low[3]); + seq_printf(m, + "\tBIOS Version : %c%c%c%c%c%c%c%c\n", + ha->nvram->bios_high[0], ha->nvram->bios_high[1], + ha->nvram->bios_high[2], ha->nvram->bios_high[3], + ha->nvram->bios_low[0], ha->nvram->bios_low[1], + ha->nvram->bios_low[2], ha->nvram->bios_low[3]); } } if (ha->enq->CodeBlkVersion[7] == 0) { - copy_info(&info, - "\tFirmware Version : %c%c%c%c%c%c%c\n", - ha->enq->CodeBlkVersion[0], ha->enq->CodeBlkVersion[1], - ha->enq->CodeBlkVersion[2], ha->enq->CodeBlkVersion[3], - ha->enq->CodeBlkVersion[4], ha->enq->CodeBlkVersion[5], - ha->enq->CodeBlkVersion[6]); + seq_printf(m, + "\tFirmware Version : %c%c%c%c%c%c%c\n", + ha->enq->CodeBlkVersion[0], ha->enq->CodeBlkVersion[1], + ha->enq->CodeBlkVersion[2], ha->enq->CodeBlkVersion[3], + ha->enq->CodeBlkVersion[4], ha->enq->CodeBlkVersion[5], + ha->enq->CodeBlkVersion[6]); } else { - copy_info(&info, - "\tFirmware Version : %c%c%c%c%c%c%c%c\n", - ha->enq->CodeBlkVersion[0], ha->enq->CodeBlkVersion[1], - ha->enq->CodeBlkVersion[2], ha->enq->CodeBlkVersion[3], - ha->enq->CodeBlkVersion[4], ha->enq->CodeBlkVersion[5], - ha->enq->CodeBlkVersion[6], ha->enq->CodeBlkVersion[7]); + seq_printf(m, + "\tFirmware Version : %c%c%c%c%c%c%c%c\n", + ha->enq->CodeBlkVersion[0], ha->enq->CodeBlkVersion[1], + ha->enq->CodeBlkVersion[2], ha->enq->CodeBlkVersion[3], + ha->enq->CodeBlkVersion[4], ha->enq->CodeBlkVersion[5], + ha->enq->CodeBlkVersion[6], ha->enq->CodeBlkVersion[7]); } if (ha->enq->BootBlkVersion[7] == 0) { - copy_info(&info, - "\tBoot Block Version : %c%c%c%c%c%c%c\n", - ha->enq->BootBlkVersion[0], ha->enq->BootBlkVersion[1], - ha->enq->BootBlkVersion[2], ha->enq->BootBlkVersion[3], - ha->enq->BootBlkVersion[4], ha->enq->BootBlkVersion[5], - ha->enq->BootBlkVersion[6]); + seq_printf(m, + "\tBoot Block Version : %c%c%c%c%c%c%c\n", + ha->enq->BootBlkVersion[0], ha->enq->BootBlkVersion[1], + ha->enq->BootBlkVersion[2], ha->enq->BootBlkVersion[3], + ha->enq->BootBlkVersion[4], ha->enq->BootBlkVersion[5], + ha->enq->BootBlkVersion[6]); } else { - copy_info(&info, - "\tBoot Block Version : %c%c%c%c%c%c%c%c\n", - ha->enq->BootBlkVersion[0], ha->enq->BootBlkVersion[1], - ha->enq->BootBlkVersion[2], ha->enq->BootBlkVersion[3], - ha->enq->BootBlkVersion[4], ha->enq->BootBlkVersion[5], - ha->enq->BootBlkVersion[6], ha->enq->BootBlkVersion[7]); + seq_printf(m, + "\tBoot Block Version : %c%c%c%c%c%c%c%c\n", + ha->enq->BootBlkVersion[0], ha->enq->BootBlkVersion[1], + ha->enq->BootBlkVersion[2], ha->enq->BootBlkVersion[3], + ha->enq->BootBlkVersion[4], ha->enq->BootBlkVersion[5], + ha->enq->BootBlkVersion[6], ha->enq->BootBlkVersion[7]); } - copy_info(&info, "\tDriver Version : %s%s\n", + seq_printf(m, "\tDriver Version : %s%s\n", IPS_VERSION_HIGH, IPS_VERSION_LOW); - copy_info(&info, "\tDriver Build : %d\n", + seq_printf(m, "\tDriver Build : %d\n", IPS_BUILD_IDENT); - copy_info(&info, "\tMax Physical Devices : %d\n", + seq_printf(m, "\tMax Physical Devices : %d\n", ha->enq->ucMaxPhysicalDevices); - copy_info(&info, "\tMax Active Commands : %d\n", + seq_printf(m, "\tMax Active Commands : %d\n", ha->max_cmds); - copy_info(&info, "\tCurrent Queued Commands : %d\n", + seq_printf(m, "\tCurrent Queued Commands : %d\n", ha->scb_waitlist.count); - copy_info(&info, "\tCurrent Active Commands : %d\n", + seq_printf(m, "\tCurrent Active Commands : %d\n", ha->scb_activelist.count - ha->num_ioctl); - copy_info(&info, "\tCurrent Queued PT Commands : %d\n", + seq_printf(m, "\tCurrent Queued PT Commands : %d\n", ha->copp_waitlist.count); - copy_info(&info, "\tCurrent Active PT Commands : %d\n", + seq_printf(m, "\tCurrent Active PT Commands : %d\n", ha->num_ioctl); - copy_info(&info, "\n"); - - return (info.localpos); -} - -/****************************************************************************/ -/* */ -/* Routine Name: copy_mem_info */ -/* */ -/* Routine Description: */ -/* */ -/* Copy data into an IPS_INFOSTR structure */ -/* */ -/****************************************************************************/ -static void -copy_mem_info(IPS_INFOSTR * info, char *data, int len) -{ - METHOD_TRACE("copy_mem_info", 1); - - if (info->pos + len < info->offset) { - info->pos += len; - return; - } - - if (info->pos < info->offset) { - data += (info->offset - info->pos); - len -= (info->offset - info->pos); - info->pos += (info->offset - info->pos); - } - - if (info->localpos + len > info->length) - len = info->length - info->localpos; + seq_printf(m, "\n"); - if (len > 0) { - memcpy(info->buffer + info->localpos, data, len); - info->pos += len; - info->localpos += len; - } -} - -/****************************************************************************/ -/* */ -/* Routine Name: copy_info */ -/* */ -/* Routine Description: */ -/* */ -/* printf style wrapper for an info structure */ -/* */ -/****************************************************************************/ -static int -copy_info(IPS_INFOSTR * info, char *fmt, ...) -{ - va_list args; - char buf[128]; - int len; - - METHOD_TRACE("copy_info", 1); - - va_start(args, fmt); - len = vsprintf(buf, fmt, args); - va_end(args); - - copy_mem_info(info, buf, len); - - return (len); + return 0; } /****************************************************************************/ diff --git a/drivers/scsi/ips.h b/drivers/scsi/ips.h index f2df0593332..45b9566b928 100644 --- a/drivers/scsi/ips.h +++ b/drivers/scsi/ips.h @@ -416,7 +416,6 @@ /* * Scsi_Host Template */ - static int ips_proc_info(struct Scsi_Host *, char *, char **, off_t, int, int); static int ips_biosparam(struct scsi_device *sdev, struct block_device *bdev, sector_t capacity, int geom[]); static int ips_slave_configure(struct scsi_device *SDptr); @@ -959,14 +958,6 @@ typedef union { IPS_ENH_SG_LIST *enh_list; } IPS_SG_LIST; -typedef struct _IPS_INFOSTR { - char *buffer; - int length; - int offset; - int pos; - int localpos; -} IPS_INFOSTR; - typedef struct { char *option_name; int *option_flag; -- cgit v1.2.3 From 1bb7109a1c7dd6266db0240b7f344fbed20b9063 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 12:17:09 -0400 Subject: ips: fix format bugs exposed by previous commit Signed-off-by: Al Viro --- drivers/scsi/ips.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c index 3f9b335292d..8d5ea8a1e5a 100644 --- a/drivers/scsi/ips.c +++ b/drivers/scsi/ips.c @@ -2049,16 +2049,16 @@ ips_host_info(ips_ha_t *ha, struct seq_file *m) if (ha->io_addr) seq_printf(m, - "\tIO region : 0x%lx (%d bytes)\n", + "\tIO region : 0x%x (%d bytes)\n", ha->io_addr, ha->io_len); if (ha->mem_addr) { seq_printf(m, - "\tMemory region : 0x%lx (%d bytes)\n", + "\tMemory region : 0x%x (%d bytes)\n", ha->mem_addr, ha->mem_len); seq_printf(m, "\tShared memory address : 0x%lx\n", - ha->mem_ptr); + (unsigned long)ha->mem_ptr); } seq_printf(m, "\tIRQ number : %d\n", ha->pcidev->irq); -- cgit v1.2.3 From 3f02567750c302637dedbb4fb90682999a770122 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 12:46:43 -0400 Subject: sata_svw: switch to ->show_info() Signed-off-by: Al Viro --- drivers/ata/sata_svw.c | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) (limited to 'drivers') diff --git a/drivers/ata/sata_svw.c b/drivers/ata/sata_svw.c index 08608de87e4..dc4f70179e7 100644 --- a/drivers/ata/sata_svw.c +++ b/drivers/ata/sata_svw.c @@ -322,23 +322,11 @@ static u8 k2_stat_check_status(struct ata_port *ap) } #ifdef CONFIG_PPC_OF -/* - * k2_sata_proc_info - * inout : decides on the direction of the dataflow and the meaning of the - * variables - * buffer: If inout==FALSE data is being written to it else read from it - * *start: If inout==FALSE start of the valid data in the buffer - * offset: If inout==FALSE offset from the beginning of the imaginary file - * from which we start writing into the buffer - * length: If inout==FALSE max number of bytes to be written into the buffer - * else number of bytes in the buffer - */ -static int k2_sata_proc_info(struct Scsi_Host *shost, char *page, char **start, - off_t offset, int count, int inout) +static int k2_sata_show_info(struct seq_file *m, struct Scsi_Host *shost) { struct ata_port *ap; struct device_node *np; - int len, index; + int index; /* Find the ata_port */ ap = ata_shost_to_port(shost); @@ -356,15 +344,12 @@ static int k2_sata_proc_info(struct Scsi_Host *shost, char *page, char **start, const u32 *reg = of_get_property(np, "reg", NULL); if (!reg) continue; - if (index == *reg) + if (index == *reg) { + seq_printf(m, "devspec: %s\n", np->full_name); break; + } } - if (np == NULL) - return 0; - - len = sprintf(page, "devspec: %s\n", np->full_name); - - return len; + return 0; } #endif /* CONFIG_PPC_OF */ @@ -372,7 +357,7 @@ static int k2_sata_proc_info(struct Scsi_Host *shost, char *page, char **start, static struct scsi_host_template k2_sata_sht = { ATA_BMDMA_SHT(DRV_NAME), #ifdef CONFIG_PPC_OF - .proc_info = k2_sata_proc_info, + .show_info = k2_sata_show_info, #endif }; -- cgit v1.2.3 From f0002e95a43e05260310eca5522db44549f62069 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 12:53:53 -0400 Subject: aix7xxx_old: switch to ->show_info() Signed-off-by: Al Viro --- drivers/scsi/aic7xxx_old.c | 2 +- drivers/scsi/aic7xxx_old/aic7xxx_proc.c | 221 +++++++++----------------------- 2 files changed, 60 insertions(+), 163 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/aic7xxx_old.c b/drivers/scsi/aic7xxx_old.c index 5b212f0df89..33ec9c64340 100644 --- a/drivers/scsi/aic7xxx_old.c +++ b/drivers/scsi/aic7xxx_old.c @@ -11108,7 +11108,7 @@ MODULE_VERSION(AIC7XXX_H_VERSION); static struct scsi_host_template driver_template = { - .proc_info = aic7xxx_proc_info, + .show_info = aic7xxx_show_info, .detect = aic7xxx_detect, .release = aic7xxx_release, .info = aic7xxx_info, diff --git a/drivers/scsi/aic7xxx_old/aic7xxx_proc.c b/drivers/scsi/aic7xxx_old/aic7xxx_proc.c index b07e4f04fd0..976f45ccf2c 100644 --- a/drivers/scsi/aic7xxx_old/aic7xxx_proc.c +++ b/drivers/scsi/aic7xxx_old/aic7xxx_proc.c @@ -30,62 +30,23 @@ *-M*************************************************************************/ -#define BLS (&aic7xxx_buffer[size]) #define HDRB \ " 0 - 4K 4 - 16K 16 - 64K 64 - 256K 256K - 1M 1M+" -#ifdef PROC_DEBUG -extern int vsprintf(char *, const char *, va_list); - -static void -proc_debug(const char *fmt, ...) -{ - va_list ap; - char buf[256]; - - va_start(ap, fmt); - vsprintf(buf, fmt, ap); - printk(buf); - va_end(ap); -} -#else /* PROC_DEBUG */ -# define proc_debug(fmt, args...) -#endif /* PROC_DEBUG */ - -static int aic7xxx_buffer_size = 0; -static char *aic7xxx_buffer = NULL; - /*+F************************************************************************* * Function: - * aic7xxx_set_info - * - * Description: - * Set parameters for the driver from the /proc filesystem. - *-F*************************************************************************/ -static int -aic7xxx_set_info(char *buffer, int length, struct Scsi_Host *HBAptr) -{ - proc_debug("aic7xxx_set_info(): %s\n", buffer); - return (-ENOSYS); /* Currently this is a no-op */ -} - - -/*+F************************************************************************* - * Function: - * aic7xxx_proc_info + * aic7xxx_show_info * * Description: * Return information to handle /proc support for the driver. *-F*************************************************************************/ int -aic7xxx_proc_info ( struct Scsi_Host *HBAptr, char *buffer, char **start, off_t offset, int length, - int inout) +aic7xxx_show_info(struct seq_file *m, struct Scsi_Host *HBAptr) { struct aic7xxx_host *p; struct aic_dev_data *aic_dev; struct scsi_device *sdptr; - int size = 0; unsigned char i; unsigned char tindex; @@ -94,66 +55,21 @@ aic7xxx_proc_info ( struct Scsi_Host *HBAptr, char *buffer, char **start, off_t if (!p) { - size += sprintf(buffer, "Can't find adapter for host number %d\n", HBAptr->host_no); - if (size > length) - { - return (size); - } - else - { - return (length); - } - } - - if (inout == TRUE) /* Has data been written to the file? */ - { - return (aic7xxx_set_info(buffer, length, HBAptr)); + seq_printf(m, "Can't find adapter for host number %d\n", HBAptr->host_no); + return 0; } p = (struct aic7xxx_host *) HBAptr->hostdata; - /* - * It takes roughly 1K of space to hold all relevant card info, not - * counting any proc stats, so we start out with a 1.5k buffer size and - * if proc_stats is defined, then we sweep the stats structure to see - * how many drives we will be printing out for and add 384 bytes per - * device with active stats. - * - * Hmmmm...that 1.5k seems to keep growing as items get added so they - * can be easily viewed for debugging purposes. So, we bumped that - * 1.5k to 4k so we can quit having to bump it all the time. - */ - - size = 4096; - list_for_each_entry(aic_dev, &p->aic_devs, list) - size += 512; - if (aic7xxx_buffer_size != size) - { - if (aic7xxx_buffer != NULL) - { - kfree(aic7xxx_buffer); - aic7xxx_buffer_size = 0; - } - aic7xxx_buffer = kmalloc(size, GFP_KERNEL); - } - if (aic7xxx_buffer == NULL) - { - size = sprintf(buffer, "AIC7xxx - kmalloc error at line %d\n", - __LINE__); - return size; - } - aic7xxx_buffer_size = size; - - size = 0; - size += sprintf(BLS, "Adaptec AIC7xxx driver version: "); - size += sprintf(BLS, "%s/", AIC7XXX_C_VERSION); - size += sprintf(BLS, "%s", AIC7XXX_H_VERSION); - size += sprintf(BLS, "\n"); - size += sprintf(BLS, "Adapter Configuration:\n"); - size += sprintf(BLS, " SCSI Adapter: %s\n", + seq_printf(m, "Adaptec AIC7xxx driver version: "); + seq_printf(m, "%s/", AIC7XXX_C_VERSION); + seq_printf(m, "%s", AIC7XXX_H_VERSION); + seq_printf(m, "\n"); + seq_printf(m, "Adapter Configuration:\n"); + seq_printf(m, " SCSI Adapter: %s\n", board_names[p->board_name_index]); if (p->flags & AHC_TWIN) - size += sprintf(BLS, " Twin Channel Controller "); + seq_printf(m, " Twin Channel Controller "); else { char *channel = ""; @@ -184,86 +100,86 @@ aic7xxx_proc_info ( struct Scsi_Host *HBAptr, char *buffer, char **start, off_t ultra = "Ultra-2 LVD/SE "; else if (p->features & AHC_ULTRA) ultra = "Ultra "; - size += sprintf(BLS, " %s%sController%s ", + seq_printf(m, " %s%sController%s ", ultra, wide, channel); } switch(p->chip & ~AHC_CHIPID_MASK) { case AHC_VL: - size += sprintf(BLS, "at VLB slot %d\n", p->pci_device_fn); + seq_printf(m, "at VLB slot %d\n", p->pci_device_fn); break; case AHC_EISA: - size += sprintf(BLS, "at EISA slot %d\n", p->pci_device_fn); + seq_printf(m, "at EISA slot %d\n", p->pci_device_fn); break; default: - size += sprintf(BLS, "at PCI %d/%d/%d\n", p->pci_bus, + seq_printf(m, "at PCI %d/%d/%d\n", p->pci_bus, PCI_SLOT(p->pci_device_fn), PCI_FUNC(p->pci_device_fn)); break; } if( !(p->maddr) ) { - size += sprintf(BLS, " Programmed I/O Base: %lx\n", p->base); + seq_printf(m, " Programmed I/O Base: %lx\n", p->base); } else { - size += sprintf(BLS, " PCI MMAPed I/O Base: 0x%lx\n", p->mbase); + seq_printf(m, " PCI MMAPed I/O Base: 0x%lx\n", p->mbase); } if( (p->chip & (AHC_VL | AHC_EISA)) ) { - size += sprintf(BLS, " BIOS Memory Address: 0x%08x\n", p->bios_address); + seq_printf(m, " BIOS Memory Address: 0x%08x\n", p->bios_address); } - size += sprintf(BLS, " Adapter SEEPROM Config: %s\n", + seq_printf(m, " Adapter SEEPROM Config: %s\n", (p->flags & AHC_SEEPROM_FOUND) ? "SEEPROM found and used." : ((p->flags & AHC_USEDEFAULTS) ? "SEEPROM not found, using defaults." : "SEEPROM not found, using leftover BIOS values.") ); - size += sprintf(BLS, " Adaptec SCSI BIOS: %s\n", + seq_printf(m, " Adaptec SCSI BIOS: %s\n", (p->flags & AHC_BIOS_ENABLED) ? "Enabled" : "Disabled"); - size += sprintf(BLS, " IRQ: %d\n", HBAptr->irq); - size += sprintf(BLS, " SCBs: Active %d, Max Active %d,\n", + seq_printf(m, " IRQ: %d\n", HBAptr->irq); + seq_printf(m, " SCBs: Active %d, Max Active %d,\n", p->activescbs, p->max_activescbs); - size += sprintf(BLS, " Allocated %d, HW %d, " + seq_printf(m, " Allocated %d, HW %d, " "Page %d\n", p->scb_data->numscbs, p->scb_data->maxhscbs, p->scb_data->maxscbs); if (p->flags & AHC_EXTERNAL_SRAM) - size += sprintf(BLS, " Using External SCB SRAM\n"); - size += sprintf(BLS, " Interrupts: %ld", p->isr_count); + seq_printf(m, " Using External SCB SRAM\n"); + seq_printf(m, " Interrupts: %ld", p->isr_count); if (p->chip & AHC_EISA) { - size += sprintf(BLS, " %s\n", + seq_printf(m, " %s\n", (p->pause & IRQMS) ? "(Level Sensitive)" : "(Edge Triggered)"); } else { - size += sprintf(BLS, "\n"); + seq_printf(m, "\n"); } - size += sprintf(BLS, " BIOS Control Word: 0x%04x\n", + seq_printf(m, " BIOS Control Word: 0x%04x\n", p->bios_control); - size += sprintf(BLS, " Adapter Control Word: 0x%04x\n", + seq_printf(m, " Adapter Control Word: 0x%04x\n", p->adapter_control); - size += sprintf(BLS, " Extended Translation: %sabled\n", + seq_printf(m, " Extended Translation: %sabled\n", (p->flags & AHC_EXTEND_TRANS_A) ? "En" : "Dis"); - size += sprintf(BLS, "Disconnect Enable Flags: 0x%04x\n", p->discenable); + seq_printf(m, "Disconnect Enable Flags: 0x%04x\n", p->discenable); if (p->features & (AHC_ULTRA | AHC_ULTRA2)) { - size += sprintf(BLS, " Ultra Enable Flags: 0x%04x\n", p->ultraenb); + seq_printf(m, " Ultra Enable Flags: 0x%04x\n", p->ultraenb); } - size += sprintf(BLS, "Default Tag Queue Depth: %d\n", aic7xxx_default_queue_depth); - size += sprintf(BLS, " Tagged Queue By Device array for aic7xxx host " + seq_printf(m, "Default Tag Queue Depth: %d\n", aic7xxx_default_queue_depth); + seq_printf(m, " Tagged Queue By Device array for aic7xxx host " "instance %d:\n", p->instance); - size += sprintf(BLS, " {"); + seq_printf(m, " {"); for(i=0; i < (MAX_TARGETS - 1); i++) - size += sprintf(BLS, "%d,",aic7xxx_tag_info[p->instance].tag_commands[i]); - size += sprintf(BLS, "%d}\n",aic7xxx_tag_info[p->instance].tag_commands[i]); + seq_printf(m, "%d,",aic7xxx_tag_info[p->instance].tag_commands[i]); + seq_printf(m, "%d}\n",aic7xxx_tag_info[p->instance].tag_commands[i]); - size += sprintf(BLS, "\n"); - size += sprintf(BLS, "Statistics:\n\n"); + seq_printf(m, "\n"); + seq_printf(m, "Statistics:\n\n"); list_for_each_entry(aic_dev, &p->aic_devs, list) { sdptr = aic_dev->SDptr; tindex = sdptr->channel << 3 | sdptr->id; - size += sprintf(BLS, "(scsi%d:%d:%d:%d)\n", + seq_printf(m, "(scsi%d:%d:%d:%d)\n", p->host_no, sdptr->channel, sdptr->id, sdptr->lun); - size += sprintf(BLS, " Device using %s/%s", + seq_printf(m, " Device using %s/%s", (aic_dev->cur.width == MSG_EXT_WDTR_BUS_16_BIT) ? "Wide" : "Narrow", (aic_dev->cur.offset != 0) ? @@ -279,78 +195,59 @@ aic7xxx_proc_info ( struct Scsi_Host *HBAptr, char *buffer, char **start, off_t sync_rate = aic7xxx_find_syncrate(p, &period, 0, &options); if (sync_rate != NULL) { - size += sprintf(BLS, "%s MByte/sec, offset %d\n", + seq_printf(m, "%s MByte/sec, offset %d\n", sync_rate->rate[rate], aic_dev->cur.offset ); } else { - size += sprintf(BLS, "3.3 MByte/sec, offset %d\n", + seq_printf(m, "3.3 MByte/sec, offset %d\n", aic_dev->cur.offset ); } } - size += sprintf(BLS, " Transinfo settings: "); - size += sprintf(BLS, "current(%d/%d/%d/%d), ", + seq_printf(m, " Transinfo settings: "); + seq_printf(m, "current(%d/%d/%d/%d), ", aic_dev->cur.period, aic_dev->cur.offset, aic_dev->cur.width, aic_dev->cur.options); - size += sprintf(BLS, "goal(%d/%d/%d/%d), ", + seq_printf(m, "goal(%d/%d/%d/%d), ", aic_dev->goal.period, aic_dev->goal.offset, aic_dev->goal.width, aic_dev->goal.options); - size += sprintf(BLS, "user(%d/%d/%d/%d)\n", + seq_printf(m, "user(%d/%d/%d/%d)\n", p->user[tindex].period, p->user[tindex].offset, p->user[tindex].width, p->user[tindex].options); if(sdptr->simple_tags) { - size += sprintf(BLS, " Tagged Command Queueing Enabled, Ordered Tags %s, Depth %d/%d\n", sdptr->ordered_tags ? "Enabled" : "Disabled", sdptr->queue_depth, aic_dev->max_q_depth); + seq_printf(m, " Tagged Command Queueing Enabled, Ordered Tags %s, Depth %d/%d\n", sdptr->ordered_tags ? "Enabled" : "Disabled", sdptr->queue_depth, aic_dev->max_q_depth); } if(aic_dev->barrier_total) - size += sprintf(BLS, " Total transfers %ld:\n (%ld/%ld/%ld/%ld reads/writes/REQ_BARRIER/Ordered Tags)\n", + seq_printf(m, " Total transfers %ld:\n (%ld/%ld/%ld/%ld reads/writes/REQ_BARRIER/Ordered Tags)\n", aic_dev->r_total+aic_dev->w_total, aic_dev->r_total, aic_dev->w_total, aic_dev->barrier_total, aic_dev->ordered_total); else - size += sprintf(BLS, " Total transfers %ld:\n (%ld/%ld reads/writes)\n", + seq_printf(m, " Total transfers %ld:\n (%ld/%ld reads/writes)\n", aic_dev->r_total+aic_dev->w_total, aic_dev->r_total, aic_dev->w_total); - size += sprintf(BLS, "%s\n", HDRB); - size += sprintf(BLS, " Reads:"); + seq_printf(m, "%s\n", HDRB); + seq_printf(m, " Reads:"); for (i = 0; i < ARRAY_SIZE(aic_dev->r_bins); i++) { - size += sprintf(BLS, " %10ld", aic_dev->r_bins[i]); + seq_printf(m, " %10ld", aic_dev->r_bins[i]); } - size += sprintf(BLS, "\n"); - size += sprintf(BLS, " Writes:"); + seq_printf(m, "\n"); + seq_printf(m, " Writes:"); for (i = 0; i < ARRAY_SIZE(aic_dev->w_bins); i++) { - size += sprintf(BLS, " %10ld", aic_dev->w_bins[i]); + seq_printf(m, " %10ld", aic_dev->w_bins[i]); } - size += sprintf(BLS, "\n"); - size += sprintf(BLS, "\n\n"); - } - if (size >= aic7xxx_buffer_size) - { - printk(KERN_WARNING "aic7xxx: Overflow in aic7xxx_proc.c\n"); - } - - if (offset > size - 1) - { - kfree(aic7xxx_buffer); - aic7xxx_buffer = NULL; - aic7xxx_buffer_size = length = 0; - *start = NULL; + seq_printf(m, "\n"); + seq_printf(m, "\n\n"); } - else - { - *start = buffer; - length = min_t(int, length, size - offset); - memcpy(buffer, &aic7xxx_buffer[offset], length); - } - - return (length); + return 0; } /* -- cgit v1.2.3 From d89537e1b124ad661ea340798965a96e123cb211 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 13:24:44 -0400 Subject: atari_scsi: switch to ->show_info() Signed-off-by: Al Viro --- drivers/scsi/atari_NCR5380.c | 145 ++++++++++++++++++------------------------- drivers/scsi/atari_scsi.c | 2 +- drivers/scsi/atari_scsi.h | 2 +- 3 files changed, 62 insertions(+), 87 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/atari_NCR5380.c b/drivers/scsi/atari_NCR5380.c index 2db79b469d9..0f3cdbc80ba 100644 --- a/drivers/scsi/atari_NCR5380.c +++ b/drivers/scsi/atari_NCR5380.c @@ -719,119 +719,94 @@ static void __init NCR5380_print_options(struct Scsi_Host *instance) * Inputs : instance, pointer to this instance. */ -static void NCR5380_print_status(struct Scsi_Host *instance) +static void lprint_Scsi_Cmnd(Scsi_Cmnd *cmd) { - char *pr_bfr; - char *start; - int len; - - NCR_PRINT(NDEBUG_ANY); - NCR_PRINT_PHASE(NDEBUG_ANY); - - pr_bfr = (char *)__get_free_page(GFP_ATOMIC); - if (!pr_bfr) { - printk("NCR5380_print_status: no memory for print buffer\n"); - return; - } - len = NCR5380_proc_info(instance, pr_bfr, &start, 0, PAGE_SIZE, 0); - pr_bfr[len] = 0; - printk("\n%s\n", pr_bfr); - free_page((unsigned long)pr_bfr); + int i, s; + unsigned char *command; + printk("scsi%d: destination target %d, lun %d\n", + H_NO(cmd), cmd->device->id, cmd->device->lun); + printk(KERN_CONT " command = "); + command = cmd->cmnd; + printk(KERN_CONT "%2d (0x%02x)", command[0], command[0]); + for (i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i) + printk(KERN_CONT " %02x", command[i]); + printk("\n"); } - -/******************************************/ -/* - * /proc/scsi/[dtc pas16 t128 generic]/[0-ASC_NUM_BOARD_SUPPORTED] - * - * *buffer: I/O buffer - * **start: if inout == FALSE pointer into buffer where user read should start - * offset: current offset - * length: length of buffer - * hostno: Scsi_Host host_no - * inout: TRUE - user is writing; FALSE - user is reading - * - * Return the number of bytes read from or written -*/ - -#undef SPRINTF -#define SPRINTF(fmt,args...) \ - do { \ - if (pos + strlen(fmt) + 20 /* slop */ < buffer + length) \ - pos += sprintf(pos, fmt , ## args); \ - } while(0) -static char *lprint_Scsi_Cmnd(Scsi_Cmnd *cmd, char *pos, char *buffer, int length); - -static int NCR5380_proc_info(struct Scsi_Host *instance, char *buffer, - char **start, off_t offset, int length, int inout) +static void NCR5380_print_status(struct Scsi_Host *instance) { - char *pos = buffer; struct NCR5380_hostdata *hostdata; Scsi_Cmnd *ptr; unsigned long flags; - off_t begin = 0; -#define check_offset() \ - do { \ - if (pos - buffer < offset - begin) { \ - begin += pos - buffer; \ - pos = buffer; \ - } \ - } while (0) + + NCR_PRINT(NDEBUG_ANY); + NCR_PRINT_PHASE(NDEBUG_ANY); hostdata = (struct NCR5380_hostdata *)instance->hostdata; - if (inout) /* Has data been written to the file ? */ - return -ENOSYS; /* Currently this is a no-op */ - SPRINTF("NCR5380 core release=%d.\n", NCR5380_PUBLIC_RELEASE); - check_offset(); + printk("\nNCR5380 core release=%d.\n", NCR5380_PUBLIC_RELEASE); local_irq_save(flags); - SPRINTF("NCR5380: coroutine is%s running.\n", + printk("NCR5380: coroutine is%s running.\n", main_running ? "" : "n't"); - check_offset(); if (!hostdata->connected) - SPRINTF("scsi%d: no currently connected command\n", HOSTNO); + printk("scsi%d: no currently connected command\n", HOSTNO); else - pos = lprint_Scsi_Cmnd((Scsi_Cmnd *) hostdata->connected, - pos, buffer, length); - SPRINTF("scsi%d: issue_queue\n", HOSTNO); - check_offset(); - for (ptr = (Scsi_Cmnd *)hostdata->issue_queue; ptr; ptr = NEXT(ptr)) { - pos = lprint_Scsi_Cmnd(ptr, pos, buffer, length); - check_offset(); - } + lprint_Scsi_Cmnd((Scsi_Cmnd *) hostdata->connected); + printk("scsi%d: issue_queue\n", HOSTNO); + for (ptr = (Scsi_Cmnd *)hostdata->issue_queue; ptr; ptr = NEXT(ptr)) + lprint_Scsi_Cmnd(ptr); - SPRINTF("scsi%d: disconnected_queue\n", HOSTNO); - check_offset(); + printk("scsi%d: disconnected_queue\n", HOSTNO); for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr; - ptr = NEXT(ptr)) { - pos = lprint_Scsi_Cmnd(ptr, pos, buffer, length); - check_offset(); - } + ptr = NEXT(ptr)) + lprint_Scsi_Cmnd(ptr); local_irq_restore(flags); - *start = buffer + (offset - begin); - if (pos - buffer < offset - begin) - return 0; - else if (pos - buffer - (offset - begin) < length) - return pos - buffer - (offset - begin); - return length; + printk("\n"); } -static char *lprint_Scsi_Cmnd(Scsi_Cmnd *cmd, char *pos, char *buffer, int length) +static void show_Scsi_Cmnd(Scsi_Cmnd *cmd, struct seq_file *m) { int i, s; unsigned char *command; - SPRINTF("scsi%d: destination target %d, lun %d\n", + seq_printf(m, "scsi%d: destination target %d, lun %d\n", H_NO(cmd), cmd->device->id, cmd->device->lun); - SPRINTF(" command = "); + seq_printf(m, " command = "); command = cmd->cmnd; - SPRINTF("%2d (0x%02x)", command[0], command[0]); + seq_printf(m, "%2d (0x%02x)", command[0], command[0]); for (i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i) - SPRINTF(" %02x", command[i]); - SPRINTF("\n"); - return pos; + seq_printf(m, " %02x", command[i]); + seq_printf(m, "\n"); } +static int NCR5380_show_info(struct seq_file *m, struct Scsi_Host *instance) +{ + struct NCR5380_hostdata *hostdata; + Scsi_Cmnd *ptr; + unsigned long flags; + + hostdata = (struct NCR5380_hostdata *)instance->hostdata; + + seq_printf(m, "NCR5380 core release=%d.\n", NCR5380_PUBLIC_RELEASE); + local_irq_save(flags); + seq_printf(m, "NCR5380: coroutine is%s running.\n", + main_running ? "" : "n't"); + if (!hostdata->connected) + seq_printf(m, "scsi%d: no currently connected command\n", HOSTNO); + else + show_Scsi_Cmnd((Scsi_Cmnd *) hostdata->connected, m); + seq_printf(m, "scsi%d: issue_queue\n", HOSTNO); + for (ptr = (Scsi_Cmnd *)hostdata->issue_queue; ptr; ptr = NEXT(ptr)) + show_Scsi_Cmnd(ptr, m); + + seq_printf(m, "scsi%d: disconnected_queue\n", HOSTNO); + for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr; + ptr = NEXT(ptr)) + show_Scsi_Cmnd(ptr, m); + + local_irq_restore(flags); + return 0; +} /* * Function : void NCR5380_init (struct Scsi_Host *instance) diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c index df740cbbaef..a3e6c8a3ff0 100644 --- a/drivers/scsi/atari_scsi.c +++ b/drivers/scsi/atari_scsi.c @@ -1100,7 +1100,7 @@ static void atari_scsi_falcon_reg_write(unsigned char reg, unsigned char value) #include "atari_NCR5380.c" static struct scsi_host_template driver_template = { - .proc_info = atari_scsi_proc_info, + .show_info = atari_scsi_show_info, .name = "Atari native SCSI", .detect = atari_scsi_detect, .release = atari_scsi_release, diff --git a/drivers/scsi/atari_scsi.h b/drivers/scsi/atari_scsi.h index bd52df78b20..11c624bb122 100644 --- a/drivers/scsi/atari_scsi.h +++ b/drivers/scsi/atari_scsi.h @@ -47,7 +47,7 @@ #define NCR5380_intr atari_scsi_intr #define NCR5380_queue_command atari_scsi_queue_command #define NCR5380_abort atari_scsi_abort -#define NCR5380_proc_info atari_scsi_proc_info +#define NCR5380_show_info atari_scsi_show_info #define NCR5380_dma_read_setup(inst,d,c) atari_scsi_dma_setup (inst, d, c, 0) #define NCR5380_dma_write_setup(inst,d,c) atari_scsi_dma_setup (inst, d, c, 1) #define NCR5380_dma_residual(inst) atari_scsi_dma_residual( inst ) -- cgit v1.2.3 From 70ef457dc92bdd03c0c8d640fce45909166983a1 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 13:27:56 -0400 Subject: scsi: bury ->proc_info() all users converted to ->show_info()/->write_info() Signed-off-by: Al Viro --- drivers/scsi/scsi_proc.c | 79 +++++------------------------------------------- 1 file changed, 8 insertions(+), 71 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/scsi_proc.c b/drivers/scsi/scsi_proc.c index 6f4c3cff03b..1670ba7ad6a 100644 --- a/drivers/scsi/scsi_proc.c +++ b/drivers/scsi/scsi_proc.c @@ -45,58 +45,6 @@ static struct proc_dir_entry *proc_scsi; /* Protect sht->present and sht->proc_dir */ static DEFINE_MUTEX(global_host_template_mutex); -/** - * proc_scsi_read - handle read from /proc by calling host's proc_info() command - * @buffer: passed to proc_info - * @start: passed to proc_info - * @offset: passed to proc_info - * @length: passed to proc_info - * @eof: returns whether length read was less than requested - * @data: pointer to a &struct Scsi_Host - */ - -static int proc_scsi_read(char *buffer, char **start, off_t offset, - int length, int *eof, void *data) -{ - struct Scsi_Host *shost = data; - int n; - - n = shost->hostt->proc_info(shost, buffer, start, offset, length, 0); - *eof = (n < length); - - return n; -} - -/** - * proc_scsi_write_proc - Handle write to /proc by calling host's proc_info() - * @file: not used - * @buf: source of data to write. - * @count: number of bytes (at most PROC_BLOCK_SIZE) to write. - * @data: pointer to &struct Scsi_Host - */ -static int proc_scsi_write_proc(struct file *file, const char __user *buf, - unsigned long count, void *data) -{ - struct Scsi_Host *shost = data; - ssize_t ret = -ENOMEM; - char *page; - char *start; - - if (count > PROC_BLOCK_SIZE) - return -EOVERFLOW; - - page = (char *)__get_free_page(GFP_KERNEL); - if (page) { - ret = -EFAULT; - if (copy_from_user(page, buf, count)) - goto out; - ret = shost->hostt->proc_info(shost, page, &start, 0, count, 1); - } -out: - free_page((unsigned long)page); - return ret; -} - static ssize_t proc_scsi_host_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { @@ -149,7 +97,7 @@ static const struct file_operations proc_scsi_fops = { void scsi_proc_hostdir_add(struct scsi_host_template *sht) { - if (!sht->proc_info && !sht->show_info) + if (!sht->show_info) return; mutex_lock(&global_host_template_mutex); @@ -168,7 +116,7 @@ void scsi_proc_hostdir_add(struct scsi_host_template *sht) */ void scsi_proc_hostdir_rm(struct scsi_host_template *sht) { - if (!sht->proc_info && !sht->show_info) + if (!sht->show_info) return; mutex_lock(&global_host_template_mutex); @@ -194,23 +142,12 @@ void scsi_proc_host_add(struct Scsi_Host *shost) return; sprintf(name,"%d", shost->host_no); - if (sht->show_info) { - p = proc_create_data(name, S_IRUGO | S_IWUSR, - sht->proc_dir, &proc_scsi_fops, shost); - if (!p) - goto Fail; - return; - } - p = create_proc_read_entry(name, S_IFREG | S_IRUGO | S_IWUSR, - sht->proc_dir, proc_scsi_read, shost); - if (p) { - p->write_proc = proc_scsi_write_proc; - return; - } -Fail: - printk(KERN_ERR "%s: Failed to register host %d in" - "%s\n", __func__, shost->host_no, - sht->proc_name); + p = proc_create_data(name, S_IRUGO | S_IWUSR, + sht->proc_dir, &proc_scsi_fops, shost); + if (!p) + printk(KERN_ERR "%s: Failed to register host %d in" + "%s\n", __func__, shost->host_no, + sht->proc_name); } /** -- cgit v1.2.3 From 859d22f9c3924ab87b05ded8ba922abc298c1d43 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 13:50:52 -0400 Subject: scsi_proc: make proc_scsi_host_open() preallocate a bigger buffer Some of the ->show_info() instances really spew a lot; it's not a problem wrt correctness (seq_read() will grow buffer and call the sucker again), but in this case it makes sense to start with a somewhat bigger one - they often do exceed one page worth of output. Signed-off-by: Al Viro --- drivers/scsi/scsi_proc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/scsi/scsi_proc.c b/drivers/scsi/scsi_proc.c index 1670ba7ad6a..1eb34c34d7b 100644 --- a/drivers/scsi/scsi_proc.c +++ b/drivers/scsi/scsi_proc.c @@ -78,7 +78,8 @@ static int proc_scsi_show(struct seq_file *m, void *v) static int proc_scsi_host_open(struct inode *inode, struct file *file) { - return single_open(file, proc_scsi_show, PDE(inode)->data); + return single_open_size(file, proc_scsi_show, PDE(inode)->data, + 4 * PAGE_SIZE); } static const struct file_operations proc_scsi_fops = { -- cgit v1.2.3 From 78846ce66d3e273a6937fddfd6752b3074c82e62 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 15:07:00 -0400 Subject: rtl8192u: switch to proc_create() Signed-off-by: Al Viro --- .../staging/rtl8192u/ieee80211/ieee80211_module.c | 53 +++++++++------------- 1 file changed, 22 insertions(+), 31 deletions(-) (limited to 'drivers') 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; } -- cgit v1.2.3 From ff9046ac92aa89d5ba3e94515baf172e79bd5395 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 15:29:21 -0400 Subject: bfin_adv7393: switch to proc_create_data() Signed-off-by: Al Viro --- drivers/video/bfin_adv7393fb.c | 43 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 24 deletions(-) (limited to 'drivers') diff --git a/drivers/video/bfin_adv7393fb.c b/drivers/video/bfin_adv7393fb.c index 8d411a3c996..b65c1f9dc15 100644 --- a/drivers/video/bfin_adv7393fb.c +++ b/drivers/video/bfin_adv7393fb.c @@ -333,29 +333,23 @@ static int proc_output(char *buf) return p - buf; } -static int -adv7393_read_proc(char *page, char **start, off_t off, - int count, int *eof, void *data) +static ssize_t +adv7393_read_proc(struct file *file, char __user *buf, + size_t size, loff_t *ppos) { - int len; - - len = proc_output(page); - if (len <= off + count) - *eof = 1; - *start = page + off; - len -= off; - if (len > count) - len = count; - if (len < 0) - len = 0; - return len; + static const char message[] = "Usage:\n" + "echo 0x[REG][Value] > adv7393\n" + "example: echo 0x1234 >adv7393\n" + "writes 0x34 into Register 0x12\n"; + return simple_read_from_buffer(buf, size, ppos, message, + sizeof(message)); } -static int +static ssize_t adv7393_write_proc(struct file *file, const char __user * buffer, - size_t count, void *data) + size_t count, loff_t *ppos) { - struct adv7393fb_device *fbdev = data; + struct adv7393fb_device *fbdev = PDE(file_inode(file))->data; unsigned int val; int ret; @@ -368,6 +362,12 @@ adv7393_write_proc(struct file *file, const char __user * buffer, return count; } +static const struct file_operations fops = { + .read = adv7393_read_proc, + .write = adv7393_write_proc, + .llseek = default_llseek, +}; + static int bfin_adv7393_fb_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -506,17 +506,12 @@ static int bfin_adv7393_fb_probe(struct i2c_client *client, fbdev->info.node, fbdev->info.fix.id); dev_info(&client->dev, "fb memory address : 0x%p\n", fbdev->fb_mem); - entry = create_proc_entry("driver/adv7393", 0, NULL); + entry = proc_create_data("driver/adv7393", 0, NULL, &fops, fbdev); if (!entry) { dev_err(&client->dev, "unable to create /proc entry\n"); ret = -EFAULT; goto free_fb; } - - entry->read_proc = adv7393_read_proc; - entry->write_proc = adv7393_write_proc; - entry->data = fbdev; - return 0; free_fb: -- cgit v1.2.3 From d9dda78bad879595d8c4220a067fc029d6484a16 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 31 Mar 2013 18:16:14 -0400 Subject: procfs: new helper - PDE_DATA(inode) The only part of proc_dir_entry the code outside of fs/proc really cares about is PDE(inode)->data. Provide a helper for that; static inline for now, eventually will be moved to fs/proc, along with the knowledge of struct proc_dir_entry layout. Signed-off-by: Al Viro --- drivers/acpi/ac.c | 2 +- drivers/acpi/battery.c | 2 +- drivers/acpi/button.c | 2 +- drivers/acpi/proc.c | 4 ++-- drivers/acpi/sbs.c | 8 +++---- drivers/block/DAC960.c | 8 +++---- drivers/block/cciss.c | 2 +- drivers/block/cpqarray.c | 2 +- drivers/block/drbd/drbd_proc.c | 2 +- drivers/block/pktcdvd.c | 2 +- drivers/block/ps3vram.c | 2 +- drivers/char/ipmi/ipmi_msghandler.c | 6 +++--- drivers/char/ipmi/ipmi_si_intf.c | 6 +++--- drivers/gpu/drm/drm_proc.c | 2 +- drivers/ide/ide-cd.c | 2 +- drivers/ide/ide-disk_proc.c | 8 +++---- drivers/ide/ide-floppy_proc.c | 2 +- drivers/ide/ide-proc.c | 22 +++++++++---------- drivers/ide/ide-tape.c | 2 +- drivers/isdn/gigaset/capi.c | 2 +- drivers/isdn/hardware/avm/b1.c | 2 +- drivers/isdn/hardware/avm/b1dma.c | 2 +- drivers/isdn/hardware/avm/c4.c | 2 +- drivers/isdn/hardware/eicon/divasproc.c | 12 +++++------ drivers/isdn/hysdn/hycapi.c | 2 +- drivers/isdn/hysdn/hysdn_procconf.c | 4 ++-- drivers/isdn/hysdn/hysdn_proclog.c | 8 +++---- drivers/macintosh/via-pmu.c | 2 +- drivers/media/pci/zoran/zoran_procfs.c | 4 ++-- drivers/message/fusion/mptbase.c | 4 ++-- drivers/message/i2o/i2o_proc.c | 38 ++++++++++++++++----------------- drivers/net/bonding/bond_procfs.c | 4 +--- drivers/net/irda/vlsi_ir.c | 2 +- drivers/net/wireless/airo.c | 33 ++++++++++------------------ drivers/net/wireless/ray_cs.c | 2 +- drivers/parisc/led.c | 4 ++-- drivers/pci/proc.c | 20 ++++++----------- drivers/platform/x86/thinkpad_acpi.c | 4 ++-- drivers/platform/x86/toshiba_acpi.c | 18 ++++++++-------- drivers/pnp/isapnp/proc.c | 4 +--- drivers/pnp/pnpbios/proc.c | 4 ++-- drivers/rtc/rtc-proc.c | 2 +- drivers/scsi/scsi_proc.c | 4 ++-- drivers/staging/ccg/rndis.c | 4 ++-- drivers/staging/dgrp/dgrp_dpa_ops.c | 9 +------- drivers/staging/dgrp/dgrp_mon_ops.c | 9 +------- drivers/staging/dgrp/dgrp_net_ops.c | 9 +------- drivers/staging/dgrp/dgrp_ports_ops.c | 2 +- drivers/staging/silicom/bpctl_mod.c | 38 ++++++++++++++++----------------- drivers/tty/serial/serial_core.c | 2 +- drivers/usb/gadget/at91_udc.c | 2 +- drivers/usb/gadget/lpc32xx_udc.c | 2 +- drivers/usb/gadget/rndis.c | 4 ++-- drivers/usb/host/isp1362-hcd.c | 2 +- drivers/usb/host/sl811-hcd.c | 2 +- drivers/video/bfin_adv7393fb.c | 2 +- drivers/zorro/proc.c | 4 +--- 57 files changed, 158 insertions(+), 202 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c index 6d5bf649196..00d2efd674d 100644 --- a/drivers/acpi/ac.c +++ b/drivers/acpi/ac.c @@ -194,7 +194,7 @@ static int acpi_ac_seq_show(struct seq_file *seq, void *offset) static int acpi_ac_open_fs(struct inode *inode, struct file *file) { - return single_open(file, acpi_ac_seq_show, PDE(inode)->data); + return single_open(file, acpi_ac_seq_show, PDE_DATA(inode)); } static int acpi_ac_add_fs(struct acpi_device *device) diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index c5cd5b5513e..169ced7e540 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -929,7 +929,7 @@ static int acpi_battery_read_##_name(struct seq_file *seq, void *offset) \ } \ static int acpi_battery_##_name##_open_fs(struct inode *inode, struct file *file) \ { \ - return single_open(file, acpi_battery_read_##_name, PDE(inode)->data); \ + return single_open(file, acpi_battery_read_##_name, PDE_DATA(inode)); \ } DECLARE_FILE_FUNCTIONS(info); diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c index 86c7d5445c3..5d57cd513f4 100644 --- a/drivers/acpi/button.c +++ b/drivers/acpi/button.c @@ -128,7 +128,7 @@ static int acpi_button_state_seq_show(struct seq_file *seq, void *offset) static int acpi_button_state_open_fs(struct inode *inode, struct file *file) { - return single_open(file, acpi_button_state_seq_show, PDE(inode)->data); + return single_open(file, acpi_button_state_seq_show, PDE_DATA(inode)); } static const struct file_operations acpi_button_state_fops = { diff --git a/drivers/acpi/proc.c b/drivers/acpi/proc.c index 52ce76725c2..aa1227a7e3f 100644 --- a/drivers/acpi/proc.c +++ b/drivers/acpi/proc.c @@ -120,7 +120,7 @@ static int acpi_system_alarm_seq_show(struct seq_file *seq, void *offset) static int acpi_system_alarm_open_fs(struct inode *inode, struct file *file) { - return single_open(file, acpi_system_alarm_seq_show, PDE(inode)->data); + return single_open(file, acpi_system_alarm_seq_show, PDE_DATA(inode)); } static int get_date_field(char **p, u32 * value) @@ -397,7 +397,7 @@ static int acpi_system_wakeup_device_open_fs(struct inode *inode, struct file *file) { return single_open(file, acpi_system_wakeup_device_seq_show, - PDE(inode)->data); + PDE_DATA(inode)); } static const struct file_operations acpi_system_wakeup_device_fops = { diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c index e523245643a..a296e08d76b 100644 --- a/drivers/acpi/sbs.c +++ b/drivers/acpi/sbs.c @@ -584,7 +584,7 @@ static int acpi_battery_read_info(struct seq_file *seq, void *offset) static int acpi_battery_info_open_fs(struct inode *inode, struct file *file) { - return single_open(file, acpi_battery_read_info, PDE(inode)->data); + return single_open(file, acpi_battery_read_info, PDE_DATA(inode)); } static int acpi_battery_read_state(struct seq_file *seq, void *offset) @@ -623,7 +623,7 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset) static int acpi_battery_state_open_fs(struct inode *inode, struct file *file) { - return single_open(file, acpi_battery_read_state, PDE(inode)->data); + return single_open(file, acpi_battery_read_state, PDE_DATA(inode)); } static int acpi_battery_read_alarm(struct seq_file *seq, void *offset) @@ -688,7 +688,7 @@ acpi_battery_write_alarm(struct file *file, const char __user * buffer, static int acpi_battery_alarm_open_fs(struct inode *inode, struct file *file) { - return single_open(file, acpi_battery_read_alarm, PDE(inode)->data); + return single_open(file, acpi_battery_read_alarm, PDE_DATA(inode)); } static const struct file_operations acpi_battery_info_fops = { @@ -736,7 +736,7 @@ static int acpi_ac_read_state(struct seq_file *seq, void *offset) static int acpi_ac_state_open_fs(struct inode *inode, struct file *file) { - return single_open(file, acpi_ac_read_state, PDE(inode)->data); + return single_open(file, acpi_ac_read_state, PDE_DATA(inode)); } static const struct file_operations acpi_ac_state_fops = { diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c index 5b5ee79ff23..eb3950113e4 100644 --- a/drivers/block/DAC960.c +++ b/drivers/block/DAC960.c @@ -6473,7 +6473,7 @@ static int dac960_initial_status_proc_show(struct seq_file *m, void *v) static int dac960_initial_status_proc_open(struct inode *inode, struct file *file) { - return single_open(file, dac960_initial_status_proc_show, PDE(inode)->data); + return single_open(file, dac960_initial_status_proc_show, PDE_DATA(inode)); } static const struct file_operations dac960_initial_status_proc_fops = { @@ -6519,7 +6519,7 @@ static int dac960_current_status_proc_show(struct seq_file *m, void *v) static int dac960_current_status_proc_open(struct inode *inode, struct file *file) { - return single_open(file, dac960_current_status_proc_show, PDE(inode)->data); + return single_open(file, dac960_current_status_proc_show, PDE_DATA(inode)); } static const struct file_operations dac960_current_status_proc_fops = { @@ -6540,14 +6540,14 @@ static int dac960_user_command_proc_show(struct seq_file *m, void *v) static int dac960_user_command_proc_open(struct inode *inode, struct file *file) { - return single_open(file, dac960_user_command_proc_show, PDE(inode)->data); + return single_open(file, dac960_user_command_proc_show, PDE_DATA(inode)); } static ssize_t dac960_user_command_proc_write(struct file *file, const char __user *Buffer, size_t Count, loff_t *pos) { - DAC960_Controller_T *Controller = (DAC960_Controller_T *) PDE(file_inode(file))->data; + DAC960_Controller_T *Controller = PDE_DATA(file_inode(file)); unsigned char CommandBuffer[80]; int Length; if (Count > sizeof(CommandBuffer)-1) return -EINVAL; diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index ade58bc8f3c..d150fe1248b 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c @@ -493,7 +493,7 @@ static int cciss_seq_open(struct inode *inode, struct file *file) struct seq_file *seq = file->private_data; if (!ret) - seq->private = PDE(inode)->data; + seq->private = PDE_DATA(inode); return ret; } diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c index 3f087133a25..3b9e8ebcb96 100644 --- a/drivers/block/cpqarray.c +++ b/drivers/block/cpqarray.c @@ -296,7 +296,7 @@ static int ida_proc_show(struct seq_file *m, void *v) static int ida_proc_open(struct inode *inode, struct file *file) { - return single_open(file, ida_proc_show, PDE(inode)->data); + return single_open(file, ida_proc_show, PDE_DATA(inode)); } static const struct file_operations ida_proc_fops = { diff --git a/drivers/block/drbd/drbd_proc.c b/drivers/block/drbd/drbd_proc.c index 56672a61eb9..928adb815b0 100644 --- a/drivers/block/drbd/drbd_proc.c +++ b/drivers/block/drbd/drbd_proc.c @@ -314,7 +314,7 @@ static int drbd_seq_show(struct seq_file *seq, void *v) static int drbd_proc_open(struct inode *inode, struct file *file) { if (try_module_get(THIS_MODULE)) - return single_open(file, drbd_seq_show, PDE(inode)->data); + return single_open(file, drbd_seq_show, PDE_DATA(inode)); return -ENODEV; } diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index 2e7de7a59bf..e0588c6dd86 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c @@ -2648,7 +2648,7 @@ static int pkt_seq_show(struct seq_file *m, void *p) static int pkt_seq_open(struct inode *inode, struct file *file) { - return single_open(file, pkt_seq_show, PDE(inode)->data); + return single_open(file, pkt_seq_show, PDE_DATA(inode)); } static const struct file_operations pkt_proc_fops = { diff --git a/drivers/block/ps3vram.c b/drivers/block/ps3vram.c index 75e112d6600..06a2e53e5f3 100644 --- a/drivers/block/ps3vram.c +++ b/drivers/block/ps3vram.c @@ -525,7 +525,7 @@ static int ps3vram_proc_show(struct seq_file *m, void *v) static int ps3vram_proc_open(struct inode *inode, struct file *file) { - return single_open(file, ps3vram_proc_show, PDE(inode)->data); + return single_open(file, ps3vram_proc_show, PDE_DATA(inode)); } static const struct file_operations ps3vram_proc_fops = { diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c index 053201b062a..1420bbbe1a6 100644 --- a/drivers/char/ipmi/ipmi_msghandler.c +++ b/drivers/char/ipmi/ipmi_msghandler.c @@ -1917,7 +1917,7 @@ static int smi_ipmb_proc_show(struct seq_file *m, void *v) static int smi_ipmb_proc_open(struct inode *inode, struct file *file) { - return single_open(file, smi_ipmb_proc_show, PDE(inode)->data); + return single_open(file, smi_ipmb_proc_show, PDE_DATA(inode)); } static const struct file_operations smi_ipmb_proc_ops = { @@ -1938,7 +1938,7 @@ static int smi_version_proc_show(struct seq_file *m, void *v) static int smi_version_proc_open(struct inode *inode, struct file *file) { - return single_open(file, smi_version_proc_show, PDE(inode)->data); + return single_open(file, smi_version_proc_show, PDE_DATA(inode)); } static const struct file_operations smi_version_proc_ops = { @@ -2013,7 +2013,7 @@ static int smi_stats_proc_show(struct seq_file *m, void *v) static int smi_stats_proc_open(struct inode *inode, struct file *file) { - return single_open(file, smi_stats_proc_show, PDE(inode)->data); + return single_open(file, smi_stats_proc_show, PDE_DATA(inode)); } static const struct file_operations smi_stats_proc_ops = { diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c index 0ac9b45a585..313538abe63 100644 --- a/drivers/char/ipmi/ipmi_si_intf.c +++ b/drivers/char/ipmi/ipmi_si_intf.c @@ -2839,7 +2839,7 @@ static int smi_type_proc_show(struct seq_file *m, void *v) static int smi_type_proc_open(struct inode *inode, struct file *file) { - return single_open(file, smi_type_proc_show, PDE(inode)->data); + return single_open(file, smi_type_proc_show, PDE_DATA(inode)); } static const struct file_operations smi_type_proc_ops = { @@ -2882,7 +2882,7 @@ static int smi_si_stats_proc_show(struct seq_file *m, void *v) static int smi_si_stats_proc_open(struct inode *inode, struct file *file) { - return single_open(file, smi_si_stats_proc_show, PDE(inode)->data); + return single_open(file, smi_si_stats_proc_show, PDE_DATA(inode)); } static const struct file_operations smi_si_stats_proc_ops = { @@ -2910,7 +2910,7 @@ static int smi_params_proc_show(struct seq_file *m, void *v) static int smi_params_proc_open(struct inode *inode, struct file *file) { - return single_open(file, smi_params_proc_show, PDE(inode)->data); + return single_open(file, smi_params_proc_show, PDE_DATA(inode)); } static const struct file_operations smi_params_proc_ops = { diff --git a/drivers/gpu/drm/drm_proc.c b/drivers/gpu/drm/drm_proc.c index ff5456b7df7..e06431897f4 100644 --- a/drivers/gpu/drm/drm_proc.c +++ b/drivers/gpu/drm/drm_proc.c @@ -63,7 +63,7 @@ static struct drm_info_list drm_proc_list[] = { static int drm_proc_open(struct inode *inode, struct file *file) { - struct drm_info_node* node = PDE(inode)->data; + struct drm_info_node* node = PDE_DATA(inode); return single_open(file, node->info_ent->show, node); } diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 8126824dacc..b2311392638 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c @@ -1408,7 +1408,7 @@ static int idecd_capacity_proc_show(struct seq_file *m, void *v) static int idecd_capacity_proc_open(struct inode *inode, struct file *file) { - return single_open(file, idecd_capacity_proc_show, PDE(inode)->data); + return single_open(file, idecd_capacity_proc_show, PDE_DATA(inode)); } static const struct file_operations idecd_capacity_proc_fops = { diff --git a/drivers/ide/ide-disk_proc.c b/drivers/ide/ide-disk_proc.c index 8b570a17bcd..0d1fae6cba6 100644 --- a/drivers/ide/ide-disk_proc.c +++ b/drivers/ide/ide-disk_proc.c @@ -53,7 +53,7 @@ static int idedisk_cache_proc_show(struct seq_file *m, void *v) static int idedisk_cache_proc_open(struct inode *inode, struct file *file) { - return single_open(file, idedisk_cache_proc_show, PDE(inode)->data); + return single_open(file, idedisk_cache_proc_show, PDE_DATA(inode)); } static const struct file_operations idedisk_cache_proc_fops = { @@ -74,7 +74,7 @@ static int idedisk_capacity_proc_show(struct seq_file *m, void *v) static int idedisk_capacity_proc_open(struct inode *inode, struct file *file) { - return single_open(file, idedisk_capacity_proc_show, PDE(inode)->data); + return single_open(file, idedisk_capacity_proc_show, PDE_DATA(inode)); } static const struct file_operations idedisk_capacity_proc_fops = { @@ -115,7 +115,7 @@ static int idedisk_sv_proc_show(struct seq_file *m, void *v) static int idedisk_sv_proc_open(struct inode *inode, struct file *file) { - return single_open(file, idedisk_sv_proc_show, PDE(inode)->data); + return single_open(file, idedisk_sv_proc_show, PDE_DATA(inode)); } static const struct file_operations idedisk_sv_proc_fops = { @@ -133,7 +133,7 @@ static int idedisk_st_proc_show(struct seq_file *m, void *v) static int idedisk_st_proc_open(struct inode *inode, struct file *file) { - return single_open(file, idedisk_st_proc_show, PDE(inode)->data); + return single_open(file, idedisk_st_proc_show, PDE_DATA(inode)); } static const struct file_operations idedisk_st_proc_fops = { diff --git a/drivers/ide/ide-floppy_proc.c b/drivers/ide/ide-floppy_proc.c index 1600720f3e8..e7a25ea757d 100644 --- a/drivers/ide/ide-floppy_proc.c +++ b/drivers/ide/ide-floppy_proc.c @@ -15,7 +15,7 @@ static int idefloppy_capacity_proc_show(struct seq_file *m, void *v) static int idefloppy_capacity_proc_open(struct inode *inode, struct file *file) { - return single_open(file, idefloppy_capacity_proc_show, PDE(inode)->data); + return single_open(file, idefloppy_capacity_proc_show, PDE_DATA(inode)); } static const struct file_operations idefloppy_capacity_proc_fops = { diff --git a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c index 2abcc4790f1..97c07007777 100644 --- a/drivers/ide/ide-proc.c +++ b/drivers/ide/ide-proc.c @@ -58,7 +58,7 @@ static int ide_imodel_proc_show(struct seq_file *m, void *v) static int ide_imodel_proc_open(struct inode *inode, struct file *file) { - return single_open(file, ide_imodel_proc_show, PDE(inode)->data); + return single_open(file, ide_imodel_proc_show, PDE_DATA(inode)); } static const struct file_operations ide_imodel_proc_fops = { @@ -82,7 +82,7 @@ static int ide_mate_proc_show(struct seq_file *m, void *v) static int ide_mate_proc_open(struct inode *inode, struct file *file) { - return single_open(file, ide_mate_proc_show, PDE(inode)->data); + return single_open(file, ide_mate_proc_show, PDE_DATA(inode)); } static const struct file_operations ide_mate_proc_fops = { @@ -103,7 +103,7 @@ static int ide_channel_proc_show(struct seq_file *m, void *v) static int ide_channel_proc_open(struct inode *inode, struct file *file) { - return single_open(file, ide_channel_proc_show, PDE(inode)->data); + return single_open(file, ide_channel_proc_show, PDE_DATA(inode)); } static const struct file_operations ide_channel_proc_fops = { @@ -143,7 +143,7 @@ static int ide_identify_proc_show(struct seq_file *m, void *v) static int ide_identify_proc_open(struct inode *inode, struct file *file) { - return single_open(file, ide_identify_proc_show, PDE(inode)->data); + return single_open(file, ide_identify_proc_show, PDE_DATA(inode)); } static const struct file_operations ide_identify_proc_fops = { @@ -325,7 +325,7 @@ static int ide_settings_proc_show(struct seq_file *m, void *v) static int ide_settings_proc_open(struct inode *inode, struct file *file) { - return single_open(file, ide_settings_proc_show, PDE(inode)->data); + return single_open(file, ide_settings_proc_show, PDE_DATA(inode)); } #define MAX_LEN 30 @@ -333,7 +333,7 @@ static int ide_settings_proc_open(struct inode *inode, struct file *file) static ssize_t ide_settings_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos) { - ide_drive_t *drive = (ide_drive_t *) PDE(file_inode(file))->data; + ide_drive_t *drive = PDE_DATA(file_inode(file)); char name[MAX_LEN + 1]; int for_real = 0, mul_factor, div_factor; unsigned long n; @@ -474,7 +474,7 @@ static int ide_geometry_proc_show(struct seq_file *m, void *v) static int ide_geometry_proc_open(struct inode *inode, struct file *file) { - return single_open(file, ide_geometry_proc_show, PDE(inode)->data); + return single_open(file, ide_geometry_proc_show, PDE_DATA(inode)); } const struct file_operations ide_geometry_proc_fops = { @@ -497,7 +497,7 @@ static int ide_dmodel_proc_show(struct seq_file *seq, void *v) static int ide_dmodel_proc_open(struct inode *inode, struct file *file) { - return single_open(file, ide_dmodel_proc_show, PDE(inode)->data); + return single_open(file, ide_dmodel_proc_show, PDE_DATA(inode)); } static const struct file_operations ide_dmodel_proc_fops = { @@ -525,7 +525,7 @@ static int ide_driver_proc_show(struct seq_file *m, void *v) static int ide_driver_proc_open(struct inode *inode, struct file *file) { - return single_open(file, ide_driver_proc_show, PDE(inode)->data); + return single_open(file, ide_driver_proc_show, PDE_DATA(inode)); } static int ide_replace_subdriver(ide_drive_t *drive, const char *driver) @@ -558,7 +558,7 @@ static int ide_replace_subdriver(ide_drive_t *drive, const char *driver) static ssize_t ide_driver_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos) { - ide_drive_t *drive = (ide_drive_t *) PDE(file_inode(file))->data; + ide_drive_t *drive = PDE_DATA(file_inode(file)); char name[32]; if (!capable(CAP_SYS_ADMIN)) @@ -601,7 +601,7 @@ static int ide_media_proc_show(struct seq_file *m, void *v) static int ide_media_proc_open(struct inode *inode, struct file *file) { - return single_open(file, ide_media_proc_show, PDE(inode)->data); + return single_open(file, ide_media_proc_show, PDE_DATA(inode)); } static const struct file_operations ide_media_proc_fops = { diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index ce8237d3615..89f859591bb 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c @@ -1847,7 +1847,7 @@ static int idetape_name_proc_show(struct seq_file *m, void *v) static int idetape_name_proc_open(struct inode *inode, struct file *file) { - return single_open(file, idetape_name_proc_show, PDE(inode)->data); + return single_open(file, idetape_name_proc_show, PDE_DATA(inode)); } static const struct file_operations idetape_name_proc_fops = { diff --git a/drivers/isdn/gigaset/capi.c b/drivers/isdn/gigaset/capi.c index 03a0a01a405..3286903a95d 100644 --- a/drivers/isdn/gigaset/capi.c +++ b/drivers/isdn/gigaset/capi.c @@ -2334,7 +2334,7 @@ static int gigaset_proc_show(struct seq_file *m, void *v) static int gigaset_proc_open(struct inode *inode, struct file *file) { - return single_open(file, gigaset_proc_show, PDE(inode)->data); + return single_open(file, gigaset_proc_show, PDE_DATA(inode)); } static const struct file_operations gigaset_proc_fops = { diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c index 821f7ac33b3..4d9b195547c 100644 --- a/drivers/isdn/hardware/avm/b1.c +++ b/drivers/isdn/hardware/avm/b1.c @@ -702,7 +702,7 @@ static int b1ctl_proc_show(struct seq_file *m, void *v) static int b1ctl_proc_open(struct inode *inode, struct file *file) { - return single_open(file, b1ctl_proc_show, PDE(inode)->data); + return single_open(file, b1ctl_proc_show, PDE_DATA(inode)); } const struct file_operations b1ctl_proc_fops = { diff --git a/drivers/isdn/hardware/avm/b1dma.c b/drivers/isdn/hardware/avm/b1dma.c index 0896aa86fc0..19b113faeb7 100644 --- a/drivers/isdn/hardware/avm/b1dma.c +++ b/drivers/isdn/hardware/avm/b1dma.c @@ -944,7 +944,7 @@ static int b1dmactl_proc_show(struct seq_file *m, void *v) static int b1dmactl_proc_open(struct inode *inode, struct file *file) { - return single_open(file, b1dmactl_proc_show, PDE(inode)->data); + return single_open(file, b1dmactl_proc_show, PDE_DATA(inode)); } const struct file_operations b1dmactl_proc_fops = { diff --git a/drivers/isdn/hardware/avm/c4.c b/drivers/isdn/hardware/avm/c4.c index 1d7fc44e3ee..5d00d72fe48 100644 --- a/drivers/isdn/hardware/avm/c4.c +++ b/drivers/isdn/hardware/avm/c4.c @@ -1129,7 +1129,7 @@ static int c4_proc_show(struct seq_file *m, void *v) static int c4_proc_open(struct inode *inode, struct file *file) { - return single_open(file, c4_proc_show, PDE(inode)->data); + return single_open(file, c4_proc_show, PDE_DATA(inode)); } static const struct file_operations c4_proc_fops = { diff --git a/drivers/isdn/hardware/eicon/divasproc.c b/drivers/isdn/hardware/eicon/divasproc.c index 3a4165c6119..56ce98a4e24 100644 --- a/drivers/isdn/hardware/eicon/divasproc.c +++ b/drivers/isdn/hardware/eicon/divasproc.c @@ -145,7 +145,7 @@ void remove_divas_proc(void) static ssize_t grp_opt_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos) { - diva_os_xdi_adapter_t *a = PDE(file_inode(file))->data; + diva_os_xdi_adapter_t *a = PDE_DATA(file_inode(file)); PISDN_ADAPTER IoAdapter = IoAdapters[a->controller - 1]; if ((count == 1) || (count == 2)) { @@ -172,7 +172,7 @@ static ssize_t grp_opt_proc_write(struct file *file, const char __user *buffer, static ssize_t d_l1_down_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos) { - diva_os_xdi_adapter_t *a = PDE(file_inode(file))->data; + diva_os_xdi_adapter_t *a = PDE_DATA(file_inode(file)); PISDN_ADAPTER IoAdapter = IoAdapters[a->controller - 1]; if ((count == 1) || (count == 2)) { @@ -210,7 +210,7 @@ static int d_l1_down_proc_show(struct seq_file *m, void *v) static int d_l1_down_proc_open(struct inode *inode, struct file *file) { - return single_open(file, d_l1_down_proc_show, PDE(inode)->data); + return single_open(file, d_l1_down_proc_show, PDE_DATA(inode)); } static const struct file_operations d_l1_down_proc_fops = { @@ -236,7 +236,7 @@ static int grp_opt_proc_show(struct seq_file *m, void *v) static int grp_opt_proc_open(struct inode *inode, struct file *file) { - return single_open(file, grp_opt_proc_show, PDE(inode)->data); + return single_open(file, grp_opt_proc_show, PDE_DATA(inode)); } static const struct file_operations grp_opt_proc_fops = { @@ -251,7 +251,7 @@ static const struct file_operations grp_opt_proc_fops = { static ssize_t info_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos) { - diva_os_xdi_adapter_t *a = PDE(file_inode(file))->data; + diva_os_xdi_adapter_t *a = PDE_DATA(file_inode(file)); PISDN_ADAPTER IoAdapter = IoAdapters[a->controller - 1]; char c[4]; @@ -335,7 +335,7 @@ static int info_proc_show(struct seq_file *m, void *v) static int info_proc_open(struct inode *inode, struct file *file) { - return single_open(file, info_proc_show, PDE(inode)->data); + return single_open(file, info_proc_show, PDE_DATA(inode)); } static const struct file_operations info_proc_fops = { diff --git a/drivers/isdn/hysdn/hycapi.c b/drivers/isdn/hysdn/hycapi.c index 931f916c9c2..00aad10507d 100644 --- a/drivers/isdn/hysdn/hycapi.c +++ b/drivers/isdn/hysdn/hycapi.c @@ -469,7 +469,7 @@ static int hycapi_proc_show(struct seq_file *m, void *v) static int hycapi_proc_open(struct inode *inode, struct file *file) { - return single_open(file, hycapi_proc_show, PDE(inode)->data); + return single_open(file, hycapi_proc_show, PDE_DATA(inode)); } static const struct file_operations hycapi_proc_fops = { diff --git a/drivers/isdn/hysdn/hysdn_procconf.c b/drivers/isdn/hysdn/hysdn_procconf.c index dc88bcb2502..73079213ec9 100644 --- a/drivers/isdn/hysdn/hysdn_procconf.c +++ b/drivers/isdn/hysdn/hysdn_procconf.c @@ -234,7 +234,7 @@ hysdn_conf_open(struct inode *ino, struct file *filep) /* now search the addressed card */ mutex_lock(&hysdn_conf_mutex); - card = PDE(ino)->data; + card = PDE_DATA(ino); if (card->debug_flags & (LOG_PROC_OPEN | LOG_PROC_ALL)) hysdn_addlog(card, "config open for uid=%d gid=%d mode=0x%x", filep->f_cred->fsuid, filep->f_cred->fsgid, @@ -308,7 +308,7 @@ hysdn_conf_close(struct inode *ino, struct file *filep) int retval = 0; mutex_lock(&hysdn_conf_mutex); - card = PDE(ino)->data; + card = PDE_DATA(ino); if (card->debug_flags & (LOG_PROC_OPEN | LOG_PROC_ALL)) hysdn_addlog(card, "config close for uid=%d gid=%d mode=0x%x", filep->f_cred->fsuid, filep->f_cred->fsgid, diff --git a/drivers/isdn/hysdn/hysdn_proclog.c b/drivers/isdn/hysdn/hysdn_proclog.c index 22f0e4ef1fb..b61e8d5e84a 100644 --- a/drivers/isdn/hysdn/hysdn_proclog.c +++ b/drivers/isdn/hysdn/hysdn_proclog.c @@ -173,7 +173,7 @@ hysdn_log_read(struct file *file, char __user *buf, size_t count, loff_t *off) { struct log_data *inf; int len; - hysdn_card *card = PDE(file_inode(file))->data; + hysdn_card *card = PDE_DATA(file_inode(file)); if (!*((struct log_data **) file->private_data)) { struct procdata *pd = card->proclog; @@ -202,7 +202,7 @@ hysdn_log_read(struct file *file, char __user *buf, size_t count, loff_t *off) static int hysdn_log_open(struct inode *ino, struct file *filep) { - hysdn_card *card = PDE(ino)->data; + hysdn_card *card = PDE_DATA(ino); mutex_lock(&hysdn_log_mutex); if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_WRITE) { @@ -255,7 +255,7 @@ hysdn_log_close(struct inode *ino, struct file *filep) pd = (struct procdata *) inf->proc_ctrl; /* still entries there */ else { /* no info available -> search card */ - card = PDE(file_inode(filep))->data; + card = PDE_DATA(file_inode(filep)); pd = card->proclog; /* pointer to procfs log */ } if (pd) @@ -286,7 +286,7 @@ static unsigned int hysdn_log_poll(struct file *file, poll_table *wait) { unsigned int mask = 0; - hysdn_card *card = PDE(file_inode(file))->data; + hysdn_card *card = PDE_DATA(file_inode(file)); struct procdata *pd = card->proclog; if ((file->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_WRITE) diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c index 22b8ce4191c..c31fbab6aa8 100644 --- a/drivers/macintosh/via-pmu.c +++ b/drivers/macintosh/via-pmu.c @@ -869,7 +869,7 @@ static int pmu_battery_proc_show(struct seq_file *m, void *v) static int pmu_battery_proc_open(struct inode *inode, struct file *file) { - return single_open(file, pmu_battery_proc_show, PDE(inode)->data); + return single_open(file, pmu_battery_proc_show, PDE_DATA(inode)); } static const struct file_operations pmu_battery_proc_fops = { diff --git a/drivers/media/pci/zoran/zoran_procfs.c b/drivers/media/pci/zoran/zoran_procfs.c index e084b0a21b1..07a104d2bd1 100644 --- a/drivers/media/pci/zoran/zoran_procfs.c +++ b/drivers/media/pci/zoran/zoran_procfs.c @@ -130,14 +130,14 @@ static int zoran_show(struct seq_file *p, void *v) static int zoran_open(struct inode *inode, struct file *file) { - struct zoran *data = PDE(inode)->data; + struct zoran *data = PDE_DATA(inode); return single_open(file, zoran_show, data); } static ssize_t zoran_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) { - struct zoran *zr = PDE(file_inode(file))->data; + struct zoran *zr = PDE_DATA(file_inode(file)); char *string, *sp; char *line, *ldelim, *varname, *svar, *tdelim; diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c index fb69baa06ca..767ff4d839f 100644 --- a/drivers/message/fusion/mptbase.c +++ b/drivers/message/fusion/mptbase.c @@ -6656,7 +6656,7 @@ static int mpt_summary_proc_show(struct seq_file *m, void *v) static int mpt_summary_proc_open(struct inode *inode, struct file *file) { - return single_open(file, mpt_summary_proc_show, PDE(inode)->data); + return single_open(file, mpt_summary_proc_show, PDE_DATA(inode)); } static const struct file_operations mpt_summary_proc_fops = { @@ -6805,7 +6805,7 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v) static int mpt_iocinfo_proc_open(struct inode *inode, struct file *file) { - return single_open(file, mpt_iocinfo_proc_show, PDE(inode)->data); + return single_open(file, mpt_iocinfo_proc_show, PDE_DATA(inode)); } static const struct file_operations mpt_iocinfo_proc_fops = { diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c index 15c1e480c0d..70a840f9b28 100644 --- a/drivers/message/i2o/i2o_proc.c +++ b/drivers/message/i2o/i2o_proc.c @@ -1599,98 +1599,98 @@ static int i2o_seq_show_sensors(struct seq_file *seq, void *v) static int i2o_seq_open_hrt(struct inode *inode, struct file *file) { - return single_open(file, i2o_seq_show_hrt, PDE(inode)->data); + return single_open(file, i2o_seq_show_hrt, PDE_DATA(inode)); }; static int i2o_seq_open_lct(struct inode *inode, struct file *file) { - return single_open(file, i2o_seq_show_lct, PDE(inode)->data); + return single_open(file, i2o_seq_show_lct, PDE_DATA(inode)); }; static int i2o_seq_open_status(struct inode *inode, struct file *file) { - return single_open(file, i2o_seq_show_status, PDE(inode)->data); + return single_open(file, i2o_seq_show_status, PDE_DATA(inode)); }; static int i2o_seq_open_hw(struct inode *inode, struct file *file) { - return single_open(file, i2o_seq_show_hw, PDE(inode)->data); + return single_open(file, i2o_seq_show_hw, PDE_DATA(inode)); }; static int i2o_seq_open_ddm_table(struct inode *inode, struct file *file) { - return single_open(file, i2o_seq_show_ddm_table, PDE(inode)->data); + return single_open(file, i2o_seq_show_ddm_table, PDE_DATA(inode)); }; static int i2o_seq_open_driver_store(struct inode *inode, struct file *file) { - return single_open(file, i2o_seq_show_driver_store, PDE(inode)->data); + return single_open(file, i2o_seq_show_driver_store, PDE_DATA(inode)); }; static int i2o_seq_open_drivers_stored(struct inode *inode, struct file *file) { - return single_open(file, i2o_seq_show_drivers_stored, PDE(inode)->data); + return single_open(file, i2o_seq_show_drivers_stored, PDE_DATA(inode)); }; static int i2o_seq_open_groups(struct inode *inode, struct file *file) { - return single_open(file, i2o_seq_show_groups, PDE(inode)->data); + return single_open(file, i2o_seq_show_groups, PDE_DATA(inode)); }; static int i2o_seq_open_phys_device(struct inode *inode, struct file *file) { - return single_open(file, i2o_seq_show_phys_device, PDE(inode)->data); + return single_open(file, i2o_seq_show_phys_device, PDE_DATA(inode)); }; static int i2o_seq_open_claimed(struct inode *inode, struct file *file) { - return single_open(file, i2o_seq_show_claimed, PDE(inode)->data); + return single_open(file, i2o_seq_show_claimed, PDE_DATA(inode)); }; static int i2o_seq_open_users(struct inode *inode, struct file *file) { - return single_open(file, i2o_seq_show_users, PDE(inode)->data); + return single_open(file, i2o_seq_show_users, PDE_DATA(inode)); }; static int i2o_seq_open_priv_msgs(struct inode *inode, struct file *file) { - return single_open(file, i2o_seq_show_priv_msgs, PDE(inode)->data); + return single_open(file, i2o_seq_show_priv_msgs, PDE_DATA(inode)); }; static int i2o_seq_open_authorized_users(struct inode *inode, struct file *file) { return single_open(file, i2o_seq_show_authorized_users, - PDE(inode)->data); + PDE_DATA(inode)); }; static int i2o_seq_open_dev_identity(struct inode *inode, struct file *file) { - return single_open(file, i2o_seq_show_dev_identity, PDE(inode)->data); + return single_open(file, i2o_seq_show_dev_identity, PDE_DATA(inode)); }; static int i2o_seq_open_ddm_identity(struct inode *inode, struct file *file) { - return single_open(file, i2o_seq_show_ddm_identity, PDE(inode)->data); + return single_open(file, i2o_seq_show_ddm_identity, PDE_DATA(inode)); }; static int i2o_seq_open_uinfo(struct inode *inode, struct file *file) { - return single_open(file, i2o_seq_show_uinfo, PDE(inode)->data); + return single_open(file, i2o_seq_show_uinfo, PDE_DATA(inode)); }; static int i2o_seq_open_sgl_limits(struct inode *inode, struct file *file) { - return single_open(file, i2o_seq_show_sgl_limits, PDE(inode)->data); + return single_open(file, i2o_seq_show_sgl_limits, PDE_DATA(inode)); }; static int i2o_seq_open_sensors(struct inode *inode, struct file *file) { - return single_open(file, i2o_seq_show_sensors, PDE(inode)->data); + return single_open(file, i2o_seq_show_sensors, PDE_DATA(inode)); }; static int i2o_seq_open_dev_name(struct inode *inode, struct file *file) { - return single_open(file, i2o_seq_show_dev_name, PDE(inode)->data); + return single_open(file, i2o_seq_show_dev_name, PDE_DATA(inode)); }; static const struct file_operations i2o_seq_fops_lct = { diff --git a/drivers/net/bonding/bond_procfs.c b/drivers/net/bonding/bond_procfs.c index 3cea38d3734..94d06f1307b 100644 --- a/drivers/net/bonding/bond_procfs.c +++ b/drivers/net/bonding/bond_procfs.c @@ -218,15 +218,13 @@ static const struct seq_operations bond_info_seq_ops = { static int bond_info_open(struct inode *inode, struct file *file) { struct seq_file *seq; - struct proc_dir_entry *proc; int res; res = seq_open(file, &bond_info_seq_ops); if (!res) { /* recover the pointer buried in proc_dir_entry data */ seq = file->private_data; - proc = PDE(inode); - seq->private = proc->data; + seq->private = PDE_DATA(inode); } return res; diff --git a/drivers/net/irda/vlsi_ir.c b/drivers/net/irda/vlsi_ir.c index 2f99f8881df..e22cd4e7017 100644 --- a/drivers/net/irda/vlsi_ir.c +++ b/drivers/net/irda/vlsi_ir.c @@ -383,7 +383,7 @@ static int vlsi_seq_show(struct seq_file *seq, void *v) static int vlsi_seq_open(struct inode *inode, struct file *file) { - return single_open(file, vlsi_seq_show, PDE(inode)->data); + return single_open(file, vlsi_seq_show, PDE_DATA(inode)); } static const struct file_operations vlsi_proc_fops = { diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c index 53295418f57..66e398d4730 100644 --- a/drivers/net/wireless/airo.c +++ b/drivers/net/wireless/airo.c @@ -4663,8 +4663,7 @@ static ssize_t proc_write( struct file *file, static int proc_status_open(struct inode *inode, struct file *file) { struct proc_data *data; - struct proc_dir_entry *dp = PDE(inode); - struct net_device *dev = dp->data; + struct net_device *dev = PDE_DATA(inode); struct airo_info *apriv = dev->ml_priv; CapabilityRid cap_rid; StatusRid status_rid; @@ -4746,8 +4745,7 @@ static int proc_stats_rid_open( struct inode *inode, u16 rid ) { struct proc_data *data; - struct proc_dir_entry *dp = PDE(inode); - struct net_device *dev = dp->data; + struct net_device *dev = PDE_DATA(inode); struct airo_info *apriv = dev->ml_priv; StatsRid stats; int i, j; @@ -4809,8 +4807,7 @@ static inline int sniffing_mode(struct airo_info *ai) static void proc_config_on_close(struct inode *inode, struct file *file) { struct proc_data *data = file->private_data; - struct proc_dir_entry *dp = PDE(inode); - struct net_device *dev = dp->data; + struct net_device *dev = PDE_DATA(inode); struct airo_info *ai = dev->ml_priv; char *line; @@ -5021,8 +5018,7 @@ static const char *get_rmode(__le16 mode) static int proc_config_open(struct inode *inode, struct file *file) { struct proc_data *data; - struct proc_dir_entry *dp = PDE(inode); - struct net_device *dev = dp->data; + struct net_device *dev = PDE_DATA(inode); struct airo_info *ai = dev->ml_priv; int i; __le16 mode; @@ -5112,8 +5108,7 @@ static int proc_config_open(struct inode *inode, struct file *file) static void proc_SSID_on_close(struct inode *inode, struct file *file) { struct proc_data *data = file->private_data; - struct proc_dir_entry *dp = PDE(inode); - struct net_device *dev = dp->data; + struct net_device *dev = PDE_DATA(inode); struct airo_info *ai = dev->ml_priv; SsidRid SSID_rid; int i; @@ -5148,8 +5143,7 @@ static void proc_SSID_on_close(struct inode *inode, struct file *file) static void proc_APList_on_close( struct inode *inode, struct file *file ) { struct proc_data *data = file->private_data; - struct proc_dir_entry *dp = PDE(inode); - struct net_device *dev = dp->data; + struct net_device *dev = PDE_DATA(inode); struct airo_info *ai = dev->ml_priv; APListRid APList_rid; int i; @@ -5283,8 +5277,7 @@ static int set_wep_tx_idx(struct airo_info *ai, u16 index, int perm, int lock) static void proc_wepkey_on_close( struct inode *inode, struct file *file ) { struct proc_data *data; - struct proc_dir_entry *dp = PDE(inode); - struct net_device *dev = dp->data; + struct net_device *dev = PDE_DATA(inode); struct airo_info *ai = dev->ml_priv; int i, rc; char key[16]; @@ -5335,8 +5328,7 @@ static void proc_wepkey_on_close( struct inode *inode, struct file *file ) { static int proc_wepkey_open( struct inode *inode, struct file *file ) { struct proc_data *data; - struct proc_dir_entry *dp = PDE(inode); - struct net_device *dev = dp->data; + struct net_device *dev = PDE_DATA(inode); struct airo_info *ai = dev->ml_priv; char *ptr; WepKeyRid wkr; @@ -5384,8 +5376,7 @@ static int proc_wepkey_open( struct inode *inode, struct file *file ) static int proc_SSID_open(struct inode *inode, struct file *file) { struct proc_data *data; - struct proc_dir_entry *dp = PDE(inode); - struct net_device *dev = dp->data; + struct net_device *dev = PDE_DATA(inode); struct airo_info *ai = dev->ml_priv; int i; char *ptr; @@ -5428,8 +5419,7 @@ static int proc_SSID_open(struct inode *inode, struct file *file) static int proc_APList_open( struct inode *inode, struct file *file ) { struct proc_data *data; - struct proc_dir_entry *dp = PDE(inode); - struct net_device *dev = dp->data; + struct net_device *dev = PDE_DATA(inode); struct airo_info *ai = dev->ml_priv; int i; char *ptr; @@ -5468,8 +5458,7 @@ static int proc_APList_open( struct inode *inode, struct file *file ) { static int proc_BSSList_open( struct inode *inode, struct file *file ) { struct proc_data *data; - struct proc_dir_entry *dp = PDE(inode); - struct net_device *dev = dp->data; + struct net_device *dev = PDE_DATA(inode); struct airo_info *ai = dev->ml_priv; char *ptr; BSSListRid BSSList_rid; diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c index 3109c0db66e..a6f660c0190 100644 --- a/drivers/net/wireless/ray_cs.c +++ b/drivers/net/wireless/ray_cs.c @@ -2778,7 +2778,7 @@ static ssize_t int_proc_write(struct file *file, const char __user *buffer, nr = nr * 10 + c; p++; } while (--len); - *(int *)PDE(file_inode(file))->data = nr; + *(int *)PDE_DATA(file_inode(file)) = nr; return count; } diff --git a/drivers/parisc/led.c b/drivers/parisc/led.c index d4d800c54d8..b4824313199 100644 --- a/drivers/parisc/led.c +++ b/drivers/parisc/led.c @@ -172,14 +172,14 @@ static int led_proc_show(struct seq_file *m, void *v) static int led_proc_open(struct inode *inode, struct file *file) { - return single_open(file, led_proc_show, PDE(inode)->data); + return single_open(file, led_proc_show, PDE_DATA(inode)); } static ssize_t led_proc_write(struct file *file, const char *buf, size_t count, loff_t *pos) { - void *data = PDE(file_inode(file))->data; + void *data = PDE_DATA(file_inode(file)); char *cur, lbuf[32]; int d; diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c index 0b009470e6d..12e4fb5824c 100644 --- a/drivers/pci/proc.c +++ b/drivers/pci/proc.c @@ -46,9 +46,7 @@ proc_bus_pci_lseek(struct file *file, loff_t off, int whence) static ssize_t proc_bus_pci_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos) { - const struct inode *ino = file_inode(file); - const struct proc_dir_entry *dp = PDE(ino); - struct pci_dev *dev = dp->data; + struct pci_dev *dev = PDE_DATA(file_inode(file)); unsigned int pos = *ppos; unsigned int cnt, size; @@ -59,7 +57,7 @@ proc_bus_pci_read(struct file *file, char __user *buf, size_t nbytes, loff_t *pp */ if (capable(CAP_SYS_ADMIN)) - size = dp->size; + size = dev->cfg_size; else if (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) size = 128; else @@ -133,10 +131,9 @@ static ssize_t proc_bus_pci_write(struct file *file, const char __user *buf, size_t nbytes, loff_t *ppos) { struct inode *ino = file_inode(file); - const struct proc_dir_entry *dp = PDE(ino); - struct pci_dev *dev = dp->data; + struct pci_dev *dev = PDE_DATA(ino); int pos = *ppos; - int size = dp->size; + int size = dev->cfg_size; int cnt; if (pos >= size) @@ -200,7 +197,7 @@ proc_bus_pci_write(struct file *file, const char __user *buf, size_t nbytes, lof pci_config_pm_runtime_put(dev); *ppos = pos; - i_size_write(ino, dp->size); + i_size_write(ino, dev->cfg_size); return nbytes; } @@ -212,8 +209,7 @@ struct pci_filp_private { static long proc_bus_pci_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { - const struct proc_dir_entry *dp = PDE(file_inode(file)); - struct pci_dev *dev = dp->data; + struct pci_dev *dev = PDE_DATA(file_inode(file)); #ifdef HAVE_PCI_MMAP struct pci_filp_private *fpriv = file->private_data; #endif /* HAVE_PCI_MMAP */ @@ -253,9 +249,7 @@ static long proc_bus_pci_ioctl(struct file *file, unsigned int cmd, #ifdef HAVE_PCI_MMAP static int proc_bus_pci_mmap(struct file *file, struct vm_area_struct *vma) { - struct inode *inode = file_inode(file); - const struct proc_dir_entry *dp = PDE(inode); - struct pci_dev *dev = dp->data; + struct pci_dev *dev = PDE_DATA(file_inode(file)); struct pci_filp_private *fpriv = file->private_data; int i, ret; diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 9a907567f41..05272e676a2 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -844,14 +844,14 @@ static int dispatch_proc_show(struct seq_file *m, void *v) static int dispatch_proc_open(struct inode *inode, struct file *file) { - return single_open(file, dispatch_proc_show, PDE(inode)->data); + return single_open(file, dispatch_proc_show, PDE_DATA(inode)); } static ssize_t dispatch_proc_write(struct file *file, const char __user *userbuf, size_t count, loff_t *pos) { - struct ibm_struct *ibm = PDE(file_inode(file))->data; + struct ibm_struct *ibm = PDE_DATA(file_inode(file)); char *kernbuf; int ret; diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c index 242abac62d8..eb3467ea6d8 100644 --- a/drivers/platform/x86/toshiba_acpi.c +++ b/drivers/platform/x86/toshiba_acpi.c @@ -553,7 +553,7 @@ static int lcd_proc_show(struct seq_file *m, void *v) static int lcd_proc_open(struct inode *inode, struct file *file) { - return single_open(file, lcd_proc_show, PDE(inode)->data); + return single_open(file, lcd_proc_show, PDE_DATA(inode)); } static int set_lcd_brightness(struct toshiba_acpi_dev *dev, int value) @@ -583,7 +583,7 @@ static int set_lcd_status(struct backlight_device *bd) static ssize_t lcd_proc_write(struct file *file, const char __user *buf, size_t count, loff_t *pos) { - struct toshiba_acpi_dev *dev = PDE(file_inode(file))->data; + struct toshiba_acpi_dev *dev = PDE_DATA(file_inode(file)); char cmd[42]; size_t len; int value; @@ -644,13 +644,13 @@ static int video_proc_show(struct seq_file *m, void *v) static int video_proc_open(struct inode *inode, struct file *file) { - return single_open(file, video_proc_show, PDE(inode)->data); + return single_open(file, video_proc_show, PDE_DATA(inode)); } static ssize_t video_proc_write(struct file *file, const char __user *buf, size_t count, loff_t *pos) { - struct toshiba_acpi_dev *dev = PDE(file_inode(file))->data; + struct toshiba_acpi_dev *dev = PDE_DATA(file_inode(file)); char *cmd, *buffer; int ret; int value; @@ -744,13 +744,13 @@ static int fan_proc_show(struct seq_file *m, void *v) static int fan_proc_open(struct inode *inode, struct file *file) { - return single_open(file, fan_proc_show, PDE(inode)->data); + return single_open(file, fan_proc_show, PDE_DATA(inode)); } static ssize_t fan_proc_write(struct file *file, const char __user *buf, size_t count, loff_t *pos) { - struct toshiba_acpi_dev *dev = PDE(file_inode(file))->data; + struct toshiba_acpi_dev *dev = PDE_DATA(file_inode(file)); char cmd[42]; size_t len; int value; @@ -816,13 +816,13 @@ static int keys_proc_show(struct seq_file *m, void *v) static int keys_proc_open(struct inode *inode, struct file *file) { - return single_open(file, keys_proc_show, PDE(inode)->data); + return single_open(file, keys_proc_show, PDE_DATA(inode)); } static ssize_t keys_proc_write(struct file *file, const char __user *buf, size_t count, loff_t *pos) { - struct toshiba_acpi_dev *dev = PDE(file_inode(file))->data; + struct toshiba_acpi_dev *dev = PDE_DATA(file_inode(file)); char cmd[42]; size_t len; int value; @@ -859,7 +859,7 @@ static int version_proc_show(struct seq_file *m, void *v) static int version_proc_open(struct inode *inode, struct file *file) { - return single_open(file, version_proc_show, PDE(inode)->data); + return single_open(file, version_proc_show, PDE_DATA(inode)); } static const struct file_operations version_proc_fops = { diff --git a/drivers/pnp/isapnp/proc.c b/drivers/pnp/isapnp/proc.c index 65f735ac6b3..af4d40affb7 100644 --- a/drivers/pnp/isapnp/proc.c +++ b/drivers/pnp/isapnp/proc.c @@ -55,9 +55,7 @@ static loff_t isapnp_proc_bus_lseek(struct file *file, loff_t off, int whence) static ssize_t isapnp_proc_bus_read(struct file *file, char __user * buf, size_t nbytes, loff_t * ppos) { - struct inode *ino = file_inode(file); - struct proc_dir_entry *dp = PDE(ino); - struct pnp_dev *dev = dp->data; + struct pnp_dev *dev = PDE_DATA(file_inode(file)); int pos = *ppos; int cnt, size = 256; diff --git a/drivers/pnp/pnpbios/proc.c b/drivers/pnp/pnpbios/proc.c index 63ddb017345..8dafd65d475 100644 --- a/drivers/pnp/pnpbios/proc.c +++ b/drivers/pnp/pnpbios/proc.c @@ -238,13 +238,13 @@ static int pnpbios_proc_show(struct seq_file *m, void *v) static int pnpbios_proc_open(struct inode *inode, struct file *file) { - return single_open(file, pnpbios_proc_show, PDE(inode)->data); + return single_open(file, pnpbios_proc_show, PDE_DATA(inode)); } static ssize_t pnpbios_proc_write(struct file *file, const char __user *buf, size_t count, loff_t *pos) { - void *data = PDE(file_inode(file))->data; + void *data = PDE_DATA(file_inode(file)); struct pnp_bios_node *node; int boot = (long)data >> 8; u8 nodenum = (long)data; diff --git a/drivers/rtc/rtc-proc.c b/drivers/rtc/rtc-proc.c index e96236ac2e7..ffa69e1c924 100644 --- a/drivers/rtc/rtc-proc.c +++ b/drivers/rtc/rtc-proc.c @@ -110,7 +110,7 @@ static int rtc_proc_show(struct seq_file *seq, void *offset) static int rtc_proc_open(struct inode *inode, struct file *file) { int ret; - struct rtc_device *rtc = PDE(inode)->data; + struct rtc_device *rtc = PDE_DATA(inode); if (!try_module_get(THIS_MODULE)) return -ENODEV; diff --git a/drivers/scsi/scsi_proc.c b/drivers/scsi/scsi_proc.c index 1eb34c34d7b..db66357211e 100644 --- a/drivers/scsi/scsi_proc.c +++ b/drivers/scsi/scsi_proc.c @@ -48,7 +48,7 @@ static DEFINE_MUTEX(global_host_template_mutex); static ssize_t proc_scsi_host_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { - struct Scsi_Host *shost = PDE(file_inode(file))->data; + struct Scsi_Host *shost = PDE_DATA(file_inode(file)); ssize_t ret = -ENOMEM; char *page; @@ -78,7 +78,7 @@ static int proc_scsi_show(struct seq_file *m, void *v) static int proc_scsi_host_open(struct inode *inode, struct file *file) { - return single_open_size(file, proc_scsi_show, PDE(inode)->data, + return single_open_size(file, proc_scsi_show, PDE_DATA(inode), 4 * PAGE_SIZE); } diff --git a/drivers/staging/ccg/rndis.c b/drivers/staging/ccg/rndis.c index d9297eebbf7..1e4cfb05f70 100644 --- a/drivers/staging/ccg/rndis.c +++ b/drivers/staging/ccg/rndis.c @@ -1065,7 +1065,7 @@ static int rndis_proc_show(struct seq_file *m, void *v) static ssize_t rndis_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) { - rndis_params *p = PDE(file_inode(file))->data; + rndis_params *p = PDE_DATA(file_inode(file)); u32 speed = 0; int i, fl_speed = 0; @@ -1109,7 +1109,7 @@ static ssize_t rndis_proc_write(struct file *file, const char __user *buffer, static int rndis_proc_open(struct inode *inode, struct file *file) { - return single_open(file, rndis_proc_show, PDE(inode)->data); + return single_open(file, rndis_proc_show, PDE_DATA(inode)); } static const struct file_operations rndis_proc_fops = { diff --git a/drivers/staging/dgrp/dgrp_dpa_ops.c b/drivers/staging/dgrp/dgrp_dpa_ops.c index cfa8e82404f..43209c163a4 100644 --- a/drivers/staging/dgrp/dgrp_dpa_ops.c +++ b/drivers/staging/dgrp/dgrp_dpa_ops.c @@ -113,8 +113,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; @@ -137,12 +135,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 52493b5c167..6edbbf06915 100644 --- a/drivers/staging/dgrp/dgrp_mon_ops.c +++ b/drivers/staging/dgrp/dgrp_mon_ops.c @@ -67,7 +67,6 @@ const struct file_operations dgrp_mon_ops = { 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; @@ -95,13 +94,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 dc826b2cf90..5448fc78bca 100644 --- a/drivers/staging/dgrp/dgrp_net_ops.c +++ b/drivers/staging/dgrp/dgrp_net_ops.c @@ -784,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; @@ -808,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 48e9079c635..4ce030815f2 100644 --- a/drivers/staging/dgrp/dgrp_ports_ops.c +++ b/drivers/staging/dgrp/dgrp_ports_ops.c @@ -149,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/silicom/bpctl_mod.c b/drivers/staging/silicom/bpctl_mod.c index f64ee07c15a..e2da0fb3f98 100644 --- a/drivers/staging/silicom/bpctl_mod.c +++ b/drivers/staging/silicom/bpctl_mod.c @@ -7250,7 +7250,7 @@ static int procfs_add(char *proc_name, const struct file_operations *fops, #define RO_FOPS(name) \ static int name##_open(struct inode *inode, struct file *file) \ { \ - return single_open(file, show_##name, PDE(inode)->data);\ + return single_open(file, show_##name, PDE_DATA(inode));\ } \ static const struct file_operations name##_ops = { \ .open = name##_open, \ @@ -7262,7 +7262,7 @@ static const struct file_operations name##_ops = { \ #define RW_FOPS(name) \ static int name##_open(struct inode *inode, struct file *file) \ { \ - return single_open(file, show_##name, PDE(inode)->data);\ + return single_open(file, show_##name, PDE_DATA(inode));\ } \ static const struct file_operations name##_ops = { \ .open = name##_open, \ @@ -7351,7 +7351,7 @@ static ssize_t bypass_write(struct file *file, const char __user *buffer, if (bypass_param < 0) return -1; - set_bypass_fn(PDE(file_inode(file))->data, bypass_param); + set_bypass_fn(PDE_DATA(file_inode(file)), bypass_param); return count; } static int show_bypass(struct seq_file *m, void *v) @@ -7375,7 +7375,7 @@ static ssize_t tap_write(struct file *file, const char __user *buffer, if (tap_param < 0) return -1; - set_tap_fn(PDE(file_inode(file))->data, tap_param); + set_tap_fn(PDE_DATA(file_inode(file)), tap_param); return count; } static int show_tap(struct seq_file *m, void *v) @@ -7399,7 +7399,7 @@ static ssize_t disc_write(struct file *file, const char __user *buffer, if (tap_param < 0) return -1; - set_disc_fn(PDE(file_inode(file))->data, tap_param); + set_disc_fn(PDE_DATA(file_inode(file)), tap_param); return count; } static int show_disc(struct seq_file *m, void *v) @@ -7461,7 +7461,7 @@ RO_FOPS(disc_change) static ssize_t bypass_wd_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos) { - bpctl_dev_t *dev = PDE(file_inode(file))->data; + bpctl_dev_t *dev = PDE_DATA(file_inode(file)); int timeout; int ret = kstrtoint_from_user(buffer, count, 10, &timeout); if (ret) @@ -7507,7 +7507,7 @@ RO_FOPS(wd_expire_time) static ssize_t tpl_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos) { - bpctl_dev_t *dev = PDE(file_inode(file))->data; + bpctl_dev_t *dev = PDE_DATA(file_inode(file)); int tpl_param = user_on_off(buffer, count); if (tpl_param < 0) return -1; @@ -7533,7 +7533,7 @@ RW_FOPS(tpl) static ssize_t wait_at_pwup_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos) { - bpctl_dev_t *dev = PDE(file_inode(file))->data; + bpctl_dev_t *dev = PDE_DATA(file_inode(file)); int tpl_param = user_on_off(buffer, count); if (tpl_param < 0) return -1; @@ -7558,7 +7558,7 @@ RW_FOPS(wait_at_pwup) static ssize_t hw_reset_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos) { - bpctl_dev_t *dev = PDE(file_inode(file))->data; + bpctl_dev_t *dev = PDE_DATA(file_inode(file)); int tpl_param = user_on_off(buffer, count); if (tpl_param < 0) return -1; @@ -7603,7 +7603,7 @@ static ssize_t dis_bypass_write(struct file *file, const char __user *buffer, if (bypass_param < 0) return -EINVAL; - set_dis_bypass_fn(PDE(file_inode(file))->data, bypass_param); + set_dis_bypass_fn(PDE_DATA(file_inode(file)), bypass_param); return count; } static int show_dis_bypass(struct seq_file *m, void *v) @@ -7627,7 +7627,7 @@ static ssize_t dis_tap_write(struct file *file, const char __user *buffer, if (tap_param < 0) return -EINVAL; - set_dis_tap_fn(PDE(file_inode(file))->data, tap_param); + set_dis_tap_fn(PDE_DATA(file_inode(file)), tap_param); return count; } static int show_dis_tap(struct seq_file *m, void *v) @@ -7651,7 +7651,7 @@ static ssize_t dis_disc_write(struct file *file, const char __user *buffer, if (tap_param < 0) return -EINVAL; - set_dis_disc_fn(PDE(file_inode(file))->data, tap_param); + set_dis_disc_fn(PDE_DATA(file_inode(file)), tap_param); return count; } static int show_dis_disc(struct seq_file *m, void *v) @@ -7675,7 +7675,7 @@ static ssize_t bypass_pwup_write(struct file *file, const char __user *buffer, if (bypass_param < 0) return -EINVAL; - set_bypass_pwup_fn(PDE(file_inode(file))->data, bypass_param); + set_bypass_pwup_fn(PDE_DATA(file_inode(file)), bypass_param); return count; } static int show_bypass_pwup(struct seq_file *m, void *v) @@ -7699,7 +7699,7 @@ static ssize_t bypass_pwoff_write(struct file *file, const char __user *buffer, if (bypass_param < 0) return -EINVAL; - set_bypass_pwoff_fn(PDE(file_inode(file))->data, bypass_param); + set_bypass_pwoff_fn(PDE_DATA(file_inode(file)), bypass_param); return count; } static int show_bypass_pwoff(struct seq_file *m, void *v) @@ -7723,7 +7723,7 @@ static ssize_t tap_pwup_write(struct file *file, const char __user *buffer, if (tap_param < 0) return -EINVAL; - set_tap_pwup_fn(PDE(file_inode(file))->data, tap_param); + set_tap_pwup_fn(PDE_DATA(file_inode(file)), tap_param); return count; } static int show_tap_pwup(struct seq_file *m, void *v) @@ -7747,7 +7747,7 @@ static ssize_t disc_pwup_write(struct file *file, const char __user *buffer, if (tap_param < 0) return -EINVAL; - set_disc_pwup_fn(PDE(file_inode(file))->data, tap_param); + set_disc_pwup_fn(PDE_DATA(file_inode(file)), tap_param); return count; } static int show_disc_pwup(struct seq_file *m, void *v) @@ -7771,7 +7771,7 @@ static ssize_t std_nic_write(struct file *file, const char __user *buffer, if (bypass_param < 0) return -EINVAL; - set_std_nic_fn(PDE(file_inode(file))->data, bypass_param); + set_std_nic_fn(PDE_DATA(file_inode(file)), bypass_param); return count; } static int show_std_nic(struct seq_file *m, void *v) @@ -7812,7 +7812,7 @@ static ssize_t wd_exp_mode_write(struct file *file, const char __user *buffer, else if (strcmp(kbuf, "disc") == 0) bypass_param = 2; - set_wd_exp_mode_fn(PDE(file_inode(file))->data, bypass_param); + set_wd_exp_mode_fn(PDE_DATA(file_inode(file)), bypass_param); return count; } @@ -7839,7 +7839,7 @@ static ssize_t wd_autoreset_write(struct file *file, const char __user *buffer, int ret = kstrtoint_from_user(buffer, count, 10, &timeout); if (ret) return ret; - set_wd_autoreset_fn(PDE(file_inode(file))->data, timeout); + set_wd_autoreset_fn(PDE_DATA(file_inode(file)), timeout); return count; } static int show_wd_autoreset(struct seq_file *m, void *v) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index a400002dfa8..19cc749f838 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -1711,7 +1711,7 @@ static int uart_proc_show(struct seq_file *m, void *v) static int uart_proc_open(struct inode *inode, struct file *file) { - return single_open(file, uart_proc_show, PDE(inode)->data); + return single_open(file, uart_proc_show, PDE_DATA(inode)); } static const struct file_operations uart_proc_fops = { diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c index 45dd2929a67..88966e0508a 100644 --- a/drivers/usb/gadget/at91_udc.c +++ b/drivers/usb/gadget/at91_udc.c @@ -221,7 +221,7 @@ static int proc_udc_show(struct seq_file *s, void *unused) static int proc_udc_open(struct inode *inode, struct file *file) { - return single_open(file, proc_udc_show, PDE(inode)->data); + return single_open(file, proc_udc_show, PDE_DATA(inode)); } static const struct file_operations proc_ops = { diff --git a/drivers/usb/gadget/lpc32xx_udc.c b/drivers/usb/gadget/lpc32xx_udc.c index aa04089d689..1049d3745d7 100644 --- a/drivers/usb/gadget/lpc32xx_udc.c +++ b/drivers/usb/gadget/lpc32xx_udc.c @@ -565,7 +565,7 @@ static int proc_udc_show(struct seq_file *s, void *unused) static int proc_udc_open(struct inode *inode, struct file *file) { - return single_open(file, proc_udc_show, PDE(inode)->data); + return single_open(file, proc_udc_show, PDE_DATA(inode)); } static const struct file_operations proc_ops = { diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c index d9297eebbf7..1e4cfb05f70 100644 --- a/drivers/usb/gadget/rndis.c +++ b/drivers/usb/gadget/rndis.c @@ -1065,7 +1065,7 @@ static int rndis_proc_show(struct seq_file *m, void *v) static ssize_t rndis_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) { - rndis_params *p = PDE(file_inode(file))->data; + rndis_params *p = PDE_DATA(file_inode(file)); u32 speed = 0; int i, fl_speed = 0; @@ -1109,7 +1109,7 @@ static ssize_t rndis_proc_write(struct file *file, const char __user *buffer, static int rndis_proc_open(struct inode *inode, struct file *file) { - return single_open(file, rndis_proc_show, PDE(inode)->data); + return single_open(file, rndis_proc_show, PDE_DATA(inode)); } static const struct file_operations rndis_proc_fops = { diff --git a/drivers/usb/host/isp1362-hcd.c b/drivers/usb/host/isp1362-hcd.c index 9137caadb1c..b04e8ece4d3 100644 --- a/drivers/usb/host/isp1362-hcd.c +++ b/drivers/usb/host/isp1362-hcd.c @@ -2175,7 +2175,7 @@ static int proc_isp1362_show(struct seq_file *s, void *unused) static int proc_isp1362_open(struct inode *inode, struct file *file) { - return single_open(file, proc_isp1362_show, PDE(inode)->data); + return single_open(file, proc_isp1362_show, PDE_DATA(inode)); } static const struct file_operations proc_ops = { diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c index d62f0404baa..313d0bbfff2 100644 --- a/drivers/usb/host/sl811-hcd.c +++ b/drivers/usb/host/sl811-hcd.c @@ -1494,7 +1494,7 @@ static int proc_sl811h_show(struct seq_file *s, void *unused) static int proc_sl811h_open(struct inode *inode, struct file *file) { - return single_open(file, proc_sl811h_show, PDE(inode)->data); + return single_open(file, proc_sl811h_show, PDE_DATA(inode)); } static const struct file_operations proc_ops = { diff --git a/drivers/video/bfin_adv7393fb.c b/drivers/video/bfin_adv7393fb.c index b65c1f9dc15..a54f7f7d763 100644 --- a/drivers/video/bfin_adv7393fb.c +++ b/drivers/video/bfin_adv7393fb.c @@ -349,7 +349,7 @@ static ssize_t adv7393_write_proc(struct file *file, const char __user * buffer, size_t count, loff_t *ppos) { - struct adv7393fb_device *fbdev = PDE(file_inode(file))->data; + struct adv7393fb_device *fbdev = PDE_DATA(file_inode(file)); unsigned int val; int ret; diff --git a/drivers/zorro/proc.c b/drivers/zorro/proc.c index 73b33837e12..6d3a602c004 100644 --- a/drivers/zorro/proc.c +++ b/drivers/zorro/proc.c @@ -47,9 +47,7 @@ proc_bus_zorro_lseek(struct file *file, loff_t off, int whence) static ssize_t proc_bus_zorro_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos) { - struct inode *ino = file_inode(file); - struct proc_dir_entry *dp = PDE(ino); - struct zorro_dev *z = dp->data; + struct zorro_dev *z = PDE_DATA(file_inode(file)); struct ConfigDev cd; loff_t pos = *ppos; -- cgit v1.2.3 From 75ef9de1267ba171ecefafca35758e2be0db10dc Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 4 Apr 2013 19:09:41 -0400 Subject: constify a bunch of struct file_operations instances Signed-off-by: Al Viro --- drivers/media/rc/ir-lirc-codec.c | 2 +- drivers/media/rc/lirc_dev.c | 2 +- drivers/s390/cio/qdio_debug.c | 2 +- drivers/scsi/qla2xxx/qla_os.c | 2 +- drivers/staging/csr/drv.c | 4 ++-- drivers/staging/dgrp/dgrp_specproc.c | 6 +++--- drivers/staging/ft1000/ft1000-usb/ft1000_debug.c | 2 +- drivers/staging/rtl8192u/ieee80211/proc.c | 2 +- drivers/staging/silicom/bpctl_mod.c | 2 +- 9 files changed, 12 insertions(+), 12 deletions(-) (limited to 'drivers') diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c index 9945e5e7f61..8ee080ef2f2 100644 --- a/drivers/media/rc/ir-lirc-codec.c +++ b/drivers/media/rc/ir-lirc-codec.c @@ -307,7 +307,7 @@ static void ir_lirc_close(void *data) return; } -static struct file_operations lirc_fops = { +static const struct file_operations lirc_fops = { .owner = THIS_MODULE, .write = ir_lirc_transmit_ir, .unlocked_ioctl = ir_lirc_ioctl, diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c index 5247d94fea2..8dc057b273f 100644 --- a/drivers/media/rc/lirc_dev.c +++ b/drivers/media/rc/lirc_dev.c @@ -152,7 +152,7 @@ static int lirc_thread(void *irctl) } -static struct file_operations lirc_dev_fops = { +static const struct file_operations lirc_dev_fops = { .owner = THIS_MODULE, .read = lirc_dev_fop_read, .write = lirc_dev_fop_write, diff --git a/drivers/s390/cio/qdio_debug.c b/drivers/s390/cio/qdio_debug.c index ccaae9d63d2..4221b02085a 100644 --- a/drivers/s390/cio/qdio_debug.c +++ b/drivers/s390/cio/qdio_debug.c @@ -224,7 +224,7 @@ static int qperf_seq_open(struct inode *inode, struct file *filp) file_inode(filp)->i_private); } -static struct file_operations debugfs_perf_fops = { +static const struct file_operations debugfs_perf_fops = { .owner = THIS_MODULE, .open = qperf_seq_open, .read = seq_read, diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 2c6dd3dfe0f..ccb5e6404d0 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -5351,7 +5351,7 @@ static struct pci_driver qla2xxx_pci_driver = { .err_handler = &qla2xxx_err_handler, }; -static struct file_operations apidev_fops = { +static const struct file_operations apidev_fops = { .owner = THIS_MODULE, .llseek = noop_llseek, }; diff --git a/drivers/staging/csr/drv.c b/drivers/staging/csr/drv.c index 3bd52fdeac3..33742ba1377 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/dgrp/dgrp_specproc.c b/drivers/staging/dgrp/dgrp_specproc.c index 99c993b1337..b990b2686ba 100644 --- a/drivers/staging/dgrp/dgrp_specproc.c +++ b/drivers/staging/dgrp/dgrp_specproc.c @@ -63,7 +63,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, @@ -72,7 +72,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, @@ -80,7 +80,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, 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/rtl8192u/ieee80211/proc.c b/drivers/staging/rtl8192u/ieee80211/proc.c index 54026a412ca..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, diff --git a/drivers/staging/silicom/bpctl_mod.c b/drivers/staging/silicom/bpctl_mod.c index e2da0fb3f98..2cfa800e248 100644 --- a/drivers/staging/silicom/bpctl_mod.c +++ b/drivers/staging/silicom/bpctl_mod.c @@ -5803,7 +5803,7 @@ 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, -- cgit v1.2.3 From 8a25378e408022c441a1d27082fea9264323b7e7 Mon Sep 17 00:00:00 2001 From: David Howells Date: Thu, 4 Apr 2013 16:44:51 +0100 Subject: nubus: Don't use create_proc_entry() Don't use create_proc_entry() in nubus_proc_subdir(). The files created aren't given any way to use them, so for the moment use create_proc_read_entry() with a NULL accessor and generate a compile-time warning. Signed-off-by: David Howells --- drivers/nubus/proc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/nubus/proc.c b/drivers/nubus/proc.c index 208dd12825b..bb1446bb280 100644 --- a/drivers/nubus/proc.c +++ b/drivers/nubus/proc.c @@ -73,8 +73,9 @@ static void nubus_proc_subdir(struct nubus_dev* dev, struct proc_dir_entry* e; sprintf(name, "%x", ent.type); - e = create_proc_entry(name, S_IFREG | S_IRUGO | - S_IWUSR, parent); +#warning Need to set some I/O handlers here + e = create_proc_read_entry(name, S_IFREG | S_IRUGO | S_IWUSR, + parent, NULL, NULL); if (!e) return; } } -- cgit v1.2.3 From 3cba53765bdaeef0a5ee8680b0dd4b028f3cae79 Mon Sep 17 00:00:00 2001 From: David Howells Date: Thu, 4 Apr 2013 16:49:26 +0100 Subject: wlags49_h2: Don't use create_proc_entry() create_proc_entry() shouldn't be used. Rather proc_create_data() should be used. The proc_write() function is only used by #if'd out code, so delete it for now. Signed-off-by: David Howells --- drivers/staging/wlags49_h2/wl_main.c | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/wlags49_h2/wl_main.c b/drivers/staging/wlags49_h2/wl_main.c index f5f120a6246..174c41af484 100644 --- a/drivers/staging/wlags49_h2/wl_main.c +++ b/drivers/staging/wlags49_h2/wl_main.c @@ -147,7 +147,6 @@ void wl_isr_handler( unsigned long p ); //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 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); #endif /* SCULL_USE_PROC */ @@ -910,7 +909,6 @@ 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_mkdir("driver/wlags49", 0); - proc_write("driver/wlags49/wlags49_type", write_int, &lp->wlags49_type); #endif /* SCULL_USE_PROC */ DBG_LEAVE( DbgInfo ); @@ -3773,15 +3771,6 @@ int scull_read_procmem(char *buf, char **start, off_t offset, int len, int *eof, return len; } // 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]; -- cgit v1.2.3 From 7294b0bb694c4376cad819bb97f2796626f50551 Mon Sep 17 00:00:00 2001 From: David Howells Date: Thu, 4 Apr 2013 20:36:00 +0100 Subject: silicom-bypass: Remove device_open/close() Remove device_open/close() functions as they don't really do anything and remove Device_Open as it isn't counted atomically and the value isn't used. Signed-off-by: David Howells --- drivers/staging/silicom/bpctl_mod.c | 24 ------------------------ 1 file changed, 24 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/silicom/bpctl_mod.c b/drivers/staging/silicom/bpctl_mod.c index 2cfa800e248..3117559c041 100644 --- a/drivers/staging/silicom/bpctl_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"); @@ -289,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); @@ -5806,8 +5784,6 @@ static long device_ioctl(struct file *file, /* see include/linux/fs.h */ 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 -- cgit v1.2.3 From 996142e61d11fc1c1bea2834a36116c9a0fae029 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 5 Apr 2013 20:39:36 -0400 Subject: pxa3xx-gcu: quite playing silly buggers with ->f_op misc device gets ->private_data pointing to struct miscdevice on open(), so we can use that to get to per-device structure instead of relying on file_operations being copied into it. Signed-off-by: Al Viro --- drivers/video/pxa3xx-gcu.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'drivers') diff --git a/drivers/video/pxa3xx-gcu.c b/drivers/video/pxa3xx-gcu.c index 6c984eacc7e..4c318a34dfe 100644 --- a/drivers/video/pxa3xx-gcu.c +++ b/drivers/video/pxa3xx-gcu.c @@ -369,15 +369,20 @@ pxa3xx_gcu_wait_free(struct pxa3xx_gcu_priv *priv) /* Misc device layer */ +static inline struct pxa3xx_gcu_priv *file_dev(struct file *file) +{ + struct miscdevice *dev = file->private_data; + return container_of(dev, struct pxa3xx_gcu_priv, misc_dev); +} + static ssize_t -pxa3xx_gcu_misc_write(struct file *filp, const char *buff, +pxa3xx_gcu_misc_write(struct file *file, const char *buff, size_t count, loff_t *offp) { int ret; unsigned long flags; struct pxa3xx_gcu_batch *buffer; - struct pxa3xx_gcu_priv *priv = - container_of(filp->f_op, struct pxa3xx_gcu_priv, misc_fops); + struct pxa3xx_gcu_priv *priv = file_dev(file); int words = count / 4; @@ -450,11 +455,10 @@ pxa3xx_gcu_misc_write(struct file *filp, const char *buff, static long -pxa3xx_gcu_misc_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) +pxa3xx_gcu_misc_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { unsigned long flags; - struct pxa3xx_gcu_priv *priv = - container_of(filp->f_op, struct pxa3xx_gcu_priv, misc_fops); + struct pxa3xx_gcu_priv *priv = file_dev(file); switch (cmd) { case PXA3XX_GCU_IOCTL_RESET: @@ -471,11 +475,10 @@ pxa3xx_gcu_misc_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) } static int -pxa3xx_gcu_misc_mmap(struct file *filp, struct vm_area_struct *vma) +pxa3xx_gcu_misc_mmap(struct file *file, struct vm_area_struct *vma) { unsigned int size = vma->vm_end - vma->vm_start; - struct pxa3xx_gcu_priv *priv = - container_of(filp->f_op, struct pxa3xx_gcu_priv, misc_fops); + struct pxa3xx_gcu_priv *priv = file_dev(file); switch (vma->vm_pgoff) { case 0: -- cgit v1.2.3 From 264bd6602edd9f309c67685770bc1c8103699428 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 5 Apr 2013 20:44:08 -0400 Subject: pxa3xx-gcu: stop embedding file_operations into device-private object no need to do that anymore... Signed-off-by: Al Viro --- drivers/video/pxa3xx-gcu.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'drivers') diff --git a/drivers/video/pxa3xx-gcu.c b/drivers/video/pxa3xx-gcu.c index 4c318a34dfe..97563c55af6 100644 --- a/drivers/video/pxa3xx-gcu.c +++ b/drivers/video/pxa3xx-gcu.c @@ -101,7 +101,6 @@ struct pxa3xx_gcu_priv { dma_addr_t shared_phys; struct resource *resource_mem; struct miscdevice misc_dev; - struct file_operations misc_fops; wait_queue_head_t wait_idle; wait_queue_head_t wait_free; spinlock_t spinlock; @@ -577,6 +576,13 @@ free_buffers(struct platform_device *dev, priv->free = NULL; } +static const struct file_operations misc_fops = { + .owner = THIS_MODULE, + .write = pxa3xx_gcu_misc_write, + .unlocked_ioctl = pxa3xx_gcu_misc_ioctl, + .mmap = pxa3xx_gcu_misc_mmap +}; + static int pxa3xx_gcu_probe(struct platform_device *dev) { int i, ret, irq; @@ -604,14 +610,9 @@ static int pxa3xx_gcu_probe(struct platform_device *dev) * container_of(). This isn't really necessary as we have a fixed minor * number anyway, but this is to avoid statics. */ - priv->misc_fops.owner = THIS_MODULE; - priv->misc_fops.write = pxa3xx_gcu_misc_write; - priv->misc_fops.unlocked_ioctl = pxa3xx_gcu_misc_ioctl; - priv->misc_fops.mmap = pxa3xx_gcu_misc_mmap; - priv->misc_dev.minor = MISCDEV_MINOR, priv->misc_dev.name = DRV_NAME, - priv->misc_dev.fops = &priv->misc_fops, + priv->misc_dev.fops = &misc_fops, /* register misc device */ ret = misc_register(&priv->misc_dev); -- cgit v1.2.3 From 7c51d177f0eac50a85abc19e60e79c1dc58955d9 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 6 Apr 2013 18:00:07 -0400 Subject: vt6656: slightly sanitized reading config Just reading - parsing the results is left alone (and unspeakably lousy). Signed-off-by: Al Viro --- drivers/staging/vt6656/main_usb.c | 63 +++++++++++++-------------------------- 1 file changed, 20 insertions(+), 43 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index a5063a6f64d..457d91c1325 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -46,6 +46,7 @@ */ #undef __NO_VERSION__ +#include #include "device.h" #include "card.h" #include "baseband.h" @@ -1316,53 +1317,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 */ -- cgit v1.2.3 From f805442e130c6eeb6c25bc5c3b3cefc27ab6dcec Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 6 Apr 2013 18:11:22 -0400 Subject: vt6655: slightly clean reading config file Signed-off-by: Al Viro --- drivers/staging/vt6655/device_main.c | 115 ++++++++++++----------------------- 1 file changed, 40 insertions(+), 75 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 453c83d7fe8..a89ab9bf38e 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -60,6 +60,7 @@ */ #undef __NO_VERSION__ +#include #include "device.h" #include "card.h" #include "channel.h" @@ -2946,87 +2947,51 @@ 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; - 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; - } +int Config_FileOperation(PSDevice pDevice,bool fwrite,unsigned char *Parameter) +{ + unsigned char *buffer = kmalloc(1024, GFP_KERNEL); + unsigned char tmpbuffer[20]; + 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) { - printk("allocate mem for file fail?\n"); - result = -1; - goto error1; -} + if (!buffer) { + printk("allocate mem for file fail?\n"); + 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) { - printk("read file error?\n"); - result = -1; - goto error1; -} + if (kernel_read(file, 0, buffer, 1024) < 0) { + printk("read file error?\n"); + result = -1; + goto error1; + } -if(Config_FileGetParameter("ZONETYPE",tmpbuffer,buffer)!=true) { - printk("get parameter error?\n"); - result = -1; - goto error1; -} + if (Config_FileGetParameter("ZONETYPE",tmpbuffer,buffer)!=true) { + printk("get parameter error?\n"); + result = -1; + goto error1; + } -if(memcmp(tmpbuffer,"USA",3)==0) { - result=ZoneType_USA; -} -else if(memcmp(tmpbuffer,"JAPAN",5)==0) { - result=ZoneType_Japan; -} -else if(memcmp(tmpbuffer,"EUROPE",5)==0) { - result=ZoneType_Europe; -} -else { - result = -1; - printk("Unknown Zonetype[%s]?\n",tmpbuffer); -} + if (memcmp(tmpbuffer,"USA",3)==0) { + result = ZoneType_USA; + } else if(memcmp(tmpbuffer,"JAPAN",5)==0) { + result = ZoneType_Japan; + } else if(memcmp(tmpbuffer,"EUROPE",5)==0) { + result = ZoneType_Europe; + } else { + result = -1; + 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; - */ - - return result; + kfree(buffer); + fput(file); + return result; } -- cgit v1.2.3 From 2ce8fce2ea1663d7a62dd780653a137ca33d6ee4 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 13 Apr 2013 16:35:35 -0400 Subject: cx25821: sanitize cx25821_get_audio_data() a bit Signed-off-by: Al Viro --- drivers/media/pci/cx25821/cx25821-audio-upstream.c | 83 +++++++--------------- 1 file changed, 25 insertions(+), 58 deletions(-) (limited to 'drivers') diff --git a/drivers/media/pci/cx25821/cx25821-audio-upstream.c b/drivers/media/pci/cx25821/cx25821-audio-upstream.c index 87491ca05ee..d930f308e94 100644 --- a/drivers/media/pci/cx25821/cx25821-audio-upstream.c +++ b/drivers/media/pci/cx25821/cx25821-audio-upstream.c @@ -259,79 +259,46 @@ void cx25821_free_mem_upstream_audio(struct cx25821_dev *dev) static int cx25821_get_audio_data(struct cx25821_dev *dev, struct sram_channel *sram_ch) { - struct file *myfile; + struct file *file; int frame_index_temp = dev->_audioframe_index; int i = 0; - int line_size = AUDIO_LINE_SIZE; int frame_size = AUDIO_DATA_BUF_SZ; int frame_offset = frame_size * frame_index_temp; - ssize_t vfs_read_retval = 0; - char mybuf[line_size]; + char mybuf[AUDIO_LINE_SIZE]; loff_t file_offset = dev->_audioframe_count * frame_size; - loff_t pos; - mm_segment_t old_fs; + char *p = NULL; if (dev->_audiofile_status == END_OF_FILE) return 0; - myfile = filp_open(dev->_audiofilename, O_RDONLY | O_LARGEFILE, 0); + file = filp_open(dev->_audiofilename, O_RDONLY | O_LARGEFILE, 0); + if (IS_ERR(file)) { + pr_err("%s(): ERROR opening file(%s) with errno = %ld!\n", + __func__, dev->_audiofilename, -PTR_ERR(file)); + return PTR_ERR(file); + } - if (IS_ERR(myfile)) { - const int open_errno = -PTR_ERR(myfile); - pr_err("%s(): ERROR opening file(%s) with errno = %d!\n", - __func__, dev->_audiofilename, open_errno); - return PTR_ERR(myfile); - } else { - if (!(myfile->f_op)) { - pr_err("%s(): File has no file operations registered!\n", - __func__); - filp_close(myfile, NULL); - return -EIO; - } + if (dev->_audiodata_buf_virt_addr) + p = (char *)dev->_audiodata_buf_virt_addr + frame_offset; - if (!myfile->f_op->read) { - pr_err("%s(): File has no READ operations registered!\n", + for (i = 0; i < dev->_audio_lines_count; i++) { + int n = kernel_read(file, file_offset, mybuf, AUDIO_LINE_SIZE); + if (n < AUDIO_LINE_SIZE) { + pr_info("Done: exit %s() since no more bytes to read from Audio file\n", __func__); - filp_close(myfile, NULL); - return -EIO; + dev->_audiofile_status = END_OF_FILE; + fput(file); + return 0; } - - pos = myfile->f_pos; - old_fs = get_fs(); - set_fs(KERNEL_DS); - - for (i = 0; i < dev->_audio_lines_count; i++) { - pos = file_offset; - - vfs_read_retval = vfs_read(myfile, mybuf, line_size, - &pos); - - if (vfs_read_retval > 0 && vfs_read_retval == line_size - && dev->_audiodata_buf_virt_addr != NULL) { - memcpy((void *)(dev->_audiodata_buf_virt_addr + - frame_offset / 4), mybuf, - vfs_read_retval); - } - - file_offset += vfs_read_retval; - frame_offset += vfs_read_retval; - - if (vfs_read_retval < line_size) { - pr_info("Done: exit %s() since no more bytes to read from Audio file\n", - __func__); - break; - } + dev->_audiofile_status = IN_PROGRESS; + if (p) { + memcpy(p, mybuf, n); + p += n; } - - if (i > 0) - dev->_audioframe_count++; - - dev->_audiofile_status = (vfs_read_retval == line_size) ? - IN_PROGRESS : END_OF_FILE; - - set_fs(old_fs); - filp_close(myfile, NULL); + file_offset += n; } + dev->_audioframe_count++; + fput(file); return 0; } -- cgit v1.2.3 From 3af0761307d04f6b9a4626fb80011a22c143d75e Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 13 Apr 2013 16:48:24 -0400 Subject: cx25821: sanitize cx25821_openfile_audio() a bit... Signed-off-by: Al Viro --- drivers/media/pci/cx25821/cx25821-audio-upstream.c | 96 +++++++--------------- 1 file changed, 28 insertions(+), 68 deletions(-) (limited to 'drivers') diff --git a/drivers/media/pci/cx25821/cx25821-audio-upstream.c b/drivers/media/pci/cx25821/cx25821-audio-upstream.c index d930f308e94..d6dfb5765d0 100644 --- a/drivers/media/pci/cx25821/cx25821-audio-upstream.c +++ b/drivers/media/pci/cx25821/cx25821-audio-upstream.c @@ -321,81 +321,41 @@ static void cx25821_audioups_handler(struct work_struct *work) static int cx25821_openfile_audio(struct cx25821_dev *dev, struct sram_channel *sram_ch) { - struct file *myfile; - int i = 0, j = 0; - int line_size = AUDIO_LINE_SIZE; - ssize_t vfs_read_retval = 0; - char mybuf[line_size]; - loff_t pos; - loff_t offset = (unsigned long)0; - mm_segment_t old_fs; - - myfile = filp_open(dev->_audiofilename, O_RDONLY | O_LARGEFILE, 0); - - if (IS_ERR(myfile)) { - const int open_errno = -PTR_ERR(myfile); - pr_err("%s(): ERROR opening file(%s) with errno = %d!\n", - __func__, dev->_audiofilename, open_errno); - return PTR_ERR(myfile); - } else { - if (!(myfile->f_op)) { - pr_err("%s(): File has no file operations registered!\n", - __func__); - filp_close(myfile, NULL); - return -EIO; - } - - if (!myfile->f_op->read) { - pr_err("%s(): File has no READ operations registered!\n", - __func__); - filp_close(myfile, NULL); - return -EIO; - } - - pos = myfile->f_pos; - old_fs = get_fs(); - set_fs(KERNEL_DS); - - for (j = 0; j < NUM_AUDIO_FRAMES; j++) { - for (i = 0; i < dev->_audio_lines_count; i++) { - pos = offset; - - vfs_read_retval = vfs_read(myfile, mybuf, - line_size, &pos); - - if (vfs_read_retval > 0 && - vfs_read_retval == line_size && - dev->_audiodata_buf_virt_addr != NULL) { - memcpy((void *)(dev-> - _audiodata_buf_virt_addr - + offset / 4), mybuf, - vfs_read_retval); - } + char *p = (void *)dev->_audiodata_buf_virt_addr; + struct file *file; + loff_t offset; + int i, j; - offset += vfs_read_retval; + file = filp_open(dev->_audiofilename, O_RDONLY | O_LARGEFILE, 0); + if (IS_ERR(file)) { + pr_err("%s(): ERROR opening file(%s) with errno = %ld!\n", + __func__, dev->_audiofilename, PTR_ERR(file)); + return PTR_ERR(file); + } - if (vfs_read_retval < line_size) { - pr_info("Done: exit %s() since no more bytes to read from Audio file\n", - __func__); - break; - } + for (j = 0, offset = 0; j < NUM_AUDIO_FRAMES; j++) { + for (i = 0; i < dev->_audio_lines_count; i++) { + char buf[AUDIO_LINE_SIZE]; + int n = kernel_read(file, offset, buf, + AUDIO_LINE_SIZE); + + if (n < AUDIO_LINE_SIZE) { + pr_info("Done: exit %s() since no more bytes to read from Audio file\n", + __func__); + dev->_audiofile_status = END_OF_FILE; + fput(file); + return 0; } - if (i > 0) - dev->_audioframe_count++; + if (p) + memcpy(p + offset, buf, n); - if (vfs_read_retval < line_size) - break; + offset += n; } - - dev->_audiofile_status = (vfs_read_retval == line_size) ? - IN_PROGRESS : END_OF_FILE; - - set_fs(old_fs); - myfile->f_pos = 0; - filp_close(myfile, NULL); + dev->_audioframe_count++; } - + dev->_audiofile_status = IN_PROGRESS; + fput(file); return 0; } -- cgit v1.2.3 From 3dce1891f3e4c334046b32c355b9e5cef50c18d9 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 14 Apr 2013 21:23:06 -0400 Subject: yurex: don't wank with fasync on ->release()... Signed-off-by: Al Viro --- drivers/usb/misc/yurex.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers') diff --git a/drivers/usb/misc/yurex.c b/drivers/usb/misc/yurex.c index 42ad2e6d86c..b6ab515bfc6 100644 --- a/drivers/usb/misc/yurex.c +++ b/drivers/usb/misc/yurex.c @@ -407,8 +407,6 @@ static int yurex_release(struct inode *inode, struct file *file) if (dev == NULL) return -ENODEV; - yurex_fasync(-1, file, 0); - /* decrement the count on our device */ kref_put(&dev->kref, yurex_delete); return 0; -- cgit v1.2.3 From 858feacd2b6790c49ba9c7521f0c7ac3a5a9cb8e Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 14 Apr 2013 22:39:37 -0400 Subject: lpfc: fix races for miscdevice open vs. rmmod mind you, I'm not sure WTF would anybody _need_ that miscdevice at all - no IO is possible for it, opening it only pins the module down and is seriously racy, at that. Signed-off-by: Al Viro --- drivers/scsi/lpfc/lpfc_init.c | 33 +-------------------------------- 1 file changed, 1 insertion(+), 32 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 314b4f61b9e..8b9c191a701 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -10368,36 +10368,6 @@ lpfc_io_resume(struct pci_dev *pdev) return; } -/** - * lpfc_mgmt_open - method called when 'lpfcmgmt' is opened from userspace - * @inode: pointer to the inode representing the lpfcmgmt device - * @filep: pointer to the file representing the open lpfcmgmt device - * - * This routine puts a reference count on the lpfc module whenever the - * character device is opened - **/ -static int -lpfc_mgmt_open(struct inode *inode, struct file *filep) -{ - try_module_get(THIS_MODULE); - return 0; -} - -/** - * lpfc_mgmt_release - method called when 'lpfcmgmt' is closed in userspace - * @inode: pointer to the inode representing the lpfcmgmt device - * @filep: pointer to the file representing the open lpfcmgmt device - * - * This routine removes a reference count from the lpfc module when the - * character device is closed - **/ -static int -lpfc_mgmt_release(struct inode *inode, struct file *filep) -{ - module_put(THIS_MODULE); - return 0; -} - static struct pci_device_id lpfc_id_table[] = { {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_VIPER, PCI_ANY_ID, PCI_ANY_ID, }, @@ -10515,8 +10485,7 @@ static struct pci_driver lpfc_driver = { }; static const struct file_operations lpfc_mgmt_fop = { - .open = lpfc_mgmt_open, - .release = lpfc_mgmt_release, + .owner = THIS_MODULE, }; static struct miscdevice lpfc_mgmt_dev = { -- cgit v1.2.3 From f0689f05371c6a7a33b4a4b85ecb6d1c79e2a371 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 15 Apr 2013 10:28:20 -0400 Subject: mptctl: don't wank with fasync in ->release() Signed-off-by: Al Viro --- drivers/message/fusion/mptctl.c | 8 -------- 1 file changed, 8 deletions(-) (limited to 'drivers') diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c index b383b6961e5..dcc8385adeb 100644 --- a/drivers/message/fusion/mptctl.c +++ b/drivers/message/fusion/mptctl.c @@ -596,13 +596,6 @@ mptctl_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply) return 1; } -static int -mptctl_release(struct inode *inode, struct file *filep) -{ - fasync_helper(-1, filep, 0, &async_queue); - return 0; -} - static int mptctl_fasync(int fd, struct file *filep, int mode) { @@ -2822,7 +2815,6 @@ static const struct file_operations mptctl_fops = { .llseek = no_llseek, .fasync = mptctl_fasync, .unlocked_ioctl = mptctl_ioctl, - .release = mptctl_release, #ifdef CONFIG_COMPAT .compat_ioctl = compat_mpctl_ioctl, #endif -- cgit v1.2.3 From e84cb41eb008fb42b357c55329c345f9a0375237 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 15 Apr 2013 10:29:11 -0400 Subject: pmcraid: don't wank with fasync in ->release() Signed-off-by: Al Viro --- drivers/scsi/pmcraid.c | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c index b46f5e90683..8e1b7377506 100644 --- a/drivers/scsi/pmcraid.c +++ b/drivers/scsi/pmcraid.c @@ -3598,19 +3598,6 @@ static int pmcraid_chr_open(struct inode *inode, struct file *filep) return 0; } -/** - * pmcraid_release - char node "release" entry point - */ -static int pmcraid_chr_release(struct inode *inode, struct file *filep) -{ - struct pmcraid_instance *pinstance = filep->private_data; - - filep->private_data = NULL; - fasync_helper(-1, filep, 0, &pinstance->aen_queue); - - return 0; -} - /** * pmcraid_fasync - Async notifier registration from applications * @@ -4167,7 +4154,6 @@ static long pmcraid_chr_ioctl( static const struct file_operations pmcraid_fops = { .owner = THIS_MODULE, .open = pmcraid_chr_open, - .release = pmcraid_chr_release, .fasync = pmcraid_chr_fasync, .unlocked_ioctl = pmcraid_chr_ioctl, #ifdef CONFIG_COMPAT -- cgit v1.2.3 From 96625a74c7968fdd02476d01579ac826799e4f08 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 15 Apr 2013 13:30:33 -0400 Subject: mpt2sas: don't wank with fasync on ->release() Signed-off-by: Al Viro --- drivers/scsi/mpt2sas/mpt2sas_ctl.c | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/mpt2sas/mpt2sas_ctl.c b/drivers/scsi/mpt2sas/mpt2sas_ctl.c index 08685c4cf23..eec052c2670 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_ctl.c +++ b/drivers/scsi/mpt2sas/mpt2sas_ctl.c @@ -504,19 +504,6 @@ _ctl_fasync(int fd, struct file *filep, int mode) return fasync_helper(fd, filep, mode, &async_queue); } -/** - * _ctl_release - - * @inode - - * @filep - - * - * Called when application releases the fasyn callback handler. - */ -static int -_ctl_release(struct inode *inode, struct file *filep) -{ - return fasync_helper(-1, filep, 0, &async_queue); -} - /** * _ctl_poll - * @file - @@ -3027,7 +3014,6 @@ struct device_attribute *mpt2sas_dev_attrs[] = { static const struct file_operations ctl_fops = { .owner = THIS_MODULE, .unlocked_ioctl = _ctl_ioctl, - .release = _ctl_release, .poll = _ctl_poll, .fasync = _ctl_fasync, #ifdef CONFIG_COMPAT -- cgit v1.2.3 From 70ab27ddb7ccb8d42a4e79730be5bcd7939851b6 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 15 Apr 2013 13:31:14 -0400 Subject: mpt3sas: don't wank with fasync on ->release() Signed-off-by: Al Viro --- drivers/scsi/mpt3sas/mpt3sas_ctl.c | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c index 054d5231c97..0b402b6f2d2 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c +++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c @@ -502,19 +502,6 @@ _ctl_fasync(int fd, struct file *filep, int mode) return fasync_helper(fd, filep, mode, &async_queue); } -/** - * _ctl_release - - * @inode - - * @filep - - * - * Called when application releases the fasyn callback handler. - */ -static int -_ctl_release(struct inode *inode, struct file *filep) -{ - return fasync_helper(-1, filep, 0, &async_queue); -} - /** * _ctl_poll - * @file - @@ -3233,7 +3220,6 @@ struct device_attribute *mpt3sas_dev_attrs[] = { static const struct file_operations ctl_fops = { .owner = THIS_MODULE, .unlocked_ioctl = _ctl_ioctl, - .release = _ctl_release, .poll = _ctl_poll, .fasync = _ctl_fasync, #ifdef CONFIG_COMPAT -- cgit v1.2.3 From 25643165c3e35cae633afe8926d49c4e558e63d2 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 15 Apr 2013 13:34:22 -0400 Subject: lis3lv02d: don't wank with fasync() on ->release() Signed-off-by: Al Viro --- drivers/misc/lis3lv02d/lis3lv02d.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers') diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c index 4a87e5c0a32..4cd4a3d2a76 100644 --- a/drivers/misc/lis3lv02d/lis3lv02d.c +++ b/drivers/misc/lis3lv02d/lis3lv02d.c @@ -593,7 +593,6 @@ static int lis3lv02d_misc_release(struct inode *inode, struct file *file) struct lis3lv02d *lis3 = container_of(file->private_data, struct lis3lv02d, miscdev); - fasync_helper(-1, file, 0, &lis3->async_queue); clear_bit(0, &lis3->misc_opened); /* release the device */ if (lis3->pm_dev) pm_runtime_put(lis3->pm_dev); -- cgit v1.2.3 From 7caf2184f264f70f76d88444e4199945041a2aca Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 15 Apr 2013 13:56:11 -0400 Subject: dvb_net: don't mess with ->f_op in ->release() Signed-off-by: Al Viro --- drivers/media/dvb-core/dvb_net.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb-core/dvb_net.c b/drivers/media/dvb-core/dvb_net.c index 44225b186f6..59ba60659a3 100644 --- a/drivers/media/dvb-core/dvb_net.c +++ b/drivers/media/dvb-core/dvb_net.c @@ -1479,11 +1479,8 @@ static int dvb_net_close(struct inode *inode, struct file *file) dvb_generic_release(inode, file); - if(dvbdev->users == 1 && dvbnet->exit == 1) { - fops_put(file->f_op); - file->f_op = NULL; + if(dvbdev->users == 1 && dvbnet->exit == 1) wake_up(&dvbdev->wait_queue); - } return 0; } -- cgit v1.2.3 From 03feee373f05d5c500dd6198015de83005df902c Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 15 Apr 2013 13:58:21 -0400 Subject: dvb_frontend: don't mess with ->f_op in ->release() Signed-off-by: Al Viro --- drivers/media/dvb-core/dvb_frontend.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c index 6e50a758156..73fc7fe0075 100644 --- a/drivers/media/dvb-core/dvb_frontend.c +++ b/drivers/media/dvb-core/dvb_frontend.c @@ -2492,11 +2492,8 @@ static int dvb_frontend_release(struct inode *inode, struct file *file) if (dvbdev->users == -1) { wake_up(&fepriv->wait_queue); - if (fepriv->exit != DVB_FE_NO_EXIT) { - fops_put(file->f_op); - file->f_op = NULL; + if (fepriv->exit != DVB_FE_NO_EXIT) wake_up(&dvbdev->wait_queue); - } if (fe->ops.ts_bus_ctrl) fe->ops.ts_bus_ctrl(fe, 0); } -- cgit v1.2.3 From c08c464d6f4136d9e48ffa23c0bcd93442343b2a Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 15 Apr 2013 16:31:13 -0400 Subject: mISDN: fix the races with timers going off just as they are deleted timer callback in timerdev.c both accesses struct mISDNtimer it's called for *and* moves it to dev->expired. We need del_timer_sync(), or we risk kfree() freeing it right under dev_expire_timer() *and* dev->expired getting corrupted. Signed-off-by: Al Viro --- drivers/isdn/mISDN/timerdev.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/isdn/mISDN/timerdev.c b/drivers/isdn/mISDN/timerdev.c index 1094667d8f3..5a1a5cadc76 100644 --- a/drivers/isdn/mISDN/timerdev.c +++ b/drivers/isdn/mISDN/timerdev.c @@ -72,14 +72,24 @@ static int mISDN_close(struct inode *ino, struct file *filep) { struct mISDNtimerdev *dev = filep->private_data; + struct list_head *list = &dev->pending; struct mISDNtimer *timer, *next; if (*debug & DEBUG_TIMER) printk(KERN_DEBUG "%s(%p,%p)\n", __func__, ino, filep); - list_for_each_entry_safe(timer, next, &dev->pending, list) { - del_timer(&timer->tl); + + spin_lock_irq(&dev->lock); + while (!list_empty(list)) { + timer = list_first_entry(list, struct mISDNtimer, list); + spin_unlock_irq(&dev->lock); + del_timer_sync(&timer->tl); + spin_lock_irq(&dev->lock); + /* it might have been moved to ->expired */ + list_del(&timer->list); kfree(timer); } + spin_unlock_irq(&dev->lock); + list_for_each_entry_safe(timer, next, &dev->expired, list) { kfree(timer); } -- cgit v1.2.3 From 1b1089561ce596a4032ba1039365090304db1cfd Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 15 Apr 2013 16:55:41 -0400 Subject: mISDN: fix races between misdn_del_timer() and timer callback mark the victim with negative ->id if misdn_del_timer() finds it on the list, have timer callback *not* move ones so marked to dev->expired Signed-off-by: Al Viro --- drivers/isdn/mISDN/timerdev.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'drivers') diff --git a/drivers/isdn/mISDN/timerdev.c b/drivers/isdn/mISDN/timerdev.c index 5a1a5cadc76..c00546f830d 100644 --- a/drivers/isdn/mISDN/timerdev.c +++ b/drivers/isdn/mISDN/timerdev.c @@ -163,7 +163,8 @@ dev_expire_timer(unsigned long data) u_long flags; spin_lock_irqsave(&timer->dev->lock, flags); - list_move_tail(&timer->list, &timer->dev->expired); + if (timer->id >= 0) + list_move_tail(&timer->list, &timer->dev->expired); spin_unlock_irqrestore(&timer->dev->lock, flags); wake_up_interruptible(&timer->dev->wait); } @@ -203,26 +204,21 @@ misdn_add_timer(struct mISDNtimerdev *dev, int timeout) static int misdn_del_timer(struct mISDNtimerdev *dev, int id) { - u_long flags; struct mISDNtimer *timer; - int ret = 0; - spin_lock_irqsave(&dev->lock, flags); + spin_lock_irq(&dev->lock); list_for_each_entry(timer, &dev->pending, list) { if (timer->id == id) { list_del_init(&timer->list); - /* RED-PEN AK: race -- timer can be still running on - * other CPU. Needs reference count I think - */ - del_timer(&timer->tl); - ret = timer->id; + timer->id = -1; + spin_unlock_irq(&dev->lock); + del_timer_sync(&timer->tl); kfree(timer); - goto unlock; + return id; } } -unlock: - spin_unlock_irqrestore(&dev->lock, flags); - return ret; + spin_unlock_irq(&dev->lock); + return 0; } static long -- cgit v1.2.3 From 1678ec00a632f8b9204e28e5c506128881171604 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 15 Apr 2013 17:04:04 -0400 Subject: mISDN: fix misdn_add_timer()/misdn_del_timer() race do add_timer() *before* unlocking dev->lock, or unpleasant things can happen if misdn_del_timer() on another CPU finds the sucker, calls del_timer_sync() (which does nothing, since we hadn't started the timer yet) and frees it, just as we get around to add_timer()... Signed-off-by: Al Viro --- drivers/isdn/mISDN/timerdev.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'drivers') diff --git a/drivers/isdn/mISDN/timerdev.c b/drivers/isdn/mISDN/timerdev.c index c00546f830d..ddb8adcd5fb 100644 --- a/drivers/isdn/mISDN/timerdev.c +++ b/drivers/isdn/mISDN/timerdev.c @@ -173,7 +173,6 @@ static int misdn_add_timer(struct mISDNtimerdev *dev, int timeout) { int id; - u_long flags; struct mISDNtimer *timer; if (!timeout) { @@ -184,19 +183,16 @@ misdn_add_timer(struct mISDNtimerdev *dev, int timeout) timer = kzalloc(sizeof(struct mISDNtimer), GFP_KERNEL); if (!timer) return -ENOMEM; - spin_lock_irqsave(&dev->lock, flags); - timer->id = dev->next_id++; + timer->dev = dev; + setup_timer(&timer->tl, dev_expire_timer, (long)timer); + spin_lock_irq(&dev->lock); + id = timer->id = dev->next_id++; if (dev->next_id < 0) dev->next_id = 1; list_add_tail(&timer->list, &dev->pending); - spin_unlock_irqrestore(&dev->lock, flags); - timer->dev = dev; - timer->tl.data = (long)timer; - timer->tl.function = dev_expire_timer; - init_timer(&timer->tl); timer->tl.expires = jiffies + ((HZ * (u_long)timeout) / 1000); add_timer(&timer->tl); - id = timer->id; + spin_unlock_irq(&dev->lock); } return id; } -- cgit v1.2.3 From ebb06be16bc9a1e66a010ca50c75c5128bafb4b1 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 15 Apr 2013 17:18:17 -0400 Subject: mISDN: fix mISDN_read()/mISDN_read() race Signed-off-by: Al Viro --- drivers/isdn/mISDN/timerdev.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'drivers') diff --git a/drivers/isdn/mISDN/timerdev.c b/drivers/isdn/mISDN/timerdev.c index ddb8adcd5fb..da2aa376a3a 100644 --- a/drivers/isdn/mISDN/timerdev.c +++ b/drivers/isdn/mISDN/timerdev.c @@ -102,36 +102,41 @@ static ssize_t mISDN_read(struct file *filep, char __user *buf, size_t count, loff_t *off) { struct mISDNtimerdev *dev = filep->private_data; + struct list_head *list = &dev->expired; struct mISDNtimer *timer; - u_long flags; int ret = 0; if (*debug & DEBUG_TIMER) printk(KERN_DEBUG "%s(%p, %p, %d, %p)\n", __func__, filep, buf, (int)count, off); - if (list_empty(&dev->expired) && (dev->work == 0)) { + if (count < sizeof(int)) + return -ENOSPC; + + spin_lock_irq(&dev->lock); + while (list_empty(list) && (dev->work == 0)) { + spin_unlock_irq(&dev->lock); if (filep->f_flags & O_NONBLOCK) return -EAGAIN; wait_event_interruptible(dev->wait, (dev->work || - !list_empty(&dev->expired))); + !list_empty(list))); if (signal_pending(current)) return -ERESTARTSYS; + spin_lock_irq(&dev->lock); } - if (count < sizeof(int)) - return -ENOSPC; if (dev->work) dev->work = 0; - if (!list_empty(&dev->expired)) { - spin_lock_irqsave(&dev->lock, flags); - timer = (struct mISDNtimer *)dev->expired.next; + if (!list_empty(list)) { + timer = list_first_entry(list, struct mISDNtimer, list); list_del(&timer->list); - spin_unlock_irqrestore(&dev->lock, flags); + spin_unlock_irq(&dev->lock); if (put_user(timer->id, (int __user *)buf)) ret = -EFAULT; else ret = sizeof(int); kfree(timer); + } else { + spin_unlock_irq(&dev->lock); } return ret; } -- cgit v1.2.3 From 89b107adce32a52920b36787b60c8f24c986c526 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 15 Apr 2013 17:27:11 -0400 Subject: mISDN: grabbing/dropping reference to THIS_MODULE in open/release is racy ... when you have no ->owner set. Signed-off-by: Al Viro --- drivers/isdn/mISDN/timerdev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/isdn/mISDN/timerdev.c b/drivers/isdn/mISDN/timerdev.c index da2aa376a3a..9438d7ec330 100644 --- a/drivers/isdn/mISDN/timerdev.c +++ b/drivers/isdn/mISDN/timerdev.c @@ -64,7 +64,6 @@ mISDN_open(struct inode *ino, struct file *filep) dev->work = 0; init_waitqueue_head(&dev->wait); filep->private_data = dev; - __module_get(THIS_MODULE); return nonseekable_open(ino, filep); } @@ -94,7 +93,6 @@ mISDN_close(struct inode *ino, struct file *filep) kfree(timer); } kfree(dev); - module_put(THIS_MODULE); return 0; } @@ -269,6 +267,7 @@ mISDN_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) } static const struct file_operations mISDN_fops = { + .owner = THIS_MODULE, .read = mISDN_read, .poll = mISDN_poll, .unlocked_ioctl = mISDN_ioctl, -- cgit v1.2.3 From 0541f9d08acfcf68b589e93cc26c3117d0b594c4 Mon Sep 17 00:00:00 2001 From: David Howells Date: Mon, 8 Apr 2013 15:17:33 +0100 Subject: rtl8192u: Don't use create_proc_read_entry() Don't use create_proc_read_entry() as that is deprecated, but rather use proc_create_data() and seq_file instead. Whilst we're at it, reduce the number of show functions where we can share them. Note: proc_get_stats_ap() should probably use seq_file iteration rather than list_for_each_entry(). Further note: There appears to be a lot of locking missing in this file to defend against concurrent access by the driver doing normal operations. Notably, ieee->network_list traversal and RWCAM/RCAMO command/response access. Further, do any of the registers read have side effects upon reading? Signed-off-by: David Howells cc: Jerry Chuang cc: Mauro Carvalho Chehab cc: Greg Kroah-Hartman cc: linux-wireless@vger.kernel.org cc: devel@driverdev.osuosl.org Signed-off-by: Al Viro --- drivers/staging/rtl8192u/r8192U_core.c | 214 ++++++++++++++------------------- 1 file changed, 91 insertions(+), 123 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index f7de2f6d49a..433c3df95de 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 #include +#include +#include // 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); - - int len = 0; - int i,n; + struct net_device *dev = m->private; + int i,n, max = 0xff; - 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,77 @@ 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 = PDE(inode)->parent->data; + 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, +}; + +/* + * Table of proc files we need to create. + */ +struct rtl8192_proc_file { + char name[12]; + int (*show)(struct seq_file *, void *); +}; + +static const struct rtl8192_proc_file rtl8192_proc_files[] = { + { "stats-rx", &proc_get_stats_rx }, + { "stats-tx", &proc_get_stats_tx }, + { "stats-ap", &proc_get_stats_ap }, + { "registers", &proc_get_registers }, + { "" } +}; void rtl8192_proc_init_one(struct net_device *dev) { - struct proc_dir_entry *e; + const struct rtl8192_proc_file *f; 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); - } - - 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); + if (rtl8192_proc) { + 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; + } + priv->dir_dev->data = dev; + + for (f = rtl8192_proc_files; f->name[0]; f++) { + if (!proc_create_data(f->name, S_IFREG | S_IRUGO, + priv->dir_dev, + 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("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); - } +void rtl8192_proc_remove_one(struct net_device *dev) +{ + struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); - 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); + if (priv->dir_dev) { + remove_proc_subtree(dev->name, rtl8192_proc); + priv->dir_dev = NULL; } } + /**************************************************************************** -----------------------------MISC STUFF------------------------- *****************************************************************************/ -- cgit v1.2.3 From 5ba02e355d00ada1ef30515a8ba2aac750d3c256 Mon Sep 17 00:00:00 2001 From: David Howells Date: Mon, 8 Apr 2013 15:48:07 +0100 Subject: rtl8187se: Don't use create_proc_read_entry() Don't use create_proc_read_entry() as that is deprecated, but rather use proc_create_data() and seq_file instead. Whilst we're at it, reduce the number of show functions where we can share them. Question: Do any of the registers read by proc_get_registers() have side effects upon reading? If so, locking will be required. Signed-off-by: David Howells cc: Greg Kroah-Hartman cc: Maxim Mikityanskiy cc: YAMANE Toshiaki cc: Bill Pemberton cc: Andrea Merello cc: linux-wireless@vger.kernel.org cc: devel@driverdev.osuosl.org Signed-off-by: Al Viro --- drivers/staging/rtl8187se/r8180_core.c | 134 ++++++++++++++++----------------- 1 file changed, 63 insertions(+), 71 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/rtl8187se/r8180_core.c b/drivers/staging/rtl8187se/r8180_core.c index d10d75e8a33..448da77e2cd 100644 --- a/drivers/staging/rtl8187se/r8180_core.c +++ b/drivers/staging/rtl8187se/r8180_core.c @@ -36,6 +36,8 @@ #include #include #include +#include +#include #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) @@ -318,9 +298,43 @@ void rtl8180_proc_remove_one(struct net_device *dev) } } +/* + * seq_file wrappers for procfile show routines. + */ +static int rtl8180_proc_open(struct inode *inode, struct file *file) +{ + struct net_device *dev = PDE(inode)->parent->data; + int (*show)(struct seq_file *, void *) = PDE_DATA(inode); + + return single_open(file, show, dev); +} + +static const struct file_operations rtl8180_proc_fops = { + .open = rtl8180_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + +/* + * Table of proc files we need to create. + */ +struct rtl8180_proc_file { + char name[12]; + int (*show)(struct seq_file *, void *); +}; + +static const struct rtl8180_proc_file rtl8180_proc_files[] = { + { "stats-hw", &proc_get_stats_hw }, + { "stats-rx", &proc_get_stats_rx }, + { "stats-tx", &proc_get_stats_tx }, + { "registers", &proc_get_registers }, + { "" } +}; + void rtl8180_proc_init_one(struct net_device *dev) { - struct proc_dir_entry *e; + const struct rtl8180_proc_file *f; struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); priv->dir_dev = rtl8180_proc; @@ -329,38 +343,16 @@ void rtl8180_proc_init_one(struct net_device *dev) dev->name); return; } + priv->dir_dev->data = 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); - } - - e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_stats_rx, dev); - if (!e) { - DMESGE("Unable to initialize " - "/proc/net/r8180/%s/stats-rx\n", - dev->name); - } - - - e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_stats_tx, dev); - if (!e) { - DMESGE("Unable to initialize " - "/proc/net/r8180/%s/stats-tx\n", - dev->name); - } - - e = create_proc_read_entry("registers", S_IFREG | S_IRUGO, - priv->dir_dev, proc_get_registers, dev); - if (!e) { - DMESGE("Unable to initialize " - "/proc/net/r8180/%s/registers\n", - dev->name); + for (f = rtl8180_proc_files; f->name[0]; f++) { + if (!proc_create_data(f->name, S_IFREG | S_IRUGO, + priv->dir_dev, + &rtl8180_proc_fops, f->show)) { + DMESGE("Unable to initialize /proc/net/r8180/%s\n", + f->name); + return; + } } } -- cgit v1.2.3 From 207e39099a90a7385900aca4868ed686f25300cb Mon Sep 17 00:00:00 2001 From: David Howells Date: Mon, 8 Apr 2013 16:06:20 +0100 Subject: ft1000: Don't use create_proc_read_entry() Don't use create_proc_read_entry() as that is deprecated, but rather use proc_create_data() and seq_file instead. Signed-off-by: David Howells cc: Marek Belisko cc: Greg Kroah-Hartman cc: Ondrej Zary cc: devel@driverdev.osuosl.org Signed-off-by: Al Viro --- drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c | 130 ++++++++++----------- drivers/staging/ft1000/ft1000-usb/ft1000_proc.c | 129 ++++++++++---------- 2 files changed, 123 insertions(+), 136 deletions(-) (limited to 'drivers') 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 #include #include +#include #include #include #include @@ -29,70 +30,55 @@ #define FT1000_PROC "ft1000" #define MAX_FILE_LEN 255 -#define PUTM_TO_PAGE(len, page, args...) \ - len += snprintf(page+len, PAGE_SIZE - len, args) - -#define PUTX_TO_PAGE(len, page, message, size, var) \ - len += snprintf(page+len, PAGE_SIZE - len, message); \ +#define seq_putx(m, message, size, var) \ + seq_printf(m, message); \ for(i = 0; i < (size - 1); i++) { \ - len += snprintf(page+len, PAGE_SIZE - len, "%02x:", var[i]); \ + seq_printf(m, "%02x:", var[i]); \ } \ - len += snprintf(page+len, PAGE_SIZE - len, "%02x\n", var[i]) + seq_printf(m, "%02x\n", var[i]) -#define PUTD_TO_PAGE(len, page, message, size, var) \ - len += snprintf(page+len, PAGE_SIZE - len, message); \ +#define seq_putd(m, message, size, var) \ + seq_printf(m, message); \ for(i = 0; i < (size - 1); i++) { \ - len += snprintf(page+len, PAGE_SIZE - len, "%d.", var[i]); \ + seq_printf(m, "%d.", var[i]); \ } \ - len += snprintf(page+len, PAGE_SIZE - len, "%d\n", var[i]) + seq_printf(m, "%d\n", var[i]) -static int ft1000ReadProc(char *page, char **start, off_t off, - int count, int *eof, void *data) +static int ft1000ReadProc(struct seq_file *m, void *v) { - struct net_device *dev; - int len; - int i; - struct ft1000_info *info; - char *status[] = { + static const char *status[] = { "Idle (Disconnect)", "Searching", "Active (Connected)", "Waiting for L2", "Sleep", "No Coverage", "", "" }; - char *signal[] = { "", "*", "**", "***", "****" }; + static const char *signal[] = { "", "*", "**", "***", "****" }; + + struct net_device *dev = m->private; + struct ft1000_info *info = netdev_priv(dev); + int i; int strength; int quality; struct timeval tv; time_t delta; - dev = (struct net_device *)data; - info = netdev_priv(dev); - - if (off > 0) { - *eof = 1; - return 0; - } - - /* Wrap-around */ - if (info->AsicID == ELECTRABUZZ_ID) { if (info->ProgConStat != 0xFF) { info->LedStat = ft1000_read_dpram(dev, FT1000_DSP_LED); info->ConStat = - ft1000_read_dpram(dev, - FT1000_DSP_CON_STATE); + ft1000_read_dpram(dev, FT1000_DSP_CON_STATE); } else { info->ConStat = 0xf; } } else { if (info->ProgConStat != 0xFF) { info->LedStat = - ntohs(ft1000_read_dpram_mag_16 - (dev, FT1000_MAG_DSP_LED, - FT1000_MAG_DSP_LED_INDX)); + ntohs(ft1000_read_dpram_mag_16( + dev, FT1000_MAG_DSP_LED, + FT1000_MAG_DSP_LED_INDX)); info->ConStat = - ntohs(ft1000_read_dpram_mag_16 - (dev, FT1000_MAG_DSP_CON_STATE, - FT1000_MAG_DSP_CON_STATE_INDX)); + ntohs(ft1000_read_dpram_mag_16( + dev, FT1000_MAG_DSP_CON_STATE, + FT1000_MAG_DSP_CON_STATE_INDX)); } else { info->ConStat = 0xf; } @@ -135,36 +121,46 @@ static int ft1000ReadProc(char *page, char **start, off_t off, } do_gettimeofday(&tv); - delta = (tv.tv_sec - info->ConTm); - len = 0; - PUTM_TO_PAGE(len, page, "Connection Time: %02ld:%02ld:%02ld\n", + delta = tv.tv_sec - info->ConTm; + seq_printf(m, "Connection Time: %02ld:%02ld:%02ld\n", ((delta / 3600) % 24), ((delta / 60) % 60), (delta % 60)); - PUTM_TO_PAGE(len, page, "Connection Time[s]: %ld\n", delta); - PUTM_TO_PAGE(len, page, "Asic ID: %s\n", - (info->AsicID) == + seq_printf(m, "Connection Time[s]: %ld\n", delta); + seq_printf(m, "Asic ID: %s\n", + info->AsicID == ELECTRABUZZ_ID ? "ELECTRABUZZ ASIC" : "MAGNEMITE ASIC"); - PUTX_TO_PAGE(len, page, "SKU: ", SKUSZ, info->Sku); - PUTX_TO_PAGE(len, page, "EUI64: ", EUISZ, info->eui64); - PUTD_TO_PAGE(len, page, "DSP version number: ", DSPVERSZ, info->DspVer); - PUTX_TO_PAGE(len, page, "Hardware Serial Number: ", HWSERNUMSZ, - info->HwSerNum); - PUTX_TO_PAGE(len, page, "Caliberation Version: ", CALVERSZ, - info->RfCalVer); - PUTD_TO_PAGE(len, page, "Caliberation Date: ", CALDATESZ, - info->RfCalDate); - PUTM_TO_PAGE(len, page, "Media State: %s\n", + seq_putx(m, "SKU: ", SKUSZ, info->Sku); + seq_putx(m, "EUI64: ", EUISZ, info->eui64); + seq_putd(m, "DSP version number: ", DSPVERSZ, info->DspVer); + seq_putx(m, "Hardware Serial Number: ", HWSERNUMSZ, info->HwSerNum); + seq_putx(m, "Caliberation Version: ", CALVERSZ, info->RfCalVer); + seq_putd(m, "Caliberation Date: ", CALDATESZ, info->RfCalDate); + seq_printf(m, "Media State: %s\n", (info->mediastate) ? "link" : "no link"); - PUTM_TO_PAGE(len, page, "Connection Status: %s\n", - status[((info->ConStat) & 0x7)]); - PUTM_TO_PAGE(len, page, "RX packets: %ld\n", info->stats.rx_packets); - PUTM_TO_PAGE(len, page, "TX packets: %ld\n", info->stats.tx_packets); - PUTM_TO_PAGE(len, page, "RX bytes: %ld\n", info->stats.rx_bytes); - PUTM_TO_PAGE(len, page, "TX bytes: %ld\n", info->stats.tx_bytes); - PUTM_TO_PAGE(len, page, "Signal Strength: %s\n", signal[strength]); - PUTM_TO_PAGE(len, page, "Signal Quality: %s\n", signal[quality]); - return len; + seq_printf(m, "Connection Status: %s\n", status[info->ConStat & 0x7]); + seq_printf(m, "RX packets: %ld\n", info->stats.rx_packets); + seq_printf(m, "TX packets: %ld\n", info->stats.tx_packets); + seq_printf(m, "RX bytes: %ld\n", info->stats.rx_bytes); + seq_printf(m, "TX bytes: %ld\n", info->stats.tx_bytes); + seq_printf(m, "Signal Strength: %s\n", signal[strength]); + seq_printf(m, "Signal Quality: %s\n", signal[quality]); + return 0; +} + +/* + * seq_file wrappers for procfile show routines. + */ +static int ft1000_proc_open(struct inode *inode, struct file *file) +{ + return single_open(file, ft1000ReadProc, PDE_DATA(inode)); } +static const struct file_operations ft1000_proc_fops = { + .open = ft1000_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + static int ft1000NotifyProc(struct notifier_block *this, unsigned long event, void *ptr) { @@ -176,8 +172,8 @@ static int ft1000NotifyProc(struct notifier_block *this, unsigned long event, switch (event) { case NETDEV_CHANGENAME: remove_proc_entry(info->netdevname, info->ft1000_proc_dir); - create_proc_read_entry(dev->name, 0644, info->ft1000_proc_dir, - ft1000ReadProc, dev); + proc_create_data(dev->name, 0644, info->ft1000_proc_dir, + &ft1000_proc_fops, dev); snprintf(info->netdevname, IFNAMSIZ, "%s", dev->name); break; } @@ -195,8 +191,10 @@ void ft1000InitProc(struct net_device *dev) info = netdev_priv(dev); info->ft1000_proc_dir = proc_mkdir(FT1000_PROC, init_net.proc_net); - create_proc_read_entry(dev->name, 0644, info->ft1000_proc_dir, - ft1000ReadProc, dev); + + proc_create_data(dev->name, 0644, info->ft1000_proc_dir, + &ft1000_proc_fops, dev); + snprintf(info->netdevname, IFNAMSIZ, "%s", dev->name); register_netdevice_notifier(&ft1000_netdev_notifier); } diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_proc.c b/drivers/staging/ft1000/ft1000-usb/ft1000_proc.c index 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 #include #include +#include #include @@ -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; } -- cgit v1.2.3 From 1f817b86d5e6aceed48dac7db6ce9a82a4375e3f Mon Sep 17 00:00:00 2001 From: David Howells Date: Mon, 8 Apr 2013 16:39:33 +0100 Subject: comedi: Don't use create_proc_read_entry() Don't use create_proc_read_entry() as that is deprecated, but rather use proc_create_data() and seq_file instead. Signed-off-by: David Howells cc: David Schleef cc: Ian Abbott cc: Mori Hess cc: Greg Kroah-Hartman cc: H Hartley Sweeten cc: devel@driverdev.osuosl.org Signed-off-by: Al Viro --- drivers/staging/comedi/proc.c | 52 ++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 21 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/comedi/proc.c b/drivers/staging/comedi/proc.c index f01e0cccac3..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 -#include +#include -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,39 +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; +} + +/* + * seq_file wrappers for procfile show routines. + */ +static int comedi_proc_open(struct inode *inode, struct file *file) +{ + 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, +}; + void comedi_proc_init(void) { - create_proc_read_entry("comedi", S_IFREG | S_IRUGO, NULL, - comedi_read, NULL); + proc_create("comedi", 0644, NULL, &comedi_proc_fops); } void comedi_proc_cleanup(void) -- cgit v1.2.3 From 294a08e4b01a9834c5b41f49bac592006156f454 Mon Sep 17 00:00:00 2001 From: David Howells Date: Mon, 8 Apr 2013 16:50:22 +0100 Subject: csr: Don't use create_proc_read_entry() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don't use create_proc_read_entry() as that is deprecated, but rather use proc_create_data() and seq_file instead. Signed-off-by: David Howells cc: Greg Kroah-Hartman cc: Randy Dunlap cc: Priit Laes cc: devel@driverdev.osuosl.org cc: Mikko Virkkilä cc: Lauri Hintsala cc: Riku Mettälä cc: Veli-Pekka Peltola Signed-off-by: Al Viro --- drivers/staging/csr/csr_wifi_hip_udi.c | 353 ++++++++++----------------- drivers/staging/csr/csr_wifi_hip_unifi_udi.h | 17 +- drivers/staging/csr/io.c | 151 +++++------- 3 files changed, 189 insertions(+), 332 deletions(-) (limited to 'drivers') 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 #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/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 +#include #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 -- cgit v1.2.3 From 766d100d4e412bf4cea59805375790db3d698331 Mon Sep 17 00:00:00 2001 From: David Howells Date: Mon, 8 Apr 2013 22:47:46 +0100 Subject: cxt1e1: Don't use create_proc_read_entry() Don't use create_proc_read_entry() as that is deprecated, but rather use proc_create_data() and seq_file instead. Signed-off-by: David Howells cc: Bob Beers cc: Greg Kroah-Hartman cc: devel@driverdev.osuosl.org Signed-off-by: Al Viro --- drivers/staging/cxt1e1/Makefile | 3 +- drivers/staging/cxt1e1/sbeproc.c | 460 ++++++++++++++------------------------- drivers/staging/cxt1e1/sbeproc.h | 14 +- 3 files changed, 175 insertions(+), 302 deletions(-) (limited to 'drivers') 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 #include #include +#include #include #include #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 "); - break; - case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPTMC_256T3_T1): - len += sprintf (buffer + len, "wanPTMC-256T3 "); - 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 "); + break; + case SBE_BOARD_ID(PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPTMC_256T3_T1): + seq_puts(m, "wanPTMC-256T3 "); + 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: 1st %p lst %p\n", - (char *) &bip->first_iname, (char *) &bip->last_iname); + seq_printf(m, "Interface: 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 = ""; - 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 = ""; + 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_ ***/ -- cgit v1.2.3 From f1cc0444ab2f0e1b254490f497363e3b0c9bcd56 Mon Sep 17 00:00:00 2001 From: David Howells Date: Mon, 8 Apr 2013 23:26:53 +0100 Subject: wlags49_h2: Don't use create_proc_read_entry() Don't use create_proc_read_entry() as that is deprecated, but rather use proc_create_data() and seq_file instead. Signed-off-by: David Howells cc: Henk de Groot cc: Bartlomiej Zolnierkiewicz cc: Greg Kroah-Hartman cc: linux-wireless@vger.kernel.org Signed-off-by: Al Viro --- drivers/staging/wlags49_h2/wl_main.c | 320 ++++++++++++++++++----------------- 1 file changed, 161 insertions(+), 159 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/wlags49_h2/wl_main.c b/drivers/staging/wlags49_h2/wl_main.c index 174c41af484..c4264e8c877 100644 --- a/drivers/staging/wlags49_h2/wl_main.c +++ b/drivers/staging/wlags49_h2/wl_main.c @@ -73,6 +73,7 @@ #include #include +#include #include #include // #include @@ -144,10 +145,24 @@ 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); +/* + * 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 */ /******************************************************************************* @@ -907,7 +922,7 @@ 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); #endif /* SCULL_USE_PROC */ @@ -2095,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 ); @@ -3529,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 @@ -3759,16 +3760,17 @@ 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 int write_int(struct file *file, const char *buffer, unsigned long count, void *data) -- cgit v1.2.3 From 96c7a22ebd2c919ed8fb93bb7c02b60aac099768 Mon Sep 17 00:00:00 2001 From: David Howells Date: Wed, 10 Apr 2013 11:51:21 +0100 Subject: goku_udc: Don't use create_proc_read_entry() Don't use create_proc_read_entry() as that is deprecated, but rather use proc_create_data() and seq_file instead. Signed-off-by: David Howells cc: Felipe Balbi cc: Greg Kroah-Hartman cc: linux-usb@vger.kernel.org Signed-off-by: Al Viro --- drivers/usb/gadget/goku_udc.c | 89 +++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 50 deletions(-) (limited to 'drivers') diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c index 85742d4c67d..57a547049df 100644 --- a/drivers/usb/gadget/goku_udc.c +++ b/drivers/usb/gadget/goku_udc.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -1008,7 +1009,7 @@ static const struct usb_gadget_ops goku_ops = { /*-------------------------------------------------------------------------*/ -static inline char *dmastr(void) +static inline const char *dmastr(void) { if (use_dma == 0) return "(dma disabled)"; @@ -1025,13 +1026,10 @@ static const char proc_node_name [] = "driver/udc"; #define FOURBITS "%s%s%s%s" #define EIGHTBITS FOURBITS FOURBITS -static void -dump_intmask(const char *label, u32 mask, char **next, unsigned *size) +static void dump_intmask(struct seq_file *m, const char *label, u32 mask) { - int t; - /* int_status is the same format ... */ - t = scnprintf(*next, *size, + seq_printf(m, "%s %05X =" FOURBITS EIGHTBITS EIGHTBITS "\n", label, mask, (mask & INT_PWRDETECT) ? " power" : "", @@ -1058,33 +1056,23 @@ dump_intmask(const char *label, u32 mask, char **next, unsigned *size) (mask & INT_ENDPOINT0) ? " ep0" : "", (mask & INT_USBRESET) ? " reset" : "", (mask & INT_SUSPEND) ? " suspend" : ""); - *size -= t; - *next += t; } -static int -udc_proc_read(char *buffer, char **start, off_t off, int count, - int *eof, void *_dev) +static int udc_proc_read(struct seq_file *m, void *v) { - char *buf = buffer; - struct goku_udc *dev = _dev; + struct goku_udc *dev = m->private; struct goku_udc_regs __iomem *regs = dev->regs; - char *next = buf; - unsigned size = count; unsigned long flags; - int i, t, is_usb_connected; + int i, is_usb_connected; u32 tmp; - if (off != 0) - return 0; - local_irq_save(flags); /* basic device status */ tmp = readl(®s->power_detect); is_usb_connected = tmp & PW_DETECT; - t = scnprintf(next, size, + seq_printf(m, "%s - %s\n" "%s version: %s %s\n" "Gadget driver: %s\n" @@ -1096,7 +1084,7 @@ udc_proc_read(char *buffer, char **start, off_t off, int count, is_usb_connected ? ((tmp & PW_PULLUP) ? "full speed" : "powered") : "disconnected", - ({char *state; + ({const char *state; switch(dev->ep0state){ case EP0_DISCONNECT: state = "ep0_disconnect"; break; case EP0_IDLE: state = "ep0_idle"; break; @@ -1108,27 +1096,24 @@ udc_proc_read(char *buffer, char **start, off_t off, int count, default: state = "ep0_?"; break; } state; }) ); - size -= t; - next += t; - dump_intmask("int_status", readl(®s->int_status), &next, &size); - dump_intmask("int_enable", readl(®s->int_enable), &next, &size); + dump_intmask(m, "int_status", readl(®s->int_status)); + dump_intmask(m, "int_enable", readl(®s->int_enable)); if (!is_usb_connected || !dev->driver || (tmp & PW_PULLUP) == 0) goto done; /* registers for (active) device and ep0 */ - t = scnprintf(next, size, "\nirqs %lu\ndataset %02x " + if (seq_printf(m, "\nirqs %lu\ndataset %02x " "single.bcs %02x.%02x state %x addr %u\n", dev->irqs, readl(®s->DataSet), readl(®s->EPxSingle), readl(®s->EPxBCS), readl(®s->UsbState), - readl(®s->address)); - size -= t; - next += t; + readl(®s->address)) < 0) + goto done; tmp = readl(®s->dma_master); - t = scnprintf(next, size, + if (seq_printf(m, "dma %03X =" EIGHTBITS "%s %s\n", tmp, (tmp & MST_EOPB_DIS) ? " eopb-" : "", (tmp & MST_EOPB_ENA) ? " eopb+" : "", @@ -1143,9 +1128,8 @@ udc_proc_read(char *buffer, char **start, off_t off, int count, (tmp & MST_WR_ENA) ? " OUT" : "", (tmp & MST_CONNECTION) ? "ep1in/ep2out" - : "ep1out/ep2in"); - size -= t; - next += t; + : "ep1out/ep2in") < 0) + goto done; /* dump endpoint queues */ for (i = 0; i < 4; i++) { @@ -1156,7 +1140,7 @@ udc_proc_read(char *buffer, char **start, off_t off, int count, continue; tmp = readl(ep->reg_status); - t = scnprintf(next, size, + if (seq_printf(m, "%s %s max %u %s, irqs %lu, " "status %02x (%s) " FOURBITS "\n", ep->ep.name, @@ -1189,18 +1173,12 @@ udc_proc_read(char *buffer, char **start, off_t off, int count, (tmp & EPxSTATUS_SUSPEND) ? " suspend" : "", (tmp & EPxSTATUS_FIFO_DISABLE) ? " disable" : "", (tmp & EPxSTATUS_STAGE_ERROR) ? " ep0stat" : "" - ); - if (t <= 0 || t > size) + ) < 0) goto done; - size -= t; - next += t; if (list_empty(&ep->queue)) { - t = scnprintf(next, size, "\t(nothing queued)\n"); - if (t <= 0 || t > size) + if (seq_puts(m, "\t(nothing queued)\n") < 0) goto done; - size -= t; - next += t; continue; } list_for_each_entry(req, &ep->queue, queue) { @@ -1214,23 +1192,34 @@ udc_proc_read(char *buffer, char **start, off_t off, int count, } else tmp = req->req.actual; - t = scnprintf(next, size, + if (seq_printf(m, "\treq %p len %u/%u buf %p\n", &req->req, tmp, req->req.length, - req->req.buf); - if (t <= 0 || t > size) + req->req.buf) < 0) goto done; - size -= t; - next += t; } } done: local_irq_restore(flags); - *eof = 1; - return count - size; + return 0; +} + +/* + * seq_file wrappers for procfile show routines. + */ +static int udc_proc_open(struct inode *inode, struct file *file) +{ + return single_open(file, udc_proc_read, PDE_DATA(file_inode(file))); } +static const struct file_operations udc_proc_fops = { + .open = udc_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + #endif /* CONFIG_USB_GADGET_DEBUG_FILES */ /*-------------------------------------------------------------------------*/ @@ -1807,7 +1796,7 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id) #ifdef CONFIG_USB_GADGET_DEBUG_FILES - create_proc_read_entry(proc_node_name, 0, NULL, udc_proc_read, dev); + proc_create_data(proc_node_name, 0, NULL, &udc_proc_fops, dev); #endif retval = device_register(&dev->gadget.dev); -- cgit v1.2.3 From 77cd02c151cb6b7d81aad4802ee8b98a033863d6 Mon Sep 17 00:00:00 2001 From: David Howells Date: Wed, 10 Apr 2013 13:23:50 +0100 Subject: fsl_udc: Don't use create_proc_read_entry() Don't use create_proc_read_entry() as that is deprecated, but rather use proc_create_data() and seq_file instead. Signed-off-by: David Howells cc: Li Yang cc: Felipe Balbi cc: Greg Kroah-Hartman cc: linux-usb@vger.kernel.org cc: linuxppc-dev@lists.ozlabs.org Signed-off-by: Al Viro --- drivers/usb/gadget/fsl_udc_core.c | 124 +++++++++++++------------------------- 1 file changed, 43 insertions(+), 81 deletions(-) (limited to 'drivers') diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c index 04d5fef1440..ede70ffe1ab 100644 --- a/drivers/usb/gadget/fsl_udc_core.c +++ b/drivers/usb/gadget/fsl_udc_core.c @@ -2038,47 +2038,37 @@ static int fsl_udc_stop(struct usb_gadget *g, static const char proc_filename[] = "driver/fsl_usb2_udc"; -static int fsl_proc_read(char *page, char **start, off_t off, int count, - int *eof, void *_dev) +static int fsl_proc_read(struct seq_file *m, void *v) { - char *buf = page; - char *next = buf; - unsigned size = count; unsigned long flags; - int t, i; + int i; u32 tmp_reg; struct fsl_ep *ep = NULL; struct fsl_req *req; struct fsl_udc *udc = udc_controller; - if (off != 0) - return 0; spin_lock_irqsave(&udc->lock, flags); /* ------basic driver information ---- */ - t = scnprintf(next, size, + seq_printf(m, DRIVER_DESC "\n" "%s version: %s\n" "Gadget driver: %s\n\n", driver_name, DRIVER_VERSION, udc->driver ? udc->driver->driver.name : "(none)"); - size -= t; - next += t; /* ------ DR Registers ----- */ tmp_reg = fsl_readl(&dr_regs->usbcmd); - t = scnprintf(next, size, + seq_printf(m, "USBCMD reg:\n" "SetupTW: %d\n" "Run/Stop: %s\n\n", (tmp_reg & USB_CMD_SUTW) ? 1 : 0, (tmp_reg & USB_CMD_RUN_STOP) ? "Run" : "Stop"); - size -= t; - next += t; tmp_reg = fsl_readl(&dr_regs->usbsts); - t = scnprintf(next, size, + seq_printf(m, "USB Status Reg:\n" "Dr Suspend: %d Reset Received: %d System Error: %s " "USB Error Interrupt: %s\n\n", @@ -2086,11 +2076,9 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count, (tmp_reg & USB_STS_RESET) ? 1 : 0, (tmp_reg & USB_STS_SYS_ERR) ? "Err" : "Normal", (tmp_reg & USB_STS_ERR) ? "Err detected" : "No err"); - size -= t; - next += t; tmp_reg = fsl_readl(&dr_regs->usbintr); - t = scnprintf(next, size, + seq_printf(m, "USB Interrupt Enable Reg:\n" "Sleep Enable: %d SOF Received Enable: %d " "Reset Enable: %d\n" @@ -2104,33 +2092,25 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count, (tmp_reg & USB_INTR_PTC_DETECT_EN) ? 1 : 0, (tmp_reg & USB_INTR_ERR_INT_EN) ? 1 : 0, (tmp_reg & USB_INTR_INT_EN) ? 1 : 0); - size -= t; - next += t; tmp_reg = fsl_readl(&dr_regs->frindex); - t = scnprintf(next, size, + seq_printf(m, "USB Frame Index Reg: Frame Number is 0x%x\n\n", (tmp_reg & USB_FRINDEX_MASKS)); - size -= t; - next += t; tmp_reg = fsl_readl(&dr_regs->deviceaddr); - t = scnprintf(next, size, + seq_printf(m, "USB Device Address Reg: Device Addr is 0x%x\n\n", (tmp_reg & USB_DEVICE_ADDRESS_MASK)); - size -= t; - next += t; tmp_reg = fsl_readl(&dr_regs->endpointlistaddr); - t = scnprintf(next, size, + seq_printf(m, "USB Endpoint List Address Reg: " "Device Addr is 0x%x\n\n", (tmp_reg & USB_EP_LIST_ADDRESS_MASK)); - size -= t; - next += t; tmp_reg = fsl_readl(&dr_regs->portsc1); - t = scnprintf(next, size, + seq_printf(m, "USB Port Status&Control Reg:\n" "Port Transceiver Type : %s Port Speed: %s\n" "PHY Low Power Suspend: %s Port Reset: %s " @@ -2139,7 +2119,7 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count, "Port Enable/Disable Change: %s\n" "Port Enabled/Disabled: %s " "Current Connect Status: %s\n\n", ( { - char *s; + const char *s; switch (tmp_reg & PORTSCX_PTS_FSLS) { case PORTSCX_PTS_UTMI: s = "UTMI"; break; @@ -2165,13 +2145,11 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count, "Not correct", (tmp_reg & PORTSCX_CURRENT_CONNECT_STATUS) ? "Attached" : "Not-Att"); - size -= t; - next += t; tmp_reg = fsl_readl(&dr_regs->usbmode); - t = scnprintf(next, size, + seq_printf(m, "USB Mode Reg: Controller Mode is: %s\n\n", ( { - char *s; + const char *s; switch (tmp_reg & USB_MODE_CTRL_MODE_HOST) { case USB_MODE_CTRL_MODE_IDLE: s = "Idle"; break; @@ -2184,103 +2162,87 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count, } s; } )); - size -= t; - next += t; tmp_reg = fsl_readl(&dr_regs->endptsetupstat); - t = scnprintf(next, size, + seq_printf(m, "Endpoint Setup Status Reg: SETUP on ep 0x%x\n\n", (tmp_reg & EP_SETUP_STATUS_MASK)); - size -= t; - next += t; for (i = 0; i < udc->max_ep / 2; i++) { tmp_reg = fsl_readl(&dr_regs->endptctrl[i]); - t = scnprintf(next, size, "EP Ctrl Reg [0x%x]: = [0x%x]\n", - i, tmp_reg); - size -= t; - next += t; + seq_printf(m, "EP Ctrl Reg [0x%x]: = [0x%x]\n", i, tmp_reg); } tmp_reg = fsl_readl(&dr_regs->endpointprime); - t = scnprintf(next, size, "EP Prime Reg = [0x%x]\n\n", tmp_reg); - size -= t; - next += t; + seq_printf(m, "EP Prime Reg = [0x%x]\n\n", tmp_reg); #ifndef CONFIG_ARCH_MXC if (udc->pdata->have_sysif_regs) { tmp_reg = usb_sys_regs->snoop1; - t = scnprintf(next, size, "Snoop1 Reg : = [0x%x]\n\n", tmp_reg); - size -= t; - next += t; + seq_printf(m, "Snoop1 Reg : = [0x%x]\n\n", tmp_reg); tmp_reg = usb_sys_regs->control; - t = scnprintf(next, size, "General Control Reg : = [0x%x]\n\n", - tmp_reg); - size -= t; - next += t; + seq_printf(m, "General Control Reg : = [0x%x]\n\n", tmp_reg); } #endif /* ------fsl_udc, fsl_ep, fsl_request structure information ----- */ ep = &udc->eps[0]; - t = scnprintf(next, size, "For %s Maxpkt is 0x%x index is 0x%x\n", + seq_printf(m, "For %s Maxpkt is 0x%x index is 0x%x\n", ep->ep.name, ep_maxpacket(ep), ep_index(ep)); - size -= t; - next += t; if (list_empty(&ep->queue)) { - t = scnprintf(next, size, "its req queue is empty\n\n"); - size -= t; - next += t; + seq_puts(m, "its req queue is empty\n\n"); } else { list_for_each_entry(req, &ep->queue, queue) { - t = scnprintf(next, size, + seq_printf(m, "req %p actual 0x%x length 0x%x buf %p\n", &req->req, req->req.actual, req->req.length, req->req.buf); - size -= t; - next += t; } } /* other gadget->eplist ep */ list_for_each_entry(ep, &udc->gadget.ep_list, ep.ep_list) { if (ep->ep.desc) { - t = scnprintf(next, size, + seq_printf(m, "\nFor %s Maxpkt is 0x%x " "index is 0x%x\n", ep->ep.name, ep_maxpacket(ep), ep_index(ep)); - size -= t; - next += t; if (list_empty(&ep->queue)) { - t = scnprintf(next, size, - "its req queue is empty\n\n"); - size -= t; - next += t; + seq_puts(m, "its req queue is empty\n\n"); } else { list_for_each_entry(req, &ep->queue, queue) { - t = scnprintf(next, size, + seq_printf(m, "req %p actual 0x%x length " "0x%x buf %p\n", &req->req, req->req.actual, req->req.length, req->req.buf); - size -= t; - next += t; - } /* end for each_entry of ep req */ - } /* end for else */ - } /* end for if(ep->queue) */ - } /* end (ep->desc) */ + } /* end for each_entry of ep req */ + } /* end for else */ + } /* end for if(ep->queue) */ + } /* end (ep->desc) */ spin_unlock_irqrestore(&udc->lock, flags); + return 0; +} - *eof = 1; - return count - size; +/* + * seq_file wrappers for procfile show routines. + */ +static int fsl_proc_open(struct inode *inode, struct file *file) +{ + return single_open(file, fsl_proc_read, NULL); } -#define create_proc_file() create_proc_read_entry(proc_filename, \ - 0, NULL, fsl_proc_read, NULL) +static const struct file_operations fsl_proc_fops = { + .open = fsl_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; +#define create_proc_file() proc_create(proc_filename, 0, NULL, &fsl_proc_fops) #define remove_proc_file() remove_proc_entry(proc_filename, NULL) #else /* !CONFIG_USB_GADGET_DEBUG_FILES */ -- cgit v1.2.3 From 11db656ad462c9aa7aff7e3817214578cfc307b3 Mon Sep 17 00:00:00 2001 From: David Howells Date: Wed, 10 Apr 2013 15:05:38 +0100 Subject: nubus: Don't use create_proc_read_entry() Don't use create_proc_read_entry() as that is deprecated, but rather use proc_create_data() and seq_file instead. Signed-off-by: David Howells cc: linux-m68k@lists.linux-m68k.org Signed-off-by: Al Viro --- drivers/nubus/nubus.c | 55 ---------------------------------- drivers/nubus/proc.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 76 insertions(+), 60 deletions(-) (limited to 'drivers') diff --git a/drivers/nubus/nubus.c b/drivers/nubus/nubus.c index 44d01afafe9..43926cd25ae 100644 --- a/drivers/nubus/nubus.c +++ b/drivers/nubus/nubus.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include @@ -954,56 +953,6 @@ void __init nubus_probe_slot(int slot) } } -#if defined(CONFIG_PROC_FS) - -/* /proc/nubus stuff */ - -static int sprint_nubus_board(struct nubus_board* board, char* ptr, int len) -{ - if(len < 100) - return -1; - - sprintf(ptr, "Slot %X: %s\n", - board->slot, board->name); - - return strlen(ptr); -} - -static int nubus_read_proc(char *page, char **start, off_t off, - int count, int *eof, void *data) -{ - int nprinted, len, begin = 0; - int size = PAGE_SIZE; - struct nubus_board* board; - - len = sprintf(page, "Nubus devices found:\n"); - /* Walk the list of NuBus boards */ - for (board = nubus_boards; board != NULL; board = board->next) - { - nprinted = sprint_nubus_board(board, page + len, size - len); - if (nprinted < 0) - break; - len += nprinted; - if (len+begin < off) { - begin += len; - len = 0; - } - if (len+begin >= off+count) - break; - } - if (len+begin < off) - *eof = 1; - off -= begin; - *start = page + off; - len -= off; - if (len>count) - len = count; - if (len<0) - len = 0; - return len; -} -#endif - void __init nubus_scan_bus(void) { int slot; @@ -1041,11 +990,7 @@ static int __init nubus_init(void) nubus_devices = NULL; nubus_boards = NULL; nubus_scan_bus(); - -#ifdef CONFIG_PROC_FS - create_proc_read_entry("nubus", 0, NULL, nubus_read_proc, NULL); nubus_proc_init(); -#endif return 0; } diff --git a/drivers/nubus/proc.c b/drivers/nubus/proc.c index bb1446bb280..b8286ed6591 100644 --- a/drivers/nubus/proc.c +++ b/drivers/nubus/proc.c @@ -52,7 +52,6 @@ static int nubus_devices_proc_open(struct inode *inode, struct file *file) } static const struct file_operations nubus_devices_proc_fops = { - .owner = THIS_MODULE, .open = nubus_devices_proc_open, .read = seq_read, .llseek = seq_lseek, @@ -61,6 +60,10 @@ static const struct file_operations nubus_devices_proc_fops = { static struct proc_dir_entry *proc_bus_nubus_dir; +static const struct file_operations nubus_proc_subdir_fops = { +#warning Need to set some I/O handlers here +}; + static void nubus_proc_subdir(struct nubus_dev* dev, struct proc_dir_entry* parent, struct nubus_dir* dir) @@ -73,10 +76,10 @@ static void nubus_proc_subdir(struct nubus_dev* dev, struct proc_dir_entry* e; sprintf(name, "%x", ent.type); -#warning Need to set some I/O handlers here - e = create_proc_read_entry(name, S_IFREG | S_IRUGO | S_IWUSR, - parent, NULL, NULL); - if (!e) return; + e = proc_create(name, S_IFREG | S_IRUGO | S_IWUSR, parent, + &nubus_proc_subdir_fops); + if (!e) + return; } } @@ -159,6 +162,73 @@ int nubus_proc_detach_device(struct nubus_dev *dev) } EXPORT_SYMBOL(nubus_proc_detach_device); +/* + * /proc/nubus stuff + */ +static int nubus_proc_show(struct seq_file *m, void *v) +{ + const struct nubus_board *board = v; + + /* Display header on line 1 */ + if (v == SEQ_START_TOKEN) + seq_puts(m, "Nubus devices found:\n"); + else + seq_printf(m, "Slot %X: %s\n", board->slot, board->name); + return 0; +} + +static void *nubus_proc_start(struct seq_file *m, loff_t *_pos) +{ + struct nubus_board *board; + unsigned pos; + + if (*_pos > LONG_MAX) + return NULL; + pos = *_pos; + if (pos == 0) + return SEQ_START_TOKEN; + for (board = nubus_boards; board; board = board->next) + if (--pos == 0) + break; + return board; +} + +static void *nubus_proc_next(struct seq_file *p, void *v, loff_t *_pos) +{ + /* Walk the list of NuBus boards */ + struct nubus_board *board = v; + + ++*_pos; + if (v == SEQ_START_TOKEN) + board = nubus_boards; + else if (board) + board = board->next; + return board; +} + +static void nubus_proc_stop(struct seq_file *p, void *v) +{ +} + +static const struct seq_operations nubus_proc_seqops = { + .start = nubus_proc_start, + .next = nubus_proc_next, + .stop = nubus_proc_stop, + .show = nubus_proc_show, +}; + +static int nubus_proc_open(struct inode *inode, struct file *file) +{ + return seq_open(file, &nubus_proc_seqops); +} + +static const struct file_operations nubus_proc_fops = { + .open = nubus_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + void __init proc_bus_nubus_add_devices(void) { struct nubus_dev *dev; @@ -169,6 +239,7 @@ void __init proc_bus_nubus_add_devices(void) void __init nubus_proc_init(void) { + proc_create("nubus", 0, NULL, &nubus_proc_fops); if (!MACH_IS_MAC) return; proc_bus_nubus_dir = proc_mkdir("bus/nubus", NULL); -- cgit v1.2.3 From c18bd9a1ff477bd010d7607a8e575da24de0b08b Mon Sep 17 00:00:00 2001 From: David Howells Date: Wed, 10 Apr 2013 15:52:18 +0100 Subject: hp_sdc_rtc: Don't use create_proc_read_entry() Don't use create_proc_read_entry() as that is deprecated, but rather use proc_create_data() and seq_file instead. Signed-off-by: David Howells cc: Brian S. Julin cc: Helge Deller cc: linux-m68k@lists.linux-m68k.org Signed-off-by: Al Viro --- drivers/input/misc/hp_sdc_rtc.c | 58 ++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 32 deletions(-) (limited to 'drivers') diff --git a/drivers/input/misc/hp_sdc_rtc.c b/drivers/input/misc/hp_sdc_rtc.c index 2e3334b8f82..770479df865 100644 --- a/drivers/input/misc/hp_sdc_rtc.c +++ b/drivers/input/misc/hp_sdc_rtc.c @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -74,9 +75,6 @@ static unsigned int hp_sdc_rtc_poll(struct file *file, poll_table *wait); static int hp_sdc_rtc_open(struct inode *inode, struct file *file); static int hp_sdc_rtc_fasync (int fd, struct file *filp, int on); -static int hp_sdc_rtc_read_proc(char *page, char **start, off_t off, - int count, int *eof, void *data); - static void hp_sdc_rtc_isr (int irq, void *dev_id, uint8_t status, uint8_t data) { @@ -427,22 +425,19 @@ static int hp_sdc_rtc_fasync (int fd, struct file *filp, int on) return fasync_helper (fd, filp, on, &hp_sdc_rtc_async_queue); } -static int hp_sdc_rtc_proc_output (char *buf) +static int hp_sdc_rtc_proc_show(struct seq_file *m, void *v) { #define YN(bit) ("no") #define NY(bit) ("yes") - char *p; struct rtc_time tm; struct timeval tv; memset(&tm, 0, sizeof(struct rtc_time)); - p = buf; - if (hp_sdc_rtc_read_bbrtc(&tm)) { - p += sprintf(p, "BBRTC\t\t: READ FAILED!\n"); + seq_puts(m, "BBRTC\t\t: READ FAILED!\n"); } else { - p += sprintf(p, + seq_printf(m, "rtc_time\t: %02d:%02d:%02d\n" "rtc_date\t: %04d-%02d-%02d\n" "rtc_epoch\t: %04lu\n", @@ -452,41 +447,41 @@ static int hp_sdc_rtc_proc_output (char *buf) } if (hp_sdc_rtc_read_rt(&tv)) { - p += sprintf(p, "i8042 rtc\t: READ FAILED!\n"); + seq_puts(m, "i8042 rtc\t: READ FAILED!\n"); } else { - p += sprintf(p, "i8042 rtc\t: %ld.%02d seconds\n", + seq_printf(m, "i8042 rtc\t: %ld.%02d seconds\n", tv.tv_sec, (int)tv.tv_usec/1000); } if (hp_sdc_rtc_read_fhs(&tv)) { - p += sprintf(p, "handshake\t: READ FAILED!\n"); + seq_puts(m, "handshake\t: READ FAILED!\n"); } else { - p += sprintf(p, "handshake\t: %ld.%02d seconds\n", + seq_printf(m, "handshake\t: %ld.%02d seconds\n", tv.tv_sec, (int)tv.tv_usec/1000); } if (hp_sdc_rtc_read_mt(&tv)) { - p += sprintf(p, "alarm\t\t: READ FAILED!\n"); + seq_puts(m, "alarm\t\t: READ FAILED!\n"); } else { - p += sprintf(p, "alarm\t\t: %ld.%02d seconds\n", + seq_printf(m, "alarm\t\t: %ld.%02d seconds\n", tv.tv_sec, (int)tv.tv_usec/1000); } if (hp_sdc_rtc_read_dt(&tv)) { - p += sprintf(p, "delay\t\t: READ FAILED!\n"); + seq_puts(m, "delay\t\t: READ FAILED!\n"); } else { - p += sprintf(p, "delay\t\t: %ld.%02d seconds\n", + seq_printf(m, "delay\t\t: %ld.%02d seconds\n", tv.tv_sec, (int)tv.tv_usec/1000); } if (hp_sdc_rtc_read_ct(&tv)) { - p += sprintf(p, "periodic\t: READ FAILED!\n"); + seq_puts(m, "periodic\t: READ FAILED!\n"); } else { - p += sprintf(p, "periodic\t: %ld.%02d seconds\n", + seq_printf(m, "periodic\t: %ld.%02d seconds\n", tv.tv_sec, (int)tv.tv_usec/1000); } - p += sprintf(p, + seq_printf(m, "DST_enable\t: %s\n" "BCD\t\t: %s\n" "24hr\t\t: %s\n" @@ -506,23 +501,23 @@ static int hp_sdc_rtc_proc_output (char *buf) 1UL, 1 ? "okay" : "dead"); - return p - buf; + return 0; #undef YN #undef NY } -static int hp_sdc_rtc_read_proc(char *page, char **start, off_t off, - int count, int *eof, void *data) +static int hp_sdc_rtc_proc_open(struct inode *inode, struct file *file) { - int len = hp_sdc_rtc_proc_output (page); - if (len <= off+count) *eof = 1; - *start = page + off; - len -= off; - if (len>count) len = count; - if (len<0) len = 0; - return len; + return single_open(file, hp_sdc_rtc_proc_show, NULL); } +static const struct file_operations hp_sdc_rtc_proc_fops = { + .open = hp_sdc_rtc_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + static int hp_sdc_rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { @@ -715,8 +710,7 @@ static int __init hp_sdc_rtc_init(void) if (misc_register(&hp_sdc_rtc_dev) != 0) printk(KERN_INFO "Could not register misc. dev for i8042 rtc\n"); - create_proc_read_entry ("driver/rtc", 0, NULL, - hp_sdc_rtc_read_proc, NULL); + proc_create("driver/rtc", 0, NULL, &hp_sdc_rtc_proc_fops); printk(KERN_INFO "HP i8042 SDC + MSM-58321 RTC support loaded " "(RTC v " RTC_VERSION ")\n"); -- cgit v1.2.3 From a6d935a5b1d945c7bec2afe21dcf6f22b653acef Mon Sep 17 00:00:00 2001 From: David Howells Date: Wed, 10 Apr 2013 16:11:53 +0100 Subject: genrtc: Don't use create_proc_read_entry() Don't use create_proc_read_entry() as that is deprecated, but rather use proc_create_data() and seq_file instead. Signed-off-by: David Howells cc: Arnd Bergmann cc: Greg Kroah-Hartman Signed-off-by: Al Viro --- drivers/char/genrtc.c | 48 +++++++++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 25 deletions(-) (limited to 'drivers') diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c index 21cb980f115..bc9b84d56ee 100644 --- a/drivers/char/genrtc.c +++ b/drivers/char/genrtc.c @@ -52,6 +52,7 @@ #include #include #include +#include #include #include @@ -386,18 +387,15 @@ static int gen_rtc_release(struct inode *inode, struct file *file) * Info exported via "/proc/driver/rtc". */ -static int gen_rtc_proc_output(char *buf) +static int gen_rtc_proc_show(struct seq_file *m, void *v) { - char *p; struct rtc_time tm; unsigned int flags; struct rtc_pll_info pll; - p = buf; - flags = get_rtc_time(&tm); - p += sprintf(p, + seq_printf(m, "rtc_time\t: %02d:%02d:%02d\n" "rtc_date\t: %04d-%02d-%02d\n" "rtc_epoch\t: %04u\n", @@ -406,23 +404,23 @@ static int gen_rtc_proc_output(char *buf) tm.tm_hour = tm.tm_min = tm.tm_sec = 0; - p += sprintf(p, "alarm\t\t: "); + seq_puts(m, "alarm\t\t: "); if (tm.tm_hour <= 24) - p += sprintf(p, "%02d:", tm.tm_hour); + seq_printf(m, "%02d:", tm.tm_hour); else - p += sprintf(p, "**:"); + seq_puts(m, "**:"); if (tm.tm_min <= 59) - p += sprintf(p, "%02d:", tm.tm_min); + seq_printf(m, "%02d:", tm.tm_min); else - p += sprintf(p, "**:"); + seq_puts(m, "**:"); if (tm.tm_sec <= 59) - p += sprintf(p, "%02d\n", tm.tm_sec); + seq_printf(m, "%02d\n", tm.tm_sec); else - p += sprintf(p, "**\n"); + seq_puts(m, "**\n"); - p += sprintf(p, + seq_printf(m, "DST_enable\t: %s\n" "BCD\t\t: %s\n" "24hr\t\t: %s\n" @@ -442,7 +440,7 @@ static int gen_rtc_proc_output(char *buf) 0L /* freq */, (flags & RTC_BATT_BAD) ? "bad" : "okay"); if (!get_rtc_pll(&pll)) - p += sprintf(p, + seq_printf(m, "PLL adjustment\t: %d\n" "PLL max +ve adjustment\t: %d\n" "PLL max -ve adjustment\t: %d\n" @@ -455,26 +453,26 @@ static int gen_rtc_proc_output(char *buf) pll.pll_posmult, pll.pll_negmult, pll.pll_clock); - return p - buf; + return 0; } -static int gen_rtc_read_proc(char *page, char **start, off_t off, - int count, int *eof, void *data) +static int gen_rtc_proc_open(struct inode *inode, struct file *file) { - int len = gen_rtc_proc_output (page); - if (len <= off+count) *eof = 1; - *start = page + off; - len -= off; - if (len>count) len = count; - if (len<0) len = 0; - return len; + return single_open(file, gen_rtc_proc_show, NULL); } +static const struct file_operations gen_rtc_proc_fops = { + .open = gen_rtc_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + static int __init gen_rtc_proc_init(void) { struct proc_dir_entry *r; - r = create_proc_read_entry("driver/rtc", 0, NULL, gen_rtc_read_proc, NULL); + r = proc_create("driver/rtc", 0, NULL, &gen_rtc_proc_fops); if (!r) return -ENOMEM; return 0; -- cgit v1.2.3 From 788416bcee1a68aa0e8ed3f49c800b6c3df1c0a4 Mon Sep 17 00:00:00 2001 From: David Howells Date: Wed, 10 Apr 2013 16:21:08 +0100 Subject: efirtc: Don't use create_proc_read_entry() Don't use create_proc_read_entry() as that is deprecated, but rather use proc_create_data() and seq_file instead. Signed-off-by: David Howells cc: Arnd Bergmann cc: Greg Kroah-Hartman Signed-off-by: Al Viro --- drivers/char/efirtc.c | 83 +++++++++++++++++++++++++-------------------------- 1 file changed, 40 insertions(+), 43 deletions(-) (limited to 'drivers') diff --git a/drivers/char/efirtc.c b/drivers/char/efirtc.c index a082d00b0f1..ea54a6e3f5a 100644 --- a/drivers/char/efirtc.c +++ b/drivers/char/efirtc.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -296,12 +297,10 @@ static struct miscdevice efi_rtc_dev= { /* * We export RAW EFI information to /proc/driver/efirtc */ -static int -efi_rtc_get_status(char *buf) +static int efi_rtc_proc_show(struct seq_file *m, void *v) { efi_time_t eft, alm; efi_time_cap_t cap; - char *p = buf; efi_bool_t enabled, pending; unsigned long flags; @@ -316,64 +315,63 @@ efi_rtc_get_status(char *buf) spin_unlock_irqrestore(&efi_rtc_lock,flags); - p += sprintf(p, - "Time : %u:%u:%u.%09u\n" - "Date : %u-%u-%u\n" - "Daylight : %u\n", - eft.hour, eft.minute, eft.second, eft.nanosecond, - eft.year, eft.month, eft.day, - eft.daylight); + seq_printf(m, + "Time : %u:%u:%u.%09u\n" + "Date : %u-%u-%u\n" + "Daylight : %u\n", + eft.hour, eft.minute, eft.second, eft.nanosecond, + eft.year, eft.month, eft.day, + eft.daylight); if (eft.timezone == EFI_UNSPECIFIED_TIMEZONE) - p += sprintf(p, "Timezone : unspecified\n"); + seq_puts(m, "Timezone : unspecified\n"); else /* XXX fixme: convert to string? */ - p += sprintf(p, "Timezone : %u\n", eft.timezone); + seq_printf(m, "Timezone : %u\n", eft.timezone); - p += sprintf(p, - "Alarm Time : %u:%u:%u.%09u\n" - "Alarm Date : %u-%u-%u\n" - "Alarm Daylight : %u\n" - "Enabled : %s\n" - "Pending : %s\n", - alm.hour, alm.minute, alm.second, alm.nanosecond, - alm.year, alm.month, alm.day, - alm.daylight, - enabled == 1 ? "yes" : "no", - pending == 1 ? "yes" : "no"); + seq_printf(m, + "Alarm Time : %u:%u:%u.%09u\n" + "Alarm Date : %u-%u-%u\n" + "Alarm Daylight : %u\n" + "Enabled : %s\n" + "Pending : %s\n", + alm.hour, alm.minute, alm.second, alm.nanosecond, + alm.year, alm.month, alm.day, + alm.daylight, + enabled == 1 ? "yes" : "no", + pending == 1 ? "yes" : "no"); if (eft.timezone == EFI_UNSPECIFIED_TIMEZONE) - p += sprintf(p, "Timezone : unspecified\n"); + seq_puts(m, "Timezone : unspecified\n"); else /* XXX fixme: convert to string? */ - p += sprintf(p, "Timezone : %u\n", alm.timezone); + seq_printf(m, "Timezone : %u\n", alm.timezone); /* * now prints the capabilities */ - p += sprintf(p, - "Resolution : %u\n" - "Accuracy : %u\n" - "SetstoZero : %u\n", - cap.resolution, cap.accuracy, cap.sets_to_zero); + seq_printf(m, + "Resolution : %u\n" + "Accuracy : %u\n" + "SetstoZero : %u\n", + cap.resolution, cap.accuracy, cap.sets_to_zero); - return p - buf; + return 0; } -static int -efi_rtc_read_proc(char *page, char **start, off_t off, - int count, int *eof, void *data) +static int efi_rtc_proc_open(struct inode *inode, struct file *file) { - int len = efi_rtc_get_status(page); - if (len <= off+count) *eof = 1; - *start = page + off; - len -= off; - if (len>count) len = count; - if (len<0) len = 0; - return len; + return single_open(file, efi_rtc_proc_show, NULL); } +static const struct file_operations efi_rtc_proc_fops = { + .open = efi_rtc_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + static int __init efi_rtc_init(void) { @@ -389,8 +387,7 @@ efi_rtc_init(void) return ret; } - dir = create_proc_read_entry ("driver/efirtc", 0, NULL, - efi_rtc_read_proc, NULL); + dir = proc_create("driver/efirtc", 0, NULL, &efi_rtc_proc_fops); if (dir == NULL) { printk(KERN_ERR "efirtc: can't create /proc/driver/efirtc.\n"); misc_deregister(&efi_rtc_dev); -- cgit v1.2.3 From 9fb8ca5c2029b41edc7dbbe478f376ead14944ec Mon Sep 17 00:00:00 2001 From: David Howells Date: Wed, 10 Apr 2013 16:48:39 +0100 Subject: ds1620: Don't use create_proc_read_entry() Don't use create_proc_read_entry() as that is deprecated, but rather use proc_create_data() and seq_file instead. Signed-off-by: David Howells cc: Arnd Bergmann cc: Greg Kroah-Hartman Signed-off-by: Al Viro --- drivers/char/ds1620.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'drivers') diff --git a/drivers/char/ds1620.c b/drivers/char/ds1620.c index b599fae698d..544b4ce617f 100644 --- a/drivers/char/ds1620.c +++ b/drivers/char/ds1620.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -329,9 +330,7 @@ ds1620_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg) } #ifdef THERM_USE_PROC -static int -proc_therm_ds1620_read(char *buf, char **start, off_t offset, - int len, int *eof, void *unused) +static int ds1620_proc_therm_show(struct seq_file *m, void *v) { struct therm th; int temp; @@ -339,17 +338,25 @@ proc_therm_ds1620_read(char *buf, char **start, off_t offset, ds1620_read_state(&th); temp = cvt_9_to_int(ds1620_in(THERM_READ_TEMP, 9)); - len = sprintf(buf, "Thermostat: HI %i.%i, LOW %i.%i; " - "temperature: %i.%i C, fan %s\n", - th.hi >> 1, th.hi & 1 ? 5 : 0, - th.lo >> 1, th.lo & 1 ? 5 : 0, - temp >> 1, temp & 1 ? 5 : 0, - fan_state[netwinder_get_fan()]); + seq_printf(m, "Thermostat: HI %i.%i, LOW %i.%i; temperature: %i.%i C, fan %s\n", + th.hi >> 1, th.hi & 1 ? 5 : 0, + th.lo >> 1, th.lo & 1 ? 5 : 0, + temp >> 1, temp & 1 ? 5 : 0, + fan_state[netwinder_get_fan()]); + return 0; +} - return len; +static int ds1620_proc_therm_open(struct inode *inode, struct file *file) +{ + return single_open(file, ds1620_proc_therm_show, NULL); } -static struct proc_dir_entry *proc_therm_ds1620; +static const struct file_operations ds1620_proc_therm_fops = { + .open = ds1620_proc_therm_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; #endif static const struct file_operations ds1620_fops = { @@ -397,9 +404,7 @@ static int __init ds1620_init(void) return ret; #ifdef THERM_USE_PROC - proc_therm_ds1620 = create_proc_read_entry("therm", 0, NULL, - proc_therm_ds1620_read, NULL); - if (!proc_therm_ds1620) + if (!proc_create("therm", 0, NULL, &ds1620_proc_therm_fops)) printk(KERN_ERR "therm: unable to register /proc/therm\n"); #endif -- cgit v1.2.3 From 4c4df9b91bf6ffd4bb01abe4cfba1f8f145878a0 Mon Sep 17 00:00:00 2001 From: David Howells Date: Wed, 10 Apr 2013 16:50:58 +0100 Subject: atmel: Don't use create_proc_read_entry() Don't use create_proc_read_entry() as that is deprecated, but rather use proc_create_data() and seq_file instead. Signed-off-by: David Howells cc: Simon Kelley cc: John W. Linville cc: linux-wireless@vger.kernel.org cc: netdev@vger.kernel.org Signed-off-by: Al Viro --- drivers/net/wireless/atmel.c | 69 ++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 38 deletions(-) (limited to 'drivers') diff --git a/drivers/net/wireless/atmel.c b/drivers/net/wireless/atmel.c index 4374079dfc2..23a3498f14d 100644 --- a/drivers/net/wireless/atmel.c +++ b/drivers/net/wireless/atmel.c @@ -63,6 +63,7 @@ #include #include #include +#include #include #include #include @@ -1409,30 +1410,28 @@ static int atmel_validate_channel(struct atmel_private *priv, int channel) return 0; } -static int atmel_proc_output (char *buf, struct atmel_private *priv) +static int atmel_proc_show(struct seq_file *m, void *v) { + struct atmel_private *priv = m->private; int i; - char *p = buf; char *s, *r, *c; - p += sprintf(p, "Driver version:\t\t%d.%d\n", - DRIVER_MAJOR, DRIVER_MINOR); + seq_printf(m, "Driver version:\t\t%d.%d\n", DRIVER_MAJOR, DRIVER_MINOR); if (priv->station_state != STATION_STATE_DOWN) { - p += sprintf(p, "Firmware version:\t%d.%d build %d\n" - "Firmware location:\t", - priv->host_info.major_version, - priv->host_info.minor_version, - priv->host_info.build_version); + seq_printf(m, + "Firmware version:\t%d.%d build %d\n" + "Firmware location:\t", + priv->host_info.major_version, + priv->host_info.minor_version, + priv->host_info.build_version); if (priv->card_type != CARD_TYPE_EEPROM) - p += sprintf(p, "on card\n"); + seq_puts(m, "on card\n"); else if (priv->firmware) - p += sprintf(p, "%s loaded by host\n", - priv->firmware_id); + seq_printf(m, "%s loaded by host\n", priv->firmware_id); else - p += sprintf(p, "%s loaded by hotplug\n", - priv->firmware_id); + seq_printf(m, "%s loaded by hotplug\n", priv->firmware_id); switch (priv->card_type) { case CARD_TYPE_PARALLEL_FLASH: @@ -1453,12 +1452,12 @@ static int atmel_proc_output (char *buf, struct atmel_private *priv) if (priv->reg_domain == channel_table[i].reg_domain) r = channel_table[i].name; - p += sprintf(p, "MAC memory type:\t%s\n", c); - p += sprintf(p, "Regulatory domain:\t%s\n", r); - p += sprintf(p, "Host CRC checking:\t%s\n", - priv->do_rx_crc ? "On" : "Off"); - p += sprintf(p, "WPA-capable firmware:\t%s\n", - priv->use_wpa ? "Yes" : "No"); + seq_printf(m, "MAC memory type:\t%s\n", c); + seq_printf(m, "Regulatory domain:\t%s\n", r); + seq_printf(m, "Host CRC checking:\t%s\n", + priv->do_rx_crc ? "On" : "Off"); + seq_printf(m, "WPA-capable firmware:\t%s\n", + priv->use_wpa ? "Yes" : "No"); } switch (priv->station_state) { @@ -1490,26 +1489,22 @@ static int atmel_proc_output (char *buf, struct atmel_private *priv) s = ""; } - p += sprintf(p, "Current state:\t\t%s\n", s); - return p - buf; + seq_printf(m, "Current state:\t\t%s\n", s); + return 0; } -static int atmel_read_proc(char *page, char **start, off_t off, - int count, int *eof, void *data) +static int atmel_proc_open(struct inode *inode, struct file *file) { - struct atmel_private *priv = data; - int len = atmel_proc_output (page, priv); - if (len <= off+count) - *eof = 1; - *start = page + off; - len -= off; - if (len > count) - len = count; - if (len < 0) - len = 0; - return len; + return single_open(file, atmel_proc_show, PDE_DATA(inode)); } +static const struct file_operations atmel_proc_fops = { + .open = atmel_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + static const struct net_device_ops atmel_netdev_ops = { .ndo_open = atmel_open, .ndo_stop = atmel_close, @@ -1525,7 +1520,6 @@ struct net_device *init_atmel_card(unsigned short irq, unsigned long port, struct device *sys_dev, int (*card_present)(void *), void *card) { - struct proc_dir_entry *ent; struct net_device *dev; struct atmel_private *priv; int rc; @@ -1630,8 +1624,7 @@ struct net_device *init_atmel_card(unsigned short irq, unsigned long port, netif_carrier_off(dev); - ent = create_proc_read_entry ("driver/atmel", 0, NULL, atmel_read_proc, priv); - if (!ent) + if (!proc_create_data("driver/atmel", 0, NULL, &atmel_proc_fops, priv)); printk(KERN_WARNING "atmel: unable to create /proc entry.\n"); printk(KERN_INFO "%s: Atmel at76c50x. Version %d.%d. MAC %pM\n", -- cgit v1.2.3 From 6bbefe86796c07fb8a6d28114f1e3f770586ba05 Mon Sep 17 00:00:00 2001 From: David Howells Date: Wed, 10 Apr 2013 21:13:23 +0100 Subject: hostap: Don't use create_proc_read_entry() Don't use create_proc_read_entry() as that is deprecated, but rather use proc_create_data() and seq_file instead. Signed-off-by: David Howells Acked-by: Greg Kroah-Hartman cc: Jouni Malinen cc: John W. Linville cc: Johannes Berg cc: linux-wireless@vger.kernel.org cc: netdev@vger.kernel.org cc: devel@driverdev.osuosl.org Signed-off-by: Al Viro --- drivers/net/wireless/hostap/hostap_ap.c | 375 +++++++++------- drivers/net/wireless/hostap/hostap_download.c | 68 ++- drivers/net/wireless/hostap/hostap_hw.c | 38 +- drivers/net/wireless/hostap/hostap_proc.c | 589 ++++++++++++++------------ drivers/net/wireless/hostap/hostap_wlan.h | 3 +- drivers/staging/rtl8192e/rtllib_crypt_ccmp.c | 21 +- drivers/staging/rtl8192e/rtllib_crypt_tkip.c | 44 +- drivers/staging/rtl8192e/rtllib_crypt_wep.c | 6 +- 8 files changed, 662 insertions(+), 482 deletions(-) (limited to 'drivers') diff --git a/drivers/net/wireless/hostap/hostap_ap.c b/drivers/net/wireless/hostap/hostap_ap.c index dd9a18f8dbc..19c45e363aa 100644 --- a/drivers/net/wireless/hostap/hostap_ap.c +++ b/drivers/net/wireless/hostap/hostap_ap.c @@ -17,6 +17,7 @@ */ #include +#include #include #include #include @@ -64,28 +65,32 @@ static void prism2_send_mgmt(struct net_device *dev, #ifndef PRISM2_NO_PROCFS_DEBUG -static int ap_debug_proc_read(char *page, char **start, off_t off, - int count, int *eof, void *data) -{ - char *p = page; - struct ap_data *ap = (struct ap_data *) data; - - if (off != 0) { - *eof = 1; - return 0; - } - - p += sprintf(p, "BridgedUnicastFrames=%u\n", ap->bridged_unicast); - p += sprintf(p, "BridgedMulticastFrames=%u\n", ap->bridged_multicast); - p += sprintf(p, "max_inactivity=%u\n", ap->max_inactivity / HZ); - p += sprintf(p, "bridge_packets=%u\n", ap->bridge_packets); - p += sprintf(p, "nullfunc_ack=%u\n", ap->nullfunc_ack); - p += sprintf(p, "autom_ap_wds=%u\n", ap->autom_ap_wds); - p += sprintf(p, "auth_algs=%u\n", ap->local->auth_algs); - p += sprintf(p, "tx_drop_nonassoc=%u\n", ap->tx_drop_nonassoc); +static int ap_debug_proc_show(struct seq_file *m, void *v) +{ + struct ap_data *ap = m->private; + + seq_printf(m, "BridgedUnicastFrames=%u\n", ap->bridged_unicast); + seq_printf(m, "BridgedMulticastFrames=%u\n", ap->bridged_multicast); + seq_printf(m, "max_inactivity=%u\n", ap->max_inactivity / HZ); + seq_printf(m, "bridge_packets=%u\n", ap->bridge_packets); + seq_printf(m, "nullfunc_ack=%u\n", ap->nullfunc_ack); + seq_printf(m, "autom_ap_wds=%u\n", ap->autom_ap_wds); + seq_printf(m, "auth_algs=%u\n", ap->local->auth_algs); + seq_printf(m, "tx_drop_nonassoc=%u\n", ap->tx_drop_nonassoc); + return 0; +} - return (p - page); +static int ap_debug_proc_open(struct inode *inode, struct file *file) +{ + return single_open(file, ap_debug_proc_show, PDE_DATA(inode)); } + +static const struct file_operations ap_debug_proc_fops = { + .open = ap_debug_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; #endif /* PRISM2_NO_PROCFS_DEBUG */ @@ -325,50 +330,81 @@ void hostap_deauth_all_stas(struct net_device *dev, struct ap_data *ap, } -static int ap_control_proc_read(char *page, char **start, off_t off, - int count, int *eof, void *data) +static int ap_control_proc_show(struct seq_file *m, void *v) { - char *p = page; - struct ap_data *ap = (struct ap_data *) data; + struct ap_data *ap = m->private; char *policy_txt; struct mac_entry *entry; - if (off != 0) { - *eof = 1; + if (v == SEQ_START_TOKEN) { + switch (ap->mac_restrictions.policy) { + case MAC_POLICY_OPEN: + policy_txt = "open"; + break; + case MAC_POLICY_ALLOW: + policy_txt = "allow"; + break; + case MAC_POLICY_DENY: + policy_txt = "deny"; + break; + default: + policy_txt = "unknown"; + break; + } + seq_printf(m, "MAC policy: %s\n", policy_txt); + seq_printf(m, "MAC entries: %u\n", ap->mac_restrictions.entries); + seq_puts(m, "MAC list:\n"); return 0; } - switch (ap->mac_restrictions.policy) { - case MAC_POLICY_OPEN: - policy_txt = "open"; - break; - case MAC_POLICY_ALLOW: - policy_txt = "allow"; - break; - case MAC_POLICY_DENY: - policy_txt = "deny"; - break; - default: - policy_txt = "unknown"; - break; - } - p += sprintf(p, "MAC policy: %s\n", policy_txt); - p += sprintf(p, "MAC entries: %u\n", ap->mac_restrictions.entries); - p += sprintf(p, "MAC list:\n"); + entry = v; + seq_printf(m, "%pM\n", entry->addr); + return 0; +} + +static void *ap_control_proc_start(struct seq_file *m, loff_t *_pos) +{ + struct ap_data *ap = m->private; spin_lock_bh(&ap->mac_restrictions.lock); - list_for_each_entry(entry, &ap->mac_restrictions.mac_list, list) { - if (p - page > PAGE_SIZE - 80) { - p += sprintf(p, "All entries did not fit one page.\n"); - break; - } + return seq_list_start_head(&ap->mac_restrictions.mac_list, *_pos); +} - p += sprintf(p, "%pM\n", entry->addr); - } +static void *ap_control_proc_next(struct seq_file *m, void *v, loff_t *_pos) +{ + struct ap_data *ap = m->private; + return seq_list_next(v, &ap->mac_restrictions.mac_list, _pos); +} + +static void ap_control_proc_stop(struct seq_file *m, void *v) +{ + struct ap_data *ap = m->private; spin_unlock_bh(&ap->mac_restrictions.lock); +} - return (p - page); +static const struct seq_operations ap_control_proc_seqops = { + .start = ap_control_proc_start, + .next = ap_control_proc_next, + .stop = ap_control_proc_stop, + .show = ap_control_proc_show, +}; + +static int ap_control_proc_open(struct inode *inode, struct file *file) +{ + int ret = seq_open(file, &ap_control_proc_seqops); + if (ret == 0) { + struct seq_file *m = file->private_data; + m->private = PDE_DATA(inode); + } + return ret; } +static const struct file_operations ap_control_proc_fops = { + .open = ap_control_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + int ap_control_add_mac(struct mac_restrictions *mac_restrictions, u8 *mac) { @@ -510,61 +546,84 @@ void ap_control_kickall(struct ap_data *ap) #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT -#define PROC_LIMIT (PAGE_SIZE - 80) - -static int prism2_ap_proc_read(char *page, char **start, off_t off, - int count, int *eof, void *data) +static int prism2_ap_proc_show(struct seq_file *m, void *v) { - char *p = page; - struct ap_data *ap = (struct ap_data *) data; - struct sta_info *sta; + struct sta_info *sta = v; int i; - if (off > PROC_LIMIT) { - *eof = 1; + if (v == SEQ_START_TOKEN) { + seq_printf(m, "# BSSID CHAN SIGNAL NOISE RATE SSID FLAGS\n"); return 0; } - p += sprintf(p, "# BSSID CHAN SIGNAL NOISE RATE SSID FLAGS\n"); - spin_lock_bh(&ap->sta_table_lock); - list_for_each_entry(sta, &ap->sta_list, list) { - if (!sta->ap) - continue; + if (!sta->ap) + return 0; - p += sprintf(p, "%pM %d %d %d %d '", - sta->addr, - sta->u.ap.channel, sta->last_rx_signal, - sta->last_rx_silence, sta->last_rx_rate); - for (i = 0; i < sta->u.ap.ssid_len; i++) - p += sprintf(p, ((sta->u.ap.ssid[i] >= 32 && - sta->u.ap.ssid[i] < 127) ? - "%c" : "<%02x>"), - sta->u.ap.ssid[i]); - p += sprintf(p, "'"); - if (sta->capability & WLAN_CAPABILITY_ESS) - p += sprintf(p, " [ESS]"); - if (sta->capability & WLAN_CAPABILITY_IBSS) - p += sprintf(p, " [IBSS]"); - if (sta->capability & WLAN_CAPABILITY_PRIVACY) - p += sprintf(p, " [WEP]"); - p += sprintf(p, "\n"); - - if ((p - page) > PROC_LIMIT) { - printk(KERN_DEBUG "hostap: ap proc did not fit\n"); - break; - } - } - spin_unlock_bh(&ap->sta_table_lock); + seq_printf(m, "%pM %d %d %d %d '", + sta->addr, + sta->u.ap.channel, sta->last_rx_signal, + sta->last_rx_silence, sta->last_rx_rate); - if ((p - page) <= off) { - *eof = 1; - return 0; + for (i = 0; i < sta->u.ap.ssid_len; i++) { + if (sta->u.ap.ssid[i] >= 32 && sta->u.ap.ssid[i] < 127) + seq_putc(m, sta->u.ap.ssid[i]); + else + seq_printf(m, "<%02x>", sta->u.ap.ssid[i]); } - *start = page + off; + seq_putc(m, '\''); + if (sta->capability & WLAN_CAPABILITY_ESS) + seq_puts(m, " [ESS]"); + if (sta->capability & WLAN_CAPABILITY_IBSS) + seq_puts(m, " [IBSS]"); + if (sta->capability & WLAN_CAPABILITY_PRIVACY) + seq_puts(m, " [WEP]"); + seq_putc(m, '\n'); + return 0; +} + +static void *prism2_ap_proc_start(struct seq_file *m, loff_t *_pos) +{ + struct ap_data *ap = m->private; + spin_lock_bh(&ap->sta_table_lock); + return seq_list_start_head(&ap->sta_list, *_pos); +} - return (p - page - off); +static void *prism2_ap_proc_next(struct seq_file *m, void *v, loff_t *_pos) +{ + struct ap_data *ap = m->private; + return seq_list_next(v, &ap->sta_list, _pos); } + +static void prism2_ap_proc_stop(struct seq_file *m, void *v) +{ + struct ap_data *ap = m->private; + spin_unlock_bh(&ap->sta_table_lock); +} + +static const struct seq_operations prism2_ap_proc_seqops = { + .start = prism2_ap_proc_start, + .next = prism2_ap_proc_next, + .stop = prism2_ap_proc_stop, + .show = prism2_ap_proc_show, +}; + +static int prism2_ap_proc_open(struct inode *inode, struct file *file) +{ + int ret = seq_open(file, &prism2_ap_proc_seqops); + if (ret == 0) { + struct seq_file *m = file->private_data; + m->private = PDE_DATA(inode); + } + return ret; +} + +static const struct file_operations prism2_ap_proc_fops = { + .open = prism2_ap_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */ @@ -836,15 +895,12 @@ void hostap_init_ap_proc(local_info_t *local) return; #ifndef PRISM2_NO_PROCFS_DEBUG - create_proc_read_entry("ap_debug", 0, ap->proc, - ap_debug_proc_read, ap); + proc_create_data("ap_debug", 0, ap->proc, &ap_debug_proc_fops, ap); #endif /* PRISM2_NO_PROCFS_DEBUG */ #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT - create_proc_read_entry("ap_control", 0, ap->proc, - ap_control_proc_read, ap); - create_proc_read_entry("ap", 0, ap->proc, - prism2_ap_proc_read, ap); + proc_create_data("ap_control", 0, ap->proc, &ap_control_proc_fops, ap); + proc_create_data("ap", 0, ap->proc, &prism2_ap_proc_fops, ap); #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */ } @@ -982,79 +1038,86 @@ static void prism2_send_mgmt(struct net_device *dev, #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */ -static int prism2_sta_proc_read(char *page, char **start, off_t off, - int count, int *eof, void *data) +static int prism2_sta_proc_show(struct seq_file *m, void *v) { - char *p = page; - struct sta_info *sta = (struct sta_info *) data; + struct sta_info *sta = m->private; int i; /* FIX: possible race condition.. the STA data could have just expired, * but proc entry was still here so that the read could have started; * some locking should be done here.. */ - if (off != 0) { - *eof = 1; - return 0; - } - - p += sprintf(p, "%s=%pM\nusers=%d\naid=%d\n" - "flags=0x%04x%s%s%s%s%s%s%s\n" - "capability=0x%02x\nlisten_interval=%d\nsupported_rates=", - sta->ap ? "AP" : "STA", - sta->addr, atomic_read(&sta->users), sta->aid, - sta->flags, - sta->flags & WLAN_STA_AUTH ? " AUTH" : "", - sta->flags & WLAN_STA_ASSOC ? " ASSOC" : "", - sta->flags & WLAN_STA_PS ? " PS" : "", - sta->flags & WLAN_STA_TIM ? " TIM" : "", - sta->flags & WLAN_STA_PERM ? " PERM" : "", - sta->flags & WLAN_STA_AUTHORIZED ? " AUTHORIZED" : "", - sta->flags & WLAN_STA_PENDING_POLL ? " POLL" : "", - sta->capability, sta->listen_interval); + seq_printf(m, + "%s=%pM\nusers=%d\naid=%d\n" + "flags=0x%04x%s%s%s%s%s%s%s\n" + "capability=0x%02x\nlisten_interval=%d\nsupported_rates=", + sta->ap ? "AP" : "STA", + sta->addr, atomic_read(&sta->users), sta->aid, + sta->flags, + sta->flags & WLAN_STA_AUTH ? " AUTH" : "", + sta->flags & WLAN_STA_ASSOC ? " ASSOC" : "", + sta->flags & WLAN_STA_PS ? " PS" : "", + sta->flags & WLAN_STA_TIM ? " TIM" : "", + sta->flags & WLAN_STA_PERM ? " PERM" : "", + sta->flags & WLAN_STA_AUTHORIZED ? " AUTHORIZED" : "", + sta->flags & WLAN_STA_PENDING_POLL ? " POLL" : "", + sta->capability, sta->listen_interval); /* supported_rates: 500 kbit/s units with msb ignored */ for (i = 0; i < sizeof(sta->supported_rates); i++) if (sta->supported_rates[i] != 0) - p += sprintf(p, "%d%sMbps ", - (sta->supported_rates[i] & 0x7f) / 2, - sta->supported_rates[i] & 1 ? ".5" : ""); - p += sprintf(p, "\njiffies=%lu\nlast_auth=%lu\nlast_assoc=%lu\n" - "last_rx=%lu\nlast_tx=%lu\nrx_packets=%lu\n" - "tx_packets=%lu\n" - "rx_bytes=%lu\ntx_bytes=%lu\nbuffer_count=%d\n" - "last_rx: silence=%d dBm signal=%d dBm rate=%d%s Mbps\n" - "tx_rate=%d\ntx[1M]=%d\ntx[2M]=%d\ntx[5.5M]=%d\n" - "tx[11M]=%d\n" - "rx[1M]=%d\nrx[2M]=%d\nrx[5.5M]=%d\nrx[11M]=%d\n", - jiffies, sta->last_auth, sta->last_assoc, sta->last_rx, - sta->last_tx, - sta->rx_packets, sta->tx_packets, sta->rx_bytes, - sta->tx_bytes, skb_queue_len(&sta->tx_buf), - sta->last_rx_silence, - sta->last_rx_signal, sta->last_rx_rate / 10, - sta->last_rx_rate % 10 ? ".5" : "", - sta->tx_rate, sta->tx_count[0], sta->tx_count[1], - sta->tx_count[2], sta->tx_count[3], sta->rx_count[0], - sta->rx_count[1], sta->rx_count[2], sta->rx_count[3]); + seq_printf(m, "%d%sMbps ", + (sta->supported_rates[i] & 0x7f) / 2, + sta->supported_rates[i] & 1 ? ".5" : ""); + seq_printf(m, + "\njiffies=%lu\nlast_auth=%lu\nlast_assoc=%lu\n" + "last_rx=%lu\nlast_tx=%lu\nrx_packets=%lu\n" + "tx_packets=%lu\n" + "rx_bytes=%lu\ntx_bytes=%lu\nbuffer_count=%d\n" + "last_rx: silence=%d dBm signal=%d dBm rate=%d%s Mbps\n" + "tx_rate=%d\ntx[1M]=%d\ntx[2M]=%d\ntx[5.5M]=%d\n" + "tx[11M]=%d\n" + "rx[1M]=%d\nrx[2M]=%d\nrx[5.5M]=%d\nrx[11M]=%d\n", + jiffies, sta->last_auth, sta->last_assoc, sta->last_rx, + sta->last_tx, + sta->rx_packets, sta->tx_packets, sta->rx_bytes, + sta->tx_bytes, skb_queue_len(&sta->tx_buf), + sta->last_rx_silence, + sta->last_rx_signal, sta->last_rx_rate / 10, + sta->last_rx_rate % 10 ? ".5" : "", + sta->tx_rate, sta->tx_count[0], sta->tx_count[1], + sta->tx_count[2], sta->tx_count[3], sta->rx_count[0], + sta->rx_count[1], sta->rx_count[2], sta->rx_count[3]); if (sta->crypt && sta->crypt->ops && sta->crypt->ops->print_stats) - p = sta->crypt->ops->print_stats(p, sta->crypt->priv); + sta->crypt->ops->print_stats(m, sta->crypt->priv); #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT if (sta->ap) { if (sta->u.ap.channel >= 0) - p += sprintf(p, "channel=%d\n", sta->u.ap.channel); - p += sprintf(p, "ssid="); - for (i = 0; i < sta->u.ap.ssid_len; i++) - p += sprintf(p, ((sta->u.ap.ssid[i] >= 32 && - sta->u.ap.ssid[i] < 127) ? - "%c" : "<%02x>"), - sta->u.ap.ssid[i]); - p += sprintf(p, "\n"); + seq_printf(m, "channel=%d\n", sta->u.ap.channel); + seq_puts(m, "ssid="); + for (i = 0; i < sta->u.ap.ssid_len; i++) { + if (sta->u.ap.ssid[i] >= 32 && sta->u.ap.ssid[i] < 127) + seq_putc(m, sta->u.ap.ssid[i]); + else + seq_printf(m, "<%02x>", sta->u.ap.ssid[i]); + } + seq_putc(m, '\n'); } #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */ - return (p - page); + return 0; +} + +static int prism2_sta_proc_open(struct inode *inode, struct file *file) +{ + return single_open(file, prism2_sta_proc_show, PDE_DATA(inode)); } +static const struct file_operations prism2_sta_proc_fops = { + .open = prism2_sta_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; static void handle_add_proc_queue(struct work_struct *work) { @@ -1076,9 +1139,9 @@ static void handle_add_proc_queue(struct work_struct *work) if (sta) { sprintf(name, "%pM", sta->addr); - sta->proc = create_proc_read_entry( + sta->proc = proc_create_data( name, 0, ap->proc, - prism2_sta_proc_read, sta); + &prism2_sta_proc_fops, sta); atomic_dec(&sta->users); } diff --git a/drivers/net/wireless/hostap/hostap_download.c b/drivers/net/wireless/hostap/hostap_download.c index e73bf739fd9..705fe668b96 100644 --- a/drivers/net/wireless/hostap/hostap_download.c +++ b/drivers/net/wireless/hostap/hostap_download.c @@ -174,20 +174,70 @@ static int prism2_pda_ok(u8 *buf) } -static int prism2_download_aux_dump(struct net_device *dev, - unsigned int addr, int len, u8 *buf) -{ - int res; +#define prism2_download_aux_dump_npages 65536 - prism2_enable_aux_port(dev, 1); - res = hfa384x_from_aux(dev, addr, len, buf); - prism2_enable_aux_port(dev, 0); - if (res) - return -1; +struct prism2_download_aux_dump { + local_info_t *local; + u16 page[0x80]; +}; + +static int prism2_download_aux_dump_proc_show(struct seq_file *m, void *v) +{ + struct prism2_download_aux_dump *ctx = m->private; + hfa384x_from_aux(ctx->local->dev, (unsigned long)v - 1, 0x80, ctx->page); + seq_write(m, ctx->page, 0x80); return 0; } +static void *prism2_download_aux_dump_proc_start(struct seq_file *m, loff_t *_pos) +{ + struct prism2_download_aux_dump *ctx = m->private; + prism2_enable_aux_port(ctx->local->dev, 1); + if (*_pos >= prism2_download_aux_dump_npages) + return NULL; + return (void *)((unsigned long)*_pos + 1); +} + +static void *prism2_download_aux_dump_proc_next(struct seq_file *m, void *v, loff_t *_pos) +{ + ++*_pos; + if (*_pos >= prism2_download_aux_dump_npages) + return NULL; + return (void *)((unsigned long)*_pos + 1); +} + +static void prism2_download_aux_dump_proc_stop(struct seq_file *m, void *v) +{ + struct prism2_download_aux_dump *ctx = m->private; + prism2_enable_aux_port(ctx->local->dev, 0); +} + +static const struct seq_operations prism2_download_aux_dump_proc_seqops = { + .start = prism2_download_aux_dump_proc_start, + .next = prism2_download_aux_dump_proc_next, + .stop = prism2_download_aux_dump_proc_stop, + .show = prism2_download_aux_dump_proc_show, +}; + +static int prism2_download_aux_dump_proc_open(struct inode *inode, struct file *file) +{ + int ret = seq_open_private(file, &prism2_download_aux_dump_proc_seqops, + sizeof(struct prism2_download_aux_dump)); + if (ret == 0) { + struct seq_file *m = file->private_data; + m->private = PDE_DATA(inode); + } + return ret; +} + +static const struct file_operations prism2_download_aux_dump_proc_fops = { + .open = prism2_download_aux_dump_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release_private, +}; + static u8 * prism2_read_pda(struct net_device *dev) { diff --git a/drivers/net/wireless/hostap/hostap_hw.c b/drivers/net/wireless/hostap/hostap_hw.c index 8e7000fd441..507ab99eef4 100644 --- a/drivers/net/wireless/hostap/hostap_hw.c +++ b/drivers/net/wireless/hostap/hostap_hw.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -129,8 +130,7 @@ static void prism2_check_sta_fw_version(local_info_t *local); #ifdef PRISM2_DOWNLOAD_SUPPORT /* hostap_download.c */ -static int prism2_download_aux_dump(struct net_device *dev, - unsigned int addr, int len, u8 *buf); +static const struct file_operations prism2_download_aux_dump_proc_fops; static u8 * prism2_read_pda(struct net_device *dev); static int prism2_download(local_info_t *local, struct prism2_download_param *param); @@ -2894,19 +2894,12 @@ static void hostap_tick_timer(unsigned long data) #ifndef PRISM2_NO_PROCFS_DEBUG -static int prism2_registers_proc_read(char *page, char **start, off_t off, - int count, int *eof, void *data) +static int prism2_registers_proc_show(struct seq_file *m, void *v) { - char *p = page; - local_info_t *local = (local_info_t *) data; - - if (off != 0) { - *eof = 1; - return 0; - } + local_info_t *local = m->private; #define SHOW_REG(n) \ -p += sprintf(p, #n "=%04x\n", hfa384x_read_reg(local->dev, HFA384X_##n##_OFF)) + seq_printf(m, #n "=%04x\n", hfa384x_read_reg(local->dev, HFA384X_##n##_OFF)) SHOW_REG(CMD); SHOW_REG(PARAM0); @@ -2952,8 +2945,21 @@ p += sprintf(p, #n "=%04x\n", hfa384x_read_reg(local->dev, HFA384X_##n##_OFF)) SHOW_REG(PCI_M1_CTL); #endif /* PRISM2_PCI */ - return (p - page); + return 0; } + +static int prism2_registers_proc_open(struct inode *inode, struct file *file) +{ + return single_open(file, prism2_registers_proc_show, PDE_DATA(inode)); +} + +static const struct file_operations prism2_registers_proc_fops = { + .open = prism2_registers_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + #endif /* PRISM2_NO_PROCFS_DEBUG */ @@ -3128,7 +3134,7 @@ prism2_init_local_data(struct prism2_helper_functions *funcs, int card_idx, local->func->reset_port = prism2_reset_port; local->func->schedule_reset = prism2_schedule_reset; #ifdef PRISM2_DOWNLOAD_SUPPORT - local->func->read_aux = prism2_download_aux_dump; + local->func->read_aux_fops = &prism2_download_aux_dump_proc_fops; local->func->download = prism2_download; #endif /* PRISM2_DOWNLOAD_SUPPORT */ local->func->tx = prism2_tx_80211; @@ -3274,8 +3280,8 @@ static int hostap_hw_ready(struct net_device *dev) } hostap_init_proc(local); #ifndef PRISM2_NO_PROCFS_DEBUG - create_proc_read_entry("registers", 0, local->proc, - prism2_registers_proc_read, local); + proc_create_data("registers", 0, local->proc, + &prism2_registers_proc_fops, local); #endif /* PRISM2_NO_PROCFS_DEBUG */ hostap_init_ap_proc(local); return 0; diff --git a/drivers/net/wireless/hostap/hostap_proc.c b/drivers/net/wireless/hostap/hostap_proc.c index dc447c1b5ab..89292cffa76 100644 --- a/drivers/net/wireless/hostap/hostap_proc.c +++ b/drivers/net/wireless/hostap/hostap_proc.c @@ -12,259 +12,297 @@ #ifndef PRISM2_NO_PROCFS_DEBUG -static int prism2_debug_proc_read(char *page, char **start, off_t off, - int count, int *eof, void *data) +static int prism2_debug_proc_show(struct seq_file *m, void *v) { - char *p = page; - local_info_t *local = (local_info_t *) data; + local_info_t *local = m->private; int i; - if (off != 0) { - *eof = 1; - return 0; - } - - p += sprintf(p, "next_txfid=%d next_alloc=%d\n", - local->next_txfid, local->next_alloc); + seq_printf(m, "next_txfid=%d next_alloc=%d\n", + local->next_txfid, local->next_alloc); for (i = 0; i < PRISM2_TXFID_COUNT; i++) - p += sprintf(p, "FID: tx=%04X intransmit=%04X\n", - local->txfid[i], local->intransmitfid[i]); - p += sprintf(p, "FW TX rate control: %d\n", local->fw_tx_rate_control); - p += sprintf(p, "beacon_int=%d\n", local->beacon_int); - p += sprintf(p, "dtim_period=%d\n", local->dtim_period); - p += sprintf(p, "wds_max_connections=%d\n", - local->wds_max_connections); - p += sprintf(p, "dev_enabled=%d\n", local->dev_enabled); - p += sprintf(p, "sw_tick_stuck=%d\n", local->sw_tick_stuck); + seq_printf(m, "FID: tx=%04X intransmit=%04X\n", + local->txfid[i], local->intransmitfid[i]); + seq_printf(m, "FW TX rate control: %d\n", local->fw_tx_rate_control); + seq_printf(m, "beacon_int=%d\n", local->beacon_int); + seq_printf(m, "dtim_period=%d\n", local->dtim_period); + seq_printf(m, "wds_max_connections=%d\n", local->wds_max_connections); + seq_printf(m, "dev_enabled=%d\n", local->dev_enabled); + seq_printf(m, "sw_tick_stuck=%d\n", local->sw_tick_stuck); for (i = 0; i < WEP_KEYS; i++) { if (local->crypt_info.crypt[i] && local->crypt_info.crypt[i]->ops) { - p += sprintf(p, "crypt[%d]=%s\n", i, - local->crypt_info.crypt[i]->ops->name); + seq_printf(m, "crypt[%d]=%s\n", i, + local->crypt_info.crypt[i]->ops->name); } } - p += sprintf(p, "pri_only=%d\n", local->pri_only); - p += sprintf(p, "pci=%d\n", local->func->hw_type == HOSTAP_HW_PCI); - p += sprintf(p, "sram_type=%d\n", local->sram_type); - p += sprintf(p, "no_pri=%d\n", local->no_pri); + seq_printf(m, "pri_only=%d\n", local->pri_only); + seq_printf(m, "pci=%d\n", local->func->hw_type == HOSTAP_HW_PCI); + seq_printf(m, "sram_type=%d\n", local->sram_type); + seq_printf(m, "no_pri=%d\n", local->no_pri); + + return 0; +} - return (p - page); +static int prism2_debug_proc_open(struct inode *inode, struct file *file) +{ + return single_open(file, prism2_debug_proc_show, PDE_DATA(inode)); } + +static const struct file_operations prism2_debug_proc_fops = { + .open = prism2_debug_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; #endif /* PRISM2_NO_PROCFS_DEBUG */ -static int prism2_stats_proc_read(char *page, char **start, off_t off, - int count, int *eof, void *data) +static int prism2_stats_proc_show(struct seq_file *m, void *v) { - char *p = page; - local_info_t *local = (local_info_t *) data; + local_info_t *local = m->private; struct comm_tallies_sums *sums = &local->comm_tallies; - if (off != 0) { - *eof = 1; - return 0; - } - - p += sprintf(p, "TxUnicastFrames=%u\n", sums->tx_unicast_frames); - p += sprintf(p, "TxMulticastframes=%u\n", sums->tx_multicast_frames); - p += sprintf(p, "TxFragments=%u\n", sums->tx_fragments); - p += sprintf(p, "TxUnicastOctets=%u\n", sums->tx_unicast_octets); - p += sprintf(p, "TxMulticastOctets=%u\n", sums->tx_multicast_octets); - p += sprintf(p, "TxDeferredTransmissions=%u\n", - sums->tx_deferred_transmissions); - p += sprintf(p, "TxSingleRetryFrames=%u\n", - sums->tx_single_retry_frames); - p += sprintf(p, "TxMultipleRetryFrames=%u\n", - sums->tx_multiple_retry_frames); - p += sprintf(p, "TxRetryLimitExceeded=%u\n", - sums->tx_retry_limit_exceeded); - p += sprintf(p, "TxDiscards=%u\n", sums->tx_discards); - p += sprintf(p, "RxUnicastFrames=%u\n", sums->rx_unicast_frames); - p += sprintf(p, "RxMulticastFrames=%u\n", sums->rx_multicast_frames); - p += sprintf(p, "RxFragments=%u\n", sums->rx_fragments); - p += sprintf(p, "RxUnicastOctets=%u\n", sums->rx_unicast_octets); - p += sprintf(p, "RxMulticastOctets=%u\n", sums->rx_multicast_octets); - p += sprintf(p, "RxFCSErrors=%u\n", sums->rx_fcs_errors); - p += sprintf(p, "RxDiscardsNoBuffer=%u\n", - sums->rx_discards_no_buffer); - p += sprintf(p, "TxDiscardsWrongSA=%u\n", sums->tx_discards_wrong_sa); - p += sprintf(p, "RxDiscardsWEPUndecryptable=%u\n", - sums->rx_discards_wep_undecryptable); - p += sprintf(p, "RxMessageInMsgFragments=%u\n", - sums->rx_message_in_msg_fragments); - p += sprintf(p, "RxMessageInBadMsgFragments=%u\n", - sums->rx_message_in_bad_msg_fragments); + seq_printf(m, "TxUnicastFrames=%u\n", sums->tx_unicast_frames); + seq_printf(m, "TxMulticastframes=%u\n", sums->tx_multicast_frames); + seq_printf(m, "TxFragments=%u\n", sums->tx_fragments); + seq_printf(m, "TxUnicastOctets=%u\n", sums->tx_unicast_octets); + seq_printf(m, "TxMulticastOctets=%u\n", sums->tx_multicast_octets); + seq_printf(m, "TxDeferredTransmissions=%u\n", + sums->tx_deferred_transmissions); + seq_printf(m, "TxSingleRetryFrames=%u\n", sums->tx_single_retry_frames); + seq_printf(m, "TxMultipleRetryFrames=%u\n", + sums->tx_multiple_retry_frames); + seq_printf(m, "TxRetryLimitExceeded=%u\n", + sums->tx_retry_limit_exceeded); + seq_printf(m, "TxDiscards=%u\n", sums->tx_discards); + seq_printf(m, "RxUnicastFrames=%u\n", sums->rx_unicast_frames); + seq_printf(m, "RxMulticastFrames=%u\n", sums->rx_multicast_frames); + seq_printf(m, "RxFragments=%u\n", sums->rx_fragments); + seq_printf(m, "RxUnicastOctets=%u\n", sums->rx_unicast_octets); + seq_printf(m, "RxMulticastOctets=%u\n", sums->rx_multicast_octets); + seq_printf(m, "RxFCSErrors=%u\n", sums->rx_fcs_errors); + seq_printf(m, "RxDiscardsNoBuffer=%u\n", sums->rx_discards_no_buffer); + seq_printf(m, "TxDiscardsWrongSA=%u\n", sums->tx_discards_wrong_sa); + seq_printf(m, "RxDiscardsWEPUndecryptable=%u\n", + sums->rx_discards_wep_undecryptable); + seq_printf(m, "RxMessageInMsgFragments=%u\n", + sums->rx_message_in_msg_fragments); + seq_printf(m, "RxMessageInBadMsgFragments=%u\n", + sums->rx_message_in_bad_msg_fragments); /* FIX: this may grow too long for one page(?) */ - return (p - page); + return 0; +} + +static int prism2_stats_proc_open(struct inode *inode, struct file *file) +{ + return single_open(file, prism2_stats_proc_show, PDE_DATA(inode)); } +static const struct file_operations prism2_stats_proc_fops = { + .open = prism2_stats_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + -static int prism2_wds_proc_read(char *page, char **start, off_t off, - int count, int *eof, void *data) +static int prism2_wds_proc_show(struct seq_file *m, void *v) { - char *p = page; - local_info_t *local = (local_info_t *) data; - struct list_head *ptr; + struct list_head *ptr = v; struct hostap_interface *iface; - if (off > PROC_LIMIT) { - *eof = 1; - return 0; - } + iface = list_entry(ptr, struct hostap_interface, list); + if (iface->type == HOSTAP_INTERFACE_WDS) + seq_printf(m, "%s\t%pM\n", + iface->dev->name, iface->u.wds.remote_addr); + return 0; +} +static void *prism2_wds_proc_start(struct seq_file *m, loff_t *_pos) +{ + local_info_t *local = m->private; read_lock_bh(&local->iface_lock); - list_for_each(ptr, &local->hostap_interfaces) { - iface = list_entry(ptr, struct hostap_interface, list); - if (iface->type != HOSTAP_INTERFACE_WDS) - continue; - p += sprintf(p, "%s\t%pM\n", - iface->dev->name, - iface->u.wds.remote_addr); - if ((p - page) > PROC_LIMIT) { - printk(KERN_DEBUG "%s: wds proc did not fit\n", - local->dev->name); - break; - } - } - read_unlock_bh(&local->iface_lock); + return seq_list_start(&local->hostap_interfaces, *_pos); +} - if ((p - page) <= off) { - *eof = 1; - return 0; - } +static void *prism2_wds_proc_next(struct seq_file *m, void *v, loff_t *_pos) +{ + local_info_t *local = m->private; + return seq_list_next(v, &local->hostap_interfaces, _pos); +} + +static void prism2_wds_proc_stop(struct seq_file *m, void *v) +{ + local_info_t *local = m->private; + read_unlock_bh(&local->iface_lock); +} - *start = page + off; +static const struct seq_operations prism2_wds_proc_seqops = { + .start = prism2_wds_proc_start, + .next = prism2_wds_proc_next, + .stop = prism2_wds_proc_stop, + .show = prism2_wds_proc_show, +}; - return (p - page - off); +static int prism2_wds_proc_open(struct inode *inode, struct file *file) +{ + int ret = seq_open(file, &prism2_wds_proc_seqops); + if (ret == 0) { + struct seq_file *m = file->private_data; + m->private = PDE_DATA(inode); + } + return ret; } +static const struct file_operations prism2_wds_proc_fops = { + .open = prism2_wds_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; -static int prism2_bss_list_proc_read(char *page, char **start, off_t off, - int count, int *eof, void *data) + +static int prism2_bss_list_proc_show(struct seq_file *m, void *v) { - char *p = page; - local_info_t *local = (local_info_t *) data; - struct list_head *ptr; + local_info_t *local = m->private; + struct list_head *ptr = v; struct hostap_bss_info *bss; int i; - if (off > PROC_LIMIT) { - *eof = 1; + if (ptr == &local->bss_list) { + seq_printf(m, "#BSSID\tlast_update\tcount\tcapab_info\tSSID(txt)\t" + "SSID(hex)\tWPA IE\n"); return 0; } - p += sprintf(p, "#BSSID\tlast_update\tcount\tcapab_info\tSSID(txt)\t" - "SSID(hex)\tWPA IE\n"); + bss = list_entry(ptr, struct hostap_bss_info, list); + seq_printf(m, "%pM\t%lu\t%u\t0x%x\t", + bss->bssid, bss->last_update, + bss->count, bss->capab_info); + + for (i = 0; i < bss->ssid_len; i++) + seq_putc(m,bss->ssid[i] >= 32 && bss->ssid[i] < 127 ? + bss->ssid[i] : '_'); + + seq_putc(m, '\t'); + for (i = 0; i < bss->ssid_len; i++) + seq_printf(m, "%02x", bss->ssid[i]); + seq_putc(m, '\t'); + for (i = 0; i < bss->wpa_ie_len; i++) + seq_printf(m, "%02x", bss->wpa_ie[i]); + seq_putc(m, '\n'); + return 0; +} + +static void *prism2_bss_list_proc_start(struct seq_file *m, loff_t *_pos) +{ + local_info_t *local = m->private; spin_lock_bh(&local->lock); - list_for_each(ptr, &local->bss_list) { - bss = list_entry(ptr, struct hostap_bss_info, list); - p += sprintf(p, "%pM\t%lu\t%u\t0x%x\t", - bss->bssid, bss->last_update, - bss->count, bss->capab_info); - for (i = 0; i < bss->ssid_len; i++) { - p += sprintf(p, "%c", - bss->ssid[i] >= 32 && bss->ssid[i] < 127 ? - bss->ssid[i] : '_'); - } - p += sprintf(p, "\t"); - for (i = 0; i < bss->ssid_len; i++) { - p += sprintf(p, "%02x", bss->ssid[i]); - } - p += sprintf(p, "\t"); - for (i = 0; i < bss->wpa_ie_len; i++) { - p += sprintf(p, "%02x", bss->wpa_ie[i]); - } - p += sprintf(p, "\n"); - if ((p - page) > PROC_LIMIT) { - printk(KERN_DEBUG "%s: BSS proc did not fit\n", - local->dev->name); - break; - } - } - spin_unlock_bh(&local->lock); + return seq_list_start_head(&local->bss_list, *_pos); +} - if ((p - page) <= off) { - *eof = 1; - return 0; - } +static void *prism2_bss_list_proc_next(struct seq_file *m, void *v, loff_t *_pos) +{ + local_info_t *local = m->private; + return seq_list_next(v, &local->bss_list, _pos); +} + +static void prism2_bss_list_proc_stop(struct seq_file *m, void *v) +{ + local_info_t *local = m->private; + spin_unlock_bh(&local->lock); +} - *start = page + off; +static const struct seq_operations prism2_bss_list_proc_seqops = { + .start = prism2_bss_list_proc_start, + .next = prism2_bss_list_proc_next, + .stop = prism2_bss_list_proc_stop, + .show = prism2_bss_list_proc_show, +}; - return (p - page - off); +static int prism2_bss_list_proc_open(struct inode *inode, struct file *file) +{ + int ret = seq_open(file, &prism2_bss_list_proc_seqops); + if (ret == 0) { + struct seq_file *m = file->private_data; + m->private = PDE_DATA(inode); + } + return ret; } +static const struct file_operations prism2_bss_list_proc_fops = { + .open = prism2_bss_list_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; -static int prism2_crypt_proc_read(char *page, char **start, off_t off, - int count, int *eof, void *data) + +static int prism2_crypt_proc_show(struct seq_file *m, void *v) { - char *p = page; - local_info_t *local = (local_info_t *) data; + local_info_t *local = m->private; int i; - if (off > PROC_LIMIT) { - *eof = 1; - return 0; - } - - p += sprintf(p, "tx_keyidx=%d\n", local->crypt_info.tx_keyidx); + seq_printf(m, "tx_keyidx=%d\n", local->crypt_info.tx_keyidx); for (i = 0; i < WEP_KEYS; i++) { if (local->crypt_info.crypt[i] && local->crypt_info.crypt[i]->ops && local->crypt_info.crypt[i]->ops->print_stats) { - p = local->crypt_info.crypt[i]->ops->print_stats( - p, local->crypt_info.crypt[i]->priv); + local->crypt_info.crypt[i]->ops->print_stats( + m, local->crypt_info.crypt[i]->priv); } } + return 0; +} - if ((p - page) <= off) { - *eof = 1; - return 0; - } - - *start = page + off; - - return (p - page - off); +static int prism2_crypt_proc_open(struct inode *inode, struct file *file) +{ + return single_open(file, prism2_crypt_proc_show, PDE_DATA(inode)); } +static const struct file_operations prism2_crypt_proc_fops = { + .open = prism2_crypt_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + -static int prism2_pda_proc_read(char *page, char **start, off_t off, - int count, int *eof, void *data) +static ssize_t prism2_pda_proc_read(struct file *file, char __user *buf, + size_t count, loff_t *_pos) { - local_info_t *local = (local_info_t *) data; + local_info_t *local = PDE_DATA(file_inode(file)); + size_t off; - if (local->pda == NULL || off >= PRISM2_PDA_SIZE) { - *eof = 1; + if (local->pda == NULL || *_pos >= PRISM2_PDA_SIZE) return 0; - } - if (off + count > PRISM2_PDA_SIZE) + off = *_pos; + if (count > PRISM2_PDA_SIZE - off) count = PRISM2_PDA_SIZE - off; - - memcpy(page, local->pda + off, count); + if (copy_to_user(buf, local->pda + off, count) != 0) + return -EFAULT; + *_pos += count; return count; } +static const struct file_operations prism2_pda_proc_fops = { + .read = prism2_pda_proc_read, + .llseek = generic_file_llseek, +}; -static int prism2_aux_dump_proc_read(char *page, char **start, off_t off, - int count, int *eof, void *data) -{ - local_info_t *local = (local_info_t *) data; - - if (local->func->read_aux == NULL) { - *eof = 1; - return 0; - } - - if (local->func->read_aux(local->dev, off, count, page)) { - *eof = 1; - return 0; - } - *start = page; - return count; +static ssize_t prism2_aux_dump_proc_no_read(struct file *file, char __user *buf, + size_t bufsize, loff_t *_pos) +{ + return 0; } +static const struct file_operations prism2_aux_dump_proc_fops = { + .read = prism2_aux_dump_proc_no_read, +}; + #ifdef PRISM2_IO_DEBUG static int prism2_io_debug_proc_read(char *page, char **start, off_t off, @@ -306,82 +344,108 @@ static int prism2_io_debug_proc_read(char *page, char **start, off_t off, #ifndef PRISM2_NO_STATION_MODES -static int prism2_scan_results_proc_read(char *page, char **start, off_t off, - int count, int *eof, void *data) +static int prism2_scan_results_proc_show(struct seq_file *m, void *v) { - char *p = page; - local_info_t *local = (local_info_t *) data; - int entry, i, len, total = 0; + local_info_t *local = m->private; + unsigned long entry; + int i, len; struct hfa384x_hostscan_result *scanres; - u8 *pos; + u8 *p; - p += sprintf(p, "CHID ANL SL BcnInt Capab Rate BSSID ATIM SupRates " - "SSID\n"); + if (v == SEQ_START_TOKEN) { + seq_printf(m, + "CHID ANL SL BcnInt Capab Rate BSSID ATIM SupRates SSID\n"); + return 0; + } + + entry = (unsigned long)v - 2; + scanres = &local->last_scan_results[entry]; + + seq_printf(m, "%d %d %d %d 0x%02x %d %pM %d ", + le16_to_cpu(scanres->chid), + (s16) le16_to_cpu(scanres->anl), + (s16) le16_to_cpu(scanres->sl), + le16_to_cpu(scanres->beacon_interval), + le16_to_cpu(scanres->capability), + le16_to_cpu(scanres->rate), + scanres->bssid, + le16_to_cpu(scanres->atim)); + + p = scanres->sup_rates; + for (i = 0; i < sizeof(scanres->sup_rates); i++) { + if (p[i] == 0) + break; + seq_printf(m, "<%02x>", p[i]); + } + seq_putc(m, ' '); + + p = scanres->ssid; + len = le16_to_cpu(scanres->ssid_len); + if (len > 32) + len = 32; + for (i = 0; i < len; i++) { + unsigned char c = p[i]; + if (c >= 32 && c < 127) + seq_putc(m, c); + else + seq_printf(m, "<%02x>", c); + } + seq_putc(m, '\n'); + return 0; +} +static void *prism2_scan_results_proc_start(struct seq_file *m, loff_t *_pos) +{ + local_info_t *local = m->private; spin_lock_bh(&local->lock); - for (entry = 0; entry < local->last_scan_results_count; entry++) { - scanres = &local->last_scan_results[entry]; - if (total + (p - page) <= off) { - total += p - page; - p = page; - } - if (total + (p - page) > off + count) - break; - if ((p - page) > (PAGE_SIZE - 200)) - break; + /* We have a header (pos 0) + N results to show (pos 1...N) */ + if (*_pos > local->last_scan_results_count) + return NULL; + return (void *)(unsigned long)(*_pos + 1); /* 0 would be EOF */ +} - p += sprintf(p, "%d %d %d %d 0x%02x %d %pM %d ", - le16_to_cpu(scanres->chid), - (s16) le16_to_cpu(scanres->anl), - (s16) le16_to_cpu(scanres->sl), - le16_to_cpu(scanres->beacon_interval), - le16_to_cpu(scanres->capability), - le16_to_cpu(scanres->rate), - scanres->bssid, - le16_to_cpu(scanres->atim)); - - pos = scanres->sup_rates; - for (i = 0; i < sizeof(scanres->sup_rates); i++) { - if (pos[i] == 0) - break; - p += sprintf(p, "<%02x>", pos[i]); - } - p += sprintf(p, " "); - - pos = scanres->ssid; - len = le16_to_cpu(scanres->ssid_len); - if (len > 32) - len = 32; - for (i = 0; i < len; i++) { - unsigned char c = pos[i]; - if (c >= 32 && c < 127) - p += sprintf(p, "%c", c); - else - p += sprintf(p, "<%02x>", c); - } - p += sprintf(p, "\n"); - } +static void *prism2_scan_results_proc_next(struct seq_file *m, void *v, loff_t *_pos) +{ + local_info_t *local = m->private; + + ++*_pos; + if (*_pos > local->last_scan_results_count) + return NULL; + return (void *)(unsigned long)(*_pos + 1); /* 0 would be EOF */ +} + +static void prism2_scan_results_proc_stop(struct seq_file *m, void *v) +{ + local_info_t *local = m->private; spin_unlock_bh(&local->lock); +} - total += (p - page); - if (total >= off + count) - *eof = 1; +static const struct seq_operations prism2_scan_results_proc_seqops = { + .start = prism2_scan_results_proc_start, + .next = prism2_scan_results_proc_next, + .stop = prism2_scan_results_proc_stop, + .show = prism2_scan_results_proc_show, +}; - if (total < off) { - *eof = 1; - return 0; +static int prism2_scan_results_proc_open(struct inode *inode, struct file *file) +{ + int ret = seq_open(file, &prism2_scan_results_proc_seqops); + if (ret == 0) { + struct seq_file *m = file->private_data; + m->private = PDE_DATA(inode); } + return ret; +} + +static const struct file_operations prism2_scan_results_proc_fops = { + .open = prism2_scan_results_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; - len = total - off; - if (len > (p - page)) - len = p - page; - *start = p - len; - if (len > count) - len = count; - return len; -} #endif /* PRISM2_NO_STATION_MODES */ @@ -403,28 +467,29 @@ void hostap_init_proc(local_info_t *local) } #ifndef PRISM2_NO_PROCFS_DEBUG - create_proc_read_entry("debug", 0, local->proc, - prism2_debug_proc_read, local); + proc_create_data("debug", 0, local->proc, + &prism2_debug_proc_fops, local); #endif /* PRISM2_NO_PROCFS_DEBUG */ - create_proc_read_entry("stats", 0, local->proc, - prism2_stats_proc_read, local); - create_proc_read_entry("wds", 0, local->proc, - prism2_wds_proc_read, local); - create_proc_read_entry("pda", 0, local->proc, - prism2_pda_proc_read, local); - create_proc_read_entry("aux_dump", 0, local->proc, - prism2_aux_dump_proc_read, local); - create_proc_read_entry("bss_list", 0, local->proc, - prism2_bss_list_proc_read, local); - create_proc_read_entry("crypt", 0, local->proc, - prism2_crypt_proc_read, local); + proc_create_data("stats", 0, local->proc, + &prism2_stats_proc_fops, local); + proc_create_data("wds", 0, local->proc, + &prism2_wds_proc_fops, local); + proc_create_data("pda", 0, local->proc, + &prism2_pda_proc_fops, local); + proc_create_data("aux_dump", 0, local->proc, + local->func->read_aux_fops ?: &prism2_aux_dump_proc_fops, + local); + proc_create_data("bss_list", 0, local->proc, + &prism2_bss_list_proc_fops, local); + proc_create_data("crypt", 0, local->proc, + &prism2_crypt_proc_fops, local); #ifdef PRISM2_IO_DEBUG - create_proc_read_entry("io_debug", 0, local->proc, - prism2_io_debug_proc_read, local); + proc_create_data("io_debug", 0, local->proc, + &prism2_io_debug_proc_fops, local); #endif /* PRISM2_IO_DEBUG */ #ifndef PRISM2_NO_STATION_MODES - create_proc_read_entry("scan_results", 0, local->proc, - prism2_scan_results_proc_read, local); + proc_create_data("scan_results", 0, local->proc, + &prism2_scan_results_proc_fops, local); #endif /* PRISM2_NO_STATION_MODES */ } diff --git a/drivers/net/wireless/hostap/hostap_wlan.h b/drivers/net/wireless/hostap/hostap_wlan.h index 7bb0b4b3f2c..57904015380 100644 --- a/drivers/net/wireless/hostap/hostap_wlan.h +++ b/drivers/net/wireless/hostap/hostap_wlan.h @@ -596,8 +596,7 @@ struct prism2_helper_functions { struct prism2_download_param *param); int (*tx)(struct sk_buff *skb, struct net_device *dev); int (*set_tim)(struct net_device *dev, int aid, int set); - int (*read_aux)(struct net_device *dev, unsigned addr, int len, - u8 *buf); + const struct file_operations *read_aux_fops; int need_tx_headroom; /* number of bytes of headroom needed before * IEEE 802.11 header */ 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 = { -- cgit v1.2.3 From c7f079ca30bc719f6f09524fb2119980c4b45d8f Mon Sep 17 00:00:00 2001 From: David Howells Date: Wed, 10 Apr 2013 13:33:21 +0100 Subject: megaraid: Don't use create_proc_read_entry() Don't use create_proc_read_entry() as that is deprecated, but rather use proc_create_data() and seq_file instead. Signed-off-by: David Howells cc: Neela Syam Kolli cc: James E.J. Bottomley cc: linux-scsi@vger.kernel.org Signed-off-by: Al Viro --- drivers/scsi/megaraid.c | 1040 +++++++++++++++++------------------------------ drivers/scsi/megaraid.h | 17 - 2 files changed, 382 insertions(+), 675 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index 9504ec0ec68..a1c90bd34e7 100644 --- a/drivers/scsi/megaraid.c +++ b/drivers/scsi/megaraid.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -2069,385 +2070,201 @@ mega_free_inquiry(void *inquiry, dma_addr_t dma_handle, struct pci_dev *pdev) #ifdef CONFIG_PROC_FS /* Following code handles /proc fs */ -#define CREATE_READ_PROC(string, func) create_proc_read_entry(string, \ - S_IRUSR | S_IFREG, \ - controller_proc_dir_entry, \ - func, adapter) - -/** - * mega_create_proc_entry() - * @index - index in soft state array - * @parent - parent node for this /proc entry - * - * Creates /proc entries for our controllers. - */ -static void -mega_create_proc_entry(int index, struct proc_dir_entry *parent) -{ - struct proc_dir_entry *controller_proc_dir_entry = NULL; - u8 string[64] = { 0 }; - adapter_t *adapter = hba_soft_state[index]; - - sprintf(string, "hba%d", adapter->host->host_no); - - controller_proc_dir_entry = - adapter->controller_proc_dir_entry = proc_mkdir(string, parent); - - if(!controller_proc_dir_entry) { - printk(KERN_WARNING "\nmegaraid: proc_mkdir failed\n"); - return; - } - adapter->proc_read = CREATE_READ_PROC("config", proc_read_config); - adapter->proc_stat = CREATE_READ_PROC("stat", proc_read_stat); - adapter->proc_mbox = CREATE_READ_PROC("mailbox", proc_read_mbox); -#if MEGA_HAVE_ENH_PROC - adapter->proc_rr = CREATE_READ_PROC("rebuild-rate", proc_rebuild_rate); - adapter->proc_battery = CREATE_READ_PROC("battery-status", - proc_battery); - - /* - * Display each physical drive on its channel - */ - adapter->proc_pdrvstat[0] = CREATE_READ_PROC("diskdrives-ch0", - proc_pdrv_ch0); - adapter->proc_pdrvstat[1] = CREATE_READ_PROC("diskdrives-ch1", - proc_pdrv_ch1); - adapter->proc_pdrvstat[2] = CREATE_READ_PROC("diskdrives-ch2", - proc_pdrv_ch2); - adapter->proc_pdrvstat[3] = CREATE_READ_PROC("diskdrives-ch3", - proc_pdrv_ch3); - - /* - * Display a set of up to 10 logical drive through each of following - * /proc entries - */ - adapter->proc_rdrvstat[0] = CREATE_READ_PROC("raiddrives-0-9", - proc_rdrv_10); - adapter->proc_rdrvstat[1] = CREATE_READ_PROC("raiddrives-10-19", - proc_rdrv_20); - adapter->proc_rdrvstat[2] = CREATE_READ_PROC("raiddrives-20-29", - proc_rdrv_30); - adapter->proc_rdrvstat[3] = CREATE_READ_PROC("raiddrives-30-39", - proc_rdrv_40); -#endif -} - - /** - * proc_read_config() - * @page - buffer to write the data in - * @start - where the actual data has been written in page - * @offset - same meaning as the read system call - * @count - same meaning as the read system call - * @eof - set if no more data needs to be returned - * @data - pointer to our soft state + * proc_show_config() + * @m - Synthetic file construction data + * @v - File iterator * * Display configuration information about the controller. */ static int -proc_read_config(char *page, char **start, off_t offset, int count, int *eof, - void *data) +proc_show_config(struct seq_file *m, void *v) { - adapter_t *adapter = (adapter_t *)data; - int len = 0; - - len += sprintf(page+len, "%s", MEGARAID_VERSION); + adapter_t *adapter = m->private; + seq_puts(m, MEGARAID_VERSION); if(adapter->product_info.product_name[0]) - len += sprintf(page+len, "%s\n", - adapter->product_info.product_name); - - len += sprintf(page+len, "Controller Type: "); + seq_printf(m, "%s\n", adapter->product_info.product_name); - if( adapter->flag & BOARD_MEMMAP ) { - len += sprintf(page+len, - "438/466/467/471/493/518/520/531/532\n"); - } - else { - len += sprintf(page+len, - "418/428/434\n"); - } + seq_puts(m, "Controller Type: "); - if(adapter->flag & BOARD_40LD) { - len += sprintf(page+len, - "Controller Supports 40 Logical Drives\n"); - } + if( adapter->flag & BOARD_MEMMAP ) + seq_puts(m, "438/466/467/471/493/518/520/531/532\n"); + else + seq_puts(m, "418/428/434\n"); - if(adapter->flag & BOARD_64BIT) { - len += sprintf(page+len, - "Controller capable of 64-bit memory addressing\n"); - } - if( adapter->has_64bit_addr ) { - len += sprintf(page+len, - "Controller using 64-bit memory addressing\n"); - } - else { - len += sprintf(page+len, - "Controller is not using 64-bit memory addressing\n"); - } + if(adapter->flag & BOARD_40LD) + seq_puts(m, "Controller Supports 40 Logical Drives\n"); - len += sprintf(page+len, "Base = %08lx, Irq = %d, ", adapter->base, - adapter->host->irq); - - len += sprintf(page+len, "Logical Drives = %d, Channels = %d\n", - adapter->numldrv, adapter->product_info.nchannels); - - len += sprintf(page+len, "Version =%s:%s, DRAM = %dMb\n", - adapter->fw_version, adapter->bios_version, - adapter->product_info.dram_size); - - len += sprintf(page+len, - "Controller Queue Depth = %d, Driver Queue Depth = %d\n", - adapter->product_info.max_commands, adapter->max_cmds); - - len += sprintf(page+len, "support_ext_cdb = %d\n", - adapter->support_ext_cdb); - len += sprintf(page+len, "support_random_del = %d\n", - adapter->support_random_del); - len += sprintf(page+len, "boot_ldrv_enabled = %d\n", - adapter->boot_ldrv_enabled); - len += sprintf(page+len, "boot_ldrv = %d\n", - adapter->boot_ldrv); - len += sprintf(page+len, "boot_pdrv_enabled = %d\n", - adapter->boot_pdrv_enabled); - len += sprintf(page+len, "boot_pdrv_ch = %d\n", - adapter->boot_pdrv_ch); - len += sprintf(page+len, "boot_pdrv_tgt = %d\n", - adapter->boot_pdrv_tgt); - len += sprintf(page+len, "quiescent = %d\n", - atomic_read(&adapter->quiescent)); - len += sprintf(page+len, "has_cluster = %d\n", - adapter->has_cluster); - - len += sprintf(page+len, "\nModule Parameters:\n"); - len += sprintf(page+len, "max_cmd_per_lun = %d\n", - max_cmd_per_lun); - len += sprintf(page+len, "max_sectors_per_io = %d\n", - max_sectors_per_io); - - *eof = 1; - - return len; + if(adapter->flag & BOARD_64BIT) + seq_puts(m, "Controller capable of 64-bit memory addressing\n"); + if( adapter->has_64bit_addr ) + seq_puts(m, "Controller using 64-bit memory addressing\n"); + else + seq_puts(m, "Controller is not using 64-bit memory addressing\n"); + + seq_printf(m, "Base = %08lx, Irq = %d, ", + adapter->base, adapter->host->irq); + + seq_printf(m, "Logical Drives = %d, Channels = %d\n", + adapter->numldrv, adapter->product_info.nchannels); + + seq_printf(m, "Version =%s:%s, DRAM = %dMb\n", + adapter->fw_version, adapter->bios_version, + adapter->product_info.dram_size); + + seq_printf(m, "Controller Queue Depth = %d, Driver Queue Depth = %d\n", + adapter->product_info.max_commands, adapter->max_cmds); + + seq_printf(m, "support_ext_cdb = %d\n", adapter->support_ext_cdb); + seq_printf(m, "support_random_del = %d\n", adapter->support_random_del); + seq_printf(m, "boot_ldrv_enabled = %d\n", adapter->boot_ldrv_enabled); + seq_printf(m, "boot_ldrv = %d\n", adapter->boot_ldrv); + seq_printf(m, "boot_pdrv_enabled = %d\n", adapter->boot_pdrv_enabled); + seq_printf(m, "boot_pdrv_ch = %d\n", adapter->boot_pdrv_ch); + seq_printf(m, "boot_pdrv_tgt = %d\n", adapter->boot_pdrv_tgt); + seq_printf(m, "quiescent = %d\n", + atomic_read(&adapter->quiescent)); + seq_printf(m, "has_cluster = %d\n", adapter->has_cluster); + + seq_puts(m, "\nModule Parameters:\n"); + seq_printf(m, "max_cmd_per_lun = %d\n", max_cmd_per_lun); + seq_printf(m, "max_sectors_per_io = %d\n", max_sectors_per_io); + return 0; } - - /** - * proc_read_stat() - * @page - buffer to write the data in - * @start - where the actual data has been written in page - * @offset - same meaning as the read system call - * @count - same meaning as the read system call - * @eof - set if no more data needs to be returned - * @data - pointer to our soft state + * proc_show_stat() + * @m - Synthetic file construction data + * @v - File iterator * - * Diaplay statistical information about the I/O activity. + * Display statistical information about the I/O activity. */ static int -proc_read_stat(char *page, char **start, off_t offset, int count, int *eof, - void *data) +proc_show_stat(struct seq_file *m, void *v) { - adapter_t *adapter; - int len; + adapter_t *adapter = m->private; +#if MEGA_HAVE_STATS int i; +#endif - i = 0; /* avoid compilation warnings */ - len = 0; - adapter = (adapter_t *)data; - - len = sprintf(page, "Statistical Information for this controller\n"); - len += sprintf(page+len, "pend_cmds = %d\n", - atomic_read(&adapter->pend_cmds)); + seq_puts(m, "Statistical Information for this controller\n"); + seq_printf(m, "pend_cmds = %d\n", atomic_read(&adapter->pend_cmds)); #if MEGA_HAVE_STATS for(i = 0; i < adapter->numldrv; i++) { - len += sprintf(page+len, "Logical Drive %d:\n", i); - - len += sprintf(page+len, - "\tReads Issued = %lu, Writes Issued = %lu\n", - adapter->nreads[i], adapter->nwrites[i]); - - len += sprintf(page+len, - "\tSectors Read = %lu, Sectors Written = %lu\n", - adapter->nreadblocks[i], adapter->nwriteblocks[i]); - - len += sprintf(page+len, - "\tRead errors = %lu, Write errors = %lu\n\n", - adapter->rd_errors[i], adapter->wr_errors[i]); + seq_printf(m, "Logical Drive %d:\n", i); + seq_printf(m, "\tReads Issued = %lu, Writes Issued = %lu\n", + adapter->nreads[i], adapter->nwrites[i]); + seq_printf(m, "\tSectors Read = %lu, Sectors Written = %lu\n", + adapter->nreadblocks[i], adapter->nwriteblocks[i]); + seq_printf(m, "\tRead errors = %lu, Write errors = %lu\n\n", + adapter->rd_errors[i], adapter->wr_errors[i]); } #else - len += sprintf(page+len, - "IO and error counters not compiled in driver.\n"); + seq_puts(m, "IO and error counters not compiled in driver.\n"); #endif - - *eof = 1; - - return len; + return 0; } /** - * proc_read_mbox() - * @page - buffer to write the data in - * @start - where the actual data has been written in page - * @offset - same meaning as the read system call - * @count - same meaning as the read system call - * @eof - set if no more data needs to be returned - * @data - pointer to our soft state + * proc_show_mbox() + * @m - Synthetic file construction data + * @v - File iterator * * Display mailbox information for the last command issued. This information * is good for debugging. */ static int -proc_read_mbox(char *page, char **start, off_t offset, int count, int *eof, - void *data) +proc_show_mbox(struct seq_file *m, void *v) { - - adapter_t *adapter = (adapter_t *)data; + adapter_t *adapter = m->private; volatile mbox_t *mbox = adapter->mbox; - int len = 0; - - len = sprintf(page, "Contents of Mail Box Structure\n"); - len += sprintf(page+len, " Fw Command = 0x%02x\n", - mbox->m_out.cmd); - len += sprintf(page+len, " Cmd Sequence = 0x%02x\n", - mbox->m_out.cmdid); - len += sprintf(page+len, " No of Sectors= %04d\n", - mbox->m_out.numsectors); - len += sprintf(page+len, " LBA = 0x%02x\n", - mbox->m_out.lba); - len += sprintf(page+len, " DTA = 0x%08x\n", - mbox->m_out.xferaddr); - len += sprintf(page+len, " Logical Drive= 0x%02x\n", - mbox->m_out.logdrv); - len += sprintf(page+len, " No of SG Elmt= 0x%02x\n", - mbox->m_out.numsgelements); - len += sprintf(page+len, " Busy = %01x\n", - mbox->m_in.busy); - len += sprintf(page+len, " Status = 0x%02x\n", - mbox->m_in.status); - - *eof = 1; - - return len; + + seq_puts(m, "Contents of Mail Box Structure\n"); + seq_printf(m, " Fw Command = 0x%02x\n", mbox->m_out.cmd); + seq_printf(m, " Cmd Sequence = 0x%02x\n", mbox->m_out.cmdid); + seq_printf(m, " No of Sectors= %04d\n", mbox->m_out.numsectors); + seq_printf(m, " LBA = 0x%02x\n", mbox->m_out.lba); + seq_printf(m, " DTA = 0x%08x\n", mbox->m_out.xferaddr); + seq_printf(m, " Logical Drive= 0x%02x\n", mbox->m_out.logdrv); + seq_printf(m, " No of SG Elmt= 0x%02x\n", mbox->m_out.numsgelements); + seq_printf(m, " Busy = %01x\n", mbox->m_in.busy); + seq_printf(m, " Status = 0x%02x\n", mbox->m_in.status); + return 0; } /** - * proc_rebuild_rate() - * @page - buffer to write the data in - * @start - where the actual data has been written in page - * @offset - same meaning as the read system call - * @count - same meaning as the read system call - * @eof - set if no more data needs to be returned - * @data - pointer to our soft state + * proc_show_rebuild_rate() + * @m - Synthetic file construction data + * @v - File iterator * * Display current rebuild rate */ static int -proc_rebuild_rate(char *page, char **start, off_t offset, int count, int *eof, - void *data) +proc_show_rebuild_rate(struct seq_file *m, void *v) { - adapter_t *adapter = (adapter_t *)data; + adapter_t *adapter = m->private; dma_addr_t dma_handle; caddr_t inquiry; struct pci_dev *pdev; - int len = 0; - if( make_local_pdev(adapter, &pdev) != 0 ) { - *eof = 1; - return len; - } + if( make_local_pdev(adapter, &pdev) != 0 ) + return 0; - if( (inquiry = mega_allocate_inquiry(&dma_handle, pdev)) == NULL ) { - free_local_pdev(pdev); - *eof = 1; - return len; - } + if( (inquiry = mega_allocate_inquiry(&dma_handle, pdev)) == NULL ) + goto free_pdev; if( mega_adapinq(adapter, dma_handle) != 0 ) { - - len = sprintf(page, "Adapter inquiry failed.\n"); - + seq_puts(m, "Adapter inquiry failed.\n"); printk(KERN_WARNING "megaraid: inquiry failed.\n"); - - mega_free_inquiry(inquiry, dma_handle, pdev); - - free_local_pdev(pdev); - - *eof = 1; - - return len; + goto free_inquiry; } - if( adapter->flag & BOARD_40LD ) { - len = sprintf(page, "Rebuild Rate: [%d%%]\n", - ((mega_inquiry3 *)inquiry)->rebuild_rate); - } - else { - len = sprintf(page, "Rebuild Rate: [%d%%]\n", + if( adapter->flag & BOARD_40LD ) + seq_printf(m, "Rebuild Rate: [%d%%]\n", + ((mega_inquiry3 *)inquiry)->rebuild_rate); + else + seq_printf(m, "Rebuild Rate: [%d%%]\n", ((mraid_ext_inquiry *) - inquiry)->raid_inq.adapter_info.rebuild_rate); - } - + inquiry)->raid_inq.adapter_info.rebuild_rate); +free_inquiry: mega_free_inquiry(inquiry, dma_handle, pdev); - +free_pdev: free_local_pdev(pdev); - - *eof = 1; - - return len; + return 0; } /** - * proc_battery() - * @page - buffer to write the data in - * @start - where the actual data has been written in page - * @offset - same meaning as the read system call - * @count - same meaning as the read system call - * @eof - set if no more data needs to be returned - * @data - pointer to our soft state + * proc_show_battery() + * @m - Synthetic file construction data + * @v - File iterator * * Display information about the battery module on the controller. */ static int -proc_battery(char *page, char **start, off_t offset, int count, int *eof, - void *data) +proc_show_battery(struct seq_file *m, void *v) { - adapter_t *adapter = (adapter_t *)data; + adapter_t *adapter = m->private; dma_addr_t dma_handle; caddr_t inquiry; struct pci_dev *pdev; - u8 battery_status = 0; - char str[256]; - int len = 0; + u8 battery_status; - if( make_local_pdev(adapter, &pdev) != 0 ) { - *eof = 1; - return len; - } + if( make_local_pdev(adapter, &pdev) != 0 ) + return 0; - if( (inquiry = mega_allocate_inquiry(&dma_handle, pdev)) == NULL ) { - free_local_pdev(pdev); - *eof = 1; - return len; - } + if( (inquiry = mega_allocate_inquiry(&dma_handle, pdev)) == NULL ) + goto free_pdev; if( mega_adapinq(adapter, dma_handle) != 0 ) { - - len = sprintf(page, "Adapter inquiry failed.\n"); - + seq_printf(m, "Adapter inquiry failed.\n"); printk(KERN_WARNING "megaraid: inquiry failed.\n"); - - mega_free_inquiry(inquiry, dma_handle, pdev); - - free_local_pdev(pdev); - - *eof = 1; - - return len; + goto free_inquiry; } if( adapter->flag & BOARD_40LD ) { @@ -2461,146 +2278,80 @@ proc_battery(char *page, char **start, off_t offset, int count, int *eof, /* * Decode the battery status */ - sprintf(str, "Battery Status:[%d]", battery_status); + seq_printf(m, "Battery Status:[%d]", battery_status); if(battery_status == MEGA_BATT_CHARGE_DONE) - strcat(str, " Charge Done"); + seq_puts(m, " Charge Done"); if(battery_status & MEGA_BATT_MODULE_MISSING) - strcat(str, " Module Missing"); + seq_puts(m, " Module Missing"); if(battery_status & MEGA_BATT_LOW_VOLTAGE) - strcat(str, " Low Voltage"); + seq_puts(m, " Low Voltage"); if(battery_status & MEGA_BATT_TEMP_HIGH) - strcat(str, " Temperature High"); + seq_puts(m, " Temperature High"); if(battery_status & MEGA_BATT_PACK_MISSING) - strcat(str, " Pack Missing"); + seq_puts(m, " Pack Missing"); if(battery_status & MEGA_BATT_CHARGE_INPROG) - strcat(str, " Charge In-progress"); + seq_puts(m, " Charge In-progress"); if(battery_status & MEGA_BATT_CHARGE_FAIL) - strcat(str, " Charge Fail"); + seq_puts(m, " Charge Fail"); if(battery_status & MEGA_BATT_CYCLES_EXCEEDED) - strcat(str, " Cycles Exceeded"); - - len = sprintf(page, "%s\n", str); + seq_puts(m, " Cycles Exceeded"); + seq_putc(m, '\n'); +free_inquiry: mega_free_inquiry(inquiry, dma_handle, pdev); - +free_pdev: free_local_pdev(pdev); - - *eof = 1; - - return len; -} - - -/** - * proc_pdrv_ch0() - * @page - buffer to write the data in - * @start - where the actual data has been written in page - * @offset - same meaning as the read system call - * @count - same meaning as the read system call - * @eof - set if no more data needs to be returned - * @data - pointer to our soft state - * - * Display information about the physical drives on physical channel 0. - */ -static int -proc_pdrv_ch0(char *page, char **start, off_t offset, int count, int *eof, - void *data) -{ - adapter_t *adapter = (adapter_t *)data; - - *eof = 1; - - return (proc_pdrv(adapter, page, 0)); -} - - -/** - * proc_pdrv_ch1() - * @page - buffer to write the data in - * @start - where the actual data has been written in page - * @offset - same meaning as the read system call - * @count - same meaning as the read system call - * @eof - set if no more data needs to be returned - * @data - pointer to our soft state - * - * Display information about the physical drives on physical channel 1. - */ -static int -proc_pdrv_ch1(char *page, char **start, off_t offset, int count, int *eof, - void *data) -{ - adapter_t *adapter = (adapter_t *)data; - - *eof = 1; - - return (proc_pdrv(adapter, page, 1)); + return 0; } -/** - * proc_pdrv_ch2() - * @page - buffer to write the data in - * @start - where the actual data has been written in page - * @offset - same meaning as the read system call - * @count - same meaning as the read system call - * @eof - set if no more data needs to be returned - * @data - pointer to our soft state - * - * Display information about the physical drives on physical channel 2. +/* + * Display scsi inquiry */ -static int -proc_pdrv_ch2(char *page, char **start, off_t offset, int count, int *eof, - void *data) +static void +mega_print_inquiry(struct seq_file *m, char *scsi_inq) { - adapter_t *adapter = (adapter_t *)data; - - *eof = 1; - - return (proc_pdrv(adapter, page, 2)); -} + int i; + seq_puts(m, " Vendor: "); + seq_write(m, scsi_inq + 8, 8); + seq_puts(m, " Model: "); + seq_write(m, scsi_inq + 16, 16); + seq_puts(m, " Rev: "); + seq_write(m, scsi_inq + 32, 4); + seq_putc(m, '\n'); -/** - * proc_pdrv_ch3() - * @page - buffer to write the data in - * @start - where the actual data has been written in page - * @offset - same meaning as the read system call - * @count - same meaning as the read system call - * @eof - set if no more data needs to be returned - * @data - pointer to our soft state - * - * Display information about the physical drives on physical channel 3. - */ -static int -proc_pdrv_ch3(char *page, char **start, off_t offset, int count, int *eof, - void *data) -{ - adapter_t *adapter = (adapter_t *)data; + i = scsi_inq[0] & 0x1f; + seq_printf(m, " Type: %s ", scsi_device_type(i)); - *eof = 1; + seq_printf(m, " ANSI SCSI revision: %02x", + scsi_inq[2] & 0x07); - return (proc_pdrv(adapter, page, 3)); + if( (scsi_inq[2] & 0x07) == 1 && (scsi_inq[3] & 0x0f) == 1 ) + seq_puts(m, " CCS\n"); + else + seq_putc(m, '\n'); } - /** - * proc_pdrv() + * proc_show_pdrv() + * @m - Synthetic file construction data * @page - buffer to write the data in * @adapter - pointer to our soft state * * Display information about the physical drives. */ static int -proc_pdrv(adapter_t *adapter, char *page, int channel) +proc_show_pdrv(struct seq_file *m, adapter_t *adapter, int channel) { dma_addr_t dma_handle; char *scsi_inq; @@ -2611,32 +2362,24 @@ proc_pdrv(adapter_t *adapter, char *page, int channel) u8 state; int tgt; int max_channels; - int len = 0; - char str[80]; int i; - if( make_local_pdev(adapter, &pdev) != 0 ) { - return len; - } + if( make_local_pdev(adapter, &pdev) != 0 ) + return 0; - if( (inquiry = mega_allocate_inquiry(&dma_handle, pdev)) == NULL ) { + if( (inquiry = mega_allocate_inquiry(&dma_handle, pdev)) == NULL ) goto free_pdev; - } if( mega_adapinq(adapter, dma_handle) != 0 ) { - len = sprintf(page, "Adapter inquiry failed.\n"); - + seq_puts(m, "Adapter inquiry failed.\n"); printk(KERN_WARNING "megaraid: inquiry failed.\n"); - goto free_inquiry; } scsi_inq = pci_alloc_consistent(pdev, 256, &scsi_inq_dma_handle); - if( scsi_inq == NULL ) { - len = sprintf(page, "memory not available for scsi inq.\n"); - + seq_puts(m, "memory not available for scsi inq.\n"); goto free_inquiry; } @@ -2659,39 +2402,31 @@ proc_pdrv(adapter_t *adapter, char *page, int channel) i = channel*16 + tgt; state = *(pdrv_state + i); - switch( state & 0x0F ) { - case PDRV_ONLINE: - sprintf(str, - "Channel:%2d Id:%2d State: Online", - channel, tgt); + seq_printf(m, "Channel:%2d Id:%2d State: Online", + channel, tgt); break; case PDRV_FAILED: - sprintf(str, - "Channel:%2d Id:%2d State: Failed", - channel, tgt); + seq_printf(m, "Channel:%2d Id:%2d State: Failed", + channel, tgt); break; case PDRV_RBLD: - sprintf(str, - "Channel:%2d Id:%2d State: Rebuild", - channel, tgt); + seq_printf(m, "Channel:%2d Id:%2d State: Rebuild", + channel, tgt); break; case PDRV_HOTSPARE: - sprintf(str, - "Channel:%2d Id:%2d State: Hot spare", - channel, tgt); + seq_printf(m, "Channel:%2d Id:%2d State: Hot spare", + channel, tgt); break; default: - sprintf(str, - "Channel:%2d Id:%2d State: Un-configured", - channel, tgt); + seq_printf(m, "Channel:%2d Id:%2d State: Un-configured", + channel, tgt); break; - } /* @@ -2710,11 +2445,8 @@ proc_pdrv(adapter_t *adapter, char *page, int channel) * Check for overflow. We print less than 240 * characters for inquiry */ - if( (len + 240) >= PAGE_SIZE ) break; - - len += sprintf(page+len, "%s.\n", str); - - len += mega_print_inquiry(page+len, scsi_inq); + seq_puts(m, ".\n"); + mega_print_inquiry(m, scsi_inq); } free_pci: @@ -2723,150 +2455,68 @@ free_inquiry: mega_free_inquiry(inquiry, dma_handle, pdev); free_pdev: free_local_pdev(pdev); - - return len; -} - - -/* - * Display scsi inquiry - */ -static int -mega_print_inquiry(char *page, char *scsi_inq) -{ - int len = 0; - int i; - - len = sprintf(page, " Vendor: "); - for( i = 8; i < 16; i++ ) { - len += sprintf(page+len, "%c", scsi_inq[i]); - } - - len += sprintf(page+len, " Model: "); - - for( i = 16; i < 32; i++ ) { - len += sprintf(page+len, "%c", scsi_inq[i]); - } - - len += sprintf(page+len, " Rev: "); - - for( i = 32; i < 36; i++ ) { - len += sprintf(page+len, "%c", scsi_inq[i]); - } - - len += sprintf(page+len, "\n"); - - i = scsi_inq[0] & 0x1f; - - len += sprintf(page+len, " Type: %s ", scsi_device_type(i)); - - len += sprintf(page+len, - " ANSI SCSI revision: %02x", scsi_inq[2] & 0x07); - - if( (scsi_inq[2] & 0x07) == 1 && (scsi_inq[3] & 0x0f) == 1 ) - len += sprintf(page+len, " CCS\n"); - else - len += sprintf(page+len, "\n"); - - return len; + return 0; } - /** - * proc_rdrv_10() - * @page - buffer to write the data in - * @start - where the actual data has been written in page - * @offset - same meaning as the read system call - * @count - same meaning as the read system call - * @eof - set if no more data needs to be returned - * @data - pointer to our soft state + * proc_show_pdrv_ch0() + * @m - Synthetic file construction data + * @v - File iterator * - * Display real time information about the logical drives 0 through 9. + * Display information about the physical drives on physical channel 0. */ static int -proc_rdrv_10(char *page, char **start, off_t offset, int count, int *eof, - void *data) +proc_show_pdrv_ch0(struct seq_file *m, void *v) { - adapter_t *adapter = (adapter_t *)data; - - *eof = 1; - - return (proc_rdrv(adapter, page, 0, 9)); + return proc_show_pdrv(m, m->private, 0); } /** - * proc_rdrv_20() - * @page - buffer to write the data in - * @start - where the actual data has been written in page - * @offset - same meaning as the read system call - * @count - same meaning as the read system call - * @eof - set if no more data needs to be returned - * @data - pointer to our soft state + * proc_show_pdrv_ch1() + * @m - Synthetic file construction data + * @v - File iterator * - * Display real time information about the logical drives 0 through 9. + * Display information about the physical drives on physical channel 1. */ static int -proc_rdrv_20(char *page, char **start, off_t offset, int count, int *eof, - void *data) +proc_show_pdrv_ch1(struct seq_file *m, void *v) { - adapter_t *adapter = (adapter_t *)data; - - *eof = 1; - - return (proc_rdrv(adapter, page, 10, 19)); + return proc_show_pdrv(m, m->private, 1); } /** - * proc_rdrv_30() - * @page - buffer to write the data in - * @start - where the actual data has been written in page - * @offset - same meaning as the read system call - * @count - same meaning as the read system call - * @eof - set if no more data needs to be returned - * @data - pointer to our soft state + * proc_show_pdrv_ch2() + * @m - Synthetic file construction data + * @v - File iterator * - * Display real time information about the logical drives 0 through 9. + * Display information about the physical drives on physical channel 2. */ static int -proc_rdrv_30(char *page, char **start, off_t offset, int count, int *eof, - void *data) +proc_show_pdrv_ch2(struct seq_file *m, void *v) { - adapter_t *adapter = (adapter_t *)data; - - *eof = 1; - - return (proc_rdrv(adapter, page, 20, 29)); + return proc_show_pdrv(m, m->private, 2); } /** - * proc_rdrv_40() - * @page - buffer to write the data in - * @start - where the actual data has been written in page - * @offset - same meaning as the read system call - * @count - same meaning as the read system call - * @eof - set if no more data needs to be returned - * @data - pointer to our soft state + * proc_show_pdrv_ch3() + * @m - Synthetic file construction data + * @v - File iterator * - * Display real time information about the logical drives 0 through 9. + * Display information about the physical drives on physical channel 3. */ static int -proc_rdrv_40(char *page, char **start, off_t offset, int count, int *eof, - void *data) +proc_show_pdrv_ch3(struct seq_file *m, void *v) { - adapter_t *adapter = (adapter_t *)data; - - *eof = 1; - - return (proc_rdrv(adapter, page, 30, 39)); + return proc_show_pdrv(m, m->private, 3); } /** - * proc_rdrv() - * @page - buffer to write the data in + * proc_show_rdrv() + * @m - Synthetic file construction data * @adapter - pointer to our soft state * @start - starting logical drive to display * @end - ending logical drive to display @@ -2875,7 +2525,7 @@ proc_rdrv_40(char *page, char **start, off_t offset, int count, int *eof, * /proc/scsi/scsi interface */ static int -proc_rdrv(adapter_t *adapter, char *page, int start, int end ) +proc_show_rdrv(struct seq_file *m, adapter_t *adapter, int start, int end ) { dma_addr_t dma_handle; logdrv_param *lparam; @@ -2887,29 +2537,18 @@ proc_rdrv(adapter_t *adapter, char *page, int start, int end ) u8 *rdrv_state; int num_ldrv; u32 array_sz; - int len = 0; int i; - if( make_local_pdev(adapter, &pdev) != 0 ) { - return len; - } + if( make_local_pdev(adapter, &pdev) != 0 ) + return 0; - if( (inquiry = mega_allocate_inquiry(&dma_handle, pdev)) == NULL ) { - free_local_pdev(pdev); - return len; - } + if( (inquiry = mega_allocate_inquiry(&dma_handle, pdev)) == NULL ) + goto free_pdev; if( mega_adapinq(adapter, dma_handle) != 0 ) { - - len = sprintf(page, "Adapter inquiry failed.\n"); - + seq_puts(m, "Adapter inquiry failed.\n"); printk(KERN_WARNING "megaraid: inquiry failed.\n"); - - mega_free_inquiry(inquiry, dma_handle, pdev); - - free_local_pdev(pdev); - - return len; + goto free_inquiry; } memset(&mc, 0, sizeof(megacmd_t)); @@ -2935,13 +2574,8 @@ proc_rdrv(adapter_t *adapter, char *page, int start, int end ) &disk_array_dma_handle); if( disk_array == NULL ) { - len = sprintf(page, "memory not available.\n"); - - mega_free_inquiry(inquiry, dma_handle, pdev); - - free_local_pdev(pdev); - - return len; + seq_puts(m, "memory not available.\n"); + goto free_inquiry; } mc.xferaddr = (u32)disk_array_dma_handle; @@ -2951,17 +2585,8 @@ proc_rdrv(adapter_t *adapter, char *page, int start, int end ) mc.opcode = OP_DCMD_READ_CONFIG; if( mega_internal_command(adapter, &mc, NULL) ) { - - len = sprintf(page, "40LD read config failed.\n"); - - mega_free_inquiry(inquiry, dma_handle, pdev); - - pci_free_consistent(pdev, array_sz, disk_array, - disk_array_dma_handle); - - free_local_pdev(pdev); - - return len; + seq_puts(m, "40LD read config failed.\n"); + goto free_pci; } } @@ -2969,24 +2594,10 @@ proc_rdrv(adapter_t *adapter, char *page, int start, int end ) mc.cmd = NEW_READ_CONFIG_8LD; if( mega_internal_command(adapter, &mc, NULL) ) { - mc.cmd = READ_CONFIG_8LD; - - if( mega_internal_command(adapter, &mc, - NULL) ){ - - len = sprintf(page, - "8LD read config failed.\n"); - - mega_free_inquiry(inquiry, dma_handle, pdev); - - pci_free_consistent(pdev, array_sz, - disk_array, - disk_array_dma_handle); - - free_local_pdev(pdev); - - return len; + if( mega_internal_command(adapter, &mc, NULL) ) { + seq_puts(m, "8LD read config failed.\n"); + goto free_pci; } } } @@ -3006,29 +2617,23 @@ proc_rdrv(adapter_t *adapter, char *page, int start, int end ) * Check for overflow. We print less than 240 characters for * information about each logical drive. */ - if( (len + 240) >= PAGE_SIZE ) break; - - len += sprintf(page+len, "Logical drive:%2d:, ", i); + seq_printf(m, "Logical drive:%2d:, ", i); switch( rdrv_state[i] & 0x0F ) { case RDRV_OFFLINE: - len += sprintf(page+len, "state: offline"); + seq_puts(m, "state: offline"); break; - case RDRV_DEGRADED: - len += sprintf(page+len, "state: degraded"); + seq_puts(m, "state: degraded"); break; - case RDRV_OPTIMAL: - len += sprintf(page+len, "state: optimal"); + seq_puts(m, "state: optimal"); break; - case RDRV_DELETED: - len += sprintf(page+len, "state: deleted"); + seq_puts(m, "state: deleted"); break; - default: - len += sprintf(page+len, "state: unknown"); + seq_puts(m, "state: unknown"); break; } @@ -3036,84 +2641,203 @@ proc_rdrv(adapter_t *adapter, char *page, int start, int end ) * Check if check consistency or initialization is going on * for this logical drive. */ - if( (rdrv_state[i] & 0xF0) == 0x20 ) { - len += sprintf(page+len, - ", check-consistency in progress"); - } - else if( (rdrv_state[i] & 0xF0) == 0x10 ) { - len += sprintf(page+len, - ", initialization in progress"); - } + if( (rdrv_state[i] & 0xF0) == 0x20 ) + seq_puts(m, ", check-consistency in progress"); + else if( (rdrv_state[i] & 0xF0) == 0x10 ) + seq_puts(m, ", initialization in progress"); - len += sprintf(page+len, "\n"); - - len += sprintf(page+len, "Span depth:%3d, ", - lparam->span_depth); - - len += sprintf(page+len, "RAID level:%3d, ", - lparam->level); - - len += sprintf(page+len, "Stripe size:%3d, ", - lparam->stripe_sz ? lparam->stripe_sz/2: 128); - - len += sprintf(page+len, "Row size:%3d\n", - lparam->row_size); + seq_putc(m, '\n'); + seq_printf(m, "Span depth:%3d, ", lparam->span_depth); + seq_printf(m, "RAID level:%3d, ", lparam->level); + seq_printf(m, "Stripe size:%3d, ", + lparam->stripe_sz ? lparam->stripe_sz/2: 128); + seq_printf(m, "Row size:%3d\n", lparam->row_size); - len += sprintf(page+len, "Read Policy: "); - + seq_puts(m, "Read Policy: "); switch(lparam->read_ahead) { - case NO_READ_AHEAD: - len += sprintf(page+len, "No read ahead, "); + seq_puts(m, "No read ahead, "); break; - case READ_AHEAD: - len += sprintf(page+len, "Read ahead, "); + seq_puts(m, "Read ahead, "); break; - case ADAP_READ_AHEAD: - len += sprintf(page+len, "Adaptive, "); + seq_puts(m, "Adaptive, "); break; } - len += sprintf(page+len, "Write Policy: "); - + seq_puts(m, "Write Policy: "); switch(lparam->write_mode) { - case WRMODE_WRITE_THRU: - len += sprintf(page+len, "Write thru, "); + seq_puts(m, "Write thru, "); break; - case WRMODE_WRITE_BACK: - len += sprintf(page+len, "Write back, "); + seq_puts(m, "Write back, "); break; } - len += sprintf(page+len, "Cache Policy: "); - + seq_puts(m, "Cache Policy: "); switch(lparam->direct_io) { - case CACHED_IO: - len += sprintf(page+len, "Cached IO\n\n"); + seq_puts(m, "Cached IO\n\n"); break; - case DIRECT_IO: - len += sprintf(page+len, "Direct IO\n\n"); + seq_puts(m, "Direct IO\n\n"); break; } } - mega_free_inquiry(inquiry, dma_handle, pdev); - +free_pci: pci_free_consistent(pdev, array_sz, disk_array, disk_array_dma_handle); - +free_inquiry: + mega_free_inquiry(inquiry, dma_handle, pdev); +free_pdev: free_local_pdev(pdev); + return 0; +} + +/** + * proc_show_rdrv_10() + * @m - Synthetic file construction data + * @v - File iterator + * + * Display real time information about the logical drives 0 through 9. + */ +static int +proc_show_rdrv_10(struct seq_file *m, void *v) +{ + return proc_show_rdrv(m, m->private, 0, 9); +} - return len; + +/** + * proc_show_rdrv_20() + * @m - Synthetic file construction data + * @v - File iterator + * + * Display real time information about the logical drives 0 through 9. + */ +static int +proc_show_rdrv_20(struct seq_file *m, void *v) +{ + return proc_show_rdrv(m, m->private, 10, 19); +} + + +/** + * proc_show_rdrv_30() + * @m - Synthetic file construction data + * @v - File iterator + * + * Display real time information about the logical drives 0 through 9. + */ +static int +proc_show_rdrv_30(struct seq_file *m, void *v) +{ + return proc_show_rdrv(m, m->private, 20, 29); } + + +/** + * proc_show_rdrv_40() + * @m - Synthetic file construction data + * @v - File iterator + * + * Display real time information about the logical drives 0 through 9. + */ +static int +proc_show_rdrv_40(struct seq_file *m, void *v) +{ + return proc_show_rdrv(m, m->private, 30, 39); +} + + +/* + * seq_file wrappers for procfile show routines. + */ +static int mega_proc_open(struct inode *inode, struct file *file) +{ + adapter_t *adapter = PDE(inode)->parent->data; + int (*show)(struct seq_file *, void *) = PDE_DATA(inode); + + return single_open(file, show, adapter); +} + +static const struct file_operations mega_proc_fops = { + .open = mega_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + +/* + * Table of proc files we need to create. + */ +struct mega_proc_file { + const char *name; + unsigned short ptr_offset; + int (*show) (struct seq_file *m, void *v); +}; + +static const struct mega_proc_file mega_proc_files[] = { + { "config", offsetof(adapter_t, proc_read), proc_show_config }, + { "stat", offsetof(adapter_t, proc_stat), proc_show_stat }, + { "mailbox", offsetof(adapter_t, proc_mbox), proc_show_mbox }, +#if MEGA_HAVE_ENH_PROC + { "rebuild-rate", offsetof(adapter_t, proc_rr), proc_show_rebuild_rate }, + { "battery-status", offsetof(adapter_t, proc_battery), proc_show_battery }, + { "diskdrives-ch0", offsetof(adapter_t, proc_pdrvstat[0]), proc_show_pdrv_ch0 }, + { "diskdrives-ch1", offsetof(adapter_t, proc_pdrvstat[1]), proc_show_pdrv_ch1 }, + { "diskdrives-ch2", offsetof(adapter_t, proc_pdrvstat[2]), proc_show_pdrv_ch2 }, + { "diskdrives-ch3", offsetof(adapter_t, proc_pdrvstat[3]), proc_show_pdrv_ch3 }, + { "raiddrives-0-9", offsetof(adapter_t, proc_rdrvstat[0]), proc_show_rdrv_10 }, + { "raiddrives-10-19", offsetof(adapter_t, proc_rdrvstat[1]), proc_show_rdrv_20 }, + { "raiddrives-20-29", offsetof(adapter_t, proc_rdrvstat[2]), proc_show_rdrv_30 }, + { "raiddrives-30-39", offsetof(adapter_t, proc_rdrvstat[3]), proc_show_rdrv_40 }, +#endif + { NULL } +}; + +/** + * mega_create_proc_entry() + * @index - index in soft state array + * @parent - parent node for this /proc entry + * + * Creates /proc entries for our controllers. + */ +static void +mega_create_proc_entry(int index, struct proc_dir_entry *parent) +{ + const struct mega_proc_file *f; + adapter_t *adapter = hba_soft_state[index]; + struct proc_dir_entry *dir, *de, **ppde; + u8 string[16]; + + sprintf(string, "hba%d", adapter->host->host_no); + + dir = adapter->controller_proc_dir_entry = proc_mkdir(string, parent); + if(!dir) { + printk(KERN_WARNING "\nmegaraid: proc_mkdir failed\n"); + return; + } + dir->data = adapter; + + for (f = mega_proc_files; f->name; f++) { + de = proc_create_data(f->name, S_IRUSR, dir, &mega_proc_fops, + f->show); + if (!de) { + printk(KERN_WARNING "\nmegaraid: proc_create failed\n"); + return; + } + + ppde = (void *)adapter + f->ptr_offset; + *ppde = de; + } +} + #else static inline void mega_create_proc_entry(int index, struct proc_dir_entry *parent) { diff --git a/drivers/scsi/megaraid.h b/drivers/scsi/megaraid.h index 4fb2adf6b80..4d0ce4e78df 100644 --- a/drivers/scsi/megaraid.h +++ b/drivers/scsi/megaraid.h @@ -987,24 +987,7 @@ static int mega_init_scb (adapter_t *); static int mega_is_bios_enabled (adapter_t *); #ifdef CONFIG_PROC_FS -static int mega_print_inquiry(char *, char *); static void mega_create_proc_entry(int, struct proc_dir_entry *); -static int proc_read_config(char *, char **, off_t, int, int *, void *); -static int proc_read_stat(char *, char **, off_t, int, int *, void *); -static int proc_read_mbox(char *, char **, off_t, int, int *, void *); -static int proc_rebuild_rate(char *, char **, off_t, int, int *, void *); -static int proc_battery(char *, char **, off_t, int, int *, void *); -static int proc_pdrv_ch0(char *, char **, off_t, int, int *, void *); -static int proc_pdrv_ch1(char *, char **, off_t, int, int *, void *); -static int proc_pdrv_ch2(char *, char **, off_t, int, int *, void *); -static int proc_pdrv_ch3(char *, char **, off_t, int, int *, void *); -static int proc_pdrv(adapter_t *, char *, int); -static int proc_rdrv_10(char *, char **, off_t, int, int *, void *); -static int proc_rdrv_20(char *, char **, off_t, int, int *, void *); -static int proc_rdrv_30(char *, char **, off_t, int, int *, void *); -static int proc_rdrv_40(char *, char **, off_t, int, int *, void *); -static int proc_rdrv(adapter_t *, char *, int, int); - static int mega_adapinq(adapter_t *, dma_addr_t); static int mega_internal_dev_inquiry(adapter_t *, u8, u8, dma_addr_t); #endif -- cgit v1.2.3 From 0d01ff2583086fd532181d2ee16112f5342eb78d Mon Sep 17 00:00:00 2001 From: David Howells Date: Thu, 11 Apr 2013 23:51:01 +0100 Subject: Include missing linux/slab.h inclusions Include missing linux/slab.h inclusions where the source file is currently expecting to get kmalloc() and co. through linux/proc_fs.h. Signed-off-by: David Howells Acked-by: Greg Kroah-Hartman cc: linux-s390@vger.kernel.org cc: sparclinux@vger.kernel.org cc: linux-efi@vger.kernel.org cc: linux-mtd@lists.infradead.org cc: devel@driverdev.osuosl.org cc: x86@kernel.org Signed-off-by: Al Viro --- drivers/mtd/mtdcore.c | 1 + drivers/pps/clients/pps_parport.c | 1 + drivers/staging/dgrp/dgrp_dpa_ops.c | 1 + drivers/staging/dgrp/dgrp_mon_ops.c | 1 + drivers/staging/dgrp/dgrp_net_ops.c | 2 +- drivers/staging/dgrp/dgrp_specproc.c | 1 + 6 files changed, 6 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index 61d5f56473e..322ca65b0cc 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include diff --git a/drivers/pps/clients/pps_parport.c b/drivers/pps/clients/pps_parport.c index e1b4705ae3e..38a8bbe7481 100644 --- a/drivers/pps/clients/pps_parport.c +++ b/drivers/pps/clients/pps_parport.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include diff --git a/drivers/staging/dgrp/dgrp_dpa_ops.c b/drivers/staging/dgrp/dgrp_dpa_ops.c index 43209c163a4..1fc13de4bdd 100644 --- a/drivers/staging/dgrp/dgrp_dpa_ops.c +++ b/drivers/staging/dgrp/dgrp_dpa_ops.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include "dgrp_common.h" diff --git a/drivers/staging/dgrp/dgrp_mon_ops.c b/drivers/staging/dgrp/dgrp_mon_ops.c index 6edbbf06915..d18be4180e3 100644 --- a/drivers/staging/dgrp/dgrp_mon_ops.c +++ b/drivers/staging/dgrp/dgrp_mon_ops.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include diff --git a/drivers/staging/dgrp/dgrp_net_ops.c b/drivers/staging/dgrp/dgrp_net_ops.c index 5448fc78bca..9914f1c5bcd 100644 --- a/drivers/staging/dgrp/dgrp_net_ops.c +++ b/drivers/staging/dgrp/dgrp_net_ops.c @@ -35,7 +35,7 @@ #include #include -#include +#include #include #include #include diff --git a/drivers/staging/dgrp/dgrp_specproc.c b/drivers/staging/dgrp/dgrp_specproc.c index b990b2686ba..205d80ef445 100644 --- a/drivers/staging/dgrp/dgrp_specproc.c +++ b/drivers/staging/dgrp/dgrp_specproc.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include -- cgit v1.2.3 From 303eb7e2c982fda734455f068633241db89d3175 Mon Sep 17 00:00:00 2001 From: David Howells Date: Thu, 11 Apr 2013 23:55:54 +0100 Subject: Include missing linux/magic.h inclusions Include missing linux/magic.h inclusions where the source file is currently expecting to get magic numbers through linux/proc_fs.h. Signed-off-by: David Howells cc: linux-efi@vger.kernel.org Signed-off-by: Al Viro --- drivers/firmware/efivars.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c index 7acafb80fd4..0f1026019c0 100644 --- a/drivers/firmware/efivars.c +++ b/drivers/firmware/efivars.c @@ -80,6 +80,7 @@ #include #include #include +#include #include #include -- cgit v1.2.3 From 271a15eabe094538d958dc68ccfc9c36b699247a Mon Sep 17 00:00:00 2001 From: David Howells Date: Fri, 12 Apr 2013 00:38:51 +0100 Subject: proc: Supply PDE attribute setting accessor functions Supply accessor functions to set attributes in proc_dir_entry structs. The following are supplied: proc_set_size() and proc_set_user(). Signed-off-by: David Howells Acked-by: Mauro Carvalho Chehab cc: linuxppc-dev@lists.ozlabs.org cc: linux-media@vger.kernel.org cc: netdev@vger.kernel.org cc: linux-wireless@vger.kernel.org cc: linux-pci@vger.kernel.org cc: netfilter-devel@vger.kernel.org cc: alsa-devel@alsa-project.org Signed-off-by: Al Viro --- drivers/media/pci/ttpci/av7110_ir.c | 2 +- drivers/net/irda/vlsi_ir.c | 2 +- drivers/net/wireless/airo.c | 34 +++++++++++----------------------- drivers/pci/proc.c | 2 +- drivers/pnp/isapnp/proc.c | 2 +- drivers/zorro/proc.c | 2 +- 6 files changed, 16 insertions(+), 28 deletions(-) (limited to 'drivers') diff --git a/drivers/media/pci/ttpci/av7110_ir.c b/drivers/media/pci/ttpci/av7110_ir.c index eb822862a64..0e763a784e2 100644 --- a/drivers/media/pci/ttpci/av7110_ir.c +++ b/drivers/media/pci/ttpci/av7110_ir.c @@ -375,7 +375,7 @@ int av7110_ir_init(struct av7110 *av7110) if (av_cnt == 1) { e = proc_create("av7110_ir", S_IWUSR, NULL, &av7110_ir_proc_fops); if (e) - e->size = 4 + 256 * sizeof(u16); + proc_set_size(e, 4 + 256 * sizeof(u16)); } tasklet_init(&av7110->ir.ir_tasklet, av7110_emit_key, (unsigned long) &av7110->ir); diff --git a/drivers/net/irda/vlsi_ir.c b/drivers/net/irda/vlsi_ir.c index e22cd4e7017..5f4758492e4 100644 --- a/drivers/net/irda/vlsi_ir.c +++ b/drivers/net/irda/vlsi_ir.c @@ -1678,7 +1678,7 @@ vlsi_irda_probe(struct pci_dev *pdev, const struct pci_device_id *id) IRDA_WARNING("%s: failed to create proc entry\n", __func__); } else { - ent->size = 0; + proc_set_size(ent, 0); } idev->proc_entry = ent; } diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c index 66e398d4730..21d02335b46 100644 --- a/drivers/net/wireless/airo.c +++ b/drivers/net/wireless/airo.c @@ -4507,73 +4507,63 @@ static int setup_proc_entry( struct net_device *dev, airo_entry); if (!apriv->proc_entry) goto fail; - apriv->proc_entry->uid = proc_kuid; - apriv->proc_entry->gid = proc_kgid; + proc_set_user(apriv->proc_entry, proc_kuid, proc_kgid); /* Setup the StatsDelta */ entry = proc_create_data("StatsDelta", S_IRUGO & proc_perm, apriv->proc_entry, &proc_statsdelta_ops, dev); if (!entry) goto fail_stats_delta; - entry->uid = proc_kuid; - entry->gid = proc_kgid; + proc_set_user(entry, proc_kuid, proc_kgid); /* Setup the Stats */ entry = proc_create_data("Stats", S_IRUGO & proc_perm, apriv->proc_entry, &proc_stats_ops, dev); if (!entry) goto fail_stats; - entry->uid = proc_kuid; - entry->gid = proc_kgid; + proc_set_user(entry, proc_kuid, proc_kgid); /* Setup the Status */ entry = proc_create_data("Status", S_IRUGO & proc_perm, apriv->proc_entry, &proc_status_ops, dev); if (!entry) goto fail_status; - entry->uid = proc_kuid; - entry->gid = proc_kgid; + proc_set_user(entry, proc_kuid, proc_kgid); /* Setup the Config */ entry = proc_create_data("Config", proc_perm, apriv->proc_entry, &proc_config_ops, dev); if (!entry) goto fail_config; - entry->uid = proc_kuid; - entry->gid = proc_kgid; + proc_set_user(entry, proc_kuid, proc_kgid); /* Setup the SSID */ entry = proc_create_data("SSID", proc_perm, apriv->proc_entry, &proc_SSID_ops, dev); if (!entry) goto fail_ssid; - entry->uid = proc_kuid; - entry->gid = proc_kgid; + proc_set_user(entry, proc_kuid, proc_kgid); /* Setup the APList */ entry = proc_create_data("APList", proc_perm, apriv->proc_entry, &proc_APList_ops, dev); if (!entry) goto fail_aplist; - entry->uid = proc_kuid; - entry->gid = proc_kgid; + proc_set_user(entry, proc_kuid, proc_kgid); /* Setup the BSSList */ entry = proc_create_data("BSSList", proc_perm, apriv->proc_entry, &proc_BSSList_ops, dev); if (!entry) goto fail_bsslist; - entry->uid = proc_kuid; - entry->gid = proc_kgid; + proc_set_user(entry, proc_kuid, proc_kgid); /* Setup the WepKey */ entry = proc_create_data("WepKey", proc_perm, apriv->proc_entry, &proc_wepkey_ops, dev); if (!entry) goto fail_wepkey; - entry->uid = proc_kuid; - entry->gid = proc_kgid; - + proc_set_user(entry, proc_kuid, proc_kgid); return 0; fail_wepkey: @@ -5695,10 +5685,8 @@ static int __init airo_init_module( void ) airo_entry = proc_mkdir_mode("driver/aironet", airo_perm, NULL); - if (airo_entry) { - airo_entry->uid = proc_kuid; - airo_entry->gid = proc_kgid; - } + if (airo_entry) + proc_set_user(airo_entry, proc_kuid, proc_kgid); for (i = 0; i < 4 && io[i] && irq[i]; i++) { airo_print_info("", "Trying to configure ISA adapter at irq=%d " diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c index 12e4fb5824c..7cde7c131fd 100644 --- a/drivers/pci/proc.c +++ b/drivers/pci/proc.c @@ -419,7 +419,7 @@ int pci_proc_attach_device(struct pci_dev *dev) &proc_bus_pci_operations, dev); if (!e) return -ENOMEM; - e->size = dev->cfg_size; + proc_set_size(e, dev->cfg_size); dev->procent = e; return 0; diff --git a/drivers/pnp/isapnp/proc.c b/drivers/pnp/isapnp/proc.c index af4d40affb7..2365ef37ae2 100644 --- a/drivers/pnp/isapnp/proc.c +++ b/drivers/pnp/isapnp/proc.c @@ -105,7 +105,7 @@ static int isapnp_proc_attach_device(struct pnp_dev *dev) &isapnp_proc_bus_file_operations, dev); if (!e) return -ENOMEM; - e->size = 256; + proc_set_size(e, 256); return 0; } diff --git a/drivers/zorro/proc.c b/drivers/zorro/proc.c index 6d3a602c004..1c15ee7456b 100644 --- a/drivers/zorro/proc.c +++ b/drivers/zorro/proc.c @@ -139,7 +139,7 @@ static int __init zorro_proc_attach_device(unsigned int slot) &zorro_autocon[slot]); if (!entry) return -ENOMEM; - entry->size = sizeof(struct zorro_dev); + proc_set_size(entry, sizeof(struct zorro_dev)); return 0; } -- cgit v1.2.3 From 270b5ac2151707c25d3327722c5badfbd95945bc Mon Sep 17 00:00:00 2001 From: David Howells Date: Fri, 12 Apr 2013 02:48:30 +0100 Subject: proc: Add proc_mkdir_data() Add proc_mkdir_data() to allow procfs directories to be created that are annotated at the time of creation with private data rather than doing this post-creation. This means no access is then required to the proc_dir_entry struct to set this. Signed-off-by: David Howells Acked-by: Mauro Carvalho Chehab Acked-by: Greg Kroah-Hartman cc: Neela Syam Kolli cc: Jerry Chuang cc: linux-scsi@vger.kernel.org cc: devel@driverdev.osuosl.org cc: linux-wireless@vger.kernel.org Signed-off-by: Al Viro --- drivers/message/i2o/i2o_proc.c | 8 ++------ drivers/scsi/megaraid.c | 4 ++-- drivers/staging/rtl8192u/r8192U_core.c | 3 +-- 3 files changed, 5 insertions(+), 10 deletions(-) (limited to 'drivers') diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c index 70a840f9b28..b7d87cd227a 100644 --- a/drivers/message/i2o/i2o_proc.c +++ b/drivers/message/i2o/i2o_proc.c @@ -1913,14 +1913,12 @@ static void i2o_proc_device_add(struct proc_dir_entry *dir, osm_debug("adding device /proc/i2o/%s/%s\n", dev->iop->name, buff); - devdir = proc_mkdir(buff, dir); + devdir = proc_mkdir_data(buff, 0, dir, dev); if (!devdir) { osm_warn("Could not allocate procdir!\n"); return; } - devdir->data = dev; - i2o_proc_create_entries(devdir, generic_dev_entries, dev); /* Inform core that we want updates about this device's status */ @@ -1954,12 +1952,10 @@ static int i2o_proc_iop_add(struct proc_dir_entry *dir, osm_debug("adding IOP /proc/i2o/%s\n", c->name); - iopdir = proc_mkdir(c->name, dir); + iopdir = proc_mkdir_data(c->name, 0, dir, c); if (!iopdir) return -1; - iopdir->data = c; - i2o_proc_create_entries(iopdir, i2o_proc_generic_iop_entries, c); list_for_each_entry(dev, &c->devices, list) diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index a1c90bd34e7..ef3384d39e1 100644 --- a/drivers/scsi/megaraid.c +++ b/drivers/scsi/megaraid.c @@ -2818,12 +2818,12 @@ mega_create_proc_entry(int index, struct proc_dir_entry *parent) sprintf(string, "hba%d", adapter->host->host_no); - dir = adapter->controller_proc_dir_entry = proc_mkdir(string, parent); + dir = adapter->controller_proc_dir_entry = + proc_mkdir_data(string, 0, parent, adapter); if(!dir) { printk(KERN_WARNING "\nmegaraid: proc_mkdir failed\n"); return; } - dir->data = adapter; for (f = mega_proc_files; f->name; f++) { de = proc_create_data(f->name, S_IRUSR, dir, &mega_proc_fops, diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 433c3df95de..d81d7d55f25 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -672,13 +672,12 @@ void rtl8192_proc_init_one(struct net_device *dev) struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); if (rtl8192_proc) { - priv->dir_dev = proc_mkdir(dev->name, rtl8192_proc); + priv->dir_dev = proc_mkdir_data(dev->name, 0, rtl8192_proc, dev); if (!priv->dir_dev) { RT_TRACE(COMP_ERR, "Unable to initialize /proc/net/rtl8192/%s\n", dev->name); return; } - priv->dir_dev->data = dev; for (f = rtl8192_proc_files; f->name[0]; f++) { if (!proc_create_data(f->name, S_IFREG | S_IRUGO, -- cgit v1.2.3 From c4558a26ff661b5299942ce2b735f3cab4aed1e5 Mon Sep 17 00:00:00 2001 From: David Howells Date: Fri, 12 Apr 2013 02:59:48 +0100 Subject: rtl8187se: Use a dir under /proc/net/r8180/ Create a dir under /proc/net/r8180/ named for the device and create that device's files under there. This means that there won't be a problem for multiple devices in the system (if such is possible) and it means we don't need to save the 'device directory' PDE any more as we can just do a proc subtree removal. Signed-off-by: David Howells Acked-by: Greg Kroah-Hartman cc: Maxim Mikityanskiy cc: YAMANE Toshiaki cc: linux-wireless@vger.kernel.org cc: devel@driverdev.osuosl.org Signed-off-by: Al Viro --- drivers/staging/rtl8187se/r8180.h | 1 - drivers/staging/rtl8187se/r8180_core.c | 26 ++++++++------------------ 2 files changed, 8 insertions(+), 19 deletions(-) (limited to 'drivers') 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 448da77e2cd..ab469ceae88 100644 --- a/drivers/staging/rtl8187se/r8180_core.c +++ b/drivers/staging/rtl8187se/r8180_core.c @@ -288,14 +288,7 @@ 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); } /* @@ -335,22 +328,19 @@ static const struct rtl8180_proc_file rtl8180_proc_files[] = { void rtl8180_proc_init_one(struct net_device *dev) { const struct rtl8180_proc_file *f; - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); + struct proc_dir_entry *dir; - priv->dir_dev = rtl8180_proc; - if (!priv->dir_dev) { - DMESGE("Unable to initialize /proc/net/r8180/%s\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; } - priv->dir_dev->data = dev; for (f = rtl8180_proc_files; f->name[0]; f++) { - if (!proc_create_data(f->name, S_IFREG | S_IRUGO, - priv->dir_dev, + if (!proc_create_data(f->name, S_IFREG | S_IRUGO, dir, &rtl8180_proc_fops, f->show)) { - DMESGE("Unable to initialize /proc/net/r8180/%s\n", - f->name); + DMESGE("Unable to initialize /proc/net/r8180/%s/%s\n", + dev->name, f->name); return; } } -- cgit v1.2.3 From cc87e0fff1e639c4c7832075b8cdd89ab30d2a1f Mon Sep 17 00:00:00 2001 From: David Howells Date: Fri, 12 Apr 2013 03:02:22 +0100 Subject: rtl8192u: Don't need to save device proc dir PDE Don't need to save the PDE of a directory created under /proc/net/rtl8192/ as we can use proc subtree deletion to get rid of it and all its children. Signed-off-by: David Howells Acked-by: Mauro Carvalho Chehab Acked-by: Greg Kroah-Hartman cc: Jerry Chuang cc: linux-wireless@vger.kernel.org cc: devel@driverdev.osuosl.org Signed-off-by: Al Viro --- drivers/staging/rtl8192u/r8192U.h | 1 - drivers/staging/rtl8192u/r8192U_core.c | 18 ++++++------------ 2 files changed, 6 insertions(+), 13 deletions(-) (limited to 'drivers') 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 d81d7d55f25..27ba2a3111d 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -669,20 +669,19 @@ static const struct rtl8192_proc_file rtl8192_proc_files[] = { void rtl8192_proc_init_one(struct net_device *dev) { const struct rtl8192_proc_file *f; - struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); + struct proc_dir_entry *dir; if (rtl8192_proc) { - priv->dir_dev = proc_mkdir_data(dev->name, 0, rtl8192_proc, dev); - if (!priv->dir_dev) { + 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; } for (f = rtl8192_proc_files; f->name[0]; f++) { - if (!proc_create_data(f->name, S_IFREG | S_IRUGO, - priv->dir_dev, - rtl8192_proc_fops, f->show)) { + 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); @@ -694,12 +693,7 @@ void rtl8192_proc_init_one(struct net_device *dev) void rtl8192_proc_remove_one(struct net_device *dev) { - struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); - - if (priv->dir_dev) { - remove_proc_subtree(dev->name, rtl8192_proc); - priv->dir_dev = NULL; - } + remove_proc_subtree(dev->name, rtl8192_proc); } /**************************************************************************** -- cgit v1.2.3 From b25f774d889e3856c6d81ffc679912f8bdef6adc Mon Sep 17 00:00:00 2001 From: David Howells Date: Fri, 12 Apr 2013 03:05:20 +0100 Subject: airo: Use remove_proc_subtree() Use remove_proc_subtree() to remove the airo device subdir and all its children instead of doing it manually. Signed-off-by: David Howells cc: linux-wireless@vger.kernel.org Signed-off-by: Al Viro --- drivers/net/wireless/airo.c | 49 ++++++++++++--------------------------------- 1 file changed, 13 insertions(+), 36 deletions(-) (limited to 'drivers') diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c index 21d02335b46..6125adb520a 100644 --- a/drivers/net/wireless/airo.c +++ b/drivers/net/wireless/airo.c @@ -4506,98 +4506,75 @@ static int setup_proc_entry( struct net_device *dev, apriv->proc_entry = proc_mkdir_mode(apriv->proc_name, airo_perm, airo_entry); if (!apriv->proc_entry) - goto fail; + return -ENOMEM; proc_set_user(apriv->proc_entry, proc_kuid, proc_kgid); /* Setup the StatsDelta */ entry = proc_create_data("StatsDelta", S_IRUGO & proc_perm, apriv->proc_entry, &proc_statsdelta_ops, dev); if (!entry) - goto fail_stats_delta; + goto fail; proc_set_user(entry, proc_kuid, proc_kgid); /* Setup the Stats */ entry = proc_create_data("Stats", S_IRUGO & proc_perm, apriv->proc_entry, &proc_stats_ops, dev); if (!entry) - goto fail_stats; + goto fail; proc_set_user(entry, proc_kuid, proc_kgid); /* Setup the Status */ entry = proc_create_data("Status", S_IRUGO & proc_perm, apriv->proc_entry, &proc_status_ops, dev); if (!entry) - goto fail_status; + goto fail; proc_set_user(entry, proc_kuid, proc_kgid); /* Setup the Config */ entry = proc_create_data("Config", proc_perm, apriv->proc_entry, &proc_config_ops, dev); if (!entry) - goto fail_config; + goto fail; proc_set_user(entry, proc_kuid, proc_kgid); /* Setup the SSID */ entry = proc_create_data("SSID", proc_perm, apriv->proc_entry, &proc_SSID_ops, dev); if (!entry) - goto fail_ssid; + goto fail; proc_set_user(entry, proc_kuid, proc_kgid); /* Setup the APList */ entry = proc_create_data("APList", proc_perm, apriv->proc_entry, &proc_APList_ops, dev); if (!entry) - goto fail_aplist; + goto fail; proc_set_user(entry, proc_kuid, proc_kgid); /* Setup the BSSList */ entry = proc_create_data("BSSList", proc_perm, apriv->proc_entry, &proc_BSSList_ops, dev); if (!entry) - goto fail_bsslist; + goto fail; proc_set_user(entry, proc_kuid, proc_kgid); /* Setup the WepKey */ entry = proc_create_data("WepKey", proc_perm, apriv->proc_entry, &proc_wepkey_ops, dev); if (!entry) - goto fail_wepkey; + goto fail; proc_set_user(entry, proc_kuid, proc_kgid); return 0; -fail_wepkey: - remove_proc_entry("BSSList", apriv->proc_entry); -fail_bsslist: - remove_proc_entry("APList", apriv->proc_entry); -fail_aplist: - remove_proc_entry("SSID", apriv->proc_entry); -fail_ssid: - remove_proc_entry("Config", apriv->proc_entry); -fail_config: - remove_proc_entry("Status", apriv->proc_entry); -fail_status: - remove_proc_entry("Stats", apriv->proc_entry); -fail_stats: - remove_proc_entry("StatsDelta", apriv->proc_entry); -fail_stats_delta: - remove_proc_entry(apriv->proc_name, airo_entry); fail: + remove_proc_subtree(apriv->proc_name, airo_entry); return -ENOMEM; } static int takedown_proc_entry( struct net_device *dev, - struct airo_info *apriv ) { - if ( !apriv->proc_entry->namelen ) return 0; - remove_proc_entry("Stats",apriv->proc_entry); - remove_proc_entry("StatsDelta",apriv->proc_entry); - remove_proc_entry("Status",apriv->proc_entry); - remove_proc_entry("Config",apriv->proc_entry); - remove_proc_entry("SSID",apriv->proc_entry); - remove_proc_entry("APList",apriv->proc_entry); - remove_proc_entry("BSSList",apriv->proc_entry); - remove_proc_entry("WepKey",apriv->proc_entry); - remove_proc_entry(apriv->proc_name,airo_entry); + struct airo_info *apriv ) +{ + remove_proc_subtree(apriv->proc_name, airo_entry); return 0; } -- cgit v1.2.3 From 4a520d2769beb736ba2bd084b8293ce148a1a7ae Mon Sep 17 00:00:00 2001 From: David Howells Date: Fri, 12 Apr 2013 14:06:01 +0100 Subject: proc: Supply an accessor for getting the data from a PDE's parent Supply an accessor function for getting the private data from the parent proc_dir_entry struct of the proc_dir_entry struct associated with an inode. ReiserFS, for instance, stores the super_block pointer in the proc directory it makes for that super_block, and a pointer to the respective seq_file show function in each of the proc files in that directory. This allows a reduction in the number of file_operations structs, open functions and seq_operations structs required. The problem otherwise is that each show function requires two pieces of data but only has storage for one per PDE (and this has no release function). Signed-off-by: David Howells Acked-by: Mauro Carvalho Chehab Acked-by: Greg Kroah-Hartman cc: Jerry Chuang cc: Maxim Mikityanskiy cc: YAMANE Toshiaki cc: linux-wireless@vger.kernel.org cc: linux-scsi@vger.kernel.org cc: devel@driverdev.osuosl.org Signed-off-by: Al Viro --- drivers/scsi/megaraid.c | 2 +- drivers/staging/rtl8187se/r8180_core.c | 2 +- drivers/staging/rtl8192u/r8192U_core.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index ef3384d39e1..7373255aa1e 100644 --- a/drivers/scsi/megaraid.c +++ b/drivers/scsi/megaraid.c @@ -2760,7 +2760,7 @@ proc_show_rdrv_40(struct seq_file *m, void *v) */ static int mega_proc_open(struct inode *inode, struct file *file) { - adapter_t *adapter = PDE(inode)->parent->data; + adapter_t *adapter = proc_get_parent_data(inode); int (*show)(struct seq_file *, void *) = PDE_DATA(inode); return single_open(file, show, adapter); diff --git a/drivers/staging/rtl8187se/r8180_core.c b/drivers/staging/rtl8187se/r8180_core.c index ab469ceae88..f7c1d9905ec 100644 --- a/drivers/staging/rtl8187se/r8180_core.c +++ b/drivers/staging/rtl8187se/r8180_core.c @@ -296,7 +296,7 @@ void rtl8180_proc_remove_one(struct net_device *dev) */ static int rtl8180_proc_open(struct inode *inode, struct file *file) { - struct net_device *dev = PDE(inode)->parent->data; + struct net_device *dev = proc_get_parent_data(inode); int (*show)(struct seq_file *, void *) = PDE_DATA(inode); return single_open(file, show, dev); diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 27ba2a3111d..14592339755 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -637,7 +637,7 @@ void rtl8192_proc_module_remove(void) */ static int rtl8192_proc_open(struct inode *inode, struct file *file) { - struct net_device *dev = PDE(inode)->parent->data; + struct net_device *dev = proc_get_parent_data(inode); int (*show)(struct seq_file *, void *) = PDE_DATA(inode); return single_open(file, show, dev); -- cgit v1.2.3 From 0c2f343825192044ffaf542854d478e00f7f0a59 Mon Sep 17 00:00:00 2001 From: David Howells Date: Fri, 12 Apr 2013 15:18:25 +0100 Subject: zoran: Don't print proc_dir_entry data in debug Don't print proc_dir_entry data in debug as we're soon to have no direct access to the contents of the PDE. Print what was put in there instead. Signed-off-by: David Howells cc: mjpeg-users@lists.sourceforge.net cc: linux-media@vger.kernel.org Signed-off-by: Al Viro --- drivers/media/pci/zoran/zoran_procfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/media/pci/zoran/zoran_procfs.c b/drivers/media/pci/zoran/zoran_procfs.c index 07a104d2bd1..f7ceee0cdef 100644 --- a/drivers/media/pci/zoran/zoran_procfs.c +++ b/drivers/media/pci/zoran/zoran_procfs.c @@ -201,7 +201,7 @@ zoran_proc_init (struct zoran *zr) dprintk(2, KERN_INFO "%s: procfs entry /proc/%s allocated. data=%p\n", - ZR_DEVNAME(zr), name, zr->zoran_proc->data); + ZR_DEVNAME(zr), name, zr); } else { dprintk(1, KERN_ERR "%s: Unable to initialise /proc/%s\n", ZR_DEVNAME(zr), name); -- cgit v1.2.3 From ce089b5472f7d0321bcb2cbc22d85bac15e4778b Mon Sep 17 00:00:00 2001 From: David Howells Date: Fri, 12 Apr 2013 15:23:25 +0100 Subject: drm: Constify drm_proc_list[] Constify drm_proc_list[] and related pointers. Signed-off-by: David Howells cc: dri-devel@lists.freedesktop.org Signed-off-by: Al Viro --- drivers/gpu/drm/drm_proc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/gpu/drm/drm_proc.c b/drivers/gpu/drm/drm_proc.c index e06431897f4..aead653c183 100644 --- a/drivers/gpu/drm/drm_proc.c +++ b/drivers/gpu/drm/drm_proc.c @@ -49,7 +49,7 @@ /** * Proc file list. */ -static struct drm_info_list drm_proc_list[] = { +static const struct drm_info_list drm_proc_list[] = { {"name", drm_name_info, 0}, {"vm", drm_vm_info, 0}, {"clients", drm_clients_info, 0}, @@ -89,7 +89,7 @@ static const struct file_operations drm_proc_fops = { * Create a given set of proc files represented by an array of * gdm_proc_lists in the given root directory. */ -static int drm_proc_create_files(struct drm_info_list *files, int count, +static int drm_proc_create_files(const struct drm_info_list *files, int count, struct proc_dir_entry *root, struct drm_minor *minor) { struct drm_device *dev = minor->dev; @@ -172,7 +172,7 @@ int drm_proc_init(struct drm_minor *minor, int minor_id, return 0; } -static int drm_proc_remove_files(struct drm_info_list *files, int count, +static int drm_proc_remove_files(const struct drm_info_list *files, int count, struct drm_minor *minor) { struct list_head *pos, *q; -- cgit v1.2.3 From b63e6aa5028dfde3b360945564290de28b47c2d7 Mon Sep 17 00:00:00 2001 From: David Howells Date: Fri, 12 Apr 2013 15:34:31 +0100 Subject: drm: proc: Use minor->index to label things, not PDE->name Use minor->index to label things, not the name field from the proc_dir_entry of the /proc/dwm// directory. Also, use "%u" not "%d" to render the value and use a 12-byte buffer in which to render the integer, not a 16-byte buffer. The longest string an unsigned int can give you is 10 chars (4294967295) plus a NUL, so round up to 12 as the stack is likely to be 4- or 8-byte aligned. Signed-off-by: David Howells cc: dri-devel@lists.freedesktop.org Signed-off-by: Al Viro --- drivers/gpu/drm/drm_proc.c | 13 +++++-------- drivers/gpu/drm/drm_stub.c | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) (limited to 'drivers') diff --git a/drivers/gpu/drm/drm_proc.c b/drivers/gpu/drm/drm_proc.c index aead653c183..0646a462d4c 100644 --- a/drivers/gpu/drm/drm_proc.c +++ b/drivers/gpu/drm/drm_proc.c @@ -116,14 +116,13 @@ static int drm_proc_create_files(const struct drm_info_list *files, int count, ent = proc_create_data(files[i].name, S_IRUGO, root, &drm_proc_fops, tmp); if (!ent) { - DRM_ERROR("Cannot create /proc/dri/%s/%s\n", - root->name, files[i].name); + DRM_ERROR("Cannot create /proc/dri/%u/%s\n", + minor->index, files[i].name); list_del(&tmp->list); kfree(tmp); ret = -1; goto fail; } - } return 0; @@ -137,7 +136,6 @@ fail: * Initialize the DRI proc filesystem for a device * * \param dev DRM device - * \param minor device minor number * \param root DRI proc dir entry. * \param dev_root resulting DRI device proc dir entry. * \return root entry pointer on success, or NULL on failure. @@ -146,14 +144,13 @@ fail: * "/proc/dri/%minor%/", and each entry in proc_list as * "/proc/dri/%minor%/%name%". */ -int drm_proc_init(struct drm_minor *minor, int minor_id, - struct proc_dir_entry *root) +int drm_proc_init(struct drm_minor *minor, struct proc_dir_entry *root) { - char name[64]; + char name[12]; int ret; INIT_LIST_HEAD(&minor->proc_nodes.list); - sprintf(name, "%d", minor_id); + sprintf(name, "%u", minor->index); minor->proc_root = proc_mkdir(name, root); if (!minor->proc_root) { DRM_ERROR("Cannot create /proc/dri/%s\n", name); diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c index 7d30802a018..16f3ec579b3 100644 --- a/drivers/gpu/drm/drm_stub.c +++ b/drivers/gpu/drm/drm_stub.c @@ -352,7 +352,7 @@ int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type) idr_replace(&drm_minors_idr, new_minor, minor_id); if (type == DRM_MINOR_LEGACY) { - ret = drm_proc_init(new_minor, minor_id, drm_proc_root); + ret = drm_proc_init(new_minor, drm_proc_root); if (ret) { DRM_ERROR("DRM: Failed to initialize /proc/dri.\n"); goto err_mem; -- cgit v1.2.3 From 8bc742e13fb2c9cd64988816749295e9ddf53101 Mon Sep 17 00:00:00 2001 From: David Howells Date: Fri, 12 Apr 2013 16:15:07 +0100 Subject: drm: proc: Use remove_proc_subtree() Use remove_proc_subtree() rather than remove_proc_entry() to remove a minor-specific drm proc directory and all its children. Things could theoretically be improved by storing the drm_minor pointer in the minor-specific dir proc_dir_entry struct data and then scrapping the list of proc files - but that's shared with the debugfs interface where you can't do that, so I don't see an easy way of doing it. Signed-off-by: David Howells cc: dri-devel@lists.freedesktop.org Signed-off-by: Al Viro --- drivers/gpu/drm/drm_proc.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'drivers') diff --git a/drivers/gpu/drm/drm_proc.c b/drivers/gpu/drm/drm_proc.c index 0646a462d4c..d7f2324b4fb 100644 --- a/drivers/gpu/drm/drm_proc.c +++ b/drivers/gpu/drm/drm_proc.c @@ -95,7 +95,7 @@ static int drm_proc_create_files(const struct drm_info_list *files, int count, struct drm_device *dev = minor->dev; struct proc_dir_entry *ent; struct drm_info_node *tmp; - int i, ret; + int i; for (i = 0; i < count; i++) { u32 features = files[i].driver_features; @@ -105,10 +105,9 @@ static int drm_proc_create_files(const struct drm_info_list *files, int count, continue; tmp = kmalloc(sizeof(struct drm_info_node), GFP_KERNEL); - if (tmp == NULL) { - ret = -1; - goto fail; - } + if (!tmp) + return -1; + tmp->minor = minor; tmp->info_ent = &files[i]; list_add(&tmp->list, &minor->proc_nodes.list); @@ -120,16 +119,10 @@ static int drm_proc_create_files(const struct drm_info_list *files, int count, minor->index, files[i].name); list_del(&tmp->list); kfree(tmp); - ret = -1; - goto fail; + return -1; } } return 0; - -fail: - for (i = 0; i < count; i++) - remove_proc_entry(drm_proc_list[i].name, minor->proc_root); - return ret; } /** @@ -160,7 +153,7 @@ int drm_proc_init(struct drm_minor *minor, struct proc_dir_entry *root) ret = drm_proc_create_files(drm_proc_list, DRM_PROC_ENTRIES, minor->proc_root, minor); if (ret) { - remove_proc_entry(name, root); + remove_proc_subtree(name, root); minor->proc_root = NULL; DRM_ERROR("Failed to create core drm proc files\n"); return ret; @@ -210,8 +203,7 @@ int drm_proc_cleanup(struct drm_minor *minor, struct proc_dir_entry *root) drm_proc_remove_files(drm_proc_list, DRM_PROC_ENTRIES, minor); sprintf(name, "%d", minor->index); - remove_proc_entry(name, root); - + remove_proc_subtree(name, root); return 0; } -- cgit v1.2.3 From 819695abb762a625d2ef8f2a6fbf6debeec35b61 Mon Sep 17 00:00:00 2001 From: David Howells Date: Fri, 12 Apr 2013 16:20:47 +0100 Subject: hostap: proc: Use remove_proc_subtree() Use remove_proc_subtree() rather than remove_proc_entry() to remove a device-specific proc directory and all its children. Signed-off-by: David Howells cc: Jouni Malinen cc: Johannes Berg cc: linux-wireless@vger.kernel.org cc: devel@driverdev.osuosl.org Signed-off-by: Al Viro --- drivers/net/wireless/hostap/hostap_proc.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) (limited to 'drivers') diff --git a/drivers/net/wireless/hostap/hostap_proc.c b/drivers/net/wireless/hostap/hostap_proc.c index 89292cffa76..7491dab2c10 100644 --- a/drivers/net/wireless/hostap/hostap_proc.c +++ b/drivers/net/wireless/hostap/hostap_proc.c @@ -496,25 +496,7 @@ void hostap_init_proc(local_info_t *local) void hostap_remove_proc(local_info_t *local) { - if (local->proc != NULL) { -#ifndef PRISM2_NO_STATION_MODES - remove_proc_entry("scan_results", local->proc); -#endif /* PRISM2_NO_STATION_MODES */ -#ifdef PRISM2_IO_DEBUG - remove_proc_entry("io_debug", local->proc); -#endif /* PRISM2_IO_DEBUG */ - remove_proc_entry("pda", local->proc); - remove_proc_entry("aux_dump", local->proc); - remove_proc_entry("wds", local->proc); - remove_proc_entry("stats", local->proc); - remove_proc_entry("bss_list", local->proc); - remove_proc_entry("crypt", local->proc); -#ifndef PRISM2_NO_PROCFS_DEBUG - remove_proc_entry("debug", local->proc); -#endif /* PRISM2_NO_PROCFS_DEBUG */ - if (hostap_proc != NULL) - remove_proc_entry(local->proc->name, hostap_proc); - } + remove_proc_subtree(local->ddev->name, hostap_proc); } -- cgit v1.2.3 From a8ca16ea7b0abb0a7e49492d1123b715f0ec62e8 Mon Sep 17 00:00:00 2001 From: David Howells Date: Fri, 12 Apr 2013 17:27:28 +0100 Subject: proc: Supply a function to remove a proc entry by PDE Supply a function (proc_remove()) to remove a proc entry (and any subtree rooted there) by proc_dir_entry pointer rather than by name and (optionally) root dir entry pointer. This allows us to eliminate all remaining pde->name accesses outside of procfs. Signed-off-by: David Howells Acked-by: Grant Likely cc: linux-acpi@vger.kernel.org cc: openipmi-developer@lists.sourceforge.net cc: devicetree-discuss@lists.ozlabs.org cc: linux-pci@vger.kernel.org cc: netdev@vger.kernel.org cc: netfilter-devel@vger.kernel.org cc: alsa-devel@alsa-project.org Signed-off-by: Al Viro --- drivers/acpi/sbs.c | 21 ++++----------------- drivers/char/ipmi/ipmi_msghandler.c | 2 +- drivers/misc/sgi-gru/gruprocfs.c | 2 +- drivers/of/base.c | 11 +---------- drivers/pci/proc.c | 12 +++--------- 5 files changed, 10 insertions(+), 38 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c index a296e08d76b..b6241eeb113 100644 --- a/drivers/acpi/sbs.c +++ b/drivers/acpi/sbs.c @@ -521,19 +521,6 @@ acpi_sbs_add_fs(struct proc_dir_entry **dir, return 0; } -static void -acpi_sbs_remove_fs(struct proc_dir_entry **dir, - struct proc_dir_entry *parent_dir) -{ - if (*dir) { - remove_proc_entry(ACPI_SBS_FILE_INFO, *dir); - remove_proc_entry(ACPI_SBS_FILE_STATE, *dir); - remove_proc_entry(ACPI_SBS_FILE_ALARM, *dir); - remove_proc_entry((*dir)->name, parent_dir); - *dir = NULL; - } -} - /* Smart Battery Interface */ static struct proc_dir_entry *acpi_battery_dir = NULL; @@ -836,8 +823,8 @@ static void acpi_battery_remove(struct acpi_sbs *sbs, int id) power_supply_unregister(&battery->bat); } #ifdef CONFIG_ACPI_PROCFS_POWER - if (battery->proc_entry) - acpi_sbs_remove_fs(&battery->proc_entry, acpi_battery_dir); + proc_remove(battery->proc_entry); + battery->proc_entry = NULL; #endif } @@ -873,8 +860,8 @@ static void acpi_charger_remove(struct acpi_sbs *sbs) if (sbs->charger.dev) power_supply_unregister(&sbs->charger); #ifdef CONFIG_ACPI_PROCFS_POWER - if (sbs->charger_entry) - acpi_sbs_remove_fs(&sbs->charger_entry, acpi_ac_dir); + proc_remove(sbs->charger_entry); + sbs->charger_entry = NULL; #endif } diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c index 1420bbbe1a6..4d439d2fcfd 100644 --- a/drivers/char/ipmi/ipmi_msghandler.c +++ b/drivers/char/ipmi/ipmi_msghandler.c @@ -4541,7 +4541,7 @@ static void __exit cleanup_ipmi(void) del_timer_sync(&ipmi_timer); #ifdef CONFIG_PROC_FS - remove_proc_entry(proc_ipmi_root->name, NULL); + proc_remove(proc_ipmi_root); #endif /* CONFIG_PROC_FS */ driver_unregister(&ipmidriver.driver); diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c index 950dbe9ecb3..797d7962cc8 100644 --- a/drivers/misc/sgi-gru/gruprocfs.c +++ b/drivers/misc/sgi-gru/gruprocfs.c @@ -355,7 +355,7 @@ static void delete_proc_files(void) for (p = proc_files; p->name; p++) if (p->entry) remove_proc_entry(p->name, proc_gru); - remove_proc_entry("gru", proc_gru->parent); + proc_remove(proc_gru); } } diff --git a/drivers/of/base.c b/drivers/of/base.c index 321d3ef0500..9c704369eda 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -1452,16 +1452,7 @@ int of_attach_node(struct device_node *np) #ifdef CONFIG_PROC_DEVICETREE static void of_remove_proc_dt_entry(struct device_node *dn) { - struct device_node *parent = dn->parent; - struct property *prop = dn->properties; - - while (prop) { - remove_proc_entry(prop->name, dn->pde); - prop = prop->next; - } - - if (dn->pde) - remove_proc_entry(dn->pde->name, parent->pde); + proc_remove(dn->pde); } #else static void of_remove_proc_dt_entry(struct device_node *dn) diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c index 7cde7c131fd..08126087ec3 100644 --- a/drivers/pci/proc.c +++ b/drivers/pci/proc.c @@ -427,20 +427,14 @@ int pci_proc_attach_device(struct pci_dev *dev) int pci_proc_detach_device(struct pci_dev *dev) { - struct proc_dir_entry *e; - - if ((e = dev->procent)) { - remove_proc_entry(e->name, dev->bus->procdir); - dev->procent = NULL; - } + proc_remove(dev->procent); + dev->procent = NULL; return 0; } int pci_proc_detach_bus(struct pci_bus* bus) { - struct proc_dir_entry *de = bus->procdir; - if (de) - remove_proc_entry(de->name, proc_bus_pci_dir); + proc_remove(bus->procdir); return 0; } -- cgit v1.2.3