* [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops
@ 2012-02-22 19:45 Alexey Dobriyan
2012-02-22 19:45 ` [PATCH 02/34] scsi proc_ops: convert drivers/scsi/scsi_debug.c Alexey Dobriyan
` (33 more replies)
0 siblings, 34 replies; 37+ messages in thread
From: Alexey Dobriyan @ 2012-02-22 19:45 UTC (permalink / raw)
To: JBottomley; +Cc: linux-scsi, Alexey Dobriyan
The last user of ->write_proc interface is scsi_proc.c passing through
data to individual drivers. There are still quite a few drivers using
->proc_info interface, so do conversion gradually.
Introduce temporary logic allowing both ->proc_info and ->proc_ops
with ->proc_ops being the first thing to check, convert drivers,
remove ->proc_info interface.
Removing all relevant SCSI proc files is risky because it'd take only one
broken user to revert whole thing and do it right.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
drivers/scsi/scsi_proc.c | 20 +++++++++++++++-----
include/scsi/scsi_host.h | 1 +
2 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/drivers/scsi/scsi_proc.c b/drivers/scsi/scsi_proc.c
index ad747dc..31da690 100644
--- a/drivers/scsi/scsi_proc.c
+++ b/drivers/scsi/scsi_proc.c
@@ -106,7 +106,7 @@ out:
void scsi_proc_hostdir_add(struct scsi_host_template *sht)
{
- if (!sht->proc_info)
+ if (!sht->proc_info && !sht->proc_ops)
return;
mutex_lock(&global_host_template_mutex);
@@ -125,7 +125,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->proc_ops)
return;
mutex_lock(&global_host_template_mutex);
@@ -151,16 +151,26 @@ void scsi_proc_host_add(struct Scsi_Host *shost)
return;
sprintf(name,"%d", shost->host_no);
- p = create_proc_read_entry(name, S_IFREG | S_IRUGO | S_IWUSR,
+ if (sht->proc_ops) {
+ mode_t mode;
+
+ mode = S_IRUGO;
+ if (sht->proc_ops->write)
+ mode |= S_IWUSR;
+ p = proc_create_data(name, mode, sht->proc_dir,
+ sht->proc_ops, shost);
+ } else {
+ 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;
+ }
if (!p) {
printk(KERN_ERR "%s: Failed to register host %d in"
"%s\n", __func__, shost->host_no,
sht->proc_name);
return;
}
-
- p->write_proc = proc_scsi_write_proc;
}
/**
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index 5f7d5b3..f81c80f 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -341,6 +341,7 @@ struct scsi_host_template {
* Status: OBSOLETE
*/
int (*proc_info)(struct Scsi_Host *, char *, char **, off_t, int, int);
+ const struct file_operations *proc_ops;
/*
* This is an optional routine that allows the transport to become
--
1.7.3.4
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH 02/34] scsi proc_ops: convert drivers/scsi/scsi_debug.c
2012-02-22 19:45 [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops Alexey Dobriyan
@ 2012-02-22 19:45 ` Alexey Dobriyan
2012-02-22 19:45 ` [PATCH 03/34] scsi proc_ops: convert drivers/scsi/nsp32.c Alexey Dobriyan
` (32 subsequent siblings)
33 siblings, 0 replies; 37+ messages in thread
From: Alexey Dobriyan @ 2012-02-22 19:45 UTC (permalink / raw)
To: JBottomley; +Cc: linux-scsi, Alexey Dobriyan
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
drivers/scsi/scsi_debug.c | 70 ++++++++++++++++++++++-----------------------
1 files changed, 34 insertions(+), 36 deletions(-)
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 6888b2c..2f3fd1d 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -40,6 +40,7 @@
#include <linux/vmalloc.h>
#include <linux/moduleparam.h>
#include <linux/scatterlist.h>
+#include <linux/seq_file.h>
#include <linux/blkdev.h>
#include <linux/crc-t10dif.h>
@@ -2803,35 +2804,12 @@ static const char * scsi_debug_info(struct Scsi_Host * shp)
return sdebug_info;
}
-/* 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_proc_show(struct seq_file *m, void *v)
{
- int len, pos, begin;
- int orig_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", &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 "
- "%s [%s]\n"
+ 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"
"delay=%d, max_luns=%d, scsi_level=%d\n"
@@ -2845,17 +2823,37 @@ 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 int scsi_debug_proc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, scsi_debug_proc_show, NULL);
+}
+
+static ssize_t scsi_debug_proc_write(struct file *file, const char __user *buf,
+ size_t count, loff_t *pos)
+{
+ int rv;
+
+ if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO))
+ return -EACCES;
+ rv = kstrtoint_from_user(buf, count, 10, &scsi_debug_opts);
+ if (rv < 0)
+ return rv;
+ if (scsi_debug_every_nth != 0)
+ scsi_debug_cmnd_count = 0;
+ return count;
+}
+
+static const struct file_operations scsi_debug_proc_ops = {
+ .open = scsi_debug_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+ .write = scsi_debug_proc_write,
+};
+
static ssize_t sdebug_delay_show(struct device_driver * ddp, char * buf)
{
return scnprintf(buf, PAGE_SIZE, "%d\n", scsi_debug_delay);
@@ -3916,7 +3914,7 @@ write:
static DEF_SCSI_QCMD(scsi_debug_queuecommand)
static struct scsi_host_template sdebug_driver_template = {
- .proc_info = scsi_debug_proc_info,
+ .proc_ops = &scsi_debug_proc_ops,
.proc_name = sdebug_proc_name,
.name = "SCSI DEBUG",
.info = scsi_debug_info,
--
1.7.3.4
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH 03/34] scsi proc_ops: convert drivers/scsi/nsp32.c
2012-02-22 19:45 [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops Alexey Dobriyan
2012-02-22 19:45 ` [PATCH 02/34] scsi proc_ops: convert drivers/scsi/scsi_debug.c Alexey Dobriyan
@ 2012-02-22 19:45 ` Alexey Dobriyan
2012-02-22 19:45 ` [PATCH 04/34] scsi proc_ops: convert drivers/scsi/imm.c Alexey Dobriyan
` (31 subsequent siblings)
33 siblings, 0 replies; 37+ messages in thread
From: Alexey Dobriyan @ 2012-02-22 19:45 UTC (permalink / raw)
To: JBottomley; +Cc: linux-scsi, Alexey Dobriyan
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
drivers/scsi/nsp32.c | 50 +++++++++++++++++++-------------------------------
1 files changed, 19 insertions(+), 31 deletions(-)
diff --git a/drivers/scsi/nsp32.c b/drivers/scsi/nsp32.c
index 0029249..5ea29a6 100644
--- a/drivers/scsi/nsp32.c
+++ b/drivers/scsi/nsp32.c
@@ -33,6 +33,8 @@
#include <linux/blkdev.h>
#include <linux/interrupt.h>
#include <linux/pci.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
#include <linux/delay.h>
#include <linux/ctype.h>
#include <linux/dma-mapping.h>
@@ -193,7 +195,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 const struct file_operations nsp32_proc_ops;
static int nsp32_detect (struct pci_dev *pdev);
static int nsp32_queuecommand(struct Scsi_Host *, struct scsi_cmnd *);
@@ -269,7 +271,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,
+ .proc_ops = &nsp32_proc_ops,
.info = nsp32_info,
.queuecommand = nsp32_queuecommand,
.can_queue = 1,
@@ -1444,18 +1446,11 @@ 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)
+ seq_printf(m, ## args)
+
+static int nsp32_proc_show(struct seq_file *m, void *v)
{
- char *pos = buffer;
- int thislength;
+ struct Scsi_Host *host = m->private;
unsigned long flags;
nsp32_hw_data *data;
int hostno;
@@ -1464,11 +1459,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;
@@ -1529,23 +1519,21 @@ 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
+static int nsp32_proc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, nsp32_proc_show, PDE(inode)->data);
+}
+static const struct file_operations nsp32_proc_ops = {
+ .open = nsp32_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
/*
* Reset parameters and call scsi_done for data->cur_lunt.
--
1.7.3.4
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH 04/34] scsi proc_ops: convert drivers/scsi/imm.c
2012-02-22 19:45 [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops Alexey Dobriyan
2012-02-22 19:45 ` [PATCH 02/34] scsi proc_ops: convert drivers/scsi/scsi_debug.c Alexey Dobriyan
2012-02-22 19:45 ` [PATCH 03/34] scsi proc_ops: convert drivers/scsi/nsp32.c Alexey Dobriyan
@ 2012-02-22 19:45 ` Alexey Dobriyan
2012-02-22 19:45 ` [PATCH 05/34] scsi proc_ops: convert drivers/scsi/ppa.c Alexey Dobriyan
` (30 subsequent siblings)
33 siblings, 0 replies; 37+ messages in thread
From: Alexey Dobriyan @ 2012-02-22 19:45 UTC (permalink / raw)
To: JBottomley; +Cc: linux-scsi, Alexey Dobriyan
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
drivers/scsi/imm.c | 72 +++++++++++++++++++++++----------------------------
1 files changed, 33 insertions(+), 39 deletions(-)
diff --git a/drivers/scsi/imm.c b/drivers/scsi/imm.c
index 26cd9d1..b655b64 100644
--- a/drivers/scsi/imm.c
+++ b/drivers/scsi/imm.c
@@ -13,6 +13,7 @@
#include <linux/module.h>
#include <linux/blkdev.h>
#include <linux/parport.h>
+#include <linux/seq_file.h>
#include <linux/workqueue.h>
#include <linux/delay.h>
#include <linux/slab.h>
@@ -114,54 +115,47 @@ static inline void imm_pb_release(imm_struct *dev)
parport_release(dev->dev);
}
-/* This is to give the imm driver a way to modify the timings (and other
- * parameters) by writing to the /proc/scsi/imm/0 file.
- * Very simple method really... (Too simple, no error checking :( )
- * Reason: Kernel hackers HATE having to unload and reload modules for
- * 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_proc_show(struct seq_file *m, void *v)
{
- unsigned long x;
+ struct Scsi_Host *host = m->private;
+ imm_struct *dev = imm_dev(host);
- if ((length > 5) && (strncmp(buffer, "mode=", 5) == 0)) {
- x = simple_strtoul(buffer + 5, NULL, 0);
- dev->mode = x;
- return length;
- }
- printk("imm /proc: invalid variable\n");
- return (-EINVAL);
+ 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;
}
-static int imm_proc_info(struct Scsi_Host *host, char *buffer, char **start,
- off_t offset, int length, int inout)
+static int imm_proc_open(struct inode *inode, struct file *file)
{
- imm_struct *dev = imm_dev(host);
- int len = 0;
-
- if (inout)
- return imm_proc_write(dev, buffer, length);
+ return single_open(file, imm_proc_show, PDE(inode)->data);
+}
- 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]);
+static ssize_t imm_proc_write(struct file *file, const char __user *buf, size_t count, loff_t *pos)
+{
+ struct Scsi_Host *host = PDE(file->f_path.dentry->d_inode)->data;
+ imm_struct *dev = imm_dev(host);
+ char kbuf[42];
+ size_t len;
- /* Request for beyond end of buffer */
- if (offset > len)
- return 0;
+ len = min(count, sizeof(kbuf) - 1);
+ if (copy_from_user(kbuf, buf, len))
+ return -EFAULT;
+ kbuf[len] = '\0';
- *start = buffer + offset;
- len -= offset;
- if (len > length)
- len = length;
- return len;
+ if (sscanf(kbuf, "mode=%i", &dev->mode) != 1)
+ return -EINVAL;
+ return count;
}
+static const struct file_operations imm_proc_ops = {
+ .open = imm_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+ .write = imm_proc_write,
+};
+
#if IMM_DEBUG > 0
#define imm_fail(x,y) printk("imm: imm_fail(%i) from %s at line %d\n",\
y, __func__, __LINE__); imm_fail_func(x,y);
@@ -1118,7 +1112,7 @@ 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,
+ .proc_ops = &imm_proc_ops,
.name = "Iomega VPI2 (imm) interface",
.queuecommand = imm_queuecommand,
.eh_abort_handler = imm_abort,
--
1.7.3.4
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH 05/34] scsi proc_ops: convert drivers/scsi/ppa.c
2012-02-22 19:45 [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops Alexey Dobriyan
` (2 preceding siblings ...)
2012-02-22 19:45 ` [PATCH 04/34] scsi proc_ops: convert drivers/scsi/imm.c Alexey Dobriyan
@ 2012-02-22 19:45 ` Alexey Dobriyan
2012-02-22 19:45 ` [PATCH 06/34] scsi proc_ops: convert drivers/scsi/atp870u.c Alexey Dobriyan
` (29 subsequent siblings)
33 siblings, 0 replies; 37+ messages in thread
From: Alexey Dobriyan @ 2012-02-22 19:45 UTC (permalink / raw)
To: JBottomley; +Cc: linux-scsi, Alexey Dobriyan
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
drivers/scsi/ppa.c | 85 +++++++++++++++++++++++----------------------------
1 files changed, 38 insertions(+), 47 deletions(-)
diff --git a/drivers/scsi/ppa.c b/drivers/scsi/ppa.c
index d164c96..d506f2a 100644
--- a/drivers/scsi/ppa.c
+++ b/drivers/scsi/ppa.c
@@ -17,6 +17,7 @@
#include <linux/workqueue.h>
#include <linux/delay.h>
#include <linux/jiffies.h>
+#include <linux/seq_file.h>
#include <asm/io.h>
#include <scsi/scsi.h>
@@ -110,64 +111,54 @@ static inline void ppa_pb_release(ppa_struct *dev)
* Start of Chipset kludges
*/
-/* This is to give the ppa driver a way to modify the timings (and other
- * parameters) by writing to the /proc/scsi/ppa/0 file.
- * Very simple method really... (To simple, no error checking :( )
- * Reason: Kernel hackers HATE having to unload and reload modules for
- * testing...
- * 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 ssize_t ppa_proc_write(struct file *file, const char __user *buf,
+ size_t count, loff_t *pos)
{
- unsigned long x;
-
- if ((length > 5) && (strncmp(buffer, "mode=", 5) == 0)) {
- x = simple_strtoul(buffer + 5, NULL, 0);
- dev->mode = x;
- return length;
- }
- if ((length > 10) && (strncmp(buffer, "recon_tmo=", 10) == 0)) {
- x = simple_strtoul(buffer + 10, NULL, 0);
- dev->recon_tmo = x;
- printk(KERN_INFO "ppa: recon_tmo set to %ld\n", x);
- return length;
- }
- printk(KERN_WARNING "ppa /proc: invalid variable\n");
+ struct Scsi_Host *host = PDE(file->f_path.dentry->d_inode)->data;
+ ppa_struct *dev = ppa_dev(host);
+ char kbuf[42];
+ size_t len;
+
+ len = min(count, sizeof(kbuf) - 1);
+ if (copy_from_user(kbuf, buf, len))
+ return -EFAULT;
+ kbuf[len] = '\0';
+
+ if (sscanf(kbuf, "mode=%i", &dev->mode) == 1)
+ return count;
+ if (sscanf(kbuf, "recon_tmo=%li", &dev->recon_tmo) == 1)
+ return count;
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_proc_show(struct seq_file *m, void *v)
{
- int len = 0;
+ struct Scsi_Host *host = m->private;
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
+ return 0;
+}
- /* Request for beyond end of buffer */
- if (offset > length)
- return 0;
-
- *start = buffer + offset;
- len -= offset;
- if (len > length)
- len = length;
- return len;
+static int ppa_proc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, ppa_proc_show, PDE(inode)->data);
}
+static const struct file_operations ppa_proc_ops = {
+ .open = ppa_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+ .write = ppa_proc_write,
+};
+
static int device_check(ppa_struct *dev);
#if PPA_DEBUG > 0
@@ -981,7 +972,7 @@ 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,
+ .proc_ops = &ppa_proc_ops,
.name = "Iomega VPI0 (ppa) interface",
.queuecommand = ppa_queuecommand,
.eh_abort_handler = ppa_abort,
--
1.7.3.4
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH 06/34] scsi proc_ops: convert drivers/scsi/atp870u.c
2012-02-22 19:45 [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops Alexey Dobriyan
` (3 preceding siblings ...)
2012-02-22 19:45 ` [PATCH 05/34] scsi proc_ops: convert drivers/scsi/ppa.c Alexey Dobriyan
@ 2012-02-22 19:45 ` Alexey Dobriyan
2012-02-22 19:45 ` [PATCH 07/34] scsi proc_ops: convert drivers/scsi/dc395x.c Alexey Dobriyan
` (28 subsequent siblings)
33 siblings, 0 replies; 37+ messages in thread
From: Alexey Dobriyan @ 2012-02-22 19:45 UTC (permalink / raw)
To: JBottomley; +Cc: linux-scsi, Alexey Dobriyan
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
drivers/scsi/atp870u.c | 52 +++++++++++++++++++----------------------------
1 files changed, 21 insertions(+), 31 deletions(-)
diff --git a/drivers/scsi/atp870u.c b/drivers/scsi/atp870u.c
index 7e6eca4..3102dd1 100644
--- a/drivers/scsi/atp870u.c
+++ b/drivers/scsi/atp870u.c
@@ -25,6 +25,7 @@
#include <linux/ioport.h>
#include <linux/delay.h>
#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
#include <linux/spinlock.h>
#include <linux/pci.h>
#include <linux/blkdev.h>
@@ -3091,40 +3092,29 @@ 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_proc_show(struct seq_file *m, void *v)
{
- static u8 buff[512];
- int size = 0;
- int len = 0;
- off_t begin = 0;
- off_t pos = 0;
+ struct Scsi_Host *HBAptr = m->private;
- 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;
}
+static int atp870u_proc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, atp870u_proc_show, PDE(inode)->data);
+}
+
+static const struct file_operations atp870u_proc_ops = {
+ .open = atp870u_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
static int atp870u_biosparam(struct scsi_device *disk, struct block_device *dev,
sector_t capacity, int *ip)
@@ -3169,7 +3159,7 @@ static struct scsi_host_template atp870u_template = {
.module = THIS_MODULE,
.name = "atp870u" /* name */,
.proc_name = "atp870u",
- .proc_info = atp870u_proc_info,
+ .proc_ops = &atp870u_proc_ops,
.info = atp870u_info /* info */,
.queuecommand = atp870u_queuecommand /* queuecommand */,
.eh_abort_handler = atp870u_abort /* abort */,
--
1.7.3.4
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH 07/34] scsi proc_ops: convert drivers/scsi/dc395x.c
2012-02-22 19:45 [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops Alexey Dobriyan
` (4 preceding siblings ...)
2012-02-22 19:45 ` [PATCH 06/34] scsi proc_ops: convert drivers/scsi/atp870u.c Alexey Dobriyan
@ 2012-02-22 19:45 ` Alexey Dobriyan
2012-02-22 19:45 ` [PATCH 08/34] scsi proc_ops: convert drivers/scsi/ibmmca.c Alexey Dobriyan
` (27 subsequent siblings)
33 siblings, 0 replies; 37+ messages in thread
From: Alexey Dobriyan @ 2012-02-22 19:45 UTC (permalink / raw)
To: JBottomley; +Cc: linux-scsi, Alexey Dobriyan
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
drivers/scsi/dc395x.c | 33 ++++++++++++++++++---------------
1 files changed, 18 insertions(+), 15 deletions(-)
diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c
index 13aeca3..6d0d614 100644
--- a/drivers/scsi/dc395x.c
+++ b/drivers/scsi/dc395x.c
@@ -53,6 +53,8 @@
#include <linux/blkdev.h>
#include <linux/interrupt.h>
#include <linux/init.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
#include <linux/spinlock.h>
#include <linux/pci.h>
#include <linux/list.h>
@@ -4616,26 +4618,22 @@ 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_proc_show(struct seq_file *m, void *v)
{
+ struct Scsi_Host *host = m->private;
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 +4733,27 @@ 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 int dc395x_proc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, dc395x_proc_show, PDE(inode)->data);
+}
+
+static const struct file_operations dc395x_proc_ops = {
+ .open = dc395x_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
static struct scsi_host_template dc395x_driver_template = {
.module = THIS_MODULE,
.proc_name = DC395X_NAME,
- .proc_info = dc395x_proc_info,
+ .proc_ops = &dc395x_proc_ops,
.name = DC395X_BANNER " " DC395X_VERSION,
.queuecommand = dc395x_queue_command,
.bios_param = dc395x_bios_param,
--
1.7.3.4
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH 08/34] scsi proc_ops: convert drivers/scsi/ibmmca.c
2012-02-22 19:45 [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops Alexey Dobriyan
` (5 preceding siblings ...)
2012-02-22 19:45 ` [PATCH 07/34] scsi proc_ops: convert drivers/scsi/dc395x.c Alexey Dobriyan
@ 2012-02-22 19:45 ` Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 09/34] scsi proc_ops: convert drivers/scsi/wd7000.c Alexey Dobriyan
` (26 subsequent siblings)
33 siblings, 0 replies; 37+ messages in thread
From: Alexey Dobriyan @ 2012-02-22 19:45 UTC (permalink / raw)
To: JBottomley; +Cc: linux-scsi, Alexey Dobriyan
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
drivers/scsi/ibmmca.c | 105 ++++++++++++++++++++++++++----------------------
1 files changed, 57 insertions(+), 48 deletions(-)
diff --git a/drivers/scsi/ibmmca.c b/drivers/scsi/ibmmca.c
index 67fc8ff..1d6ca0f 100644
--- a/drivers/scsi/ibmmca.c
+++ b/drivers/scsi/ibmmca.c
@@ -27,6 +27,7 @@
#include <linux/delay.h>
#include <linux/blkdev.h>
#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
#include <linux/stat.h>
#include <linux/mca.h>
#include <linux/spinlock.h>
@@ -43,7 +44,7 @@ static int ibmmca_queuecommand (struct Scsi_Host *, struct scsi_cmnd *);
static int ibmmca_abort (Scsi_Cmnd *);
static int ibmmca_host_reset (Scsi_Cmnd *);
static int ibmmca_biosparam (struct scsi_device *, struct block_device *, sector_t, int *);
-static int ibmmca_proc_info(struct Scsi_Host *shpnt, char *buffer, char **start, off_t offset, int length, int inout);
+static const struct file_operations ibmmca_proc_ops;
@@ -1490,7 +1491,7 @@ static int ibmmca_getinfo(char *buf, int slot, void *dev_id)
static struct scsi_host_template ibmmca_driver_template = {
.proc_name = "ibmmca",
- .proc_info = ibmmca_proc_info,
+ .proc_ops = &ibmmca_proc_ops,
.name = "IBM SCSI-Subsystem",
.queuecommand = ibmmca_queuecommand,
.eh_abort_handler = ibmmca_abort,
@@ -2262,9 +2263,9 @@ static int ldn_access_total_modeselect(struct Scsi_Host *shpnt)
}
/* routine to display info in the proc-fs-structure (a deluxe feature) */
-static int ibmmca_proc_info(struct Scsi_Host *shpnt, char *buffer, char **start, off_t offset, int length, int inout)
+static int ibmmca_proc_show(struct seq_file *m, void *v)
{
- int len = 0;
+ struct Scsi_Host *shpnt = m->private;
int i, id, lun;
unsigned long flags;
int max_pun;
@@ -2274,64 +2275,72 @@ static int ibmmca_proc_info(struct Scsi_Host *shpnt, char *buffer, char **start,
max_pun = subsystem_maxid(shpnt);
- len += sprintf(buffer + len, "\n IBM-SCSI-Subsystem-Linux-Driver, Version %s\n\n\n", IBMMCA_SCSI_DRIVER_VERSION);
- len += sprintf(buffer + len, " SCSI Access-Statistics:\n");
- len += sprintf(buffer + len, " Device Scanning Order....: %s\n", (ibm_ansi_order) ? "IBM/ANSI" : "New Industry Standard");
+ seq_printf(m, "\n IBM-SCSI-Subsystem-Linux-Driver, Version %s\n\n\n", IBMMCA_SCSI_DRIVER_VERSION);
+ seq_printf(m, " SCSI Access-Statistics:\n");
+ seq_printf(m, " Device Scanning Order....: %s\n", (ibm_ansi_order) ? "IBM/ANSI" : "New Industry Standard");
#ifdef CONFIG_SCSI_MULTI_LUN
- len += sprintf(buffer + len, " Multiple LUN probing.....: Yes\n");
+ seq_printf(m, " Multiple LUN probing.....: Yes\n");
#else
- len += sprintf(buffer + len, " Multiple LUN probing.....: No\n");
+ seq_printf(m, " Multiple LUN probing.....: No\n");
#endif
- len += sprintf(buffer + len, " This Hostnumber..........: %d\n", shpnt->host_no);
- len += sprintf(buffer + len, " Base I/O-Port............: 0x%x\n", (unsigned int) (IM_CMD_REG(shpnt)));
- len += sprintf(buffer + len, " (Shared) IRQ.............: %d\n", IM_IRQ);
- len += sprintf(buffer + len, " Total Interrupts.........: %d\n", IBM_DS(shpnt).total_interrupts);
- len += sprintf(buffer + len, " Total SCSI Accesses......: %d\n", IBM_DS(shpnt).total_accesses);
- len += sprintf(buffer + len, " Total short SCBs.........: %d\n", IBM_DS(shpnt).scbs);
- len += sprintf(buffer + len, " Total long SCBs..........: %d\n", IBM_DS(shpnt).long_scbs);
- len += sprintf(buffer + len, " Total SCSI READ/WRITE..: %d\n", ldn_access_total_read_write(shpnt));
- len += sprintf(buffer + len, " Total SCSI Inquiries...: %d\n", ldn_access_total_inquiry(shpnt));
- len += sprintf(buffer + len, " Total SCSI Modeselects.: %d\n", ldn_access_total_modeselect(shpnt));
- len += sprintf(buffer + len, " Total SCSI other cmds..: %d\n", IBM_DS(shpnt).total_accesses - ldn_access_total_read_write(shpnt)
+ seq_printf(m, " This Hostnumber..........: %d\n", shpnt->host_no);
+ seq_printf(m, " Base I/O-Port............: 0x%x\n", (unsigned int) (IM_CMD_REG(shpnt)));
+ seq_printf(m, " (Shared) IRQ.............: %d\n", IM_IRQ);
+ seq_printf(m, " Total Interrupts.........: %d\n", IBM_DS(shpnt).total_interrupts);
+ seq_printf(m, " Total SCSI Accesses......: %d\n", IBM_DS(shpnt).total_accesses);
+ seq_printf(m, " Total short SCBs.........: %d\n", IBM_DS(shpnt).scbs);
+ seq_printf(m, " Total long SCBs..........: %d\n", IBM_DS(shpnt).long_scbs);
+ seq_printf(m, " Total SCSI READ/WRITE..: %d\n", ldn_access_total_read_write(shpnt));
+ seq_printf(m, " Total SCSI Inquiries...: %d\n", ldn_access_total_inquiry(shpnt));
+ seq_printf(m, " Total SCSI Modeselects.: %d\n", ldn_access_total_modeselect(shpnt));
+ seq_printf(m, " Total SCSI other cmds..: %d\n", IBM_DS(shpnt).total_accesses - ldn_access_total_read_write(shpnt)
- ldn_access_total_modeselect(shpnt)
- ldn_access_total_inquiry(shpnt));
- len += sprintf(buffer + len, " Total SCSI command fails.: %d\n\n", IBM_DS(shpnt).total_errors);
- len += sprintf(buffer + len, " Logical-Device-Number (LDN) Access-Statistics:\n");
- len += sprintf(buffer + len, " LDN | Accesses [%%] | READ | WRITE | ASSIGNMENTS\n");
- len += sprintf(buffer + len, " -----|--------------|-----------|-----------|--------------\n");
+ seq_printf(m, " Total SCSI command fails.: %d\n\n", IBM_DS(shpnt).total_errors);
+ seq_printf(m, " Logical-Device-Number (LDN) Access-Statistics:\n");
+ seq_printf(m, " LDN | Accesses [%%] | READ | WRITE | ASSIGNMENTS\n");
+ seq_printf(m, " -----|--------------|-----------|-----------|--------------\n");
for (i = 0; i <= MAX_LOG_DEV; i++)
- len += sprintf(buffer + len, " %2X | %3d | %8d | %8d | %8d\n", i, ldn_access_load(shpnt, i), IBM_DS(shpnt).ldn_read_access[i], IBM_DS(shpnt).ldn_write_access[i], IBM_DS(shpnt).ldn_assignments[i]);
- len += sprintf(buffer + len, " -----------------------------------------------------------\n\n");
- len += sprintf(buffer + len, " Dynamical-LDN-Assignment-Statistics:\n");
- len += sprintf(buffer + len, " Number of physical SCSI-devices..: %d (+ Adapter)\n", IBM_DS(shpnt).total_scsi_devices);
- len += sprintf(buffer + len, " Dynamical Assignment necessary...: %s\n", IBM_DS(shpnt).dyn_flag ? "Yes" : "No ");
- len += sprintf(buffer + len, " Next LDN to be assigned..........: 0x%x\n", next_ldn(shpnt));
- len += sprintf(buffer + len, " Dynamical assignments done yet...: %d\n", IBM_DS(shpnt).dynamical_assignments);
- len += sprintf(buffer + len, "\n Current SCSI-Device-Mapping:\n");
- len += sprintf(buffer + len, " Physical SCSI-Device Map Logical SCSI-Device Map\n");
- len += sprintf(buffer + len, " ID\\LUN 0 1 2 3 4 5 6 7 ID\\LUN 0 1 2 3 4 5 6 7\n");
+ seq_printf(m, " %2X | %3d | %8d | %8d | %8d\n", i, ldn_access_load(shpnt, i), IBM_DS(shpnt).ldn_read_access[i], IBM_DS(shpnt).ldn_write_access[i], IBM_DS(shpnt).ldn_assignments[i]);
+ seq_printf(m, " -----------------------------------------------------------\n\n");
+ seq_printf(m, " Dynamical-LDN-Assignment-Statistics:\n");
+ seq_printf(m, " Number of physical SCSI-devices..: %d (+ Adapter)\n", IBM_DS(shpnt).total_scsi_devices);
+ seq_printf(m, " Dynamical Assignment necessary...: %s\n", IBM_DS(shpnt).dyn_flag ? "Yes" : "No ");
+ seq_printf(m, " Next LDN to be assigned..........: 0x%x\n", next_ldn(shpnt));
+ seq_printf(m, " Dynamical assignments done yet...: %d\n", IBM_DS(shpnt).dynamical_assignments);
+ seq_printf(m, "\n Current SCSI-Device-Mapping:\n");
+ seq_printf(m, " Physical SCSI-Device Map Logical SCSI-Device Map\n");
+ seq_printf(m, " ID\\LUN 0 1 2 3 4 5 6 7 ID\\LUN 0 1 2 3 4 5 6 7\n");
for (id = 0; id < max_pun; id++) {
- len += sprintf(buffer + len, " %2d ", id);
+ seq_printf(m, " %2d ", id);
for (lun = 0; lun < 8; lun++)
- len += sprintf(buffer + len, "%2s ", ti_p(get_scsi(shpnt)[id][lun]));
- len += sprintf(buffer + len, " %2d ", id);
+ seq_printf(m, "%2s ", ti_p(get_scsi(shpnt)[id][lun]));
+ seq_printf(m, " %2d ", id);
for (lun = 0; lun < 8; lun++)
- len += sprintf(buffer + len, "%2s ", ti_l(get_ldn(shpnt)[id][lun]));
- len += sprintf(buffer + len, "\n");
+ seq_printf(m, "%2s ", ti_l(get_ldn(shpnt)[id][lun]));
+ seq_printf(m, "\n");
}
+ spin_unlock_irqrestore(shpnt->host_lock, flags);
- len += sprintf(buffer + len, "(A = IBM-Subsystem, D = Harddisk, T = Tapedrive, P = Processor, W = WORM,\n");
- len += sprintf(buffer + len, " R = CD-ROM, S = Scanner, M = MO-Drive, C = Medium-Changer, + = unprovided LUN,\n");
- len += sprintf(buffer + len, " - = nothing found, nothing assigned or unprobed LUN)\n\n");
+ seq_printf(m, "(A = IBM-Subsystem, D = Harddisk, T = Tapedrive, P = Processor, W = WORM,\n");
+ seq_printf(m, " R = CD-ROM, S = Scanner, M = MO-Drive, C = Medium-Changer, + = unprovided LUN,\n");
+ seq_printf(m, " - = nothing found, nothing assigned or unprobed LUN)\n\n");
- *start = buffer + offset;
- len -= offset;
- if (len > length)
- len = length;
- spin_unlock_irqrestore(shpnt->host_lock, flags);
- return len;
+ return 0;
}
+static int ibmmca_proc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, ibmmca_proc_show, PDE(inode)->data);
+}
+
+static const struct file_operations ibmmca_proc_ops = {
+ .open = ibmmca_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
static int option_setup(char *str)
{
int ints[IM_MAX_HOSTS];
--
1.7.3.4
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH 09/34] scsi proc_ops: convert drivers/scsi/wd7000.c
2012-02-22 19:45 [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops Alexey Dobriyan
` (6 preceding siblings ...)
2012-02-22 19:45 ` [PATCH 08/34] scsi proc_ops: convert drivers/scsi/ibmmca.c Alexey Dobriyan
@ 2012-02-22 19:46 ` Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 10/34] scsi proc_ops: convert drivers/scsi/pcmcia/nsp_cs.c Alexey Dobriyan
` (25 subsequent siblings)
33 siblings, 0 replies; 37+ messages in thread
From: Alexey Dobriyan @ 2012-02-22 19:46 UTC (permalink / raw)
To: JBottomley; +Cc: linux-scsi, Alexey Dobriyan
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
drivers/scsi/wd7000.c | 50 ++++++++++++++++--------------------------------
1 files changed, 17 insertions(+), 33 deletions(-)
diff --git a/drivers/scsi/wd7000.c b/drivers/scsi/wd7000.c
index 9ee0afe..11673f7 100644
--- a/drivers/scsi/wd7000.c
+++ b/drivers/scsi/wd7000.c
@@ -174,6 +174,7 @@
#include <linux/spinlock.h>
#include <linux/ioport.h>
#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
#include <linux/blkdev.h>
#include <linux/init.h>
#include <linux/stat.h>
@@ -1297,36 +1298,18 @@ 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)
-{
- dprintk("Buffer = <%.*s>, length = %d\n", length, buffer, length);
-
- /*
- * Currently this is a no-op
- */
- dprintk("Sorry, this function is currently out of order...\n");
- return (length);
-}
-
-
-static int wd7000_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, int length, int inout)
+static int wd7000_proc_show(struct seq_file *m, void *v)
{
+ struct Scsi_Host *host = m->private;
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);
@@ -1369,19 +1352,20 @@ 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;
+ return 0;
+}
- if ((pos - buffer) < offset)
- return (0);
- else if ((pos - buffer - offset) < length)
- return (pos - buffer - offset);
- else
- return (length);
+static int wd7000_proc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, wd7000_proc_show, PDE(inode)->data);
}
+static const struct file_operations wd7000_proc_ops = {
+ .open = wd7000_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
/*
* Returns the number of adapters this driver is supporting.
@@ -1414,7 +1398,7 @@ 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->proc_ops = &wd7000_proc_ops;
/*
* Set up SCB free list, which is shared by all adapters
@@ -1659,7 +1643,7 @@ MODULE_LICENSE("GPL");
static struct scsi_host_template driver_template = {
.proc_name = "wd7000",
- .proc_info = wd7000_proc_info,
+ .proc_ops = &wd7000_proc_ops,
.name = "Western Digital WD-7000",
.detect = wd7000_detect,
.release = wd7000_release,
--
1.7.3.4
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH 10/34] scsi proc_ops: convert drivers/scsi/pcmcia/nsp_cs.c
2012-02-22 19:45 [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops Alexey Dobriyan
` (7 preceding siblings ...)
2012-02-22 19:46 ` [PATCH 09/34] scsi proc_ops: convert drivers/scsi/wd7000.c Alexey Dobriyan
@ 2012-02-22 19:46 ` Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 11/34] scsi proc_ops: convert drivers/scsi/fd_mcs.c Alexey Dobriyan
` (24 subsequent siblings)
33 siblings, 0 replies; 37+ messages in thread
From: Alexey Dobriyan @ 2012-02-22 19:46 UTC (permalink / raw)
To: JBottomley; +Cc: linux-scsi, Alexey Dobriyan
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
drivers/scsi/pcmcia/nsp_cs.c | 48 +++++++++++++++++------------------------
drivers/scsi/pcmcia/nsp_cs.h | 8 +------
2 files changed, 21 insertions(+), 35 deletions(-)
diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
index b61a753..9eb0df6 100644
--- a/drivers/scsi/pcmcia/nsp_cs.c
+++ b/drivers/scsi/pcmcia/nsp_cs.c
@@ -36,6 +36,8 @@
#include <linux/interrupt.h>
#include <linux/major.h>
#include <linux/blkdev.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
#include <linux/stat.h>
#include <asm/io.h>
@@ -76,7 +78,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,
+ .proc_ops = &nsp_proc_ops,
.name = "WorkBit NinjaSCSI-3/32Bi(16bit)",
.info = nsp_info,
.queuecommand = nsp_queuecommand,
@@ -1366,28 +1368,17 @@ 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)
+ seq_printf(m, ## args)
+
+static int nsp_proc_show(struct seq_file *m, void *v)
{
+ struct Scsi_Host *host = m->private;
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;
@@ -1459,21 +1450,22 @@ 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
+static int nsp_proc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, nsp_proc_show, PDE(inode)->data);
+}
+
+static const struct file_operations nsp_proc_ops = {
+ .open = nsp_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
/*---------------------------------------------------------------*/
/* error handler */
/*---------------------------------------------------------------*/
diff --git a/drivers/scsi/pcmcia/nsp_cs.h b/drivers/scsi/pcmcia/nsp_cs.h
index 7fc9a9d..f3ced4c 100644
--- a/drivers/scsi/pcmcia/nsp_cs.h
+++ b/drivers/scsi/pcmcia/nsp_cs.h
@@ -292,13 +292,7 @@ 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 const struct file_operations nsp_proc_ops;
static int nsp_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *SCpnt);
/* Error handler */
--
1.7.3.4
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH 11/34] scsi proc_ops: convert drivers/scsi/fd_mcs.c
2012-02-22 19:45 [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops Alexey Dobriyan
` (8 preceding siblings ...)
2012-02-22 19:46 ` [PATCH 10/34] scsi proc_ops: convert drivers/scsi/pcmcia/nsp_cs.c Alexey Dobriyan
@ 2012-02-22 19:46 ` Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 12/34] scsi proc_ops: convert drivers/scsi/aha152x.c Alexey Dobriyan
` (23 subsequent siblings)
33 siblings, 0 replies; 37+ messages in thread
From: Alexey Dobriyan @ 2012-02-22 19:46 UTC (permalink / raw)
To: JBottomley; +Cc: linux-scsi, Alexey Dobriyan
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
drivers/scsi/fd_mcs.c | 47 ++++++++++++++++++++---------------------------
1 files changed, 20 insertions(+), 27 deletions(-)
diff --git a/drivers/scsi/fd_mcs.c b/drivers/scsi/fd_mcs.c
index a2c6135..ff6175d 100644
--- a/drivers/scsi/fd_mcs.c
+++ b/drivers/scsi/fd_mcs.c
@@ -85,6 +85,7 @@
#include <linux/string.h>
#include <linux/ioport.h>
#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
#include <linux/delay.h>
#include <linux/mca.h>
#include <linux/spinlock.h>
@@ -529,37 +530,29 @@ static const char *fd_mcs_info(struct Scsi_Host *shpnt)
static int TOTAL_INTR = 0;
-/*
- * 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 fd_mcs_proc_info(struct Scsi_Host *shpnt, char *buffer, char **start, off_t offset, int length, int inout)
+static int fd_mcs_proc_show(struct seq_file *m, void *v)
{
- int len = 0;
+ struct Scsi_Host *shpnt = m->private;
- if (inout)
- return (-ENOSYS);
-
- *start = buffer + offset;
-
- len += sprintf(buffer + len, "Future Domain MCS-600/700 Driver %s\n", DRIVER_VERSION);
- len += sprintf(buffer + len, "HOST #%d: %s\n", shpnt->host_no, adapter_name);
- len += sprintf(buffer + len, "FIFO Size=0x%x, FIFO Count=%d\n", FIFO_Size, FIFO_COUNT);
- len += sprintf(buffer + len, "DriverCalls=%d, Interrupts=%d, BytesRead=%d, BytesWrite=%d\n\n", TOTAL_INTR, INTR_Processed, Bytes_Read, Bytes_Written);
+ seq_printf(m, "Future Domain MCS-600/700 Driver %s\n", DRIVER_VERSION);
+ seq_printf(m, "HOST #%d: %s\n", shpnt->host_no, adapter_name);
+ seq_printf(m, "FIFO Size=0x%x, FIFO Count=%d\n", FIFO_Size, FIFO_COUNT);
+ seq_printf(m, "DriverCalls=%d, Interrupts=%d, BytesRead=%d, BytesWrite=%d\n\n", TOTAL_INTR, INTR_Processed, Bytes_Read, Bytes_Written);
+ return 0;
+}
- if ((len -= offset) <= 0)
- return 0;
- if (len > length)
- len = length;
- return len;
+static int fd_mcs_proc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, fd_mcs_proc_show, PDE(inode)->data);
}
+static const struct file_operations fd_mcs_proc_ops = {
+ .open = fd_mcs_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
static int fd_mcs_select(struct Scsi_Host *shpnt, int target)
{
int status;
@@ -1336,7 +1329,7 @@ static int fd_mcs_biosparam(struct scsi_device * disk, struct block_device *bdev
static struct scsi_host_template driver_template = {
.proc_name = "fd_mcs",
- .proc_info = fd_mcs_proc_info,
+ .proc_ops = &fd_mcs_proc_ops,
.detect = fd_mcs_detect,
.release = fd_mcs_release,
.info = fd_mcs_info,
--
1.7.3.4
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH 12/34] scsi proc_ops: convert drivers/scsi/aha152x.c
2012-02-22 19:45 [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops Alexey Dobriyan
` (9 preceding siblings ...)
2012-02-22 19:46 ` [PATCH 11/34] scsi proc_ops: convert drivers/scsi/fd_mcs.c Alexey Dobriyan
@ 2012-02-22 19:46 ` Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 13/34] scsi proc_ops: convert drivers/scsi/sym53c8xx_2/sym_glue.c Alexey Dobriyan
` (22 subsequent siblings)
33 siblings, 0 replies; 37+ messages in thread
From: Alexey Dobriyan @ 2012-02-22 19:46 UTC (permalink / raw)
To: JBottomley; +Cc: linux-scsi, Alexey Dobriyan
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
drivers/scsi/aha152x.c | 94 ++++++++++++++++++++++-------------------------
1 files changed, 44 insertions(+), 50 deletions(-)
diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
index f17c92c..ebe3c9b 100644
--- a/drivers/scsi/aha152x.c
+++ b/drivers/scsi/aha152x.c
@@ -251,6 +251,7 @@
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/isapnp.h>
+#include <linux/seq_file.h>
#include <linux/spinlock.h>
#include <linux/workqueue.h>
#include <linux/list.h>
@@ -2978,11 +2979,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("0x%08x: target=%d; lun=%d; cmnd=( ",
@@ -3012,13 +3012,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 Scsi_Host *shpnt, struct seq_file *m)
{
- char *start = pos;
int s;
SPRINTF("\n%s: %s(%s) ", CURRENT_SC ? "on bus" : "waiting", states[STATE].name, states[PREVSTATE].name);
@@ -3274,26 +3271,37 @@ 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 ssize_t aha152x_proc_write(struct file *file, const char __user *buf,
+ size_t count, loff_t *pos)
{
- if(!shpnt || !buffer || length<8 || strncmp("aha152x ", buffer, 8)!=0)
+ struct Scsi_Host *shpnt = PDE(file->f_path.dentry->d_inode)->data;
+ char cmd[42];
+ size_t len;
+
+ if (!shpnt)
+ return -EINVAL;
+
+ len = min(count, sizeof(cmd) - 1);
+ if (copy_from_user(cmd, buf, len))
+ return -EFAULT;
+ cmd[len] = '\0';
+
+ if (len < 8 || strncmp("aha152x ", cmd, 8) != 0)
return -EINVAL;
#if defined(AHA152X_DEBUG)
- if(length>14 && strncmp("debug ", buffer+8, 6)==0) {
+ if (len > 14 && strncmp("debug ", cmd + 8, 6) == 0) {
int debug = HOSTDATA(shpnt)->debug;
- HOSTDATA(shpnt)->debug = simple_strtoul(buffer+14, NULL, 0);
+ HOSTDATA(shpnt)->debug = simple_strtoul(cmd + 14, NULL, 0);
printk(KERN_INFO "aha152x%d: debugging options set to 0x%04x (were 0x%04x)\n", HOSTNO, HOSTDATA(shpnt)->debug, debug);
} else
#endif
#if defined(AHA152X_STAT)
- if(length>13 && strncmp("reset", buffer+8, 5)==0) {
+ if (len > 13 && strncmp("reset", cmd + 8, 5) == 0) {
int i;
HOSTDATA(shpnt)->total_commands=0;
@@ -3317,30 +3325,19 @@ static int aha152x_set_info(char *buffer, int length, struct Scsi_Host *shpnt)
return -EINVAL;
}
-
- return length;
+ return count;
}
#undef SPRINTF
#define SPRINTF(args...) \
- do { if(pos < buffer + length) pos += sprintf(pos, ## args); } while(0)
+ seq_printf(m, ## args)
-static int aha152x_proc_info(struct Scsi_Host *shpnt, char *buffer, char **start,
- off_t offset, int length, int inout)
+static int aha152x_proc_show(struct seq_file *m, void *v)
{
+ struct Scsi_Host *shpnt = m->private;
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");
@@ -3393,25 +3390,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(shpnt, m);
#if defined(AHA152X_STAT)
SPRINTF("statistics:\n"
@@ -3442,25 +3439,22 @@ static int aha152x_proc_info(struct Scsi_Host *shpnt, char *buffer, char **start
}
#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<length ? thislength : length;
-
- DPRINTK(debug_procinfo, KERN_DEBUG "aha152x_proc_info: return %d\n", thislength);
+ return 0;
+}
- *start = buffer + offset;
- return thislength < length ? thislength : length;
+static int aha152x_proc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, aha152x_proc_show, PDE(inode)->data);
}
+static const struct file_operations aha152x_proc_ops = {
+ .open = aha152x_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+ .write = aha152x_proc_write,
+};
+
static int aha152x_adjust_queue(struct scsi_device *device)
{
blk_queue_bounce_limit(device->request_queue, BLK_BOUNCE_HIGH);
@@ -3471,7 +3465,7 @@ static struct scsi_host_template aha152x_driver_template = {
.module = THIS_MODULE,
.name = AHA152X_REVID,
.proc_name = "aha152x",
- .proc_info = aha152x_proc_info,
+ .proc_ops = &aha152x_proc_ops,
.queuecommand = aha152x_queue,
.eh_abort_handler = aha152x_abort,
.eh_device_reset_handler = aha152x_device_reset,
--
1.7.3.4
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH 13/34] scsi proc_ops: convert drivers/scsi/sym53c8xx_2/sym_glue.c
2012-02-22 19:45 [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops Alexey Dobriyan
` (10 preceding siblings ...)
2012-02-22 19:46 ` [PATCH 12/34] scsi proc_ops: convert drivers/scsi/aha152x.c Alexey Dobriyan
@ 2012-02-22 19:46 ` Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 14/34] scsi proc_ops: convert drivers/scsi/advansys.c Alexey Dobriyan
` (21 subsequent siblings)
33 siblings, 0 replies; 37+ messages in thread
From: Alexey Dobriyan @ 2012-02-22 19:46 UTC (permalink / raw)
To: JBottomley; +Cc: linux-scsi, Alexey Dobriyan
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
drivers/scsi/sym53c8xx_2/sym_glue.c | 134 +++++++++++++----------------------
1 files changed, 50 insertions(+), 84 deletions(-)
diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c
index 36d1ed7..2507a3e 100644
--- a/drivers/scsi/sym53c8xx_2/sym_glue.c
+++ b/drivers/scsi/sym53c8xx_2/sym_glue.c
@@ -41,6 +41,8 @@
#include <linux/init.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
#include <linux/spinlock.h>
#include <scsi/scsi.h>
#include <scsi/scsi_tcq.h>
@@ -1167,116 +1169,80 @@ printk("sym_user_command: data=%ld\n", uc->data);
}
return length;
}
+#endif
-#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)
+static ssize_t sym53c8xx_proc_write(struct file *file, const char __user *buf,
+ size_t count, loff_t *pos)
{
- 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;
+#ifdef SYM_LINUX_USER_COMMAND_SUPPORT
+ struct Scsi_Host *shost = PDE(file->f_path.dentry->d_inode)->data;
+ char *cmd;
+ size_t len;
+ int rv;
+
+ cmd = kmalloc(PAGE_SIZE, GFP_KERNEL);
+ if (!cmd)
+ return -ENOMEM;
+ len = min_t(size_t, count, PAGE_SIZE - 1);
+ if (copy_from_user(cmd, buf, len)) {
+ kfree(cmd);
+ return -EFAULT;
}
-}
-
-static int copy_info(struct info_str *info, char *fmt, ...)
-{
- va_list args;
- char buf[81];
- int len;
+ cmd[len] = '\0';
- va_start(args, fmt);
- len = vsprintf(buf, fmt, args);
- va_end(args);
-
- copy_mem_info(info, buf, len);
- return len;
+ rv = sym_user_command(shost, cmd, len);
+ kfree(cmd);
+ if (rv < 0)
+ return rv;
+ return count;
+#else
+ return -EINVAL;
+#endif
}
/*
- * Copy formatted information into the input buffer.
+ * Informations through the proc file system.
*/
-static int sym_host_info(struct Scsi_Host *shost, char *ptr, off_t offset, int len)
+static int sym53c8xx_proc_show(struct seq_file *m, void *v)
{
+#ifdef SYM_LINUX_USER_INFO_SUPPORT
+ struct Scsi_Host *shost = m->private;
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, "
+ seq_printf(m, "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, "At PCI address %s, IRQ %u\n",
pci_name(pdev), pdev->irq);
- copy_info(&info, "Min. period factor %d, %s SCSI BUS%s\n",
+ 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, "
+ 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;
+ return -EINVAL;
#endif
- }
+}
- return retv;
+static int sym53c8xx_proc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, sym53c8xx_proc_show, PDE(inode)->data);
}
+
+static const struct file_operations sym53c8xx_proc_ops = {
+ .open = sym53c8xx_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+ .write = sym53c8xx_proc_write,
+};
#endif /* SYM_LINUX_PROC_INFO_SUPPORT */
/*
@@ -1744,7 +1710,7 @@ 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,
+ .proc_ops = &sym53c8xx_proc_ops,
.proc_name = NAME53C8XX,
#endif
};
--
1.7.3.4
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH 14/34] scsi proc_ops: convert drivers/scsi/advansys.c
2012-02-22 19:45 [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops Alexey Dobriyan
` (11 preceding siblings ...)
2012-02-22 19:46 ` [PATCH 13/34] scsi proc_ops: convert drivers/scsi/sym53c8xx_2/sym_glue.c Alexey Dobriyan
@ 2012-02-22 19:46 ` Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 15/34] scsi proc_ops: convert drivers/scsi/BusLogic.c Alexey Dobriyan
` (20 subsequent siblings)
33 siblings, 0 replies; 37+ messages in thread
From: Alexey Dobriyan @ 2012-02-22 19:46 UTC (permalink / raw)
To: JBottomley; +Cc: linux-scsi, Alexey Dobriyan
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
drivers/scsi/advansys.c | 823 +++++++++++------------------------------------
1 files changed, 181 insertions(+), 642 deletions(-)
diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index bfd618a..13484a0 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -36,6 +36,7 @@
#include <linux/isa.h>
#include <linux/eisa.h>
#include <linux/pci.h>
+#include <linux/seq_file.h>
#include <linux/spinlock.h>
#include <linux/dma-mapping.h>
#include <linux/firmware.h>
@@ -2179,22 +2180,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,8 +2369,6 @@ struct asc_board {
ADVEEP_38C1600_CONFIG adv_38C1600_eep; /* 38C1600 EEPROM config. */
} 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 */
@@ -2877,63 +2860,19 @@ 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 Scsi_Host *shost, struct seq_file *m)
{
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,
+ seq_printf(m,
"\nDevice Information for AdvanSys SCSI Host %d:\n",
shost->host_no);
- ASC_PRT_NEXT();
if (ASC_NARROW_BOARD(boardp)) {
chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
@@ -2941,59 +2880,43 @@ 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();
+ 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 Scsi_Host *shost, struct seq_file *m)
{
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,
+ 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");
- ASC_PRT_NEXT();
- len = asc_prt_line(cp, leftlen,
+ seq_printf(m,
"can be found at the ConnectCom FTP site: ftp://ftp.connectcom.net/pub\n");
- ASC_PRT_NEXT();
} 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
@@ -3002,16 +2925,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,
+ seq_printf(m,
"Newer version of ROM BIOS is available at the ConnectCom FTP site:\n");
- ASC_PRT_NEXT();
- len = asc_prt_line(cp, leftlen,
+ seq_printf(m,
"ftp://ftp.connectcom.net/pub\n");
- ASC_PRT_NEXT();
}
}
-
- return totlen;
}
/*
@@ -3116,20 +3035,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 Scsi_Host *shost, struct seq_file *m)
{
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
@@ -3140,129 +3050,91 @@ 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,
+ seq_printf(m,
"\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
shost->host_no);
- ASC_PRT_NEXT();
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();
+ seq_printf(m, " Serial Number: %s\n", serialstr);
} else {
if (ep->adapter_info[5] == 0xBB) {
- len = asc_prt_line(cp, leftlen,
+ seq_printf(m,
" Default Settings Used for EEPROM-less Adapter.\n");
- ASC_PRT_NEXT();
} else {
- len = asc_prt_line(cp, leftlen,
+ seq_printf(m,
" Serial Number Signature Not Present.\n");
- ASC_PRT_NEXT();
}
}
- len = asc_prt_line(cp, leftlen,
+ 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);
- ASC_PRT_NEXT();
- len = asc_prt_line(cp, leftlen,
+ seq_printf(m,
" 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();
+ seq_printf(m, " Target ID: ");
for (i = 0; i <= ASC_MAX_TID; i++) {
- len = asc_prt_line(cp, leftlen, " %d", i);
- ASC_PRT_NEXT();
+ seq_printf(m, " %d", i);
}
- len = asc_prt_line(cp, leftlen, "\n");
- ASC_PRT_NEXT();
+ seq_printf(m, "\n");
- len = asc_prt_line(cp, leftlen, " Disconnects: ");
- ASC_PRT_NEXT();
+ seq_printf(m, " Disconnects: ");
for (i = 0; i <= ASC_MAX_TID; i++) {
- len = asc_prt_line(cp, leftlen, " %c",
+ seq_printf(m, " %c",
(ep->
disc_enable & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
'N');
- ASC_PRT_NEXT();
}
- len = asc_prt_line(cp, leftlen, "\n");
- ASC_PRT_NEXT();
+ seq_printf(m, "\n");
- len = asc_prt_line(cp, leftlen, " Command Queuing: ");
- ASC_PRT_NEXT();
+ seq_printf(m, " Command Queuing: ");
for (i = 0; i <= ASC_MAX_TID; i++) {
- len = asc_prt_line(cp, leftlen, " %c",
+ seq_printf(m, " %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();
+ seq_printf(m, "\n");
- len = asc_prt_line(cp, leftlen, " Start Motor: ");
- ASC_PRT_NEXT();
+ seq_printf(m, " Start Motor: ");
for (i = 0; i <= ASC_MAX_TID; i++) {
- len = asc_prt_line(cp, leftlen, " %c",
+ seq_printf(m, " %c",
(ep->
start_motor & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
'N');
- ASC_PRT_NEXT();
}
- 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++) {
- len = asc_prt_line(cp, leftlen, " %c",
+ seq_printf(m, " %c",
(ep->
init_sdtr & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
'N');
- ASC_PRT_NEXT();
}
- len = asc_prt_line(cp, leftlen, "\n");
- ASC_PRT_NEXT();
+ seq_printf(m, "\n");
#ifdef CONFIG_ISA
if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
- len = asc_prt_line(cp, leftlen,
+ seq_printf(m,
" Host ISA DMA speed: %d MB/S\n",
isa_dma_speed[ASC_EEP_GET_DMA_SPD(ep)]);
- ASC_PRT_NEXT();
}
#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 Scsi_Host *shost, struct seq_file *m)
{
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];
@@ -3282,13 +3154,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,
+ seq_printf(m,
"\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
shost->host_no);
- ASC_PRT_NEXT();
if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
wordp = &ep_3550->serial_number_word1;
@@ -3299,36 +3167,29 @@ static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen
}
if (asc_get_eeprom_string(wordp, serialstr) == ASC_TRUE) {
- len =
- asc_prt_line(cp, leftlen, " Serial Number: %s\n",
- serialstr);
- ASC_PRT_NEXT();
+ seq_printf(m, " Serial Number: %s\n", serialstr);
} else {
- len = asc_prt_line(cp, leftlen,
+ seq_printf(m,
" Serial Number Signature Not Present.\n");
- ASC_PRT_NEXT();
}
if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
- len = asc_prt_line(cp, leftlen,
+ 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);
- ASC_PRT_NEXT();
} else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
- len = asc_prt_line(cp, leftlen,
+ 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);
- ASC_PRT_NEXT();
} else {
- len = asc_prt_line(cp, leftlen,
+ 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);
- ASC_PRT_NEXT();
}
if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
word = ep_3550->termination;
@@ -3354,33 +3215,27 @@ static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen
}
if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
- len = asc_prt_line(cp, leftlen,
+ seq_printf(m,
" 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,
+ seq_printf(m,
" 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,
+ seq_printf(m,
" termination: %u (%s), bios_ctrl: 0x%x\n",
ep_38C1600->termination_lvd, termstr,
ep_38C1600->bios_ctrl);
- ASC_PRT_NEXT();
}
- len = asc_prt_line(cp, leftlen, " Target ID: ");
- ASC_PRT_NEXT();
+ seq_printf(m, " Target ID: ");
for (i = 0; i <= ADV_MAX_TID; i++) {
- len = asc_prt_line(cp, leftlen, " %X", i);
- ASC_PRT_NEXT();
+ seq_printf(m, " %X", i);
}
- len = asc_prt_line(cp, leftlen, "\n");
- ASC_PRT_NEXT();
+ seq_printf(m, "\n");
if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
word = ep_3550->disc_enable;
@@ -3389,15 +3244,12 @@ 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();
+ seq_printf(m, " Disconnects: ");
for (i = 0; i <= ADV_MAX_TID; i++) {
- len = asc_prt_line(cp, leftlen, " %c",
+ seq_printf(m, " %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, "\n");
if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
word = ep_3550->tagqng_able;
@@ -3406,15 +3258,12 @@ 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();
+ seq_printf(m, " Command Queuing: ");
for (i = 0; i <= ADV_MAX_TID; i++) {
- len = asc_prt_line(cp, leftlen, " %c",
+ seq_printf(m, " %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, "\n");
if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
word = ep_3550->start_motor;
@@ -3423,42 +3272,33 @@ 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();
+ seq_printf(m, " Start Motor: ");
for (i = 0; i <= ADV_MAX_TID; i++) {
- len = asc_prt_line(cp, leftlen, " %c",
+ seq_printf(m, " %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, "\n");
if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
- len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
- ASC_PRT_NEXT();
+ seq_printf(m, " Synchronous Transfer:");
for (i = 0; i <= ADV_MAX_TID; i++) {
- len = asc_prt_line(cp, leftlen, " %c",
+ seq_printf(m, " %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, "\n");
}
if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
- len = asc_prt_line(cp, leftlen, " Ultra Transfer: ");
- ASC_PRT_NEXT();
+ seq_printf(m, " Ultra Transfer: ");
for (i = 0; i <= ADV_MAX_TID; i++) {
- len = asc_prt_line(cp, leftlen, " %c",
+ seq_printf(m, " %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, "\n");
}
if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
@@ -3468,21 +3308,17 @@ 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();
+ seq_printf(m, " Wide Transfer: ");
for (i = 0; i <= ADV_MAX_TID; i++) {
- len = asc_prt_line(cp, leftlen, " %c",
+ seq_printf(m, " %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, "\n");
if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800 ||
adv_dvc_varp->chip_type == ADV_CHIP_ASC38C1600) {
- len = asc_prt_line(cp, leftlen,
+ seq_printf(m,
" Synchronous Transfer Speed (Mhz):\n ");
- ASC_PRT_NEXT();
for (i = 0; i <= ADV_MAX_TID; i++) {
char *speed_str;
@@ -3518,99 +3354,65 @@ 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();
+ seq_printf(m, "%X:%s ", i, speed_str);
if (i == 7) {
- len = asc_prt_line(cp, leftlen, "\n ");
- ASC_PRT_NEXT();
+ 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 Scsi_Host *shost, struct seq_file *m)
{
struct asc_board *boardp = shost_priv(shost);
- int leftlen;
- int totlen;
- int len;
int chip_scsi_id;
- leftlen = cplen;
- totlen = len = 0;
-
- len = asc_prt_line(cp, leftlen,
+ seq_printf(m,
"\nLinux Driver Configuration and Information for AdvanSys SCSI Host %d:\n",
shost->host_no);
- ASC_PRT_NEXT();
- len = asc_prt_line(cp, leftlen,
- " host_busy %u, last_reset %u, max_id %u, max_lun %u, max_channel %u\n",
+ seq_printf(m,
+ " 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);
- ASC_PRT_NEXT();
- len = asc_prt_line(cp, leftlen,
+ 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);
- ASC_PRT_NEXT();
- len = asc_prt_line(cp, leftlen,
+ seq_printf(m,
" unchecked_isa_dma %d, use_clustering %d\n",
shost->unchecked_isa_dma, shost->use_clustering);
- ASC_PRT_NEXT();
- len = asc_prt_line(cp, leftlen,
- " flags 0x%x, last_reset 0x%x, jiffies 0x%x, asc_n_io_port 0x%x\n",
+ seq_printf(m,
+ " 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);
- 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%lx\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 Scsi_Host *shost, struct seq_file *m)
{
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;
@@ -3620,105 +3422,84 @@ 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;
-
- len = asc_prt_line(cp, leftlen,
+ seq_printf(m,
"\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, "
+ 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);
- ASC_PRT_NEXT();
/* Current number of commands waiting for the host. */
- len = asc_prt_line(cp, leftlen,
+ seq_printf(m,
" Total Command Pending: %d\n", v->cur_total_qng);
- ASC_PRT_NEXT();
- 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",
+ seq_printf(m, " %X:%c",
i,
(v->
use_tagged_qng & ADV_TID_TO_TIDMASK(i)) ?
'Y' : 'N');
- ASC_PRT_NEXT();
}
- 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",
+ seq_printf(m, " %X:Y-%d",
i, boardp->queue_full_cnt[i]);
} else {
- len = asc_prt_line(cp, leftlen, " %X:N", i);
+ seq_printf(m, " %X:N", i);
}
- ASC_PRT_NEXT();
}
- 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",
+ seq_printf(m, " %X:%c",
i,
(v->
sdtr_done & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
'N');
- ASC_PRT_NEXT();
}
- 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;
@@ -3729,18 +3510,16 @@ 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,
+ seq_printf(m,
" Transfer Period Factor: %d (%d.%d Mhz),",
v->sdtr_period_tbl[syn_period_ix],
250 /
@@ -3749,49 +3528,34 @@ static int asc_prt_asc_board_info(struct Scsi_Host *shost, char *cp, int cplen)
v->
sdtr_period_tbl
[syn_period_ix]));
- ASC_PRT_NEXT();
- len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d",
+ seq_printf(m, " REQ/ACK Offset: %d",
boardp->
sdtr_data[i] & ASC_SYN_MAX_OFFSET);
- ASC_PRT_NEXT();
}
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,
+ seq_printf(m,
" * = Re-negotiation pending before next command.\n");
- ASC_PRT_NEXT();
}
-
- 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 Scsi_Host *shost, struct seq_file *m)
{
struct asc_board *boardp = shost_priv(shost);
- int leftlen;
- int totlen;
- int len;
int i;
ADV_DVC_VAR *v;
ADV_DVC_CFG *c;
@@ -3810,47 +3574,37 @@ 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,
+ seq_printf(m,
"\nAdv Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
shost->host_no);
- ASC_PRT_NEXT();
- len = asc_prt_line(cp, leftlen,
- " iop_base 0x%lx, cable_detect: %X, err_code %u\n",
+ seq_printf(m,
+ " iop_base %p, cable_detect: %X, err_code %u\n",
v->iop_base,
AdvReadWordRegister(iop_base,
IOPW_SCSI_CFG1) & CABLE_DETECT,
v->err_code);
- ASC_PRT_NEXT();
- len = asc_prt_line(cp, leftlen, " chip_version %u, mcode_date 0x%x, "
+ seq_printf(m, " chip_version %u, mcode_date 0x%x, "
"mcode_version 0x%x\n", c->chip_version,
c->mcode_date, c->mcode_version);
- ASC_PRT_NEXT();
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",
+ seq_printf(m, " %X:%c",
i,
(tagqng_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
'N');
- ASC_PRT_NEXT();
}
- 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)) {
@@ -3860,14 +3614,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)) {
@@ -3877,33 +3628,27 @@ 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",
+ seq_printf(m, " %X:%c",
i,
(wdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
'N');
- ASC_PRT_NEXT();
}
- 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)) {
@@ -3914,37 +3659,31 @@ 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",
+ seq_printf(m, " %X:%d",
i, (lramword & 0x8000) ? 16 : 8);
- ASC_PRT_NEXT();
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",
+ seq_printf(m, " %X:%c",
i,
(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, "\n");
AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, sdtr_done);
for (i = 0; i <= ADV_MAX_TID; i++) {
@@ -3960,359 +3699,176 @@ 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), ", period);
} else {
- len = asc_prt_line(cp, leftlen,
+ seq_printf(m,
"%d (%d.%d Mhz),",
period, 250 / period,
ASC_TENTHS(250,
period));
- ASC_PRT_NEXT();
}
}
- len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d",
+ seq_printf(m, " REQ/ACK Offset: %d",
lramword & 0x1F);
- ASC_PRT_NEXT();
}
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,
+ seq_printf(m,
" * = Re-negotiation pending before next command.\n");
- ASC_PRT_NEXT();
}
-
- 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 Scsi_Host *shost, struct seq_file *m)
{
struct asc_board *boardp = shost_priv(shost);
struct asc_stats *s = &boardp->asc_stats;
- int leftlen = cplen;
- int len, totlen = 0;
-
- len = asc_prt_line(cp, leftlen,
+ seq_printf(m,
"\nLinux Driver Statistics for AdvanSys SCSI Host %d:\n",
shost->host_no);
- ASC_PRT_NEXT();
- len = asc_prt_line(cp, leftlen,
- " queuecommand %lu, reset %lu, biosparam %lu, interrupt %lu\n",
+ seq_printf(m,
+ " queuecommand %u, reset %u, biosparam %u, interrupt %u\n",
s->queuecommand, s->reset, s->biosparam,
s->interrupt);
- ASC_PRT_NEXT();
- len = asc_prt_line(cp, leftlen,
- " callback %lu, done %lu, build_error %lu, build_noreq %lu, build_nosg %lu\n",
+ seq_printf(m,
+ " 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);
- ASC_PRT_NEXT();
- len = asc_prt_line(cp, leftlen,
- " exe_noerror %lu, exe_busy %lu, exe_error %lu, exe_unknown %lu\n",
+ seq_printf(m,
+ " 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);
- ASC_PRT_NEXT();
/*
* Display data transfer statistics.
*/
if (s->xfer_cnt > 0) {
- len = asc_prt_line(cp, leftlen, " xfer_cnt %lu, xfer_elem %lu, ",
+ seq_printf(m, " xfer_cnt %u, xfer_elem %u, ",
s->xfer_cnt, s->xfer_elem);
- ASC_PRT_NEXT();
- len = asc_prt_line(cp, leftlen, "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));
- ASC_PRT_NEXT();
/* Scatter gather transfer statistics */
- len = asc_prt_line(cp, leftlen, " 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));
- ASC_PRT_NEXT();
- len = asc_prt_line(cp, leftlen, "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));
- ASC_PRT_NEXT();
- len = asc_prt_line(cp, leftlen, "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));
- ASC_PRT_NEXT();
}
-
- return totlen;
}
#endif /* ADVANSYS_STATS */
/*
- * advansys_proc_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
- *
- * 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.
+ * /proc/scsi/advansys/{0,1,2,3,...}
*/
-static int
-advansys_proc_info(struct Scsi_Host *shost, char *buffer, char **start,
- off_t offset, int length, int inout)
+static int advansys_proc_show(struct seq_file *m, void *v)
{
+ struct Scsi_Host *shost = m->private;
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", 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;
+ asc_prt_adv_bios(shost, m);
}
/*
* 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(shost, m);
/*
* 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);
+ asc_prt_asc_board_eeprom(shost, m);
} 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;
+ asc_prt_adv_board_eeprom(shost, m);
}
- advoffset += cplen;
- curbuf += cnt;
/*
* 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(shost, m);
#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(shost, m);
#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);
+ asc_prt_asc_board_info(shost, m);
} else {
- cplen = asc_prt_adv_board_info(shost, cp, ASC_PRTBUF_SIZE);
+ asc_prt_adv_board_info(shost, m);
}
- 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 0;
+}
- return totcnt;
+static int advansys_proc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, advansys_proc_show, PDE(inode)->data);
}
+
+static const struct file_operations advansys_proc_ops = {
+ .open = advansys_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
#endif /* CONFIG_PROC_FS */
static void asc_scsi_done(struct scsi_cmnd *scp)
@@ -11746,7 +11302,7 @@ 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,
+ .proc_ops = &advansys_proc_ops,
#endif
.name = DRV_NAME,
.info = advansys_info,
@@ -11942,20 +11498,6 @@ static int __devinit advansys_board_found(struct Scsi_Host *shost,
#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
@@ -12375,8 +11917,6 @@ static int __devinit advansys_board_found(struct Scsi_Host *shost,
free_dma(shost->dma_channel);
#endif
err_free_proc:
- kfree(boardp->prtbuf);
- err_unmap:
if (boardp->ioremap_addr)
iounmap(boardp->ioremap_addr);
err_shost:
@@ -12409,7 +11949,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;
--
1.7.3.4
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH 15/34] scsi proc_ops: convert drivers/scsi/BusLogic.c
2012-02-22 19:45 [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops Alexey Dobriyan
` (12 preceding siblings ...)
2012-02-22 19:46 ` [PATCH 14/34] scsi proc_ops: convert drivers/scsi/advansys.c Alexey Dobriyan
@ 2012-02-22 19:46 ` Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 16/34] scsi proc_ops: convert drivers/scsi/aha1740.c Alexey Dobriyan
` (19 subsequent siblings)
33 siblings, 0 replies; 37+ messages in thread
From: Alexey Dobriyan @ 2012-02-22 19:46 UTC (permalink / raw)
To: JBottomley; +Cc: linux-scsi, Alexey Dobriyan
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
drivers/scsi/BusLogic.c | 103 ++++++++++++++++++++++++----------------------
drivers/scsi/BusLogic.h | 1 -
2 files changed, 54 insertions(+), 50 deletions(-)
diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c
index f66c33b..58e9bd2 100644
--- a/drivers/scsi/BusLogic.c
+++ b/drivers/scsi/BusLogic.c
@@ -39,6 +39,8 @@
#include <linux/mm.h>
#include <linux/stat.h>
#include <linux/pci.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
#include <linux/spinlock.h>
#include <linux/jiffies.h>
#include <linux/dma-mapping.h>
@@ -3198,30 +3200,19 @@ static int BusLogic_BIOSDiskParameters(struct scsi_device *sdev, struct block_de
}
-/*
- BugLogic_ProcDirectoryInfo implements /proc/scsi/BusLogic/<N>.
-*/
-
-static int BusLogic_ProcDirectoryInfo(struct Scsi_Host *shost, char *ProcBuffer, char **StartPointer, off_t Offset, int BytesAvailable, int WriteFlag)
+/* /proc/scsi/BusLogic/<N> */
+static int buslogic_proc_show(struct seq_file *m, void *v)
{
+ struct Scsi_Host *shost = m->private;
struct BusLogic_HostAdapter *HostAdapter = (struct BusLogic_HostAdapter *) shost->hostdata;
struct BusLogic_TargetStatistics *TargetStatistics;
- int TargetID, Length;
- char *Buffer;
+ int TargetID;
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\
+ 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\
@@ -3230,66 +3221,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\
@@ -3300,22 +3287,40 @@ 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;
+}
+
+static int buslogic_proc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, buslogic_proc_show, PDE(inode)->data);
+}
+
+static ssize_t buslogic_proc_write(struct file *file, const char __user *buf, size_t count, loff_t *pos)
+{
+ struct Scsi_Host *shost = PDE(file->f_path.dentry->d_inode)->data;
+ struct BusLogic_HostAdapter *HostAdapter = (struct BusLogic_HostAdapter *) shost->hostdata;
+ struct BusLogic_TargetStatistics *TargetStatistics = HostAdapter->TargetStatistics;
+
+ HostAdapter->ExternalHostAdapterResets = 0;
+ HostAdapter->HostAdapterInternalErrors = 0;
+ memset(TargetStatistics, 0, BusLogic_MaxTargetDevices * sizeof(struct BusLogic_TargetStatistics));
+
+ return count;
}
+static const struct file_operations buslogic_proc_ops = {
+ .open = buslogic_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+ .write = buslogic_proc_write,
+};
/*
BusLogic_Message prints Driver Messages.
@@ -3567,7 +3572,7 @@ 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,
+ .proc_ops = &buslogic_proc_ops,
.name = "BusLogic",
.info = BusLogic_DriverInfo,
.queuecommand = BusLogic_QueueCommand,
diff --git a/drivers/scsi/BusLogic.h b/drivers/scsi/BusLogic.h
index 649fcb3..6c6c13c 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 *);
--
1.7.3.4
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH 16/34] scsi proc_ops: convert drivers/scsi/aha1740.c
2012-02-22 19:45 [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops Alexey Dobriyan
` (13 preceding siblings ...)
2012-02-22 19:46 ` [PATCH 15/34] scsi proc_ops: convert drivers/scsi/BusLogic.c Alexey Dobriyan
@ 2012-02-22 19:46 ` Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 17/34] scsi proc_ops: convert drivers/scsi/aic7xxx_old.c Alexey Dobriyan
` (18 subsequent siblings)
33 siblings, 0 replies; 37+ messages in thread
From: Alexey Dobriyan @ 2012-02-22 19:46 UTC (permalink / raw)
To: JBottomley; +Cc: linux-scsi, Alexey Dobriyan
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
drivers/scsi/aha1740.c | 36 +++++++++++++++++-------------------
1 files changed, 17 insertions(+), 19 deletions(-)
diff --git a/drivers/scsi/aha1740.c b/drivers/scsi/aha1740.c
index 1c10b79..293f1d3 100644
--- a/drivers/scsi/aha1740.c
+++ b/drivers/scsi/aha1740.c
@@ -45,6 +45,7 @@
#include <linux/string.h>
#include <linux/ioport.h>
#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
#include <linux/stat.h>
#include <linux/init.h>
#include <linux/device.h>
@@ -107,35 +108,32 @@ 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_proc_show(struct seq_file *m, void *v)
{
- int len;
+ struct Scsi_Host *shpnt = m->private;
struct aha1740_hostdata *host;
- if (inout)
- return-ENOSYS;
-
host = HOSTDATA(shpnt);
- len = sprintf(buffer, "aha174x at IO:%lx, IRQ %d, SLOT %d.\n"
+ 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");
+ return 0;
+}
- if (offset > len) {
- *start = buffer;
- return 0;
- }
-
- *start = buffer + offset;
- len -= offset;
- if (len > length)
- len = length;
- return len;
+static int aha1740_proc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, aha1740_proc_show, PDE(inode)->data);
}
+static const struct file_operations aha1740_proc_ops = {
+ .open = aha1740_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
static int aha1740_makecode(unchar *sense, unchar *status)
{
struct statusword
@@ -557,7 +555,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,
+ .proc_ops = &aha1740_proc_ops,
.name = "Adaptec 174x (EISA)",
.queuecommand = aha1740_queuecommand,
.bios_param = aha1740_biosparam,
--
1.7.3.4
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH 17/34] scsi proc_ops: convert drivers/scsi/aic7xxx_old.c
2012-02-22 19:45 [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops Alexey Dobriyan
` (14 preceding siblings ...)
2012-02-22 19:46 ` [PATCH 16/34] scsi proc_ops: convert drivers/scsi/aha1740.c Alexey Dobriyan
@ 2012-02-22 19:46 ` Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 18/34] scsi proc_ops: convert drivers/scsi/ips.c Alexey Dobriyan
` (17 subsequent siblings)
33 siblings, 0 replies; 37+ messages in thread
From: Alexey Dobriyan @ 2012-02-22 19:46 UTC (permalink / raw)
To: JBottomley; +Cc: linux-scsi, Alexey Dobriyan
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
drivers/scsi/aic7xxx_old.c | 2 +-
drivers/scsi/aic7xxx_old/aic7xxx_proc.c | 240 +++++++++----------------------
2 files changed, 72 insertions(+), 170 deletions(-)
diff --git a/drivers/scsi/aic7xxx_old.c b/drivers/scsi/aic7xxx_old.c
index 5b212f0..aab11d1 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,
+ .proc_ops = &aic7xxx_proc_ops,
.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 b07e4f0..05d4d66 100644
--- a/drivers/scsi/aic7xxx_old/aic7xxx_proc.c
+++ b/drivers/scsi/aic7xxx_old/aic7xxx_proc.c
@@ -28,64 +28,17 @@
*
* $Id: aic7xxx_proc.c,v 4.1 1997/06/97 08:23:42 deang Exp $
*-M*************************************************************************/
+#include <linux/seq_file.h>
-
-#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
- *
- * 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)
+static int aic7xxx_proc_show(struct seq_file *m, void *v)
{
+ struct Scsi_Host *HBAptr = m->private;
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 +47,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 +92,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,80 +187,74 @@ 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");
+ seq_printf(m, "\n");
+ seq_printf(m, "\n\n");
}
- if (offset > size - 1)
- {
- kfree(aic7xxx_buffer);
- aic7xxx_buffer = NULL;
- aic7xxx_buffer_size = length = 0;
- *start = NULL;
- }
- else
- {
- *start = buffer;
- length = min_t(int, length, size - offset);
- memcpy(buffer, &aic7xxx_buffer[offset], length);
- }
+ return 0;
+}
- return (length);
+static int aic7xxx_proc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, aic7xxx_proc_show, PDE(inode)->data);
}
+static const struct file_operations aic7xxx_proc_ops = {
+ .open = aic7xxx_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
/*
* Overrides for Emacs so that we follow Linus's tabbing style.
* Emacs will notice this stuff at the end of the file and automatically
--
1.7.3.4
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH 18/34] scsi proc_ops: convert drivers/scsi/ips.c
2012-02-22 19:45 [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops Alexey Dobriyan
` (15 preceding siblings ...)
2012-02-22 19:46 ` [PATCH 17/34] scsi proc_ops: convert drivers/scsi/aic7xxx_old.c Alexey Dobriyan
@ 2012-02-22 19:46 ` Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 19/34] scsi proc_ops: convert drivers/scsi/in2000.c Alexey Dobriyan
` (16 subsequent siblings)
33 siblings, 0 replies; 37+ messages in thread
From: Alexey Dobriyan @ 2012-02-22 19:46 UTC (permalink / raw)
To: JBottomley; +Cc: linux-scsi, Alexey Dobriyan
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
drivers/scsi/ips.c | 176 ++++++++++++++--------------------------------------
drivers/scsi/ips.h | 9 ---
2 files changed, 46 insertions(+), 139 deletions(-)
diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c
index d77891e..6e960cc 100644
--- a/drivers/scsi/ips.c
+++ b/drivers/scsi/ips.c
@@ -174,6 +174,7 @@
#include <linux/pci.h>
#include <linux/proc_fs.h>
#include <linux/reboot.h>
+#include <linux/seq_file.h>
#include <linux/interrupt.h>
#include <linux/blkdev.h>
@@ -326,10 +327,8 @@ 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 const struct file_operations ips_proc_ops;
+static void 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,7 @@ 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,
+ .proc_ops = &ips_proc_ops,
.slave_configure = ips_slave_configure,
.bios_param = ips_biosparam,
.this_id = -1,
@@ -1433,25 +1432,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)
+static int ips_proc_show(struct seq_file *m, void *v)
{
+ struct Scsi_Host *host = m->private;
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,20 +1451,22 @@ 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;
-
- ret = ips_host_info(ha, buffer, offset, length);
+ ips_host_info(ha, m);
+ return 0;
+}
- return (ret);
- }
+static int ips_proc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, ips_proc_show, PDE(inode)->data);
}
+static const struct file_operations ips_proc_ops = {
+ .open = ips_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
/*--------------------------------------------------------------------------*/
/* Helper Functions */
/*--------------------------------------------------------------------------*/
@@ -2034,51 +2022,43 @@ ips_cleanup_passthru(ips_ha_t * ha, ips_scb_t * scb)
/* The passthru interface for the driver */
/* */
/****************************************************************************/
-static int
-ips_host_info(ips_ha_t * ha, char *ptr, off_t offset, int len)
+static void
+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,
- "\tIO region : 0x%lx (%d bytes)\n",
+ seq_printf(m,
+ "\tIO region : 0x%x (%d bytes)\n",
ha->io_addr, ha->io_len);
if (ha->mem_addr) {
- copy_info(&info,
- "\tMemory region : 0x%lx (%d bytes)\n",
+ seq_printf(m,
+ "\tMemory region : 0x%x (%d bytes)\n",
ha->mem_addr, ha->mem_len);
- copy_info(&info,
- "\tShared memory address : 0x%lx\n",
+ seq_printf(m,
+ "\tShared memory address : %p\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,
+ 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],
@@ -2086,7 +2066,7 @@ ips_host_info(ips_ha_t * ha, char *ptr, off_t offset, int len)
ha->nvram->bios_low[2]);
} else {
- copy_info(&info,
+ 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],
@@ -2097,14 +2077,14 @@ ips_host_info(ips_ha_t * ha, char *ptr, off_t offset, int len)
}
if (ha->enq->CodeBlkVersion[7] == 0) {
- copy_info(&info,
+ 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,
+ 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],
@@ -2113,14 +2093,14 @@ ips_host_info(ips_ha_t * ha, char *ptr, off_t offset, int len)
}
if (ha->enq->BootBlkVersion[7] == 0) {
- copy_info(&info,
+ 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,
+ 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],
@@ -2128,90 +2108,26 @@ ips_host_info(ips_ha_t * ha, char *ptr, off_t offset, int len)
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;
-
- 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);
+ seq_printf(m, "\n");
}
/****************************************************************************/
diff --git a/drivers/scsi/ips.h b/drivers/scsi/ips.h
index f2df059..45b9566 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;
--
1.7.3.4
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH 19/34] scsi proc_ops: convert drivers/scsi/in2000.c
2012-02-22 19:45 [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops Alexey Dobriyan
` (16 preceding siblings ...)
2012-02-22 19:46 ` [PATCH 18/34] scsi proc_ops: convert drivers/scsi/ips.c Alexey Dobriyan
@ 2012-02-22 19:46 ` Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 20/34] scsi proc_ops: convert aic79xx Alexey Dobriyan
` (15 subsequent siblings)
33 siblings, 0 replies; 37+ messages in thread
From: Alexey Dobriyan @ 2012-02-22 19:46 UTC (permalink / raw)
To: JBottomley; +Cc: linux-scsi, Alexey Dobriyan
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
drivers/scsi/in2000.c | 191 ++++++++++++++++++++++++-------------------------
drivers/scsi/in2000.h | 1 -
2 files changed, 93 insertions(+), 99 deletions(-)
diff --git a/drivers/scsi/in2000.c b/drivers/scsi/in2000.c
index 112f1be..1f45434 100644
--- a/drivers/scsi/in2000.c
+++ b/drivers/scsi/in2000.c
@@ -119,6 +119,7 @@
#include <linux/string.h>
#include <linux/delay.h>
#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
#include <linux/ioport.h>
#include <linux/stat.h>
@@ -2056,7 +2057,7 @@ static int __init in2000_detect(struct scsi_host_template * tpnt)
hostdata->sync_off = 0xff; /* sync defaults to off */
#ifdef PROC_INTERFACE
- hostdata->proc = PR_VERSION | PR_INFO | PR_STATISTICS | PR_CONNECTED | PR_INPUTQ | PR_DISCQ | PR_STOP;
+ hostdata->proc = PR_VERSION | PR_INFO | PR_STATISTICS | PR_CONNECTED | PR_INPUTQ | PR_DISCQ;
#ifdef PROC_STATISTICS
hostdata->int_cnt = 0;
#endif
@@ -2166,161 +2167,155 @@ static int in2000_biosparam(struct scsi_device *sdev, struct block_device *bdev,
return 0;
}
-
-static int in2000_proc_info(struct Scsi_Host *instance, char *buf, char **start, off_t off, int len, int in)
-{
-
#ifdef PROC_INTERFACE
-
- char *bp;
- char tbuf[128];
+static int in2000_proc_show(struct seq_file *m, void *v)
+{
+ struct Scsi_Host *instance = m->private;
unsigned long flags;
struct IN2000_hostdata *hd;
Scsi_Cmnd *cmd;
- int x, i;
- static int stop = 0;
+ int x;
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;
- }
-
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);
+ 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[] = ");
+ 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++) {
- sprintf(tbuf, "\t%02x", hd->sync_xfer[x]);
- strcat(bp, tbuf);
+ seq_printf(m, "\t%02x", hd->sync_xfer[x]);
}
- strcat(bp, "\nsync_stat[] = ");
+ seq_printf(m, "\nsync_stat[] = ");
for (x = 0; x < 7; x++) {
- sprintf(tbuf, "\t%02x", hd->sync_stat[x]);
- strcat(bp, tbuf);
+ seq_printf(m, "\t%02x", hd->sync_stat[x]);
}
}
#ifdef PROC_STATISTICS
if (hd->proc & PR_STATISTICS) {
- strcat(bp, "\ncommands issued: ");
+ seq_printf(m, "\ncommands issued: ");
for (x = 0; x < 7; x++) {
- sprintf(tbuf, "\t%ld", hd->cmd_cnt[x]);
- strcat(bp, tbuf);
+ seq_printf(m, "\t%ld", hd->cmd_cnt[x]);
}
- strcat(bp, "\ndisconnects allowed:");
+ seq_printf(m, "\ndisconnects allowed:");
for (x = 0; x < 7; x++) {
- sprintf(tbuf, "\t%ld", hd->disc_allowed_cnt[x]);
- strcat(bp, tbuf);
+ seq_printf(m, "\t%ld", hd->disc_allowed_cnt[x]);
}
- strcat(bp, "\ndisconnects done: ");
+ seq_printf(m, "\ndisconnects done: ");
for (x = 0; x < 7; x++) {
- sprintf(tbuf, "\t%ld", hd->disc_done_cnt[x]);
- strcat(bp, tbuf);
+ seq_printf(m, "\t%ld", hd->disc_done_cnt[x]);
}
- sprintf(tbuf, "\ninterrupts: \t%ld", hd->int_cnt);
- strcat(bp, tbuf);
+ 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_putc(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);
+ return 0;
+}
-#else /* PROC_INTERFACE */
+static int in2000_proc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, in2000_proc_show, PDE(inode)->data);
+}
- return 0;
+static ssize_t in2000_proc_write(struct file *file, const char __user *buf, size_t count, loff_t *pos)
+{
+ struct Scsi_Host *instance = PDE(file->f_path.dentry->d_inode)->data;
+ struct IN2000_hostdata *hd = (struct IN2000_hostdata *)instance->hostdata;
+ char cmd[42], *bp;
+ size_t len;
+ int x, i;
+
+ len = min(count, sizeof(cmd) - 1);
+ if (copy_from_user(cmd, buf, len))
+ return -EFAULT;
+ cmd[len] = '\0';
-#endif /* PROC_INTERFACE */
+ /*
+ * We accept the following keywords (same format as command-line,
+ * but only ONE per read):
+ * debug
+ * disconnect
+ * period
+ * resync
+ * proc
+ */
+ bp = cmd;
+ 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 count;
}
+static const struct file_operations in2000_proc_ops = {
+ .open = in2000_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+ .write = in2000_proc_write,
+};
+#endif
+
MODULE_LICENSE("GPL");
static struct scsi_host_template driver_template = {
.proc_name = "in2000",
- .proc_info = in2000_proc_info,
+#ifdef PROC_INTERFACE
+ .proc_ops = &in2000_proc_ops,
+#endif
.name = "Always IN2000",
.detect = in2000_detect,
.release = in2000_release,
diff --git a/drivers/scsi/in2000.h b/drivers/scsi/in2000.h
index 5821e1f..bf86cc7 100644
--- a/drivers/scsi/in2000.h
+++ b/drivers/scsi/in2000.h
@@ -383,7 +383,6 @@ struct IN2000_hostdata {
#define PR_INPUTQ 1<<4
#define PR_DISCQ 1<<5
#define PR_TEST 1<<6
-#define PR_STOP 1<<7
# include <linux/init.h>
--
1.7.3.4
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH 20/34] scsi proc_ops: convert aic79xx
2012-02-22 19:45 [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops Alexey Dobriyan
` (17 preceding siblings ...)
2012-02-22 19:46 ` [PATCH 19/34] scsi proc_ops: convert drivers/scsi/in2000.c Alexey Dobriyan
@ 2012-02-22 19:46 ` Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 21/34] scsi proc_ops: convert aic7xxx Alexey Dobriyan
` (14 subsequent siblings)
33 siblings, 0 replies; 37+ messages in thread
From: Alexey Dobriyan @ 2012-02-22 19:46 UTC (permalink / raw)
To: JBottomley; +Cc: linux-scsi, Alexey Dobriyan
Remove dead code at ahd_send_async() while I'm at it.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
drivers/scsi/aic7xxx/aic79xx_osm.c | 8 +-
drivers/scsi/aic7xxx/aic79xx_osm.h | 13 +--
drivers/scsi/aic7xxx/aic79xx_proc.c | 214 ++++++++++++++---------------------
3 files changed, 91 insertions(+), 144 deletions(-)
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c
index 7d48700..3367b85 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm.c
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.c
@@ -906,7 +906,7 @@ struct scsi_host_template aic79xx_driver_template = {
.module = THIS_MODULE,
.name = "aic79xx",
.proc_name = "aic79xx",
- .proc_info = ahd_linux_proc_info,
+ .proc_ops = &ahd_linux_proc_ops,
.info = ahd_linux_info,
.queuecommand = ahd_linux_queue,
.eh_abort_handler = ahd_linux_abort,
@@ -1702,19 +1702,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 28e4349..c6a6d8d 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm.h
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.h
@@ -49,6 +49,8 @@
#include <linux/pci.h>
#include <linux/interrupt.h>
#include <linux/module.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
#include <linux/slab.h>
#include <asm/byteorder.h>
#include <asm/io.h>
@@ -379,14 +381,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 +507,7 @@ 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);
+extern const struct file_operations ahd_linux_proc_ops;
/*********************** 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 59c85d5..12f7663 100644
--- a/drivers/scsi/aic7xxx/aic79xx_proc.c
+++ b/drivers/scsi/aic7xxx/aic79xx_proc.c
@@ -42,16 +42,8 @@
#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,
- 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 +85,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 +105,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 +140,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_putc(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 +162,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,37 +182,37 @@ 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)
+ahd_proc_write_seeprom(struct ahd_softc *ahd, struct seeprom_config *sc)
{
ahd_mode_state saved_modes;
int have_seeprom;
u_long s;
int paused;
- int written;
+ int rv;
+ rv = -EINVAL;
/* Default to failure. */
- written = -EINVAL;
ahd_lock(ahd, &s);
paused = ahd_is_paused(ahd);
if (!paused)
@@ -271,12 +220,8 @@ ahd_proc_write_seeprom(struct ahd_softc *ahd, char *buffer, int length)
saved_modes = ahd_save_modes(ahd);
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
- if (length != sizeof(struct seeprom_config)) {
- printk("ahd_proc_write_seeprom: incorrect buffer size\n");
- goto done;
- }
- have_seeprom = ahd_verify_cksum((struct seeprom_config*)buffer);
+ have_seeprom = ahd_verify_cksum(sc);
if (have_seeprom == 0) {
printk("ahd_proc_write_seeprom: cksum verification failed\n");
goto done;
@@ -299,13 +244,13 @@ ahd_proc_write_seeprom(struct ahd_softc *ahd, char *buffer, int length)
}
printk("aic79xx: Writing Serial EEPROM\n");
start_addr = 32 * (ahd->channel - 'A');
- ahd_write_seeprom(ahd, (u_int16_t *)buffer, start_addr,
+ ahd_write_seeprom(ahd, (u_int16_t *)sc, start_addr,
sizeof(struct seeprom_config)/2);
ahd_read_seeprom(ahd, (uint16_t *)ahd->seep_config,
start_addr, sizeof(struct seeprom_config)/2,
/*ByteStream*/FALSE);
ahd_release_seeprom(ahd);
- written = length;
+ rv = 0;
}
done:
@@ -313,70 +258,85 @@ done:
if (!paused)
ahd_unpause(ahd);
ahd_unlock(ahd, &s);
- return (written);
+ return rv;
+}
+
+static ssize_t ahd_linux_proc_write(struct file *file, const char __user *buf,
+ size_t count, loff_t *pos)
+{
+ struct Scsi_Host *shost = PDE(file->f_path.dentry->d_inode)->data;
+ struct ahd_softc *ahd = *(struct ahd_softc **)shost->hostdata;
+ struct seeprom_config sc;
+ int rv;
+
+ if (count != sizeof(struct seeprom_config))
+ return -EINVAL;
+ if (copy_from_user(&sc, buf, sizeof(struct seeprom_config)))
+ return -EFAULT;
+
+ rv = ahd_proc_write_seeprom(ahd, &sc);
+ if (rv < 0)
+ return rv;
+ return count;
}
+
/*
* 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)
+static int ahd_linux_proc_show(struct seq_file *m, void *v)
{
+ struct Scsi_Host *shost = m->private;
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_putc(m, '\n');
}
- copy_info(&info, "0x%.4x ",
+ seq_printf(m, "0x%.4x ",
((uint16_t*)ahd->seep_config)[i]);
}
- copy_info(&info, "\n");
+ seq_putc(m, '\n');
}
- copy_info(&info, "\n");
+ seq_putc(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;
}
+
+static int ahd_linux_proc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, ahd_linux_proc_show, PDE(inode)->data);
+}
+
+const struct file_operations ahd_linux_proc_ops = {
+ .open = ahd_linux_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+ .write = ahd_linux_proc_write,
+};
--
1.7.3.4
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH 21/34] scsi proc_ops: convert aic7xxx
2012-02-22 19:45 [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops Alexey Dobriyan
` (18 preceding siblings ...)
2012-02-22 19:46 ` [PATCH 20/34] scsi proc_ops: convert aic79xx Alexey Dobriyan
@ 2012-02-22 19:46 ` Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 22/34] scsi proc_ops: convert drivers/scsi/dpt_i2o.c Alexey Dobriyan
` (13 subsequent siblings)
33 siblings, 0 replies; 37+ messages in thread
From: Alexey Dobriyan @ 2012-02-22 19:46 UTC (permalink / raw)
To: JBottomley; +Cc: linux-scsi, Alexey Dobriyan
Remove dead code at ahc_send_async() while I'm at it.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
drivers/scsi/aic7xxx/aic7xxx_osm.c | 8 +--
drivers/scsi/aic7xxx/aic7xxx_osm.h | 13 +--
drivers/scsi/aic7xxx/aic7xxx_proc.c | 203 ++++++++++++++---------------------
3 files changed, 84 insertions(+), 140 deletions(-)
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c
index c6251bb..345700d 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c
@@ -803,7 +803,7 @@ struct scsi_host_template aic7xxx_driver_template = {
.module = THIS_MODULE,
.name = "aic7xxx",
.proc_name = "aic7xxx",
- .proc_info = ahc_linux_proc_info,
+ .proc_ops = &ahc_linux_proc_ops,
.info = ahc_linux_info,
.queuecommand = ahc_linux_queue,
.eh_abort_handler = ahc_linux_abort,
@@ -1631,10 +1631,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 +1640,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 bca0fb83..d9a08d8 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.h
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.h
@@ -66,6 +66,8 @@
#include <linux/pci.h>
#include <linux/interrupt.h>
#include <linux/module.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
#include <linux/slab.h>
#include <asm/byteorder.h>
#include <asm/io.h>
@@ -383,14 +385,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 +517,7 @@ 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);
+extern const struct file_operations ahc_linux_proc_ops;
/*************************** Domain Validation ********************************/
/*********************** Transaction Access Wrappers *************************/
diff --git a/drivers/scsi/aic7xxx/aic7xxx_proc.c b/drivers/scsi/aic7xxx/aic7xxx_proc.c
index f2525f8..7232798 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_proc.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_proc.c
@@ -43,16 +43,8 @@
#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,
- 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 +86,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 +102,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 +115,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_putc(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 +139,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,48 +160,43 @@ 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)
+ahc_proc_write_seeprom(struct ahc_softc *ahc, struct seeprom_config *sc)
{
struct seeprom_descriptor sd;
int have_seeprom;
u_long s;
int paused;
- int written;
+ int rv;
/* Default to failure. */
- written = -EINVAL;
+ rv = -EINVAL;
ahc_lock(ahc, &s);
paused = ahc_is_paused(ahc);
if (!paused)
ahc_pause(ahc);
- if (length != sizeof(struct seeprom_config)) {
- printk("ahc_proc_write_seeprom: incorrect buffer size\n");
- goto done;
- }
-
- have_seeprom = ahc_verify_cksum((struct seeprom_config*)buffer);
+ have_seeprom = ahc_verify_cksum(sc);
if (have_seeprom == 0) {
printk("ahc_proc_write_seeprom: cksum verification failed\n");
goto done;
@@ -310,7 +254,7 @@ ahc_proc_write_seeprom(struct ahc_softc *ahc, char *buffer, int length)
}
printk("aic7xxx: Writing Serial EEPROM\n");
start_addr = 32 * (ahc->channel - 'A');
- ahc_write_seeprom(&sd, (u_int16_t *)buffer, start_addr,
+ ahc_write_seeprom(&sd, (u_int16_t *)sc, start_addr,
sizeof(struct seeprom_config)/2);
ahc_read_seeprom(&sd, (uint16_t *)ahc->seep_config,
start_addr, sizeof(struct seeprom_config)/2);
@@ -318,67 +262,69 @@ ahc_proc_write_seeprom(struct ahc_softc *ahc, char *buffer, int length)
if ((ahc->chip & AHC_VL) == 0)
ahc_release_seeprom(&sd);
#endif
- written = length;
+ rv = 0;
}
done:
if (!paused)
ahc_unpause(ahc);
ahc_unlock(ahc, &s);
- return (written);
+ return rv;
+}
+
+static ssize_t ahc_linux_proc_write(struct file *file, const char __user *buf,
+ size_t count, loff_t *pos)
+{
+ struct Scsi_Host *shost = PDE(file->f_path.dentry->d_inode)->data;
+ struct ahc_softc *ahc = *(struct ahc_softc **)shost->hostdata;
+ struct seeprom_config sc;
+ int rv;
+
+ if (count != sizeof(struct seeprom_config))
+ return -EINVAL;
+ if (copy_from_user(&sc, buf, sizeof(struct seeprom_config)))
+ return -EFAULT;
+
+ rv = ahc_proc_write_seeprom(ahc, &sc);
+ if (rv < 0)
+ return rv;
+ return count;
}
/*
* 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)
+static int ahc_linux_proc_show(struct seq_file *m, void *v)
{
+ struct Scsi_Host *shost = m->private;
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_putc(m, '\n');
}
- copy_info(&info, "0x%.4x ",
+ seq_printf(m, "0x%.4x ",
((uint16_t*)ahc->seep_config)[i]);
}
- copy_info(&info, "\n");
+ seq_putc(m, '\n');
}
- copy_info(&info, "\n");
+ seq_putc(m, '\n');
max_targ = 16;
if ((ahc->features & (AHC_WIDE|AHC_TWIN)) == 0)
@@ -398,10 +344,21 @@ 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;
}
+
+static int ahc_linux_proc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, ahc_linux_proc_show, PDE(inode)->data);
+}
+
+const struct file_operations ahc_linux_proc_ops = {
+ .open = ahc_linux_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+ .write = ahc_linux_proc_write,
+};
--
1.7.3.4
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH 22/34] scsi proc_ops: convert drivers/scsi/dpt_i2o.c
2012-02-22 19:45 [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops Alexey Dobriyan
` (19 preceding siblings ...)
2012-02-22 19:46 ` [PATCH 21/34] scsi proc_ops: convert aic7xxx Alexey Dobriyan
@ 2012-02-22 19:46 ` Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 23/34] scsi proc_ops: convert drivers/scsi/gdth.c Alexey Dobriyan
` (12 subsequent siblings)
33 siblings, 0 replies; 37+ messages in thread
From: Alexey Dobriyan @ 2012-02-22 19:46 UTC (permalink / raw)
To: JBottomley; +Cc: linux-scsi, Alexey Dobriyan
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
drivers/scsi/dpt_i2o.c | 112 +++++++++++-------------------------------------
1 files changed, 25 insertions(+), 87 deletions(-)
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index b4f6c9a..46c4c5f 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -48,6 +48,7 @@ MODULE_DESCRIPTION("Adaptec I2O RAID Driver");
#include <linux/interrupt.h>
#include <linux/kernel.h> /* for printk */
#include <linux/sched.h>
+#include <linux/seq_file.h>
#include <linux/reboot.h>
#include <linux/spinlock.h>
#include <linux/dma-mapping.h>
@@ -553,36 +554,15 @@ 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_proc_show(struct seq_file *m, void *v)
{
+ struct Scsi_Host *host = m->private;
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,88 +576,46 @@ 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;
- }
+ 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;
+}
+
+static int adpt_proc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, adpt_proc_show, PDE(inode)->data);
}
+static const struct file_operations adpt_proc_ops = {
+ .open = adpt_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
/*
* Turn a struct scsi_cmnd * into a unique 32 bit 'context'.
*/
@@ -3639,7 +3577,7 @@ static struct scsi_host_template driver_template = {
.module = THIS_MODULE,
.name = "dpt_i2o",
.proc_name = "dpt_i2o",
- .proc_info = adpt_proc_info,
+ .proc_ops = &adpt_proc_ops,
.info = adpt_info,
.queuecommand = adpt_queue,
.eh_abort_handler = adpt_abort,
--
1.7.3.4
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH 23/34] scsi proc_ops: convert drivers/scsi/gdth.c
2012-02-22 19:45 [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops Alexey Dobriyan
` (20 preceding siblings ...)
2012-02-22 19:46 ` [PATCH 22/34] scsi proc_ops: convert drivers/scsi/dpt_i2o.c Alexey Dobriyan
@ 2012-02-22 19:46 ` Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 24/34] scsi proc_ops: convert drivers/usb/storage/scsiglue.c Alexey Dobriyan
` (11 subsequent siblings)
33 siblings, 0 replies; 37+ messages in thread
From: Alexey Dobriyan @ 2012-02-22 19:46 UTC (permalink / raw)
To: JBottomley; +Cc: linux-scsi, Alexey Dobriyan
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
drivers/scsi/gdth.c | 2 +-
drivers/scsi/gdth.h | 6 --
drivers/scsi/gdth_proc.c | 215 ++++++++++++++++------------------------------
drivers/scsi/gdth_proc.h | 2 -
4 files changed, 76 insertions(+), 149 deletions(-)
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index 3242bca..fa3a1e3 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -4683,7 +4683,7 @@ 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,
+ .proc_ops = &gdth_proc_ops,
.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 d3e4d7c..b8e1302 100644
--- a/drivers/scsi/gdth.h
+++ b/drivers/scsi/gdth.h
@@ -1012,10 +1012,4 @@ typedef struct {
typedef struct {
unsigned long b[10]; /* 32/64 bit compiler ! */
} __attribute__((packed)) gdth_stackframe;
-
-
-/* function prototyping */
-
-int gdth_proc_info(struct Scsi_Host *, char *,char **,off_t,int,int);
-
#endif
diff --git a/drivers/scsi/gdth_proc.c b/drivers/scsi/gdth_proc.c
index 6527543..e6ad478 100644
--- a/drivers/scsi/gdth_proc.c
+++ b/drivers/scsi/gdth_proc.c
@@ -3,22 +3,9 @@
*/
#include <linux/completion.h>
+#include <linux/seq_file.h>
#include <linux/slab.h>
-int gdth_proc_info(struct Scsi_Host *host, char *buffer,char **start,off_t offset,int length,
- int inout)
-{
- 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)
{
@@ -149,12 +136,11 @@ 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)
+static int gdth_proc_show(struct seq_file *m, void *v)
{
- int size = 0,len = 0;
+ struct Scsi_Host *host = m->private;
+ 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 +175,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,23 +186,19 @@ 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;
+ seq_printf(m, "\nDisk Array Controller Information:\n");
strcpy(hrec, ha->binfo.type_string);
- size = sprintf(buffer+len,
+ seq_printf(m,
" Number: \t%d \tName: \t%s\n",
ha->hanum, hrec);
- len += size; pos = begin + len;
if (ha->more_proc)
sprintf(hrec, "%d.%02d.%02d-%c%03X",
@@ -230,40 +211,28 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
sprintf(hrec, "%d.%02d", (u8)(ha->cpar.version>>8),
(u8)(ha->cpar.version));
- size = sprintf(buffer+len,
+ seq_printf(m,
" Driver Ver.: \t%-10s\tFirmware Ver.: \t%s\n",
GDTH_VERSION_STR, hrec);
- len += size; pos = begin + len;
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 +278,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 +300,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 +321,21 @@ 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;
+ 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 +373,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 +390,39 @@ 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,
+ 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;
+ 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 +457,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 +470,20 @@ 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;
+ 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 +525,23 @@ 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;
+ 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,28 +553,15 @@ 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;
}
+ rc = 0;
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;
free_fail:
kfree(gdtcmd);
@@ -758,3 +655,41 @@ static void gdth_wait_completion(gdth_ha_str *ha, int busnum, int id)
}
spin_unlock_irqrestore(&ha->smp_lock, flags);
}
+
+static int gdth_proc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, gdth_proc_show, PDE(inode)->data);
+}
+
+static ssize_t gdth_proc_write(struct file *file, const char __user *buf, size_t count, loff_t *pos)
+{
+ struct Scsi_Host *host = PDE(file->f_path.dentry->d_inode)->data;
+ gdth_ha_str *ha = shost_priv(host);
+ char *cmd;
+ size_t len;
+ int rv;
+
+ cmd = kmalloc(PAGE_SIZE, GFP_KERNEL);
+ if (!cmd)
+ return -ENOMEM;
+ len = min_t(size_t, count, PAGE_SIZE - 1);
+ if (copy_from_user(cmd, buf, len)) {
+ kfree(cmd);
+ return -ENOMEM;
+ }
+ cmd[len] = '\0';
+
+ rv = gdth_set_info(cmd, len, host, ha);
+ kfree(cmd);
+ if (rv < 0)
+ return rv;
+ return count;
+}
+
+static const struct file_operations gdth_proc_ops = {
+ .open = gdth_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+ .write = gdth_proc_write,
+};
diff --git a/drivers/scsi/gdth_proc.h b/drivers/scsi/gdth_proc.h
index dab15f5..7914dcf 100644
--- a/drivers/scsi/gdth_proc.h
+++ b/drivers/scsi/gdth_proc.h
@@ -10,8 +10,6 @@ int gdth_execute(struct Scsi_Host *shost, gdth_cmd_str *gdtcmd, char *cmnd,
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);
--
1.7.3.4
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH 24/34] scsi proc_ops: convert drivers/usb/storage/scsiglue.c
2012-02-22 19:45 [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops Alexey Dobriyan
` (21 preceding siblings ...)
2012-02-22 19:46 ` [PATCH 23/34] scsi proc_ops: convert drivers/scsi/gdth.c Alexey Dobriyan
@ 2012-02-22 19:46 ` Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 25/34] scsi proc_ops: convert drivers/block/cciss.c Alexey Dobriyan
` (10 subsequent siblings)
33 siblings, 0 replies; 37+ messages in thread
From: Alexey Dobriyan @ 2012-02-22 19:46 UTC (permalink / raw)
To: JBottomley; +Cc: linux-scsi, Alexey Dobriyan
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
drivers/usb/storage/scsiglue.c | 45 ++++++++++++++++++---------------------
1 files changed, 21 insertions(+), 24 deletions(-)
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index 13b8bcd..40376cb 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -45,6 +45,8 @@
#include <linux/module.h>
#include <linux/mutex.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
@@ -418,19 +420,14 @@ 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)
+ 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 usb_stor_proc_show(struct seq_file *m, void *v)
{
+ struct Scsi_Host *host = m->private;
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);
@@ -460,30 +457,30 @@ 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:");
+ seq_printf(m, " 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';
- }
+ seq_putc(m, '\n');
- /*
- * Calculate start of next buffer, and return value.
- */
- *start = buffer + offset;
+ return 0;
+}
- if ((pos - buffer) < offset)
- return (0);
- else if ((pos - buffer - offset) < length)
- return (pos - buffer - offset);
- else
- return (length);
+static int usb_stor_proc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, usb_stor_proc_show, PDE(inode)->data);
}
+static const struct file_operations usb_stor_proc_ops = {
+ .open = usb_stor_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
/***********************************************************************
* Sysfs interface
***********************************************************************/
@@ -526,7 +523,7 @@ struct scsi_host_template usb_stor_host_template = {
/* basic userland interface stuff */
.name = "usb-storage",
.proc_name = "usb-storage",
- .proc_info = proc_info,
+ .proc_ops = &usb_stor_proc_ops,
.info = host_info,
/* command interface -- queued only */
--
1.7.3.4
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH 25/34] scsi proc_ops: convert drivers/block/cciss.c
2012-02-22 19:45 [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops Alexey Dobriyan
` (22 preceding siblings ...)
2012-02-22 19:46 ` [PATCH 24/34] scsi proc_ops: convert drivers/usb/storage/scsiglue.c Alexey Dobriyan
@ 2012-02-22 19:46 ` Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 26/34] scsi proc_ops: convert drivers/message/fusion/ Alexey Dobriyan
` (9 subsequent siblings)
33 siblings, 0 replies; 37+ messages in thread
From: Alexey Dobriyan @ 2012-02-22 19:46 UTC (permalink / raw)
To: JBottomley; +Cc: linux-scsi, Alexey Dobriyan
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
drivers/block/cciss_scsi.c | 123 ++++++++++++++++++++-----------------------
1 files changed, 57 insertions(+), 66 deletions(-)
diff --git a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c
index e820b68..b55a195 100644
--- a/drivers/block/cciss_scsi.c
+++ b/drivers/block/cciss_scsi.c
@@ -54,13 +54,7 @@ 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,
- 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 */
+static const struct file_operations cciss_scsi_proc_ops;
static int cciss_scsi_queue_command (struct Scsi_Host *h,
struct scsi_cmnd *cmd);
@@ -82,7 +76,7 @@ static struct scsi_host_template cciss_driver_template = {
.module = THIS_MODULE,
.name = "cciss",
.proc_name = "cciss",
- .proc_info = cciss_scsi_proc_info,
+ .proc_ops = &cciss_scsi_proc_ops,
.queuecommand = cciss_scsi_queue_command,
.this_id = 7,
.cmd_per_lun = 1,
@@ -1287,39 +1281,9 @@ out:
return;
}
-static int
-is_keyword(char *ptr, int len, char *verb) // Thanks to ncr53c8xx.c
-{
- int verb_len = strlen(verb);
- if (len >= verb_len && !memcmp(verb,ptr,verb_len))
- return verb_len;
- else
- return 0;
-}
-
-static int
-cciss_scsi_user_command(ctlr_info_t *h, int hostno, char *buffer, int length)
+static int cciss_scsi_proc_show(struct seq_file *m, void *v)
{
- int arg_len;
-
- if ((arg_len = is_keyword(buffer, length, "rescan")) != 0)
- cciss_update_non_disk_devices(h, hostno);
- else
- return -EINVAL;
- return length;
-}
-
-
-static int
-cciss_scsi_proc_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 buflen, datalen;
+ struct Scsi_Host *sh = m->private;
ctlr_info_t *h;
int i;
@@ -1327,22 +1291,20 @@ cciss_scsi_proc_info(struct Scsi_Host *sh,
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 "
+ 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,
@@ -1351,18 +1313,47 @@ cciss_scsi_proc_info(struct Scsi_Host *sh,
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);
+ return 0;
}
+static int cciss_scsi_proc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, cciss_scsi_proc_show, PDE(inode)->data);
+}
+
+static ssize_t cciss_scsi_proc_write(struct file *file, const char __user *buf,
+ size_t count, loff_t *pos)
+{
+ struct Scsi_Host *sh = PDE(file->f_path.dentry->d_inode)->data;
+ ctlr_info_t *h;
+ char cmd[sizeof("rescan")];
+ size_t len;
+
+ h = (ctlr_info_t *)sh->hostdata[0];
+ if (h == NULL) /* This really shouldn't ever happen. */
+ return -EINVAL;
+
+ len = min(count, sizeof(cmd) - 1);
+ if (copy_from_user(cmd, buf, len))
+ return -EFAULT;
+ cmd[len] = '\0';
+
+ if (strcmp(cmd, "rescan") != 0)
+ return -EINVAL;
+
+ cciss_update_non_disk_devices(h, sh->host_no);
+
+ return count;
+}
+
+static const struct file_operations cciss_scsi_proc_ops = {
+ .open = cciss_scsi_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+ .write = cciss_scsi_proc_write,
+};
+
/* cciss_scatter_gather takes a struct scsi_cmnd, (cmd), and does the pci
dma mapping and fills in the scatter gather entries of the
cciss command, c. */
--
1.7.3.4
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH 26/34] scsi proc_ops: convert drivers/message/fusion/
2012-02-22 19:45 [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops Alexey Dobriyan
` (23 preceding siblings ...)
2012-02-22 19:46 ` [PATCH 25/34] scsi proc_ops: convert drivers/block/cciss.c Alexey Dobriyan
@ 2012-02-22 19:46 ` Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 27/34] scsi proc_ops: remove tcm_loop proc code Alexey Dobriyan
` (8 subsequent siblings)
33 siblings, 0 replies; 37+ messages in thread
From: Alexey Dobriyan @ 2012-02-22 19:46 UTC (permalink / raw)
To: JBottomley; +Cc: linux-scsi, Alexey Dobriyan
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
drivers/message/fusion/mptfc.c | 2 +-
drivers/message/fusion/mptsas.c | 2 +-
drivers/message/fusion/mptscsih.c | 109 +++++++------------------------------
drivers/message/fusion/mptscsih.h | 2 +-
drivers/message/fusion/mptspi.c | 2 +-
5 files changed, 23 insertions(+), 94 deletions(-)
diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c
index d784c36..80e7508 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,
+ .proc_ops = &mptscsih_proc_ops,
.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 551262e..40806d3 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,
+ .proc_ops = &mptscsih_proc_ops,
.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 0c3ced7..866f782 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -54,6 +54,7 @@
#include <linux/delay.h> /* for mdelay */
#include <linux/interrupt.h> /* needed for in_interrupt() proto */
#include <linux/reboot.h> /* notifier code */
+#include <linux/seq_file.h>
#include <linux/workqueue.h>
#include <scsi/scsi.h>
@@ -1283,102 +1284,31 @@ 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)
+static int mptscsih_proc_show(struct seq_file *m, void *v)
{
- 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);
- }
+ struct Scsi_Host *host = m->private;
+ MPT_SCSI_HOST *hd = shost_priv(host);
+ MPT_ADAPTER *ioc = hd->ioc;
- if (len > 0) {
- memcpy(info->buffer + info->pos, data, len);
- info->pos += len;
- }
+ 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 0;
}
-static int
-mptscsih_copy_info(struct info_str *info, char *fmt, ...)
+static int mptscsih_proc_open(struct inode *inode, struct file *file)
{
- 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;
+ return single_open(file, mptscsih_proc_show, PDE(inode)->data);
}
-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)
-{
- 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);
- }
-
- return size;
-}
+const struct file_operations mptscsih_proc_ops = {
+ .open = mptscsih_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+EXPORT_SYMBOL(mptscsih_proc_ops);
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
#define ADD_INDEX_LOG(req_ent) do { } while(0)
@@ -3347,7 +3277,6 @@ EXPORT_SYMBOL(mptscsih_shutdown);
EXPORT_SYMBOL(mptscsih_suspend);
EXPORT_SYMBOL(mptscsih_resume);
#endif
-EXPORT_SYMBOL(mptscsih_proc_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 43e75ff..3a4f9a1 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 const struct file_operations mptscsih_proc_ops;
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 8f61ba6..85a0ba2 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,
+ .proc_ops = &mptscsih_proc_ops,
.name = "MPT SPI Host",
.info = mptscsih_info,
.queuecommand = mptspi_qcmd,
--
1.7.3.4
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH 27/34] scsi proc_ops: remove tcm_loop proc code
2012-02-22 19:45 [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops Alexey Dobriyan
` (24 preceding siblings ...)
2012-02-22 19:46 ` [PATCH 26/34] scsi proc_ops: convert drivers/message/fusion/ Alexey Dobriyan
@ 2012-02-22 19:46 ` Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 28/34] scsi proc_ops: convert drivers/scsi/eata_pio.c Alexey Dobriyan
` (7 subsequent siblings)
33 siblings, 0 replies; 37+ messages in thread
From: Alexey Dobriyan @ 2012-02-22 19:46 UTC (permalink / raw)
To: JBottomley; +Cc: linux-scsi, Alexey Dobriyan
proc file shows absolutely useless info, remove it.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
drivers/target/loopback/tcm_loop.c | 9 ---------
1 files changed, 0 insertions(+), 9 deletions(-)
diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c
index c47ff7f..e2a4ec4 100644
--- a/drivers/target/loopback/tcm_loop.c
+++ b/drivers/target/loopback/tcm_loop.c
@@ -205,13 +205,6 @@ 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)
-{
- return sprintf(buffer, "tcm_loop_proc_info()\n");
-}
-
static int tcm_loop_driver_probe(struct device *);
static int tcm_loop_driver_remove(struct device *);
@@ -410,8 +403,6 @@ 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,
- .proc_name = "tcm_loopback",
.name = "TCM_Loopback",
.queuecommand = tcm_loop_queuecommand,
.change_queue_depth = tcm_loop_change_queue_depth,
--
1.7.3.4
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH 28/34] scsi proc_ops: convert drivers/scsi/eata_pio.c
2012-02-22 19:45 [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops Alexey Dobriyan
` (25 preceding siblings ...)
2012-02-22 19:46 ` [PATCH 27/34] scsi proc_ops: remove tcm_loop proc code Alexey Dobriyan
@ 2012-02-22 19:46 ` Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 29/34] scsi proc_ops: convert drivers/ata/sata_svw.c Alexey Dobriyan
` (6 subsequent siblings)
33 siblings, 0 replies; 37+ messages in thread
From: Alexey Dobriyan @ 2012-02-22 19:46 UTC (permalink / raw)
To: JBottomley; +Cc: linux-scsi, Alexey Dobriyan
BROKEN, but convert anyway.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
drivers/scsi/eata_pio.c | 69 ++++++++++++++++------------------------------
1 files changed, 24 insertions(+), 45 deletions(-)
diff --git a/drivers/scsi/eata_pio.c b/drivers/scsi/eata_pio.c
index d5f8362..7d601e7 100644
--- a/drivers/scsi/eata_pio.c
+++ b/drivers/scsi/eata_pio.c
@@ -55,6 +55,7 @@
#include <linux/proc_fs.h>
#include <linux/interrupt.h>
#include <linux/blkdev.h>
+#include <linux/seq_file.h>
#include <linux/spinlock.h>
#include <linux/delay.h>
@@ -92,60 +93,38 @@ 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_proc_show(struct seq_file *m, void *v)
{
- int len = 0;
- off_t begin = 0, pos = 0;
+ struct Scsi_Host *shost = m->private;
- 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_proc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, eata_pio_proc_show, PDE(inode)->data);
}
+static const struct file_operations eata_pio_proc_ops = {
+ .open = eata_pio_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
static int eata_pio_release(struct Scsi_Host *sh)
{
hostdata *hd = SD(sh);
@@ -985,7 +964,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,
+ .proc_ops = &eata_pio_proc_ops,
.detect = eata_pio_detect,
.release = eata_pio_release,
.queuecommand = eata_pio_queue,
--
1.7.3.4
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH 29/34] scsi proc_ops: convert drivers/ata/sata_svw.c
2012-02-22 19:45 [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops Alexey Dobriyan
` (26 preceding siblings ...)
2012-02-22 19:46 ` [PATCH 28/34] scsi proc_ops: convert drivers/scsi/eata_pio.c Alexey Dobriyan
@ 2012-02-22 19:46 ` Alexey Dobriyan
2012-03-22 17:25 ` Jeff Garzik
2012-02-22 19:46 ` [PATCH 30/34] scsi proc_ops: convert drivers/scsi/g_NCR5380.c Alexey Dobriyan
` (5 subsequent siblings)
33 siblings, 1 reply; 37+ messages in thread
From: Alexey Dobriyan @ 2012-02-22 19:46 UTC (permalink / raw)
To: JBottomley; +Cc: linux-scsi, Alexey Dobriyan
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
drivers/ata/sata_svw.c | 34 +++++++++++++++++-----------------
1 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/drivers/ata/sata_svw.c b/drivers/ata/sata_svw.c
index c646118..05838bf 100644
--- a/drivers/ata/sata_svw.c
+++ b/drivers/ata/sata_svw.c
@@ -289,23 +289,12 @@ 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_proc_show(struct seq_file *m, void *v)
{
+ struct Scsi_Host *shost = m->private;
struct ata_port *ap;
struct device_node *np;
- int len, index;
+ int index;
/* Find the ata_port */
ap = ata_shost_to_port(shost);
@@ -329,17 +318,28 @@ static int k2_sata_proc_info(struct Scsi_Host *shost, char *page, char **start,
if (np == NULL)
return 0;
- len = sprintf(page, "devspec: %s\n", np->full_name);
+ seq_printf(m, "devspec: %s\n", np->full_name);
+ return 0;
+}
- return len;
+static int k2_sata_proc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, k2_sata_proc_show, PDE(inode)->data);
}
+
+static const struct file_operations k2_sata_proc_ops = {
+ .open = k2_sata_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
#endif /* CONFIG_PPC_OF */
static struct scsi_host_template k2_sata_sht = {
ATA_BMDMA_SHT(DRV_NAME),
#ifdef CONFIG_PPC_OF
- .proc_info = k2_sata_proc_info,
+ .proc_ops = &k2_sata_proc_ops,
#endif
};
--
1.7.3.4
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH 30/34] scsi proc_ops: convert drivers/scsi/g_NCR5380.c
2012-02-22 19:45 [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops Alexey Dobriyan
` (27 preceding siblings ...)
2012-02-22 19:46 ` [PATCH 29/34] scsi proc_ops: convert drivers/ata/sata_svw.c Alexey Dobriyan
@ 2012-02-22 19:46 ` Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 31/34] scsi proc_ops: convert NCR5380-based drivers Alexey Dobriyan
` (4 subsequent siblings)
33 siblings, 0 replies; 37+ messages in thread
From: Alexey Dobriyan @ 2012-02-22 19:46 UTC (permalink / raw)
To: JBottomley; +Cc: linux-scsi, Alexey Dobriyan
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
drivers/scsi/g_NCR5380.c | 79 +++++++++++++++++++--------------------------
1 files changed, 33 insertions(+), 46 deletions(-)
diff --git a/drivers/scsi/g_NCR5380.c b/drivers/scsi/g_NCR5380.c
index 81182ba..cdd8dc2 100644
--- a/drivers/scsi/g_NCR5380.c
+++ b/drivers/scsi/g_NCR5380.c
@@ -114,6 +114,8 @@
#include <linux/isapnp.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
#define NCR_NOT_SET 0
static int ncr_irq = NCR_NOT_SET;
@@ -746,24 +748,21 @@ 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;
}
/**
@@ -775,35 +774,16 @@ static int sprint_command(char *buffer, int len, unsigned char *command)
* 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);
}
-/**
- * generic_NCR5380_proc_info - /proc for NCR5380 driver
- * @buffer: buffer to print into
- * @start: start position
- * @offset: offset into buffer
- * @len: length
- * @hostno: instance to affect
- * @inout: read/write
- *
- * Provide the procfs information for the 5380 controller. We fill
- * this with useful debugging information including the commands
- * being executed, disconnected command queue and the statistical
- * data
- *
- * 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_proc_show(struct seq_file *m, void *v)
{
- int len = 0;
+ struct Scsi_Host *scsi_ptr = m->private;
NCR5380_local_declare();
unsigned long flags;
unsigned char status;
@@ -854,16 +834,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)
@@ -887,32 +867,39 @@ 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 int generic_NCR5380_proc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, generic_NCR5380_proc_show, PDE(inode)->data);
+}
+
+static const struct file_operations generic_NCR5380_proc_ops = {
+ .open = generic_NCR5380_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
static struct scsi_host_template driver_template = {
- .proc_info = generic_NCR5380_proc_info,
+ .proc_ops = &generic_NCR5380_proc_ops,
.name = "Generic NCR5380/NCR53C400 Scsi Driver",
.detect = generic_NCR5380_detect,
.release = generic_NCR5380_release_resources,
--
1.7.3.4
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH 31/34] scsi proc_ops: convert NCR5380-based drivers
2012-02-22 19:45 [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops Alexey Dobriyan
` (28 preceding siblings ...)
2012-02-22 19:46 ` [PATCH 30/34] scsi proc_ops: convert drivers/scsi/g_NCR5380.c Alexey Dobriyan
@ 2012-02-22 19:46 ` Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 32/34] scsi proc_ops: convert drivers/scsi/arm/ drivers Alexey Dobriyan
` (3 subsequent siblings)
33 siblings, 0 replies; 37+ messages in thread
From: Alexey Dobriyan @ 2012-02-22 19:46 UTC (permalink / raw)
To: JBottomley; +Cc: linux-scsi, Alexey Dobriyan
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
drivers/scsi/NCR5380.c | 100 ++++++++++++++++++++++----------------------
drivers/scsi/NCR5380.h | 3 +-
drivers/scsi/arm/oak.c | 4 +-
drivers/scsi/atari_scsi.c | 2 +-
drivers/scsi/atari_scsi.h | 2 +-
drivers/scsi/dtc.c | 2 +-
drivers/scsi/dtc.h | 2 +-
drivers/scsi/mac_scsi.c | 2 +-
drivers/scsi/mac_scsi.h | 2 +-
drivers/scsi/pas16.c | 2 +-
drivers/scsi/pas16.h | 2 +-
drivers/scsi/t128.c | 2 +-
drivers/scsi/t128.h | 2 +-
13 files changed, 63 insertions(+), 64 deletions(-)
diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
index 165e4dd86..ec9822d 100644
--- a/drivers/scsi/NCR5380.c
+++ b/drivers/scsi/NCR5380.c
@@ -86,6 +86,8 @@
* 5. Test linked command handling code after Eric is ready with
* the high level code.
*/
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
#include <scsi/scsi_dbg.h>
#include <scsi/scsi_transport_spi.h>
@@ -696,32 +698,36 @@ static void NCR5380_print_status(struct Scsi_Host *instance)
*/
#undef SPRINTF
-#define SPRINTF(args...) do { if(pos < buffer + length-80) pos += sprintf(pos, ## args); } while(0)
-static
-char *lprint_Scsi_Cmnd(Scsi_Cmnd * cmd, char *pos, char *buffer, int length);
-static
-char *lprint_command(unsigned char *cmd, char *pos, char *buffer, int len);
-static
-char *lprint_opcode(int opcode, char *pos, char *buffer, int length);
-
-static int __maybe_unused NCR5380_proc_info(struct Scsi_Host *instance,
- char *buffer, char **start, off_t offset, int length, int inout)
+#define SPRINTF(args...) seq_printf(m, ## args)
+
+static void lprint_opcode(struct seq_file *m, int opcode)
{
- char *pos = buffer;
- struct NCR5380_hostdata *hostdata;
- Scsi_Cmnd *ptr;
+ SPRINTF("%2d (0x%02x)", opcode, opcode);
+}
- hostdata = (struct NCR5380_hostdata *) instance->hostdata;
+static void lprint_command(struct seq_file *m, unsigned char *command)
+{
+ int i, s;
+
+ lprint_opcode(m, command[0]);
+ for (i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i)
+ SPRINTF("%02x ", command[i]);
+ SPRINTF("\n");
+}
+
+static void lprint_Scsi_Cmnd(struct seq_file *m, Scsi_Cmnd *cmd)
+{
+ SPRINTF("scsi%d : destination target %d, lun %d\n", cmd->device->host->host_no, cmd->device->id, cmd->device->lun);
+ SPRINTF(" command = ");
+ lprint_command(m, cmd->cmnd);
+}
+
+static int NCR5380_proc_show(struct seq_file *m, void *v)
+{
+ struct Scsi_Host *instance = m->private;
+ struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *)instance->hostdata;
+ Scsi_Cmnd *ptr;
- 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,48 +761,42 @@ 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(m, (Scsi_Cmnd *) hostdata->connected);
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(m, ptr);
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(m, ptr);
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 int NCR5380_proc_open(struct inode *inode, struct file *file)
{
- 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);
+ return single_open(file, NCR5380_proc_show, PDE(inode)->data);
}
-static char *lprint_command(unsigned char *command, char *pos, char *buffer, int length)
+static ssize_t NCR5380_proc_write(struct file *file, const char __user *buf, size_t count, loff_t *pos)
{
- int i, s;
- pos = lprint_opcode(command[0], pos, buffer, length);
- 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)
-{
- SPRINTF("%2d (0x%02x)", opcode, opcode);
- return (pos);
+#ifdef DTC_PUBLIC_RELEASE
+ dtc_wmaxi = dtc_maxi = 0;
+#endif
+#ifdef PAS16_PUBLIC_RELEASE
+ pas_wmaxi = pas_maxi = 0;
+#endif
+ return -ENOSYS;
}
+static const struct file_operations __maybe_unused NCR5380_proc_ops = {
+ .open = NCR5380_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+ .write = NCR5380_proc_write,
+};
/**
* NCR5380_init - initialise an NCR5380
diff --git a/drivers/scsi/NCR5380.h b/drivers/scsi/NCR5380.h
index fd40a32..00445e2 100644
--- a/drivers/scsi/NCR5380.h
+++ b/drivers/scsi/NCR5380.h
@@ -314,8 +314,7 @@ 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 const struct file_operations __maybe_unused NCR5380_proc_ops;
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/oak.c b/drivers/scsi/arm/oak.c
index 849cdf8..d738399 100644
--- a/drivers/scsi/arm/oak.c
+++ b/drivers/scsi/arm/oak.c
@@ -31,7 +31,7 @@
#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_proc_ops oakscsi_proc_ops
#define NCR5380_implementation_fields \
void __iomem *base
@@ -115,7 +115,7 @@ printk("reading %p len %d\n", addr, len);
static struct scsi_host_template oakscsi_template = {
.module = THIS_MODULE,
- .proc_info = oakscsi_proc_info,
+ .proc_ops = &oakscsi_proc_ops,
.name = "Oak 16-bit SCSI",
.info = oakscsi_info,
.queuecommand = oakscsi_queue_command,
diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c
index 04a154f..0674d17 100644
--- a/drivers/scsi/atari_scsi.c
+++ b/drivers/scsi/atari_scsi.c
@@ -1090,7 +1090,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,
+ .proc_ops = &atari_scsi_proc_ops,
.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 efadb8d..0e12195 100644
--- a/drivers/scsi/atari_scsi.h
+++ b/drivers/scsi/atari_scsi.h
@@ -52,7 +52,7 @@ int atari_scsi_release (struct Scsi_Host *);
#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_proc_ops atari_scsi_proc_ops
#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 )
diff --git a/drivers/scsi/dtc.c b/drivers/scsi/dtc.c
index c2677ba..b98b1f1 100644
--- a/drivers/scsi/dtc.c
+++ b/drivers/scsi/dtc.c
@@ -217,7 +217,7 @@ static int __init dtc_detect(struct scsi_host_template * tpnt)
int sig, count;
tpnt->proc_name = "dtc3x80";
- tpnt->proc_info = &dtc_proc_info;
+ tpnt->proc_ops = &dtc_proc_ops;
for (count = 0; current_override < NO_OVERRIDES; ++current_override) {
addr = 0;
diff --git a/drivers/scsi/dtc.h b/drivers/scsi/dtc.h
index cdc6212..e1ef490 100644
--- a/drivers/scsi/dtc.h
+++ b/drivers/scsi/dtc.h
@@ -88,7 +88,7 @@ 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_proc_ops dtc_proc_ops
/* 15 12 11 10
1001 1100 0000 0000 */
diff --git a/drivers/scsi/mac_scsi.c b/drivers/scsi/mac_scsi.c
index 2bccfbe..1c2e2a1 100644
--- a/drivers/scsi/mac_scsi.c
+++ b/drivers/scsi/mac_scsi.c
@@ -562,7 +562,7 @@ static int macscsi_pwrite (struct Scsi_Host *instance,
static struct scsi_host_template driver_template = {
.proc_name = "Mac5380",
- .proc_info = macscsi_proc_info,
+ .proc_ops = &macscsi_proc_ops,
.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 d26e331..1e6f673 100644
--- a/drivers/scsi/mac_scsi.h
+++ b/drivers/scsi/mac_scsi.h
@@ -72,7 +72,7 @@
#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_proc_ops macscsi_proc_ops
#define BOARD_NORMAL 0
#define BOARD_NCR53C400 1
diff --git a/drivers/scsi/pas16.c b/drivers/scsi/pas16.c
index f2018b4..25c42b1 100644
--- a/drivers/scsi/pas16.c
+++ b/drivers/scsi/pas16.c
@@ -389,7 +389,7 @@ int __init pas16_detect(struct scsi_host_template * tpnt)
int count;
tpnt->proc_name = "pas16";
- tpnt->proc_info = &pas16_proc_info;
+ tpnt->proc_ops = &pas16_proc_ops;
if (pas16_addr != 0) {
overrides[0].io_port = pas16_addr;
diff --git a/drivers/scsi/pas16.h b/drivers/scsi/pas16.h
index a04281c..ecec4d9 100644
--- a/drivers/scsi/pas16.h
+++ b/drivers/scsi/pas16.h
@@ -163,7 +163,7 @@ 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_proc_ops pas16_proc_ops
/* 15 14 12 10 7 5 3
1101 0100 1010 1000 */
diff --git a/drivers/scsi/t128.c b/drivers/scsi/t128.c
index 041eaaa..1ba9b1b 100644
--- a/drivers/scsi/t128.c
+++ b/drivers/scsi/t128.c
@@ -202,7 +202,7 @@ int __init t128_detect(struct scsi_host_template * tpnt){
int sig, count;
tpnt->proc_name = "t128";
- tpnt->proc_info = &t128_proc_info;
+ tpnt->proc_ops = &t128_proc_ops;
for (count = 0; current_override < NO_OVERRIDES; ++current_override) {
base = 0;
diff --git a/drivers/scsi/t128.h b/drivers/scsi/t128.h
index ada1115..4992f7d 100644
--- a/drivers/scsi/t128.h
+++ b/drivers/scsi/t128.h
@@ -140,7 +140,7 @@ 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_proc_ops t128_proc_ops
/* 15 14 12 10 7 5 3
1101 0100 1010 1000 */
--
1.7.3.4
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH 32/34] scsi proc_ops: convert drivers/scsi/arm/ drivers
2012-02-22 19:45 [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops Alexey Dobriyan
` (29 preceding siblings ...)
2012-02-22 19:46 ` [PATCH 31/34] scsi proc_ops: convert NCR5380-based drivers Alexey Dobriyan
@ 2012-02-22 19:46 ` Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 33/34] scsi proc_ops: convert wd33c93-based drivers Alexey Dobriyan
` (2 subsequent siblings)
33 siblings, 0 replies; 37+ messages in thread
From: Alexey Dobriyan @ 2012-02-22 19:46 UTC (permalink / raw)
To: JBottomley; +Cc: linux-scsi, Alexey Dobriyan
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
drivers/scsi/arm/acornscsi.c | 70 +++++++++++--------------
drivers/scsi/arm/arxescsi.c | 55 +++++++-------------
drivers/scsi/arm/cumana_2.c | 117 +++++++++++++++++++-----------------------
drivers/scsi/arm/eesox.c | 117 +++++++++++++++++++-----------------------
drivers/scsi/arm/fas216.c | 31 ++++-------
drivers/scsi/arm/fas216.h | 6 +-
drivers/scsi/arm/powertec.c | 116 +++++++++++++++++++-----------------------
7 files changed, 221 insertions(+), 291 deletions(-)
diff --git a/drivers/scsi/arm/acornscsi.c b/drivers/scsi/arm/acornscsi.c
index c454e44..78a57ed 100644
--- a/drivers/scsi/arm/acornscsi.c
+++ b/drivers/scsi/arm/acornscsi.c
@@ -135,6 +135,7 @@
#include <linux/interrupt.h>
#include <linux/init.h>
#include <linux/bitops.h>
+#include <linux/seq_file.h>
#include <linux/stringify.h>
#include <linux/io.h>
@@ -2837,20 +2838,16 @@ 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_proc_show(struct seq_file *m, void *v)
{
- int pos, begin = 0, devidx;
+ struct Scsi_Host *instance = m->private;
+ 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
@@ -2865,14 +2862,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"
@@ -2887,7 +2884,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)
@@ -2897,7 +2894,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,
@@ -2908,51 +2905,44 @@ 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");
-
- pos = p - buffer;
- if (pos + begin < offset) {
- begin += pos;
- p = buffer;
- }
- pos = p - buffer;
- if (pos + begin > offset + length) {
- scsi_device_put(scd);
- break;
- }
+ seq_printf(m, "async\n");
}
- pos = p - buffer;
-
- *start = buffer + (offset - begin);
- pos -= offset - begin;
-
- if (pos > length)
- pos = length;
+ return 0;
+}
- return pos;
+static int acornscsi_proc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, acornscsi_proc_show, PDE(inode)->data);
}
+static const struct file_operations acornscsi_proc_ops = {
+ .open = acornscsi_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
static struct scsi_host_template acornscsi_template = {
.module = THIS_MODULE,
- .proc_info = acornscsi_proc_info,
+ .proc_ops = &acornscsi_proc_ops,
.name = "AcornSCSI",
.info = acornscsi_info,
.queuecommand = acornscsi_queuecmd,
diff --git a/drivers/scsi/arm/arxescsi.c b/drivers/scsi/arm/arxescsi.c
index a750aa7..5f016b1 100644
--- a/drivers/scsi/arm/arxescsi.c
+++ b/drivers/scsi/arm/arxescsi.c
@@ -220,47 +220,32 @@ 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)
+static int arxescsi_proc_show(struct seq_file *m, void *v)
{
- 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);
+ struct Scsi_Host *host = m->private;
+ struct arxescsi_info *info = (struct arxescsi_info *)host->hostdata;
- *start = buffer + offset;
- pos = p - buffer - offset;
- if (pos > length)
- pos = length;
+ 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;
+}
- return pos;
+static int arxescsi_proc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, arxescsi_proc_show, PDE(inode)->data);
}
+static const struct file_operations arxescsi_proc_ops = {
+ .open = arxescsi_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
static struct scsi_host_template arxescsi_template = {
- .proc_info = arxescsi_proc_info,
+ .proc_ops = &arxescsi_proc_ops,
.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 547987b..d986cbf 100644
--- a/drivers/scsi/arm/cumana_2.c
+++ b/drivers/scsi/arm/cumana_2.c
@@ -306,81 +306,68 @@ const char *cumanascsi_2_info(struct Scsi_Host *host)
return string;
}
-/* Prototype: int cumanascsi_2_set_proc_info(struct Scsi_Host *host, char *buffer, int length)
- * Purpose : Set a driver specific function
- * Params : host - host to setup
- * : buffer - buffer containing string describing operation
- * : length - length of string
- * Returns : -EINVAL, or 0
- */
-static int
-cumanascsi_2_set_proc_info(struct Scsi_Host *host, char *buffer, int length)
-{
- int ret = length;
-
- if (length >= 11 && strncmp(buffer, "CUMANASCSI2", 11) == 0) {
- buffer += 11;
- length -= 11;
-
- if (length >= 5 && strncmp(buffer, "term=", 5) == 0) {
- if (buffer[5] == '1')
- cumanascsi_2_terminator_ctl(host, 1);
- else if (buffer[5] == '0')
- cumanascsi_2_terminator_ctl(host, 0);
- else
- ret = -EINVAL;
- } else
- ret = -EINVAL;
- } else
- ret = -EINVAL;
-
- 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_proc_show(struct seq_file *m, void *v)
{
- 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;
+ struct Scsi_Host *host = m->private;
+ struct cumanascsi2_info *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);
+ fas216_print_stats(&info->info, m);
+ fas216_print_devices(&info->info, m);
+ return 0;
+}
- *start = buffer + offset;
- pos = p - buffer - offset;
- if (pos > length)
- pos = length;
+static int cumanascsi_2_proc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, cumanascsi_2_proc_show, PDE(inode)->data);
+}
- return pos;
+static ssize_t cumanascsi_2_proc_write(struct file *file, const char __user *buf, size_t count, loff_t *pos)
+{
+ struct Scsi_Host *host = PDE(file->f_path.dentry->d_inode)->data;
+ char kbuf[42], *p;
+ size_t len;
+
+ len = min(count, sizeof(kbuf) - 1);
+ if (copy_from_user(kbuf, buf, len))
+ return -EFAULT;
+ kbuf[len] = '\0';
+
+ p = kbuf;
+ if (strncmp(p, "CUMANASCSI2", 11) != 0)
+ return -EINVAL;
+ p += 11;
+ if (strncmp(p, "term=", 5) != 0)
+ return -EINVAL;
+ p += 5;
+ switch (*p) {
+ case '0':
+ cumanascsi_2_terminator_ctl(host, 0);
+ break;
+ case '1':
+ cumanascsi_2_terminator_ctl(host, 1);
+ break;
+ default:
+ return -EINVAL;
+ }
+ return count;
}
+static const struct file_operations cumanascsi_2_proc_ops = {
+ .open = cumanascsi_2_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+ .write = cumanascsi_2_proc_write,
+};
+
static struct scsi_host_template cumanascsi2_template = {
.module = THIS_MODULE,
- .proc_info = cumanascsi_2_proc_info,
+ .proc_ops = &cumanascsi_2_proc_ops,
.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 edfd12b..468e686 100644
--- a/drivers/scsi/arm/eesox.c
+++ b/drivers/scsi/arm/eesox.c
@@ -391,78 +391,65 @@ const char *eesoxscsi_info(struct Scsi_Host *host)
return string;
}
-/* Prototype: int eesoxscsi_set_proc_info(struct Scsi_Host *host, char *buffer, int length)
- * Purpose : Set a driver specific function
- * Params : host - host to setup
- * : buffer - buffer containing string describing operation
- * : length - length of string
- * Returns : -EINVAL, or 0
- */
-static int
-eesoxscsi_set_proc_info(struct Scsi_Host *host, char *buffer, int length)
-{
- int ret = length;
-
- if (length >= 9 && strncmp(buffer, "EESOXSCSI", 9) == 0) {
- buffer += 9;
- length -= 9;
-
- if (length >= 5 && strncmp(buffer, "term=", 5) == 0) {
- if (buffer[5] == '1')
- eesoxscsi_terminator_ctl(host, 1);
- else if (buffer[5] == '0')
- eesoxscsi_terminator_ctl(host, 0);
- else
- ret = -EINVAL;
- } else
- ret = -EINVAL;
- } else
- ret = -EINVAL;
-
- 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_proc_show(struct seq_file *m, void *v)
{
- 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;
+ struct Scsi_Host *host = m->private;
+ struct eesoxscsi_info *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);
+ fas216_print_stats(&info->info, m);
+ fas216_print_devices(&info->info, m);
+ return 0;
+}
- *start = buffer + offset;
- pos = p - buffer - offset;
- if (pos > length)
- pos = length;
+static int eesoxscsi_proc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, eesoxscsi_proc_show, PDE(inode)->data);
+}
- return pos;
+static ssize_t eesoxscsi_proc_write(struct file *file, const char __user *buf, size_t count, loff_t *pos)
+{
+ struct Scsi_Host *host = PDE(file->f_path.dentry->d_inode)->data;
+ char kbuf[42], *p;
+ size_t len;
+
+ len = min(count, sizeof(kbuf) - 1);
+ if (copy_from_user(kbuf, buf, len))
+ return -EFAULT;
+ kbuf[len] = '\0';
+
+ p = kbuf;
+ if (strncmp(p, "EESOXSCSI", 9) != 0)
+ return -EINVAL;
+ p += 9;
+ if (strncmp(p, "term=", 5) != 0)
+ return -EINVAL;
+ p += 5;
+ switch (*p) {
+ case '0':
+ eesoxscsi_terminator_ctl(host, 0);
+ break;
+ case '1':
+ eesoxscsi_terminator_ctl(host, 1);
+ break;
+ default:
+ return -EINVAL;
+ }
+ return count;
}
+static const struct file_operations eesoxscsi_proc_ops = {
+ .open = eesoxscsi_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+ .write = eesoxscsi_proc_write,
+};
+
static ssize_t eesoxscsi_show_term(struct device *dev, struct device_attribute *attr, char *buf)
{
struct expansion_card *ec = ECARD_DEV(dev);
@@ -498,7 +485,7 @@ static DEVICE_ATTR(bus_term, S_IRUGO | S_IWUSR,
static struct scsi_host_template eesox_template = {
.module = THIS_MODULE,
- .proc_info = eesoxscsi_proc_info,
+ .proc_ops = &eesoxscsi_proc_ops,
.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 e85c40b..eb02a11 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 84b7127..914b4e4 100644
--- a/drivers/scsi/arm/fas216.h
+++ b/drivers/scsi/arm/fas216.h
@@ -362,9 +362,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 9274c06..e854fad 100644
--- a/drivers/scsi/arm/powertec.c
+++ b/drivers/scsi/arm/powertec.c
@@ -194,77 +194,65 @@ const char *powertecscsi_info(struct Scsi_Host *host)
return string;
}
-/* Prototype: int powertecscsi_set_proc_info(struct Scsi_Host *host, char *buffer, int length)
- * Purpose : Set a driver specific function
- * Params : host - host to setup
- * : buffer - buffer containing string describing operation
- * : length - length of string
- * Returns : -EINVAL, or 0
- */
-static int
-powertecscsi_set_proc_info(struct Scsi_Host *host, char *buffer, int length)
-{
- int ret = length;
-
- if (length >= 12 && strncmp(buffer, "POWERTECSCSI", 12) == 0) {
- buffer += 12;
- length -= 12;
-
- if (length >= 5 && strncmp(buffer, "term=", 5) == 0) {
- if (buffer[5] == '1')
- powertecscsi_terminator_ctl(host, 1);
- else if (buffer[5] == '0')
- powertecscsi_terminator_ctl(host, 0);
- else
- ret = -EINVAL;
- } else
- ret = -EINVAL;
- } else
- ret = -EINVAL;
-
- return ret;
-}
-
-/* Prototype: int powertecscsi_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
- * 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_proc_show(struct seq_file *m, void *v)
{
- 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;
+ struct Scsi_Host *host = m->private;
+ struct powertec_info *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);
+ fas216_print_stats(&info->info, m);
+ fas216_print_devices(&info->info, m);
+ return 0;
+}
- *start = buffer + offset;
- pos = p - buffer - offset;
- if (pos > length)
- pos = length;
+static int powertecscsi_proc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, powertecscsi_proc_show, PDE(inode)->data);
+}
- return pos;
+static ssize_t powertecscsi_proc_write(struct file *file, const char __user *buf, size_t count, loff_t *pos)
+{
+ struct Scsi_Host *host = PDE(file->f_path.dentry->d_inode)->data;
+ char kbuf[42], *p;
+ size_t len;
+
+ len = min(count, sizeof(kbuf) - 1);
+ if (copy_from_user(kbuf, buf, len))
+ return -EFAULT;
+ kbuf[len] = '\0';
+
+ p = kbuf;
+ if (strncmp(p, "POWERTECSCSI", 12) != 0)
+ return -EINVAL;
+ p += 12;
+ if (strncmp(p, "term=", 5) != 0)
+ return -EINVAL;
+ p += 5;
+ switch (*p) {
+ case '0':
+ powertecscsi_terminator_ctl(host, 0);
+ break;
+ case '1':
+ powertecscsi_terminator_ctl(host, 1);
+ break;
+ default:
+ return -EINVAL;
+ }
+ return count;
}
+static const struct file_operations powertecscsi_proc_ops = {
+ .open = powertecscsi_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+ .write = powertecscsi_proc_write,
+};
+
static ssize_t powertecscsi_show_term(struct device *dev, struct device_attribute *attr, char *buf)
{
struct expansion_card *ec = ECARD_DEV(dev);
@@ -291,7 +279,7 @@ static DEVICE_ATTR(bus_term, S_IRUGO | S_IWUSR,
static struct scsi_host_template powertecscsi_template = {
.module = THIS_MODULE,
- .proc_info = powertecscsi_proc_info,
+ .proc_ops = &powertecscsi_proc_ops,
.name = "PowerTec SCSI",
.info = powertecscsi_info,
.queuecommand = fas216_queue_command,
--
1.7.3.4
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH 33/34] scsi proc_ops: convert wd33c93-based drivers
2012-02-22 19:45 [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops Alexey Dobriyan
` (30 preceding siblings ...)
2012-02-22 19:46 ` [PATCH 32/34] scsi proc_ops: convert drivers/scsi/arm/ drivers Alexey Dobriyan
@ 2012-02-22 19:46 ` Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 34/34] scsi proc_ops: remove scsi_host_template::proc_info Alexey Dobriyan
2012-02-29 13:39 ` [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops Alexey Dobriyan
33 siblings, 0 replies; 37+ messages in thread
From: Alexey Dobriyan @ 2012-02-22 19:46 UTC (permalink / raw)
To: JBottomley; +Cc: linux-scsi, Alexey Dobriyan
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
drivers/scsi/a2091.c | 2 +-
drivers/scsi/a3000.c | 2 +-
drivers/scsi/gvp11.c | 2 +-
drivers/scsi/mvme147.c | 2 +-
drivers/scsi/wd33c93.c | 228 ++++++++++++++++++++++++-----------------------
drivers/scsi/wd33c93.h | 3 +-
6 files changed, 121 insertions(+), 118 deletions(-)
diff --git a/drivers/scsi/a2091.c b/drivers/scsi/a2091.c
index 79a3063..8667f87 100644
--- a/drivers/scsi/a2091.c
+++ b/drivers/scsi/a2091.c
@@ -166,7 +166,7 @@ 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,
+ .proc_ops = &wd33c93_proc_ops,
.proc_name = "A2901",
.queuecommand = wd33c93_queuecommand,
.eh_abort_handler = wd33c93_abort,
diff --git a/drivers/scsi/a3000.c b/drivers/scsi/a3000.c
index e29fe0e..e74f99d 100644
--- a/drivers/scsi/a3000.c
+++ b/drivers/scsi/a3000.c
@@ -181,7 +181,7 @@ 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,
+ .proc_ops = &wd33c93_proc_ops,
.proc_name = "A3000",
.queuecommand = wd33c93_queuecommand,
.eh_abort_handler = wd33c93_abort,
diff --git a/drivers/scsi/gvp11.c b/drivers/scsi/gvp11.c
index 488fbc6..70aefaa 100644
--- a/drivers/scsi/gvp11.c
+++ b/drivers/scsi/gvp11.c
@@ -191,7 +191,7 @@ 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,
+ .proc_ops = &wd33c93_proc_ops,
.proc_name = "GVP11",
.queuecommand = wd33c93_queuecommand,
.eh_abort_handler = wd33c93_abort,
diff --git a/drivers/scsi/mvme147.c b/drivers/scsi/mvme147.c
index c29d0db..21d3c1c 100644
--- a/drivers/scsi/mvme147.c
+++ b/drivers/scsi/mvme147.c
@@ -76,7 +76,7 @@ int mvme147_detect(struct scsi_host_template *tpnt)
called++;
tpnt->proc_name = "MVME147";
- tpnt->proc_info = &wd33c93_proc_info;
+ tpnt->proc_ops = &wd33c93_proc_ops;
instance = scsi_register(tpnt, sizeof(struct WD33C93_hostdata));
if (!instance)
diff --git a/drivers/scsi/wd33c93.c b/drivers/scsi/wd33c93.c
index c0ee4ea..daad614 100644
--- a/drivers/scsi/wd33c93.c
+++ b/drivers/scsi/wd33c93.c
@@ -78,6 +78,8 @@
#include <linux/module.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
#include <linux/string.h>
#include <linux/delay.h>
#include <linux/init.h>
@@ -1978,7 +1980,7 @@ wd33c93_init(struct Scsi_Host *instance, const wd33c93_regs regs,
#ifdef PROC_INTERFACE
hostdata->proc = PR_VERSION | PR_INFO | PR_STATISTICS |
- PR_CONNECTED | PR_INPUTQ | PR_DISCQ | PR_STOP;
+ PR_CONNECTED | PR_INPUTQ | PR_DISCQ;
#ifdef PROC_STATISTICS
hostdata->dma_cnt = 0;
hostdata->pio_cnt = 0;
@@ -2054,179 +2056,181 @@ 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)
+static int wd33c93_proc_show(struct seq_file *m, void *v)
{
+ struct Scsi_Host *instance = m->private;
#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
- * keywords (same format as command-line, but arguments are not optional):
- * debug
- * disconnect
- * period
- * resync
- * proc
- * nodma
- * level2
- * burst
- * fast
- * 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)) {
- 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,... */
- }
- }
- return len;
- }
-
spin_lock_irq(&hd->lock);
- bp = buf;
- *bp = '\0';
if (hd->proc & PR_VERSION) {
- sprintf(tbuf, "\nVersion %s - %s.",
+ seq_printf(m, "\nVersion %s - %s.\n",
WD33C93_VERSION, WD33C93_DATE);
- strcat(bp, tbuf);
}
if (hd->proc & PR_INFO) {
- sprintf(tbuf, "\nclock_freq=%02x no_sync=%02x no_dma=%d"
- " dma_mode=%02x fast=%d",
+ seq_printf(m, "clock_freq=%02x no_sync=%02x no_dma=%d"
+ " dma_mode=%02x fast=%d\n",
hd->clock_freq, hd->no_sync, hd->no_dma, hd->dma_mode, hd->fast);
- strcat(bp, tbuf);
- strcat(bp, "\nsync_xfer[] = ");
+ seq_printf(m, "sync_xfer[] = ");
for (x = 0; x < 7; x++) {
- sprintf(tbuf, "\t%02x", hd->sync_xfer[x]);
- strcat(bp, tbuf);
+ seq_printf(m, "\t%02x", hd->sync_xfer[x]);
}
- strcat(bp, "\nsync_stat[] = ");
+ seq_putc(m, '\n');
+ seq_printf(m, "sync_stat[] = ");
for (x = 0; x < 7; x++) {
- sprintf(tbuf, "\t%02x", hd->sync_stat[x]);
- strcat(bp, tbuf);
+ seq_printf(m, "\t%02x", hd->sync_stat[x]);
}
+ seq_putc(m, '\n');
}
#ifdef PROC_STATISTICS
if (hd->proc & PR_STATISTICS) {
- strcat(bp, "\ncommands issued: ");
+ seq_printf(m, "commands issued: ");
for (x = 0; x < 7; x++) {
- sprintf(tbuf, "\t%ld", hd->cmd_cnt[x]);
- strcat(bp, tbuf);
+ seq_printf(m, "\t%ld", hd->cmd_cnt[x]);
}
- strcat(bp, "\ndisconnects allowed:");
+ seq_putc(m, '\n');
+ seq_printf(m, "disconnects allowed:");
for (x = 0; x < 7; x++) {
- sprintf(tbuf, "\t%ld", hd->disc_allowed_cnt[x]);
- strcat(bp, tbuf);
+ seq_printf(m, "\t%ld", hd->disc_allowed_cnt[x]);
}
- strcat(bp, "\ndisconnects done: ");
+ seq_putc(m, '\n');
+ seq_printf(m, "disconnects done: ");
for (x = 0; x < 7; x++) {
- sprintf(tbuf, "\t%ld", hd->disc_done_cnt[x]);
- strcat(bp, tbuf);
+ seq_printf(m, "\t%ld", hd->disc_done_cnt[x]);
}
- sprintf(tbuf,
- "\ninterrupts: %ld, DATA_PHASE ints: %ld DMA, %ld PIO",
+ seq_putc(m, '\n');
+ seq_printf(m,
+ "interrupts: %ld, DATA_PHASE ints: %ld DMA, %ld PIO\n",
hd->int_cnt, hd->dma_cnt, hd->pio_cnt);
- strcat(bp, tbuf);
}
#endif
if (hd->proc & PR_CONNECTED) {
- strcat(bp, "\nconnected: ");
+ seq_printf(m, "connected: ");
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);
+ seq_putc(m, '\n');
}
}
if (hd->proc & PR_INPUTQ) {
- strcat(bp, "\ninput_Q: ");
+ seq_printf(m, "input_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;
}
+ seq_putc(m, '\n');
}
if (hd->proc & PR_DISCQ) {
- strcat(bp, "\ndisconnected_Q:");
+ seq_printf(m, "disconnected_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;
}
+ seq_putc(m, '\n');
}
- strcat(bp, "\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 */
+#endif /* PROC_INTERFACE */
return 0;
+}
-#endif /* PROC_INTERFACE */
+static int wd33c93_proc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, wd33c93_proc_show, PDE(inode)->data);
+}
+static ssize_t wd33c93_proc_write(struct file *file, const char __user *buf, size_t count, loff_t *pos)
+{
+ struct Scsi_Host *instance = PDE(file->f_path.dentry->d_inode)->data;
+ struct WD33C93_hostdata *hd = (struct WD33C93_hostdata *)instance->hostdata;
+ char kbuf[42], *bp;
+ size_t len;
+ int x;
+
+ len = min(count, sizeof(kbuf) - 1);
+ if (copy_from_user(kbuf, buf, len))
+ return -EFAULT;
+ kbuf[len] = '\0';
+
+ /*
+ * We accept the following keywords (same format as command-line,
+ * but arguments are not optional):
+ * debug
+ * disconnect
+ * period
+ * resync
+ * proc
+ * nodma
+ * level2
+ * burst
+ * fast
+ * nosync
+ */
+ for (bp = kbuf; *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);
+ set_resync(hd, x ^ hd->no_sync);
+ hd->no_sync = x;
+ } else {
+ break; /* unknown keyword,syntax-error,... */
+ }
+ }
+ return count;
}
+const struct file_operations wd33c93_proc_ops = {
+ .open = wd33c93_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+ .write = wd33c93_proc_write,
+};
+
EXPORT_SYMBOL(wd33c93_host_reset);
EXPORT_SYMBOL(wd33c93_init);
EXPORT_SYMBOL(wd33c93_abort);
EXPORT_SYMBOL(wd33c93_queuecommand);
EXPORT_SYMBOL(wd33c93_intr);
-EXPORT_SYMBOL(wd33c93_proc_info);
+EXPORT_SYMBOL(wd33c93_proc_ops);
diff --git a/drivers/scsi/wd33c93.h b/drivers/scsi/wd33c93.h
index 3b463d7..49974b2 100644
--- a/drivers/scsi/wd33c93.h
+++ b/drivers/scsi/wd33c93.h
@@ -337,7 +337,6 @@ struct WD33C93_hostdata {
#define PR_INPUTQ 1<<4
#define PR_DISCQ 1<<5
#define PR_TEST 1<<6
-#define PR_STOP 1<<7
void wd33c93_init (struct Scsi_Host *instance, const wd33c93_regs regs,
@@ -345,7 +344,7 @@ 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);
+extern const struct file_operations wd33c93_proc_ops;
int wd33c93_host_reset (struct scsi_cmnd *);
#endif /* WD33C93_H */
--
1.7.3.4
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [PATCH 34/34] scsi proc_ops: remove scsi_host_template::proc_info
2012-02-22 19:45 [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops Alexey Dobriyan
` (31 preceding siblings ...)
2012-02-22 19:46 ` [PATCH 33/34] scsi proc_ops: convert wd33c93-based drivers Alexey Dobriyan
@ 2012-02-22 19:46 ` Alexey Dobriyan
2012-02-29 13:39 ` [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops Alexey Dobriyan
33 siblings, 0 replies; 37+ messages in thread
From: Alexey Dobriyan @ 2012-02-22 19:46 UTC (permalink / raw)
To: JBottomley; +Cc: linux-scsi, Alexey Dobriyan
Now that all users have been converted.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
drivers/scsi/scsi_proc.c | 79 ++++-----------------------------------------
include/scsi/scsi_host.h | 1 -
2 files changed, 7 insertions(+), 73 deletions(-)
diff --git a/drivers/scsi/scsi_proc.c b/drivers/scsi/scsi_proc.c
index 31da690..cb72a61 100644
--- a/drivers/scsi/scsi_proc.c
+++ b/drivers/scsi/scsi_proc.c
@@ -36,68 +36,12 @@
#include "scsi_priv.h"
#include "scsi_logging.h"
-
-/* 4K page size, but our output routines, use some slack for overruns */
-#define PROC_BLOCK_SIZE (3*1024)
-
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;
-}
-
-/**
* scsi_proc_hostdir_add - Create directory in /proc for a scsi host
* @sht: owner of this directory
*
@@ -106,7 +50,7 @@ out:
void scsi_proc_hostdir_add(struct scsi_host_template *sht)
{
- if (!sht->proc_info && !sht->proc_ops)
+ if (!sht->proc_ops)
return;
mutex_lock(&global_host_template_mutex);
@@ -125,7 +69,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->proc_ops)
+ if (!sht->proc_ops)
return;
mutex_lock(&global_host_template_mutex);
@@ -146,25 +90,16 @@ void scsi_proc_host_add(struct Scsi_Host *shost)
struct scsi_host_template *sht = shost->hostt;
struct proc_dir_entry *p;
char name[10];
+ mode_t mode;
if (!sht->proc_dir)
return;
sprintf(name,"%d", shost->host_no);
- if (sht->proc_ops) {
- mode_t mode;
-
- mode = S_IRUGO;
- if (sht->proc_ops->write)
- mode |= S_IWUSR;
- p = proc_create_data(name, mode, sht->proc_dir,
- sht->proc_ops, shost);
- } else {
- 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;
- }
+ mode = S_IRUGO;
+ if (sht->proc_ops->write)
+ mode |= S_IWUSR;
+ p = proc_create_data(name, mode, sht->proc_dir, sht->proc_ops, shost);
if (!p) {
printk(KERN_ERR "%s: Failed to register host %d in"
"%s\n", __func__, shost->host_no,
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index f81c80f..34fd834 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -340,7 +340,6 @@ struct scsi_host_template {
*
* Status: OBSOLETE
*/
- int (*proc_info)(struct Scsi_Host *, char *, char **, off_t, int, int);
const struct file_operations *proc_ops;
/*
--
1.7.3.4
^ permalink raw reply related [flat|nested] 37+ messages in thread
* Re: [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops
2012-02-22 19:45 [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops Alexey Dobriyan
` (32 preceding siblings ...)
2012-02-22 19:46 ` [PATCH 34/34] scsi proc_ops: remove scsi_host_template::proc_info Alexey Dobriyan
@ 2012-02-29 13:39 ` Alexey Dobriyan
2012-02-29 22:29 ` James Bottomley
33 siblings, 1 reply; 37+ messages in thread
From: Alexey Dobriyan @ 2012-02-29 13:39 UTC (permalink / raw)
To: JBottomley; +Cc: linux-scsi, Alexey Dobriyan
James, ping!
Are you going to apply this?
If not, what can I do to make them applied?
On Wed, Feb 22, 2012 at 10:45 PM, Alexey Dobriyan <adobriyan@gmail.com> wrote:
> The last user of ->write_proc interface is scsi_proc.c passing through
> data to individual drivers. There are still quite a few drivers using
> ->proc_info interface, so do conversion gradually.
>
> Introduce temporary logic allowing both ->proc_info and ->proc_ops
> with ->proc_ops being the first thing to check, convert drivers,
> remove ->proc_info interface.
>
> Removing all relevant SCSI proc files is risky because it'd take only one
> broken user to revert whole thing and do it right.
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops
2012-02-29 13:39 ` [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops Alexey Dobriyan
@ 2012-02-29 22:29 ` James Bottomley
0 siblings, 0 replies; 37+ messages in thread
From: James Bottomley @ 2012-02-29 22:29 UTC (permalink / raw)
To: Alexey Dobriyan; +Cc: linux-scsi
On Wed, 2012-02-29 at 15:39 +0200, Alexey Dobriyan wrote:
> James, ping!
>
> Are you going to apply this?
I think so ... I've queued them for inspection and testing (probably
this weekend).
Ideally, I'd have liked some maintainer acks because the changes are
quite invasive, but I'm reasonably OK with pushing them as an
infrastructure change
> If not, what can I do to make them applied?
Well, next time around, a more conformant change log would have been
nice (saves me having to edit every commit).
the form is
[driver]: change
so instead of
scsi proc_ops: convert drivers/scsi/ips.c
it should be
ips: convert to proc_ops
James
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [PATCH 29/34] scsi proc_ops: convert drivers/ata/sata_svw.c
2012-02-22 19:46 ` [PATCH 29/34] scsi proc_ops: convert drivers/ata/sata_svw.c Alexey Dobriyan
@ 2012-03-22 17:25 ` Jeff Garzik
0 siblings, 0 replies; 37+ messages in thread
From: Jeff Garzik @ 2012-03-22 17:25 UTC (permalink / raw)
To: Alexey Dobriyan; +Cc: JBottomley, linux-scsi, Linux IDE mailing list
On 02/22/2012 02:46 PM, Alexey Dobriyan wrote:
> Signed-off-by: Alexey Dobriyan<adobriyan@gmail.com>
Acked-by: Jeff Garzik <jgarzik@redhat.com>
Please CC linux-ide on all drivers/ata patches. Thanks.
Jeff
^ permalink raw reply [flat|nested] 37+ messages in thread
end of thread, other threads:[~2012-03-22 17:25 UTC | newest]
Thread overview: 37+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-22 19:45 [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops Alexey Dobriyan
2012-02-22 19:45 ` [PATCH 02/34] scsi proc_ops: convert drivers/scsi/scsi_debug.c Alexey Dobriyan
2012-02-22 19:45 ` [PATCH 03/34] scsi proc_ops: convert drivers/scsi/nsp32.c Alexey Dobriyan
2012-02-22 19:45 ` [PATCH 04/34] scsi proc_ops: convert drivers/scsi/imm.c Alexey Dobriyan
2012-02-22 19:45 ` [PATCH 05/34] scsi proc_ops: convert drivers/scsi/ppa.c Alexey Dobriyan
2012-02-22 19:45 ` [PATCH 06/34] scsi proc_ops: convert drivers/scsi/atp870u.c Alexey Dobriyan
2012-02-22 19:45 ` [PATCH 07/34] scsi proc_ops: convert drivers/scsi/dc395x.c Alexey Dobriyan
2012-02-22 19:45 ` [PATCH 08/34] scsi proc_ops: convert drivers/scsi/ibmmca.c Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 09/34] scsi proc_ops: convert drivers/scsi/wd7000.c Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 10/34] scsi proc_ops: convert drivers/scsi/pcmcia/nsp_cs.c Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 11/34] scsi proc_ops: convert drivers/scsi/fd_mcs.c Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 12/34] scsi proc_ops: convert drivers/scsi/aha152x.c Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 13/34] scsi proc_ops: convert drivers/scsi/sym53c8xx_2/sym_glue.c Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 14/34] scsi proc_ops: convert drivers/scsi/advansys.c Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 15/34] scsi proc_ops: convert drivers/scsi/BusLogic.c Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 16/34] scsi proc_ops: convert drivers/scsi/aha1740.c Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 17/34] scsi proc_ops: convert drivers/scsi/aic7xxx_old.c Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 18/34] scsi proc_ops: convert drivers/scsi/ips.c Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 19/34] scsi proc_ops: convert drivers/scsi/in2000.c Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 20/34] scsi proc_ops: convert aic79xx Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 21/34] scsi proc_ops: convert aic7xxx Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 22/34] scsi proc_ops: convert drivers/scsi/dpt_i2o.c Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 23/34] scsi proc_ops: convert drivers/scsi/gdth.c Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 24/34] scsi proc_ops: convert drivers/usb/storage/scsiglue.c Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 25/34] scsi proc_ops: convert drivers/block/cciss.c Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 26/34] scsi proc_ops: convert drivers/message/fusion/ Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 27/34] scsi proc_ops: remove tcm_loop proc code Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 28/34] scsi proc_ops: convert drivers/scsi/eata_pio.c Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 29/34] scsi proc_ops: convert drivers/ata/sata_svw.c Alexey Dobriyan
2012-03-22 17:25 ` Jeff Garzik
2012-02-22 19:46 ` [PATCH 30/34] scsi proc_ops: convert drivers/scsi/g_NCR5380.c Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 31/34] scsi proc_ops: convert NCR5380-based drivers Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 32/34] scsi proc_ops: convert drivers/scsi/arm/ drivers Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 33/34] scsi proc_ops: convert wd33c93-based drivers Alexey Dobriyan
2012-02-22 19:46 ` [PATCH 34/34] scsi proc_ops: remove scsi_host_template::proc_info Alexey Dobriyan
2012-02-29 13:39 ` [PATCH 01/34] scsi proc_ops: add struct scsi_host_template::proc_ops Alexey Dobriyan
2012-02-29 22:29 ` James Bottomley
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).