dect
/
linux-2.6
Archived
13
0
Fork 0

[SCSI] gdth: clean up host private data

- Based on same patch from Christoph Hellwig <hch@lst.de>

  - Get rid of all the indirection in the Scsi_Host private data and always
    put the gdth_ha_str directly into it.

  - Change all internal functions prototype to recieve an "gdth_ha_str *ha"
    pointer directlly and kill all that redundent access to the "gdth_ctr_tab[]"
    controller-table.

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
This commit is contained in:
Boaz Harrosh 2007-10-02 23:05:53 +02:00 committed by James Bottomley
parent 52759e6abc
commit 45f1a41b2b
4 changed files with 291 additions and 384 deletions

File diff suppressed because it is too large Load Diff

View File

@ -853,6 +853,8 @@ typedef struct {
/* controller information structure */ /* controller information structure */
typedef struct { typedef struct {
struct Scsi_Host *shost;
ushort hanum;
ushort oem_id; /* OEM */ ushort oem_id; /* OEM */
ushort type; /* controller class */ ushort type; /* controller class */
ulong32 stype; /* subtype (PCI: device ID) */ ulong32 stype; /* subtype (PCI: device ID) */
@ -864,6 +866,7 @@ typedef struct {
void __iomem *brd; /* DPRAM address */ void __iomem *brd; /* DPRAM address */
ulong32 brd_phys; /* slot number/BIOS address */ ulong32 brd_phys; /* slot number/BIOS address */
gdt6c_plx_regs *plx; /* PLX regs (new PCI contr.) */ gdt6c_plx_regs *plx; /* PLX regs (new PCI contr.) */
gdth_cmd_str cmdext;
gdth_cmd_str *pccb; /* address command structure */ gdth_cmd_str *pccb; /* address command structure */
ulong32 ccb_phys; /* phys. address */ ulong32 ccb_phys; /* phys. address */
#ifdef INT_COAL #ifdef INT_COAL
@ -937,20 +940,6 @@ typedef struct {
struct scsi_device *sdev; struct scsi_device *sdev;
} gdth_ha_str; } gdth_ha_str;
/* structure for scsi_register(), SCSI bus != 0 */
typedef struct {
ushort hanum;
ushort busnum;
} gdth_num_str;
/* structure for scsi_register() */
typedef struct {
gdth_num_str numext; /* must be the first element */
gdth_ha_str haext;
gdth_cmd_str cmdext;
} gdth_ext_str;
/* INQUIRY data format */ /* INQUIRY data format */
typedef struct { typedef struct {
unchar type_qual; unchar type_qual;

View File

@ -7,31 +7,29 @@
int gdth_proc_info(struct Scsi_Host *host, char *buffer,char **start,off_t offset,int length, int gdth_proc_info(struct Scsi_Host *host, char *buffer,char **start,off_t offset,int length,
int inout) int inout)
{ {
int hanum; gdth_ha_str *ha = shost_priv(host);
TRACE2(("gdth_proc_info() length %d offs %d inout %d\n", TRACE2(("gdth_proc_info() length %d offs %d inout %d\n",
length,(int)offset,inout)); length,(int)offset,inout));
hanum = NUMDATA(host)->hanum;
if (inout) if (inout)
return(gdth_set_info(buffer,length,host,hanum)); return(gdth_set_info(buffer,length,host,ha));
else else
return(gdth_get_info(buffer,start,offset,length,host,hanum)); return(gdth_get_info(buffer,start,offset,length,host,ha));
} }
static int gdth_set_info(char *buffer,int length,struct Scsi_Host *host, static int gdth_set_info(char *buffer,int length,struct Scsi_Host *host,
int hanum) gdth_ha_str *ha)
{ {
int ret_val = -EINVAL; int ret_val = -EINVAL;
TRACE2(("gdth_set_info() ha %d\n",hanum,)); TRACE2(("gdth_set_info() ha %d\n",ha->hanum,));
if (length >= 4) { if (length >= 4) {
if (strncmp(buffer,"gdth",4) == 0) { if (strncmp(buffer,"gdth",4) == 0) {
buffer += 5; buffer += 5;
length -= 5; length -= 5;
ret_val = gdth_set_asc_info(host, buffer, length, hanum); ret_val = gdth_set_asc_info(host, buffer, length, ha);
} }
} }
@ -39,11 +37,10 @@ static int gdth_set_info(char *buffer,int length,struct Scsi_Host *host,
} }
static int gdth_set_asc_info(struct Scsi_Host *host, char *buffer, static int gdth_set_asc_info(struct Scsi_Host *host, char *buffer,
int length,int hanum) int length, gdth_ha_str *ha)
{ {
int orig_length, drive, wb_mode; int orig_length, drive, wb_mode;
int i, found; int i, found;
gdth_ha_str *ha;
gdth_cmd_str gdtcmd; gdth_cmd_str gdtcmd;
gdth_cpar_str *pcpar; gdth_cpar_str *pcpar;
ulong64 paddr; ulong64 paddr;
@ -52,8 +49,7 @@ static int gdth_set_asc_info(struct Scsi_Host *host, char *buffer,
memset(cmnd, 0xff, 12); memset(cmnd, 0xff, 12);
memset(&gdtcmd, 0, sizeof(gdth_cmd_str)); memset(&gdtcmd, 0, sizeof(gdth_cmd_str));
TRACE2(("gdth_set_asc_info() ha %d\n",hanum)); TRACE2(("gdth_set_asc_info() ha %d\n",ha->hanum));
ha = HADATA(gdth_ctr_tab[hanum]);
orig_length = length + 5; orig_length = length + 5;
drive = -1; drive = -1;
wb_mode = 0; wb_mode = 0;
@ -129,7 +125,7 @@ static int gdth_set_asc_info(struct Scsi_Host *host, char *buffer,
} }
if (wb_mode) { if (wb_mode) {
if (!gdth_ioctl_alloc(hanum, sizeof(gdth_cpar_str), TRUE, &paddr)) if (!gdth_ioctl_alloc(ha, sizeof(gdth_cpar_str), TRUE, &paddr))
return(-EBUSY); return(-EBUSY);
pcpar = (gdth_cpar_str *)ha->pscratch; pcpar = (gdth_cpar_str *)ha->pscratch;
memcpy( pcpar, &ha->cpar, sizeof(gdth_cpar_str) ); memcpy( pcpar, &ha->cpar, sizeof(gdth_cpar_str) );
@ -143,7 +139,7 @@ static int gdth_set_asc_info(struct Scsi_Host *host, char *buffer,
gdth_execute(host, &gdtcmd, cmnd, 30, NULL); gdth_execute(host, &gdtcmd, cmnd, 30, NULL);
gdth_ioctl_free(hanum, GDTH_SCRATCH, ha->pscratch, paddr); gdth_ioctl_free(ha, GDTH_SCRATCH, ha->pscratch, paddr);
printk("Done.\n"); printk("Done.\n");
return(orig_length); return(orig_length);
} }
@ -153,11 +149,10 @@ static int gdth_set_asc_info(struct Scsi_Host *host, char *buffer,
} }
static int gdth_get_info(char *buffer,char **start,off_t offset,int length, static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
struct Scsi_Host *host,int hanum) struct Scsi_Host *host, gdth_ha_str *ha)
{ {
int size = 0,len = 0; int size = 0,len = 0;
off_t begin = 0,pos = 0; off_t begin = 0,pos = 0;
gdth_ha_str *ha;
int id, i, j, k, sec, flag; int id, i, j, k, sec, flag;
int no_mdrv = 0, drv_no, is_mirr; int no_mdrv = 0, drv_no, is_mirr;
ulong32 cnt; ulong32 cnt;
@ -186,8 +181,7 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
memset(cmnd, 0xff, 12); memset(cmnd, 0xff, 12);
memset(gdtcmd, 0, sizeof(gdth_cmd_str)); memset(gdtcmd, 0, sizeof(gdth_cmd_str));
TRACE2(("gdth_get_info() ha %d\n",hanum)); TRACE2(("gdth_get_info() ha %d\n",ha->hanum));
ha = HADATA(gdth_ctr_tab[hanum]);
/* request is i.e. "cat /proc/scsi/gdth/0" */ /* request is i.e. "cat /proc/scsi/gdth/0" */
@ -220,7 +214,7 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
strcpy(hrec, ha->binfo.type_string); strcpy(hrec, ha->binfo.type_string);
size = sprintf(buffer+len, size = sprintf(buffer+len,
" Number: \t%d \tName: \t%s\n", " Number: \t%d \tName: \t%s\n",
hanum, hrec); ha->hanum, hrec);
len += size; pos = begin + len; len += size; pos = begin + len;
if (ha->more_proc) if (ha->more_proc)
@ -270,7 +264,7 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
len += size; pos = begin + len; len += size; pos = begin + len;
flag = FALSE; flag = FALSE;
buf = gdth_ioctl_alloc(hanum, GDTH_SCRATCH, FALSE, &paddr); buf = gdth_ioctl_alloc(ha, GDTH_SCRATCH, FALSE, &paddr);
if (!buf) if (!buf)
goto stop_output; goto stop_output;
for (i = 0; i < ha->bus_cnt; ++i) { for (i = 0; i < ha->bus_cnt; ++i) {
@ -373,7 +367,7 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
goto stop_output; goto stop_output;
} }
} }
gdth_ioctl_free(hanum, GDTH_SCRATCH, buf, paddr); gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr);
if (!flag) { if (!flag) {
size = sprintf(buffer+len, "\n --\n"); size = sprintf(buffer+len, "\n --\n");
@ -385,7 +379,7 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
len += size; pos = begin + len; len += size; pos = begin + len;
flag = FALSE; flag = FALSE;
buf = gdth_ioctl_alloc(hanum, GDTH_SCRATCH, FALSE, &paddr); buf = gdth_ioctl_alloc(ha, GDTH_SCRATCH, FALSE, &paddr);
if (!buf) if (!buf)
goto stop_output; goto stop_output;
for (i = 0; i < MAX_LDRIVES; ++i) { for (i = 0; i < MAX_LDRIVES; ++i) {
@ -479,7 +473,7 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
if (pos > offset + length) if (pos > offset + length)
goto stop_output; goto stop_output;
} }
gdth_ioctl_free(hanum, GDTH_SCRATCH, buf, paddr); gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr);
if (!flag) { if (!flag) {
size = sprintf(buffer+len, "\n --\n"); size = sprintf(buffer+len, "\n --\n");
@ -491,7 +485,7 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
len += size; pos = begin + len; len += size; pos = begin + len;
flag = FALSE; flag = FALSE;
buf = gdth_ioctl_alloc(hanum, GDTH_SCRATCH, FALSE, &paddr); buf = gdth_ioctl_alloc(ha, GDTH_SCRATCH, FALSE, &paddr);
if (!buf) if (!buf)
goto stop_output; goto stop_output;
for (i = 0; i < MAX_LDRIVES; ++i) { for (i = 0; i < MAX_LDRIVES; ++i) {
@ -550,7 +544,7 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
goto stop_output; goto stop_output;
} }
} }
gdth_ioctl_free(hanum, GDTH_SCRATCH, buf, paddr); gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr);
if (!flag) { if (!flag) {
size = sprintf(buffer+len, "\n --\n"); size = sprintf(buffer+len, "\n --\n");
@ -562,7 +556,7 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
len += size; pos = begin + len; len += size; pos = begin + len;
flag = FALSE; flag = FALSE;
buf = gdth_ioctl_alloc(hanum, sizeof(gdth_hget_str), FALSE, &paddr); buf = gdth_ioctl_alloc(ha, sizeof(gdth_hget_str), FALSE, &paddr);
if (!buf) if (!buf)
goto stop_output; goto stop_output;
for (i = 0; i < MAX_LDRIVES; ++i) { for (i = 0; i < MAX_LDRIVES; ++i) {
@ -595,7 +589,7 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
} }
} }
} }
gdth_ioctl_free(hanum, sizeof(gdth_hget_str), buf, paddr); gdth_ioctl_free(ha, sizeof(gdth_hget_str), buf, paddr);
for (i = 0; i < MAX_HDRIVES; ++i) { for (i = 0; i < MAX_HDRIVES; ++i) {
if (!(ha->hdr[i].present)) if (!(ha->hdr[i].present))
@ -633,7 +627,7 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
id = gdth_read_event(ha, id, estr); id = gdth_read_event(ha, id, estr);
if (estr->event_source == 0) if (estr->event_source == 0)
break; break;
if (estr->event_data.eu.driver.ionode == hanum && if (estr->event_data.eu.driver.ionode == ha->hanum &&
estr->event_source == ES_ASYNC) { estr->event_source == ES_ASYNC) {
gdth_log_event(&estr->event_data, hrec); gdth_log_event(&estr->event_data, hrec);
do_gettimeofday(&tv); do_gettimeofday(&tv);
@ -668,17 +662,15 @@ free_fail:
return rc; return rc;
} }
static char *gdth_ioctl_alloc(int hanum, int size, int scratch, static char *gdth_ioctl_alloc(gdth_ha_str *ha, int size, int scratch,
ulong64 *paddr) ulong64 *paddr)
{ {
gdth_ha_str *ha;
ulong flags; ulong flags;
char *ret_val; char *ret_val;
if (size == 0) if (size == 0)
return NULL; return NULL;
ha = HADATA(gdth_ctr_tab[hanum]);
spin_lock_irqsave(&ha->smp_lock, flags); spin_lock_irqsave(&ha->smp_lock, flags);
if (!ha->scratch_busy && size <= GDTH_SCRATCH) { if (!ha->scratch_busy && size <= GDTH_SCRATCH) {
@ -698,12 +690,10 @@ static char *gdth_ioctl_alloc(int hanum, int size, int scratch,
return ret_val; return ret_val;
} }
static void gdth_ioctl_free(int hanum, int size, char *buf, ulong64 paddr) static void gdth_ioctl_free(gdth_ha_str *ha, int size, char *buf, ulong64 paddr)
{ {
gdth_ha_str *ha;
ulong flags; ulong flags;
ha = HADATA(gdth_ctr_tab[hanum]);
spin_lock_irqsave(&ha->smp_lock, flags); spin_lock_irqsave(&ha->smp_lock, flags);
if (buf == ha->pscratch) { if (buf == ha->pscratch) {
@ -716,13 +706,11 @@ static void gdth_ioctl_free(int hanum, int size, char *buf, ulong64 paddr)
} }
#ifdef GDTH_IOCTL_PROC #ifdef GDTH_IOCTL_PROC
static int gdth_ioctl_check_bin(int hanum, ushort size) static int gdth_ioctl_check_bin(gdth_ha_str *ha, ushort size)
{ {
gdth_ha_str *ha;
ulong flags; ulong flags;
int ret_val; int ret_val;
ha = HADATA(gdth_ctr_tab[hanum]);
spin_lock_irqsave(&ha->smp_lock, flags); spin_lock_irqsave(&ha->smp_lock, flags);
ret_val = FALSE; ret_val = FALSE;
@ -735,15 +723,13 @@ static int gdth_ioctl_check_bin(int hanum, ushort size)
} }
#endif #endif
static void gdth_wait_completion(int hanum, int busnum, int id) static void gdth_wait_completion(gdth_ha_str *ha, int busnum, int id)
{ {
gdth_ha_str *ha;
ulong flags; ulong flags;
int i; int i;
Scsi_Cmnd *scp; Scsi_Cmnd *scp;
unchar b, t; unchar b, t;
ha = HADATA(gdth_ctr_tab[hanum]);
spin_lock_irqsave(&ha->smp_lock, flags); spin_lock_irqsave(&ha->smp_lock, flags);
for (i = 0; i < GDTH_MAXCMDS; ++i) { for (i = 0; i < GDTH_MAXCMDS; ++i) {
@ -763,14 +749,12 @@ static void gdth_wait_completion(int hanum, int busnum, int id)
spin_unlock_irqrestore(&ha->smp_lock, flags); spin_unlock_irqrestore(&ha->smp_lock, flags);
} }
static void gdth_stop_timeout(int hanum, int busnum, int id) static void gdth_stop_timeout(gdth_ha_str *ha, int busnum, int id)
{ {
gdth_ha_str *ha;
ulong flags; ulong flags;
Scsi_Cmnd *scp; Scsi_Cmnd *scp;
unchar b, t; unchar b, t;
ha = HADATA(gdth_ctr_tab[hanum]);
spin_lock_irqsave(&ha->smp_lock, flags); spin_lock_irqsave(&ha->smp_lock, flags);
for (scp = ha->req_first; scp; scp = (Scsi_Cmnd *)scp->SCp.ptr) { for (scp = ha->req_first; scp; scp = (Scsi_Cmnd *)scp->SCp.ptr) {
@ -779,21 +763,19 @@ static void gdth_stop_timeout(int hanum, int busnum, int id)
t = scp->device->id; t = scp->device->id;
if (t == (unchar)id && b == (unchar)busnum) { if (t == (unchar)id && b == (unchar)busnum) {
TRACE2(("gdth_stop_timeout(): update_timeout()\n")); TRACE2(("gdth_stop_timeout(): update_timeout()\n"));
scp->SCp.buffers_residual = gdth_update_timeout(hanum, scp, 0); scp->SCp.buffers_residual = gdth_update_timeout(scp, 0);
} }
} }
} }
spin_unlock_irqrestore(&ha->smp_lock, flags); spin_unlock_irqrestore(&ha->smp_lock, flags);
} }
static void gdth_start_timeout(int hanum, int busnum, int id) static void gdth_start_timeout(gdth_ha_str *ha, int busnum, int id)
{ {
gdth_ha_str *ha;
ulong flags; ulong flags;
Scsi_Cmnd *scp; Scsi_Cmnd *scp;
unchar b, t; unchar b, t;
ha = HADATA(gdth_ctr_tab[hanum]);
spin_lock_irqsave(&ha->smp_lock, flags); spin_lock_irqsave(&ha->smp_lock, flags);
for (scp = ha->req_first; scp; scp = (Scsi_Cmnd *)scp->SCp.ptr) { for (scp = ha->req_first; scp; scp = (Scsi_Cmnd *)scp->SCp.ptr) {
@ -802,14 +784,14 @@ static void gdth_start_timeout(int hanum, int busnum, int id)
t = scp->device->id; t = scp->device->id;
if (t == (unchar)id && b == (unchar)busnum) { if (t == (unchar)id && b == (unchar)busnum) {
TRACE2(("gdth_start_timeout(): update_timeout()\n")); TRACE2(("gdth_start_timeout(): update_timeout()\n"));
gdth_update_timeout(hanum, scp, scp->SCp.buffers_residual); gdth_update_timeout(scp, scp->SCp.buffers_residual);
} }
} }
} }
spin_unlock_irqrestore(&ha->smp_lock, flags); spin_unlock_irqrestore(&ha->smp_lock, flags);
} }
static int gdth_update_timeout(int hanum, Scsi_Cmnd *scp, int timeout) static int gdth_update_timeout(Scsi_Cmnd *scp, int timeout)
{ {
int oldto; int oldto;

View File

@ -9,20 +9,20 @@ int gdth_execute(struct Scsi_Host *shost, gdth_cmd_str *gdtcmd, char *cmnd,
int timeout, u32 *info); int timeout, u32 *info);
static int gdth_set_info(char *buffer,int length,struct Scsi_Host *host, static int gdth_set_info(char *buffer,int length,struct Scsi_Host *host,
int hanum); gdth_ha_str *ha);
static int gdth_get_info(char *buffer,char **start,off_t offset,int length, static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
struct Scsi_Host *host,int hanum); struct Scsi_Host *host, gdth_ha_str *ha);
static int gdth_set_asc_info(struct Scsi_Host *host, char *buffer, static int gdth_set_asc_info(struct Scsi_Host *host, char *buffer,
int length, int hanum); int length, gdth_ha_str *ha);
static char *gdth_ioctl_alloc(int hanum, int size, int scratch, static char *gdth_ioctl_alloc(gdth_ha_str *ha, int size, int scratch,
ulong64 *paddr); ulong64 *paddr);
static void gdth_ioctl_free(int hanum, int size, char *buf, ulong64 paddr); static void gdth_ioctl_free(gdth_ha_str *ha, int size, char *buf, ulong64 paddr);
static void gdth_wait_completion(int hanum, int busnum, int id); static void gdth_wait_completion(gdth_ha_str *ha, int busnum, int id);
static void gdth_stop_timeout(int hanum, int busnum, int id); static void gdth_stop_timeout(gdth_ha_str *ha, int busnum, int id);
static void gdth_start_timeout(int hanum, int busnum, int id); static void gdth_start_timeout(gdth_ha_str *ha, int busnum, int id);
static int gdth_update_timeout(int hanum, Scsi_Cmnd *scp, int timeout); static int gdth_update_timeout(Scsi_Cmnd *scp, int timeout);
#endif #endif