linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexey Dobriyan <adobriyan@gmail.com>
To: JBottomley@parallels.com
Cc: linux-scsi@vger.kernel.org, Alexey Dobriyan <adobriyan@gmail.com>
Subject: [PATCH 31/34] scsi proc_ops: convert NCR5380-based drivers
Date: Wed, 22 Feb 2012 22:46:22 +0300	[thread overview]
Message-ID: <1329939985-26793-31-git-send-email-adobriyan@gmail.com> (raw)
In-Reply-To: <1329939985-26793-1-git-send-email-adobriyan@gmail.com>

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


  parent reply	other threads:[~2012-02-22 19:47 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Alexey Dobriyan [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1329939985-26793-31-git-send-email-adobriyan@gmail.com \
    --to=adobriyan@gmail.com \
    --cc=JBottomley@parallels.com \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).