[1735] in linux-scsi channel archive
Improved generic /proc/scsi [PATCH]
daemon@ATHENA.MIT.EDU (Michael Griffith)
Mon Apr 21 14:36:58 1997
From: Michael Griffith <grif@cs.ucr.edu>
To: linux-kernel@vger.rutgers.edu, linux-scsi@vger.rutgers.edu
Date: Mon, 21 Apr 1997 11:32:51 -0700 (PDT)
Cc: torvalds@transmeta.com
This simple patch adds /proc/scsi support for all SCSI drivers
which support an xxxx_info() routine. With this patch, almost all
Linux SCSI drivers will have at least some /proc/scsi support.
For drivers with a simple (read-only) procfs interface, this should be
the preferred method, since it makes for a simpler and smaller kernel
by avoiding the duplication of effort between the xxxx_info() and
xxxx_proc_info() routines. As an example, I have removed
seagate_st0x_proc_info(), with no change in functionality.
This patch was tested with the 'seagate' and 'qlogicisp' drivers on
i386 linux 2.1.32 and 2.1.35.
--
Michael A. Griffith | "I say, I say, son you're goin' about this
<grif@acm.org> | thing all wrong, boy." -- Foghorn Leghorn
http://www.cs.ucr.edu/~grif/ |
diff -u --recursive linux.build/drivers/scsi/scsi_proc.c linux/drivers/scsi/scsi_proc.c
--- linux.build/drivers/scsi/scsi_proc.c Mon Apr 21 22:30:23 1997
+++ linux/drivers/scsi/scsi_proc.c Mon Apr 21 22:26:52 1997
@@ -11,6 +11,9 @@
*
* generic command parser provided by:
* Andreas Heilwagen <crashcar@informatik.uni-koblenz.de>
+ *
+ * generic_proc_info() support of xxxx_info() by:
+ * Michael A. Griffith <grif@acm.org>
*/
/*
@@ -48,7 +51,9 @@
* Used if the driver currently has no own support for /proc/scsi
*/
int generic_proc_info(char *buffer, char **start, off_t offset,
- int length, int inode, int inout)
+ int length, int inode, int inout,
+ const char *(*info)(struct Scsi_Host *),
+ struct Scsi_Host *sh)
{
int len, pos, begin;
@@ -56,8 +61,13 @@
return(-ENOSYS); /* This is a no-op */
begin = 0;
- pos = len = sprintf(buffer,
- "The driver does not yet support the proc-fs\n");
+ if (info && sh) {
+ pos = len = sprintf(buffer, "%s\n", info(sh));
+ }
+ else {
+ pos = len = sprintf(buffer,
+ "The driver does not yet support the proc-fs\n");
+ }
if(pos < offset) {
len = 0;
begin = pos;
@@ -91,7 +101,9 @@
if (ino == (hpnt->host_no + PROC_SCSI_FILE)) {
if(hpnt->hostt->proc_info == NULL)
return generic_proc_info(buffer, start, offset, length,
- hpnt->host_no, func);
+ hpnt->host_no, func,
+ hpnt->hostt->info,
+ hpnt);
else
return(hpnt->hostt->proc_info(buffer, start, offset,
length, hpnt->host_no, func));
diff -u --recursive linux.build/drivers/scsi/seagate.c linux/drivers/scsi/seagate.c
--- linux.build/drivers/scsi/seagate.c Mon Apr 21 22:30:23 1997
+++ linux/drivers/scsi/seagate.c Sat Apr 19 11:57:51 1997
@@ -564,36 +564,6 @@
return buffer;
}
-int seagate_st0x_proc_info (char *buffer, char **start, off_t offset,
- int length, int hostno, int inout)
-{
- const char *info = seagate_st0x_info (NULL);
- int len;
- int pos;
- int begin;
-
- if (inout)
- return (-ENOSYS);
-
- begin = 0;
- strcpy (buffer, info);
- strcat (buffer, "\n");
-
- pos = len = strlen (buffer);
-
- if (pos < offset)
- {
- len = 0;
- begin = pos;
- }
-
- *start = buffer + (offset - begin);
- len -= (offset - begin);
- if (len > length)
- len = length;
- return (len);
-}
-
/*
* These are our saved pointers for the outstanding command that is
* waiting for a reconnect
diff -u --recursive linux.build/drivers/scsi/seagate.h linux/drivers/scsi/seagate.h
--- linux.build/drivers/scsi/seagate.h Mon Apr 21 22:30:23 1997
+++ linux/drivers/scsi/seagate.h Sat Apr 19 11:57:50 1997
@@ -19,7 +19,6 @@
int seagate_st0x_abort(Scsi_Cmnd *);
const char *seagate_st0x_info(struct Scsi_Host *);
int seagate_st0x_reset(Scsi_Cmnd *, unsigned int);
-int seagate_st0x_proc_info(char *,char **,off_t,int,int,int);
#ifndef NULL
#define NULL 0
@@ -28,7 +27,7 @@
#include <linux/kdev_t.h>
int seagate_st0x_biosparam(Disk *, kdev_t, int*);
-#define SEAGATE_ST0X { NULL, NULL, NULL, seagate_st0x_proc_info, \
+#define SEAGATE_ST0X { NULL, NULL, NULL, NULL, \
NULL, seagate_st0x_detect, \
NULL, \
seagate_st0x_info, seagate_st0x_command, \