Commit 209287fb authored by Mike Anderson's avatar Mike Anderson Committed by James Bottomley

[PATCH] scsi host cleanup 3/3 (driver changes)

If you read my previous post on this patch I indicated that few of the
driver changes I was only able to compile test ( block/cciss_scsi.c,
scsi/53c700.c, scsi/pcmcia/*, scsi/wd33c93.c). The changes to the
drivers are to remove the old interfaces and possibly extra NULL inits
of struct members. These changes will need to be ok'd by there
respective maintainers. I did receive feedback from two.

I have tested these changes on ips, aic, qlogicisp, and scsi_debug
drivers.

This is a resend of my previous patch clean ups to the scsi_host lists.

	* Made function naming consistent with rest of SCSI
	* Corrected a problem with driverfs registration to early. Also
	  changed from put_device to device_unregister.
        * Fixed a regression in my previous patch that the scsi_host
          list was not sorted by host number. When we get some device
          naming this hack can be removed.
        * Switch scsi host template, name, host lists to struct
          list_head's.
        * Moved all scsi_host related register / unregister functions
          into hosts.c
        * Added list accessor interface and created a function similar
          to driverfs bus_for_each_dev.

The full patch is available at:
http://www-124.ibm.com/storageio/patches/2.5/scsi-host

-andmike
--
Michael Anderson
andmike@us.ibm.com

 acorn/scsi/acornscsi.c            |    6 ++----
 acorn/scsi/arxescsi.c             |    8 ++------
 acorn/scsi/cumana_2.c             |    8 ++------
 acorn/scsi/eesox.c                |    8 ++------
 acorn/scsi/powertec.c             |    8 ++------
 block/cciss_scsi.c                |   21 ++-------------------
 scsi/53c700.c                     |    6 ++----
 scsi/aic7xxx/aic7xxx_linux_host.h |    1 -
 scsi/cpqfcTSinit.c                |    4 +---
 scsi/fcal.c                       |    4 +---
 scsi/ips.h                        |    3 ---
 scsi/pcmcia/aha152x_stub.c        |    3 ++-
 scsi/pcmcia/fdomain_stub.c        |    3 ++-
 scsi/pcmcia/nsp_cs.c              |    3 ++-
 scsi/pcmcia/qlogic_stub.c         |    3 ++-
 scsi/wd33c93.c                    |    5 +----
 16 files changed, 25 insertions(+), 69 deletions(-)
parent 68fe1e0f
...@@ -3010,14 +3010,12 @@ int acornscsi_proc_info(char *buffer, char **start, off_t offset, ...@@ -3010,14 +3010,12 @@ int acornscsi_proc_info(char *buffer, char **start, off_t offset,
int length, int host_no, int inout) int length, int host_no, int inout)
{ {
int pos, begin = 0, devidx; int pos, begin = 0, devidx;
struct Scsi_Host *instance = scsi_hostlist; struct Scsi_Host *instance;
Scsi_Device *scd; Scsi_Device *scd;
AS_Host *host; AS_Host *host;
char *p = buffer; char *p = buffer;
for (instance = scsi_hostlist; instance = scsi_host_hn_get(host_no);
instance && instance->host_no != host_no;
instance = instance->next);
if (inout == 1 || !instance) if (inout == 1 || !instance)
return -EINVAL; return -EINVAL;
......
...@@ -384,15 +384,11 @@ int arxescsi_proc_info(char *buffer, char **start, off_t offset, ...@@ -384,15 +384,11 @@ int arxescsi_proc_info(char *buffer, char **start, off_t offset,
int length, int host_no, int inout) int length, int host_no, int inout)
{ {
int pos, begin; int pos, begin;
struct Scsi_Host *host = scsi_hostlist; struct Scsi_Host *host;
ARXEScsi_Info *info; ARXEScsi_Info *info;
Scsi_Device *scd; Scsi_Device *scd;
while (host) { host = scsi_host_hn_get(host_no);
if (host->host_no == host_no)
break;
host = host->next;
}
if (!host) if (!host)
return 0; return 0;
......
...@@ -498,15 +498,11 @@ int cumanascsi_2_proc_info (char *buffer, char **start, off_t offset, ...@@ -498,15 +498,11 @@ int cumanascsi_2_proc_info (char *buffer, char **start, off_t offset,
int length, int host_no, int inout) int length, int host_no, int inout)
{ {
int pos, begin; int pos, begin;
struct Scsi_Host *host = scsi_hostlist; struct Scsi_Host *host;
CumanaScsi2_Info *info; CumanaScsi2_Info *info;
Scsi_Device *scd; Scsi_Device *scd;
while (host) { host = scsi_host_hn_get(host_no);
if (host->host_no == host_no)
break;
host = host->next;
}
if (!host) if (!host)
return 0; return 0;
......
...@@ -499,15 +499,11 @@ int eesoxscsi_proc_info(char *buffer, char **start, off_t offset, ...@@ -499,15 +499,11 @@ int eesoxscsi_proc_info(char *buffer, char **start, off_t offset,
int length, int host_no, int inout) int length, int host_no, int inout)
{ {
int pos, begin; int pos, begin;
struct Scsi_Host *host = scsi_hostlist; struct Scsi_Host *host;
EESOXScsi_Info *info; EESOXScsi_Info *info;
Scsi_Device *scd; Scsi_Device *scd;
while (host) { host = scsi_host_hn_get(host_no);
if (host->host_no == host_no)
break;
host = host->next;
}
if (!host) if (!host)
return 0; return 0;
......
...@@ -404,15 +404,11 @@ int powertecscsi_proc_info(char *buffer, char **start, off_t offset, ...@@ -404,15 +404,11 @@ int powertecscsi_proc_info(char *buffer, char **start, off_t offset,
int length, int host_no, int inout) int length, int host_no, int inout)
{ {
int pos, begin; int pos, begin;
struct Scsi_Host *host = scsi_hostlist; struct Scsi_Host *host;
PowerTecScsi_Info *info; PowerTecScsi_Info *info;
Scsi_Device *scd; Scsi_Device *scd;
while (host) { host = scsi_host_hn_get(host_no);
if (host->host_no == host_no)
break;
host = host->next;
}
if (!host) if (!host)
return 0; return 0;
......
...@@ -1250,8 +1250,6 @@ cciss_scsi_user_command(int ctlr, int hostno, char *buffer, int length) ...@@ -1250,8 +1250,6 @@ cciss_scsi_user_command(int ctlr, int hostno, char *buffer, int length)
return length; return length;
} }
/* It's a pity that we need this, but, we do... */
extern struct Scsi_Host *scsi_hostlist; /* from ../scsi/hosts.c */
int int
cciss_scsi_proc_info(char *buffer, /* data buffer */ cciss_scsi_proc_info(char *buffer, /* data buffer */
...@@ -1268,24 +1266,9 @@ cciss_scsi_proc_info(char *buffer, /* data buffer */ ...@@ -1268,24 +1266,9 @@ cciss_scsi_proc_info(char *buffer, /* data buffer */
ctlr_info_t *ci; ctlr_info_t *ci;
int cntl_num; int cntl_num;
/* Lets see if we can find our Scsi_Host...
this might be kind of "bad", searching scis_hostlist this way
but how else can we find the scsi host? I think I've seen
this coded both ways, (circular list and null terminated list)
I coded it to work either way, since I wasn't sure. */
sh = scsi_hostlist; sh = scsi_host_hn_get(hostnum);
found=0; if (sh == NULL) /* This really shouldn't ever happen. */
do {
if (sh == NULL) break;
if (sh->host_no == hostnum) {
found++;
break;
}
sh = sh->next;
} while (sh != scsi_hostlist && sh != NULL);
if (sh == NULL || found == 0) /* This really shouldn't ever happen. */
return -EINVAL; return -EINVAL;
ci = (ctlr_info_t *) sh->hostdata[0]; ci = (ctlr_info_t *) sh->hostdata[0];
......
...@@ -1719,13 +1719,11 @@ NCR_700_proc_directory_info(char *proc_buf, char **startp, ...@@ -1719,13 +1719,11 @@ NCR_700_proc_directory_info(char *proc_buf, char **startp,
{ {
static char buf[4096]; /* 1 page should be sufficient */ static char buf[4096]; /* 1 page should be sufficient */
int len = 0; int len = 0;
struct Scsi_Host *host = scsi_hostlist; struct Scsi_Host *host;
struct NCR_700_Host_Parameters *hostdata; struct NCR_700_Host_Parameters *hostdata;
Scsi_Device *SDp; Scsi_Device *SDp;
while(host != NULL && host->host_no != host_no) host = scsi_host_hn_get(host_no);
host = host->next;
if(host == NULL) if(host == NULL)
return 0; return 0;
......
...@@ -63,7 +63,6 @@ int ahc_linux_abort(Scsi_Cmnd *); ...@@ -63,7 +63,6 @@ int ahc_linux_abort(Scsi_Cmnd *);
* to do with card config are filled in after the card is detected. * to do with card config are filled in after the card is detected.
*/ */
#define AIC7XXX { \ #define AIC7XXX { \
next: NULL, \
module: NULL, \ module: NULL, \
proc_dir: NULL, \ proc_dir: NULL, \
proc_info: ahc_linux_proc_info, \ proc_info: ahc_linux_proc_info, \
......
...@@ -938,9 +938,7 @@ int cpqfcTS_proc_info (char *buffer, char **start, off_t offset, int length, ...@@ -938,9 +938,7 @@ int cpqfcTS_proc_info (char *buffer, char **start, off_t offset, int length,
char buf[81]; char buf[81];
// Search the Scsi host list for our controller // Search the Scsi host list for our controller
for (host=scsi_hostlist; host; host=host->next) host = scsi_host_hn_get(hostno);
if (host->host_no == hostno)
break;
if (!host) return -ESRCH; if (!host) return -ESRCH;
......
...@@ -213,9 +213,7 @@ int fcal_proc_info (char *buffer, char **start, off_t offset, int length, int ho ...@@ -213,9 +213,7 @@ int fcal_proc_info (char *buffer, char **start, off_t offset, int length, int ho
char *pos = buffer; char *pos = buffer;
int i, j; int i, j;
for (host=scsi_hostlist; host; host=host->next) host = scsi_host_hn_get(hostno);
if (host->host_no == hostno)
break;
if (!host) return -ESRCH; if (!host) return -ESRCH;
......
...@@ -407,7 +407,6 @@ ...@@ -407,7 +407,6 @@
*/ */
#if LINUX_VERSION_CODE < LinuxVersionCode(2,4,0) #if LINUX_VERSION_CODE < LinuxVersionCode(2,4,0)
#define IPS { \ #define IPS { \
next : NULL, \
module : NULL, \ module : NULL, \
proc_info : NULL, \ proc_info : NULL, \
proc_dir : NULL, \ proc_dir : NULL, \
...@@ -437,7 +436,6 @@ ...@@ -437,7 +436,6 @@
} }
#elif LINUX_VERSION_CODE < LinuxVersionCode(2,5,0) #elif LINUX_VERSION_CODE < LinuxVersionCode(2,5,0)
#define IPS { \ #define IPS { \
next : NULL, \
module : NULL, \ module : NULL, \
proc_info : NULL, \ proc_info : NULL, \
name : NULL, \ name : NULL, \
...@@ -466,7 +464,6 @@ ...@@ -466,7 +464,6 @@
} }
#else #else
#define IPS { \ #define IPS { \
next : NULL, \
module : NULL, \ module : NULL, \
proc_info : NULL, \ proc_info : NULL, \
name : NULL, \ name : NULL, \
......
...@@ -294,7 +294,8 @@ static void aha152x_config_cs(dev_link_t *link) ...@@ -294,7 +294,8 @@ static void aha152x_config_cs(dev_link_t *link)
tail = &link->dev; tail = &link->dev;
info->ndev = 0; info->ndev = 0;
for (host = scsi_hostlist; host; host = host->next) for (host = scsi_host_get_next(NULL); host;
host = scsi_host_get_next(host))
if (host->hostt == &driver_template) if (host->hostt == &driver_template)
for (dev = host->host_queue; dev; dev = dev->next) { for (dev = host->host_queue; dev; dev = dev->next) {
u_long arg[2], id; u_long arg[2], id;
......
...@@ -258,7 +258,8 @@ static void fdomain_config(dev_link_t *link) ...@@ -258,7 +258,8 @@ static void fdomain_config(dev_link_t *link)
tail = &link->dev; tail = &link->dev;
info->ndev = 0; info->ndev = 0;
for (host = scsi_hostlist; host; host = host->next) for (host = scsi_host_get_next(NULL); host;
host = scsi_host_get_next(host))
if (host->hostt == &driver_template) if (host->hostt == &driver_template)
for (dev = host->host_queue; dev; dev = dev->next) { for (dev = host->host_queue; dev; dev = dev->next) {
u_long arg[2], id; u_long arg[2], id;
......
...@@ -1520,7 +1520,8 @@ static void nsp_cs_config(dev_link_t *link) ...@@ -1520,7 +1520,8 @@ static void nsp_cs_config(dev_link_t *link)
DEBUG(0, "GET_SCSI_INFO\n"); DEBUG(0, "GET_SCSI_INFO\n");
tail = &link->dev; tail = &link->dev;
info->ndev = 0; info->ndev = 0;
for (host = scsi_hostlist; host != NULL; host = host->next) { for (host = scsi_host_get_next(NULL); host;
host = scsi_host_get_next(host))
if (host->hostt == &driver_template) { if (host->hostt == &driver_template) {
for (dev = host->host_queue; dev != NULL; dev = dev->next) { for (dev = host->host_queue; dev != NULL; dev = dev->next) {
u_long arg[2], id; u_long arg[2], id;
......
...@@ -281,7 +281,8 @@ static void qlogic_config(dev_link_t *link) ...@@ -281,7 +281,8 @@ static void qlogic_config(dev_link_t *link)
tail = &link->dev; tail = &link->dev;
info->ndev = 0; info->ndev = 0;
for (host = scsi_hostlist; host; host = host->next) for (host = scsi_host_get_next(NULL); host;
host = scsi_host_get_next(host))
if (host->hostt == &driver_template) if (host->hostt == &driver_template)
for (dev = host->host_queue; dev; dev = dev->next) { for (dev = host->host_queue; dev; dev = dev->next) {
u_long arg[2], id; u_long arg[2], id;
......
...@@ -1871,10 +1871,7 @@ Scsi_Cmnd *cmd; ...@@ -1871,10 +1871,7 @@ Scsi_Cmnd *cmd;
int x,i; int x,i;
static int stop = 0; static int stop = 0;
for (instance=scsi_hostlist; instance; instance=instance->next) { instance = scsi_host_hn_get(hn);
if (instance->host_no == hn)
break;
}
if (!instance) { if (!instance) {
printk("*** Hmm... Can't find host #%d!\n",hn); printk("*** Hmm... Can't find host #%d!\n",hn);
return (-ESRCH); return (-ESRCH);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment