Commit 68fe1e0f authored by Mike Anderson's avatar Mike Anderson Committed by James Bottomley

[PATCH] scsi host cleanup 2/3 (mid lvl changes)

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

 scsi.c      |  456 +++---------------------------------------------------------
 scsi_proc.c |   57 ++++---
 scsi_syms.c |    5
 sg.c        |    6
 4 files changed, 63 insertions(+), 461 deletions(-)
parent 728df29f
This diff is collapsed.
...@@ -119,35 +119,44 @@ static int proc_scsi_write(struct file * file, const char * buf, ...@@ -119,35 +119,44 @@ static int proc_scsi_write(struct file * file, const char * buf,
return(ret); return(ret);
} }
void build_proc_dir_entries(Scsi_Host_Template * tpnt) void scsi_proc_host_mkdir(Scsi_Host_Template *shost_tp)
{ {
struct Scsi_Host *hpnt; shost_tp->proc_dir = proc_mkdir(shost_tp->proc_name, proc_scsi);
char name[10]; /* see scsi_unregister_host() */ if (!shost_tp->proc_dir) {
printk(KERN_ERR "%s: proc_mkdir failed for %s\n",
tpnt->proc_dir = proc_mkdir(tpnt->proc_name, proc_scsi); __FUNCTION__, shost_tp->proc_name);
if (!tpnt->proc_dir) {
printk(KERN_ERR "Unable to proc_mkdir in scsi.c/build_proc_dir_entries");
return; return;
} }
tpnt->proc_dir->owner = tpnt->module; shost_tp->proc_dir->owner = shost_tp->module;
}
hpnt = scsi_hostlist; void scsi_proc_host_add(struct Scsi_Host *shost)
while (hpnt) { {
if (tpnt == hpnt->hostt) { char name[10];
struct proc_dir_entry *p; struct proc_dir_entry *p;
sprintf(name,"%d",hpnt->host_no);
sprintf(name,"%d",shost->host_no);
p = create_proc_read_entry(name, p = create_proc_read_entry(name,
S_IFREG | S_IRUGO | S_IWUSR, S_IFREG | S_IRUGO | S_IWUSR,
tpnt->proc_dir, shost->hostt->proc_dir,
proc_scsi_read, proc_scsi_read,
(void *)hpnt); (void *)shost);
if (!p) if (!p) {
panic("Not enough memory to register SCSI HBA in /proc/scsi !\n"); printk(KERN_ERR "%s: Failed to register host %d in"
"%s\n", __FUNCTION__, shost->host_no,
shost->hostt->proc_name);
} else {
p->write_proc=proc_scsi_write; p->write_proc=proc_scsi_write;
p->owner = tpnt->module; p->owner = shost->hostt->module;
}
hpnt = hpnt->next;
} }
}
void scsi_proc_host_rm(struct Scsi_Host *shost)
{
char name[10];
sprintf(name,"%d",shost->host_no);
remove_proc_entry(name, shost->hostt->proc_dir);
} }
/* /*
......
...@@ -91,8 +91,9 @@ EXPORT_SYMBOL(scsi_reset_provider); ...@@ -91,8 +91,9 @@ EXPORT_SYMBOL(scsi_reset_provider);
/* /*
* These are here only while I debug the rest of the scsi stuff. * These are here only while I debug the rest of the scsi stuff.
*/ */
EXPORT_SYMBOL(scsi_hostlist); EXPORT_SYMBOL(scsi_host_get_next);
EXPORT_SYMBOL(scsi_hosts); EXPORT_SYMBOL(scsi_host_hn_get);
EXPORT_SYMBOL(scsi_host_put);
EXPORT_SYMBOL(scsi_devicelist); EXPORT_SYMBOL(scsi_devicelist);
EXPORT_SYMBOL(scsi_device_types); EXPORT_SYMBOL(scsi_device_types);
......
...@@ -3103,7 +3103,8 @@ sg_proc_host_info(char *buffer, int *len, off_t * begin, off_t offset, int size) ...@@ -3103,7 +3103,8 @@ sg_proc_host_info(char *buffer, int *len, off_t * begin, off_t offset, int size)
struct Scsi_Host *shp; struct Scsi_Host *shp;
int k; int k;
for (k = 0, shp = scsi_hostlist; shp; shp = shp->next, ++k) { for (k = 0, shp = scsi_host_get_next(NULL); shp;
shp = scsi_host_get_next(shp), ++k) {
for (; k < shp->host_no; ++k) for (; k < shp->host_no; ++k)
PRINT_PROC("-1\t-1\t-1\t-1\t-1\t-1\n"); PRINT_PROC("-1\t-1\t-1\t-1\t-1\t-1\n");
PRINT_PROC("%u\t%hu\t%hd\t%hu\t%d\t%d\n", PRINT_PROC("%u\t%hu\t%hd\t%hu\t%d\t%d\n",
...@@ -3147,7 +3148,8 @@ sg_proc_hoststrs_info(char *buffer, int *len, off_t * begin, ...@@ -3147,7 +3148,8 @@ sg_proc_hoststrs_info(char *buffer, int *len, off_t * begin,
char buff[SG_MAX_HOST_STR_LEN]; char buff[SG_MAX_HOST_STR_LEN];
char *cp; char *cp;
for (k = 0, shp = scsi_hostlist; shp; shp = shp->next, ++k) { for (k = 0, shp = scsi_host_get_next(NULL); shp;
shp = scsi_host_get_next(shp), ++k) {
for (; k < shp->host_no; ++k) for (; k < shp->host_no; ++k)
PRINT_PROC("<no active host>\n"); PRINT_PROC("<no active host>\n");
strncpy(buff, shp->hostt->info ? shp->hostt->info(shp) : strncpy(buff, shp->hostt->info ? shp->hostt->info(shp) :
......
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