Commit 45f1a41b authored by Boaz Harrosh's avatar Boaz Harrosh Committed by James Bottomley

[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: default avatarBoaz Harrosh <bharrosh@panasas.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent 52759e6a
...@@ -139,14 +139,15 @@ ...@@ -139,14 +139,15 @@
static void gdth_delay(int milliseconds); static void gdth_delay(int milliseconds);
static void gdth_eval_mapping(ulong32 size, ulong32 *cyls, int *heads, int *secs); static void gdth_eval_mapping(ulong32 size, ulong32 *cyls, int *heads, int *secs);
static irqreturn_t gdth_interrupt(int irq, void *dev_id); static irqreturn_t gdth_interrupt(int irq, void *dev_id);
static int gdth_sync_event(int hanum,int service,unchar index,Scsi_Cmnd *scp); static int gdth_sync_event(gdth_ha_str *ha, int service, unchar index,
static int gdth_async_event(int hanum); Scsi_Cmnd *scp);
static int gdth_async_event(gdth_ha_str *ha);
static void gdth_log_event(gdth_evt_data *dvr, char *buffer); static void gdth_log_event(gdth_evt_data *dvr, char *buffer);
static void gdth_putq(int hanum,Scsi_Cmnd *scp,unchar priority); static void gdth_putq(gdth_ha_str *ha, Scsi_Cmnd *scp, unchar priority);
static void gdth_next(int hanum); static void gdth_next(gdth_ha_str *ha);
static int gdth_fill_raw_cmd(int hanum,Scsi_Cmnd *scp,unchar b); static int gdth_fill_raw_cmd(gdth_ha_str *ha, Scsi_Cmnd *scp, unchar b);
static int gdth_special_cmd(int hanum,Scsi_Cmnd *scp); static int gdth_special_cmd(gdth_ha_str *ha, Scsi_Cmnd *scp);
static gdth_evt_str *gdth_store_event(gdth_ha_str *ha, ushort source, static gdth_evt_str *gdth_store_event(gdth_ha_str *ha, ushort source,
ushort idx, gdth_evt_data *evt); ushort idx, gdth_evt_data *evt);
static int gdth_read_event(gdth_ha_str *ha, int handle, gdth_evt_str *estr); static int gdth_read_event(gdth_ha_str *ha, int handle, gdth_evt_str *estr);
...@@ -154,30 +155,30 @@ static void gdth_readapp_event(gdth_ha_str *ha, unchar application, ...@@ -154,30 +155,30 @@ static void gdth_readapp_event(gdth_ha_str *ha, unchar application,
gdth_evt_str *estr); gdth_evt_str *estr);
static void gdth_clear_events(void); static void gdth_clear_events(void);
static void gdth_copy_internal_data(int hanum,Scsi_Cmnd *scp, static void gdth_copy_internal_data(gdth_ha_str *ha, Scsi_Cmnd *scp,
char *buffer,ushort count); char *buffer,ushort count);
static int gdth_internal_cache_cmd(int hanum,Scsi_Cmnd *scp); static int gdth_internal_cache_cmd(gdth_ha_str *ha, Scsi_Cmnd *scp);
static int gdth_fill_cache_cmd(int hanum,Scsi_Cmnd *scp,ushort hdrive); static int gdth_fill_cache_cmd(gdth_ha_str *ha, Scsi_Cmnd *scp, ushort hdrive);
static void gdth_enable_int(int hanum); static void gdth_enable_int(gdth_ha_str *ha);
static int gdth_get_status(unchar *pIStatus,int irq); static int gdth_get_status(unchar *pIStatus,int irq);
static int gdth_test_busy(int hanum); static int gdth_test_busy(gdth_ha_str *ha);
static int gdth_get_cmd_index(int hanum); static int gdth_get_cmd_index(gdth_ha_str *ha);
static void gdth_release_event(int hanum); static void gdth_release_event(gdth_ha_str *ha);
static int gdth_wait(int hanum,int index,ulong32 time); static int gdth_wait(gdth_ha_str *ha, int index,ulong32 time);
static int gdth_internal_cmd(int hanum,unchar service,ushort opcode,ulong32 p1, static int gdth_internal_cmd(gdth_ha_str *ha, unchar service, ushort opcode,
ulong64 p2,ulong64 p3); ulong32 p1, ulong64 p2,ulong64 p3);
static int gdth_search_drives(int hanum); static int gdth_search_drives(gdth_ha_str *ha);
static int gdth_analyse_hdrive(int hanum, ushort hdrive); static int gdth_analyse_hdrive(gdth_ha_str *ha, ushort hdrive);
static const char *gdth_ctr_name(int hanum); static const char *gdth_ctr_name(gdth_ha_str *ha);
static int gdth_open(struct inode *inode, struct file *filep); static int gdth_open(struct inode *inode, struct file *filep);
static int gdth_close(struct inode *inode, struct file *filep); static int gdth_close(struct inode *inode, struct file *filep);
static int gdth_ioctl(struct inode *inode, struct file *filep, static int gdth_ioctl(struct inode *inode, struct file *filep,
unsigned int cmd, unsigned long arg); unsigned int cmd, unsigned long arg);
static void gdth_flush(int hanum); static void gdth_flush(gdth_ha_str *ha);
static int gdth_halt(struct notifier_block *nb, ulong event, void *buf); static int gdth_halt(struct notifier_block *nb, ulong event, void *buf);
static int gdth_queuecommand(Scsi_Cmnd *scp,void (*done)(Scsi_Cmnd *)); static int gdth_queuecommand(Scsi_Cmnd *scp,void (*done)(Scsi_Cmnd *));
static void gdth_scsi_done(struct scsi_cmnd *scp); static void gdth_scsi_done(struct scsi_cmnd *scp);
...@@ -285,10 +286,6 @@ static struct timer_list gdth_timer; ...@@ -285,10 +286,6 @@ static struct timer_list gdth_timer;
#define GDTOFFSOF(a,b) (size_t)&(((a*)0)->b) #define GDTOFFSOF(a,b) (size_t)&(((a*)0)->b)
#define INDEX_OK(i,t) ((i)<ARRAY_SIZE(t)) #define INDEX_OK(i,t) ((i)<ARRAY_SIZE(t))
#define NUMDATA(a) ( (gdth_num_str *)((a)->hostdata))
#define HADATA(a) (&((gdth_ext_str *)((a)->hostdata))->haext)
#define CMDDATA(a) (&((gdth_ext_str *)((a)->hostdata))->cmdext)
#define BUS_L2P(a,b) ((b)>(a)->virt_bus ? (b-1):(b)) #define BUS_L2P(a,b) ((b)>(a)->virt_bus ? (b-1):(b))
#ifdef CONFIG_ISA #ifdef CONFIG_ISA
...@@ -1212,16 +1209,14 @@ static int __init gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha) ...@@ -1212,16 +1209,14 @@ static int __init gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha)
/* controller protocol functions */ /* controller protocol functions */
static void __init gdth_enable_int(int hanum) static void __init gdth_enable_int(gdth_ha_str *ha)
{ {
gdth_ha_str *ha;
ulong flags; ulong flags;
gdt2_dpram_str __iomem *dp2_ptr; gdt2_dpram_str __iomem *dp2_ptr;
gdt6_dpram_str __iomem *dp6_ptr; gdt6_dpram_str __iomem *dp6_ptr;
gdt6m_dpram_str __iomem *dp6m_ptr; gdt6m_dpram_str __iomem *dp6m_ptr;
TRACE(("gdth_enable_int() hanum %d\n",hanum)); TRACE(("gdth_enable_int() hanum %d\n",ha->hanum));
ha = HADATA(gdth_ctr_tab[hanum]);
spin_lock_irqsave(&ha->smp_lock, flags); spin_lock_irqsave(&ha->smp_lock, flags);
if (ha->type == GDT_EISA) { if (ha->type == GDT_EISA) {
...@@ -1261,7 +1256,7 @@ static int gdth_get_status(unchar *pIStatus,int irq) ...@@ -1261,7 +1256,7 @@ static int gdth_get_status(unchar *pIStatus,int irq)
*pIStatus = 0; *pIStatus = 0;
for (i=0; i<gdth_ctr_count; ++i) { for (i=0; i<gdth_ctr_count; ++i) {
ha = HADATA(gdth_ctr_tab[i]); ha = shost_priv(gdth_ctr_tab[i]);
if (ha->irq != (unchar)irq) /* check IRQ */ if (ha->irq != (unchar)irq) /* check IRQ */
continue; continue;
if (ha->type == GDT_EISA) if (ha->type == GDT_EISA)
...@@ -1285,14 +1280,12 @@ static int gdth_get_status(unchar *pIStatus,int irq) ...@@ -1285,14 +1280,12 @@ static int gdth_get_status(unchar *pIStatus,int irq)
} }
static int gdth_test_busy(int hanum) static int gdth_test_busy(gdth_ha_str *ha)
{ {
register gdth_ha_str *ha;
register int gdtsema0 = 0; register int gdtsema0 = 0;
TRACE(("gdth_test_busy() hanum %d\n",hanum)); TRACE(("gdth_test_busy() hanum %d\n", ha->hanum));
ha = HADATA(gdth_ctr_tab[hanum]);
if (ha->type == GDT_EISA) if (ha->type == GDT_EISA)
gdtsema0 = (int)inb(ha->bmic + SEMA0REG); gdtsema0 = (int)inb(ha->bmic + SEMA0REG);
else if (ha->type == GDT_ISA) else if (ha->type == GDT_ISA)
...@@ -1309,14 +1302,12 @@ static int gdth_test_busy(int hanum) ...@@ -1309,14 +1302,12 @@ static int gdth_test_busy(int hanum)
} }
static int gdth_get_cmd_index(int hanum) static int gdth_get_cmd_index(gdth_ha_str *ha)
{ {
register gdth_ha_str *ha;
int i; int i;
TRACE(("gdth_get_cmd_index() hanum %d\n",hanum)); TRACE(("gdth_get_cmd_index() hanum %d\n", ha->hanum));
ha = HADATA(gdth_ctr_tab[hanum]);
for (i=0; i<GDTH_MAXCMDS; ++i) { for (i=0; i<GDTH_MAXCMDS; ++i) {
if (ha->cmd_tab[i].cmnd == UNUSED_CMND) { if (ha->cmd_tab[i].cmnd == UNUSED_CMND) {
ha->cmd_tab[i].cmnd = ha->pccb->RequestBuffer; ha->cmd_tab[i].cmnd = ha->pccb->RequestBuffer;
...@@ -1329,13 +1320,10 @@ static int gdth_get_cmd_index(int hanum) ...@@ -1329,13 +1320,10 @@ static int gdth_get_cmd_index(int hanum)
} }
static void gdth_set_sema0(int hanum) static void gdth_set_sema0(gdth_ha_str *ha)
{ {
register gdth_ha_str *ha; TRACE(("gdth_set_sema0() hanum %d\n", ha->hanum));
TRACE(("gdth_set_sema0() hanum %d\n",hanum));
ha = HADATA(gdth_ctr_tab[hanum]);
if (ha->type == GDT_EISA) { if (ha->type == GDT_EISA) {
outb(1, ha->bmic + SEMA0REG); outb(1, ha->bmic + SEMA0REG);
} else if (ha->type == GDT_ISA) { } else if (ha->type == GDT_ISA) {
...@@ -1350,9 +1338,8 @@ static void gdth_set_sema0(int hanum) ...@@ -1350,9 +1338,8 @@ static void gdth_set_sema0(int hanum)
} }
static void gdth_copy_command(int hanum) static void gdth_copy_command(gdth_ha_str *ha)
{ {
register gdth_ha_str *ha;
register gdth_cmd_str *cmd_ptr; register gdth_cmd_str *cmd_ptr;
register gdt6m_dpram_str __iomem *dp6m_ptr; register gdt6m_dpram_str __iomem *dp6m_ptr;
register gdt6c_dpram_str __iomem *dp6c_ptr; register gdt6c_dpram_str __iomem *dp6c_ptr;
...@@ -1360,9 +1347,8 @@ static void gdth_copy_command(int hanum) ...@@ -1360,9 +1347,8 @@ static void gdth_copy_command(int hanum)
gdt2_dpram_str __iomem *dp2_ptr; gdt2_dpram_str __iomem *dp2_ptr;
ushort cp_count,dp_offset,cmd_no; ushort cp_count,dp_offset,cmd_no;
TRACE(("gdth_copy_command() hanum %d\n",hanum)); TRACE(("gdth_copy_command() hanum %d\n", ha->hanum));
ha = HADATA(gdth_ctr_tab[hanum]);
cp_count = ha->cmd_len; cp_count = ha->cmd_len;
dp_offset= ha->cmd_offs_dpmem; dp_offset= ha->cmd_offs_dpmem;
cmd_no = ha->cmd_cnt; cmd_no = ha->cmd_cnt;
...@@ -1411,12 +1397,9 @@ static void gdth_copy_command(int hanum) ...@@ -1411,12 +1397,9 @@ static void gdth_copy_command(int hanum)
} }
static void gdth_release_event(int hanum) static void gdth_release_event(gdth_ha_str *ha)
{ {
register gdth_ha_str *ha; TRACE(("gdth_release_event() hanum %d\n", ha->hanum));
TRACE(("gdth_release_event() hanum %d\n",hanum));
ha = HADATA(gdth_ctr_tab[hanum]);
#ifdef GDTH_STATISTICS #ifdef GDTH_STATISTICS
{ {
...@@ -1450,46 +1433,41 @@ static void gdth_release_event(int hanum) ...@@ -1450,46 +1433,41 @@ static void gdth_release_event(int hanum)
} }
} }
static int gdth_wait(gdth_ha_str *ha, int index, ulong32 time)
static int gdth_wait(int hanum,int index,ulong32 time)
{ {
gdth_ha_str *ha;
int answer_found = FALSE; int answer_found = FALSE;
TRACE(("gdth_wait() hanum %d index %d time %d\n",hanum,index,time)); TRACE(("gdth_wait() hanum %d index %d time %d\n", ha->hanum, index, time));
ha = HADATA(gdth_ctr_tab[hanum]);
if (index == 0) if (index == 0)
return 1; /* no wait required */ return 1; /* no wait required */
gdth_from_wait = TRUE; gdth_from_wait = TRUE;
do { do {
gdth_interrupt((int)ha->irq,ha); gdth_interrupt((int)ha->irq,ha);
if (wait_hanum==hanum && wait_index==index) { if (wait_hanum==ha->hanum && wait_index==index) {
answer_found = TRUE; answer_found = TRUE;
break; break;
} }
gdth_delay(1); gdth_delay(1);
} while (--time); } while (--time);
gdth_from_wait = FALSE; gdth_from_wait = FALSE;
while (gdth_test_busy(hanum)) while (gdth_test_busy(ha))
gdth_delay(0); gdth_delay(0);
return (answer_found); return (answer_found);
} }
static int gdth_internal_cmd(int hanum,unchar service,ushort opcode,ulong32 p1, static int gdth_internal_cmd(gdth_ha_str *ha, unchar service, ushort opcode,
ulong64 p2,ulong64 p3) ulong32 p1, ulong64 p2, ulong64 p3)
{ {
register gdth_ha_str *ha;
register gdth_cmd_str *cmd_ptr; register gdth_cmd_str *cmd_ptr;
int retries,index; int retries,index;
TRACE2(("gdth_internal_cmd() service %d opcode %d\n",service,opcode)); TRACE2(("gdth_internal_cmd() service %d opcode %d\n",service,opcode));
ha = HADATA(gdth_ctr_tab[hanum]);
cmd_ptr = ha->pccb; cmd_ptr = ha->pccb;
memset((char*)cmd_ptr,0,sizeof(gdth_cmd_str)); memset((char*)cmd_ptr,0,sizeof(gdth_cmd_str));
...@@ -1497,11 +1475,11 @@ static int gdth_internal_cmd(int hanum,unchar service,ushort opcode,ulong32 p1, ...@@ -1497,11 +1475,11 @@ static int gdth_internal_cmd(int hanum,unchar service,ushort opcode,ulong32 p1,
for (retries = INIT_RETRIES;;) { for (retries = INIT_RETRIES;;) {
cmd_ptr->Service = service; cmd_ptr->Service = service;
cmd_ptr->RequestBuffer = INTERNAL_CMND; cmd_ptr->RequestBuffer = INTERNAL_CMND;
if (!(index=gdth_get_cmd_index(hanum))) { if (!(index=gdth_get_cmd_index(ha))) {
TRACE(("GDT: No free command index found\n")); TRACE(("GDT: No free command index found\n"));
return 0; return 0;
} }
gdth_set_sema0(hanum); gdth_set_sema0(ha);
cmd_ptr->OpCode = opcode; cmd_ptr->OpCode = opcode;
cmd_ptr->BoardNode = LOCALBOARD; cmd_ptr->BoardNode = LOCALBOARD;
if (service == CACHESERVICE) { if (service == CACHESERVICE) {
...@@ -1541,10 +1519,10 @@ static int gdth_internal_cmd(int hanum,unchar service,ushort opcode,ulong32 p1, ...@@ -1541,10 +1519,10 @@ static int gdth_internal_cmd(int hanum,unchar service,ushort opcode,ulong32 p1,
ha->cmd_len = sizeof(gdth_cmd_str); ha->cmd_len = sizeof(gdth_cmd_str);
ha->cmd_offs_dpmem = 0; ha->cmd_offs_dpmem = 0;
ha->cmd_cnt = 0; ha->cmd_cnt = 0;
gdth_copy_command(hanum); gdth_copy_command(ha);
gdth_release_event(hanum); gdth_release_event(ha);
gdth_delay(20); gdth_delay(20);
if (!gdth_wait(hanum,index,INIT_TIMEOUT)) { if (!gdth_wait(ha, index, INIT_TIMEOUT)) {
printk("GDT: Initialization error (timeout service %d)\n",service); printk("GDT: Initialization error (timeout service %d)\n",service);
return 0; return 0;
} }
...@@ -1559,9 +1537,8 @@ static int gdth_internal_cmd(int hanum,unchar service,ushort opcode,ulong32 p1, ...@@ -1559,9 +1537,8 @@ static int gdth_internal_cmd(int hanum,unchar service,ushort opcode,ulong32 p1,
/* search for devices */ /* search for devices */
static int __init gdth_search_drives(int hanum) static int __init gdth_search_drives(gdth_ha_str *ha)
{ {
register gdth_ha_str *ha;
ushort cdev_cnt, i; ushort cdev_cnt, i;
int ok; int ok;
ulong32 bus_no, drv_cnt, drv_no, j; ulong32 bus_no, drv_cnt, drv_no, j;
...@@ -1581,22 +1558,21 @@ static int __init gdth_search_drives(int hanum) ...@@ -1581,22 +1558,21 @@ static int __init gdth_search_drives(int hanum)
ulong flags; ulong flags;
#endif #endif
TRACE(("gdth_search_drives() hanum %d\n",hanum)); TRACE(("gdth_search_drives() hanum %d\n", ha->hanum));
ha = HADATA(gdth_ctr_tab[hanum]);
ok = 0; ok = 0;
/* initialize controller services, at first: screen service */ /* initialize controller services, at first: screen service */
ha->screen_feat = 0; ha->screen_feat = 0;
if (!force_dma32) { if (!force_dma32) {
ok = gdth_internal_cmd(hanum,SCREENSERVICE,GDT_X_INIT_SCR,0,0,0); ok = gdth_internal_cmd(ha, SCREENSERVICE, GDT_X_INIT_SCR, 0, 0, 0);
if (ok) if (ok)
ha->screen_feat = GDT_64BIT; ha->screen_feat = GDT_64BIT;
} }
if (force_dma32 || (!ok && ha->status == (ushort)S_NOFUNC)) if (force_dma32 || (!ok && ha->status == (ushort)S_NOFUNC))
ok = gdth_internal_cmd(hanum,SCREENSERVICE,GDT_INIT,0,0,0); ok = gdth_internal_cmd(ha, SCREENSERVICE, GDT_INIT, 0, 0, 0);
if (!ok) { if (!ok) {
printk("GDT-HA %d: Initialization error screen service (code %d)\n", printk("GDT-HA %d: Initialization error screen service (code %d)\n",
hanum, ha->status); ha->hanum, ha->status);
return 0; return 0;
} }
TRACE2(("gdth_search_drives(): SCREENSERVICE initialized\n")); TRACE2(("gdth_search_drives(): SCREENSERVICE initialized\n"));
...@@ -1620,25 +1596,26 @@ static int __init gdth_search_drives(int hanum) ...@@ -1620,25 +1596,26 @@ static int __init gdth_search_drives(int hanum)
TRACE2(("gdth_search_drives(): RTC: %x/%x/%x\n",*(ulong32 *)&rtc[0], TRACE2(("gdth_search_drives(): RTC: %x/%x/%x\n",*(ulong32 *)&rtc[0],
*(ulong32 *)&rtc[4], *(ulong32 *)&rtc[8])); *(ulong32 *)&rtc[4], *(ulong32 *)&rtc[8]));
/* 3. send to controller firmware */ /* 3. send to controller firmware */
gdth_internal_cmd(hanum,SCREENSERVICE,GDT_REALTIME, *(ulong32 *)&rtc[0], gdth_internal_cmd(ha, SCREENSERVICE, GDT_REALTIME, *(ulong32 *)&rtc[0],
*(ulong32 *)&rtc[4], *(ulong32 *)&rtc[8]); *(ulong32 *)&rtc[4], *(ulong32 *)&rtc[8]);
#endif #endif
/* unfreeze all IOs */ /* unfreeze all IOs */
gdth_internal_cmd(hanum,CACHESERVICE,GDT_UNFREEZE_IO,0,0,0); gdth_internal_cmd(ha, CACHESERVICE, GDT_UNFREEZE_IO, 0, 0, 0);
/* initialize cache service */ /* initialize cache service */
ha->cache_feat = 0; ha->cache_feat = 0;
if (!force_dma32) { if (!force_dma32) {
ok = gdth_internal_cmd(hanum,CACHESERVICE,GDT_X_INIT_HOST,LINUX_OS,0,0); ok = gdth_internal_cmd(ha, CACHESERVICE, GDT_X_INIT_HOST, LINUX_OS,
0, 0);
if (ok) if (ok)
ha->cache_feat = GDT_64BIT; ha->cache_feat = GDT_64BIT;
} }
if (force_dma32 || (!ok && ha->status == (ushort)S_NOFUNC)) if (force_dma32 || (!ok && ha->status == (ushort)S_NOFUNC))
ok = gdth_internal_cmd(hanum,CACHESERVICE,GDT_INIT,LINUX_OS,0,0); ok = gdth_internal_cmd(ha, CACHESERVICE, GDT_INIT, LINUX_OS, 0, 0);
if (!ok) { if (!ok) {
printk("GDT-HA %d: Initialization error cache service (code %d)\n", printk("GDT-HA %d: Initialization error cache service (code %d)\n",
hanum, ha->status); ha->hanum, ha->status);
return 0; return 0;
} }
TRACE2(("gdth_search_drives(): CACHESERVICE initialized\n")); TRACE2(("gdth_search_drives(): CACHESERVICE initialized\n"));
...@@ -1667,9 +1644,9 @@ static int __init gdth_search_drives(int hanum) ...@@ -1667,9 +1644,9 @@ static int __init gdth_search_drives(int hanum)
pmod->cmd_buff_size = 0; pmod->cmd_buff_size = 0;
pmod->reserved1 = 0; pmod->reserved1 = 0;
pmod->reserved2 = 0; pmod->reserved2 = 0;
if (gdth_internal_cmd(hanum,CACHESERVICE,GDT_IOCTL,SET_PERF_MODES, if (gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL, SET_PERF_MODES,
INVALID_CHANNEL,sizeof(gdth_perf_modes))) { INVALID_CHANNEL,sizeof(gdth_perf_modes))) {
printk("GDT-HA %d: Interrupt coalescing activated\n", hanum); printk("GDT-HA %d: Interrupt coalescing activated\n", ha->hanum);
} }
} }
#endif #endif
...@@ -1681,7 +1658,7 @@ static int __init gdth_search_drives(int hanum) ...@@ -1681,7 +1658,7 @@ static int __init gdth_search_drives(int hanum)
iocr->hdr.first_chan = 0; iocr->hdr.first_chan = 0;
iocr->hdr.last_chan = MAXBUS-1; iocr->hdr.last_chan = MAXBUS-1;
iocr->hdr.list_offset = GDTOFFSOF(gdth_raw_iochan_str, list[0]); iocr->hdr.list_offset = GDTOFFSOF(gdth_raw_iochan_str, list[0]);
if (gdth_internal_cmd(hanum,CACHESERVICE,GDT_IOCTL,IOCHAN_RAW_DESC, if (gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL, IOCHAN_RAW_DESC,
INVALID_CHANNEL,sizeof(gdth_raw_iochan_str))) { INVALID_CHANNEL,sizeof(gdth_raw_iochan_str))) {
TRACE2(("IOCHAN_RAW_DESC supported!\n")); TRACE2(("IOCHAN_RAW_DESC supported!\n"));
ha->bus_cnt = iocr->hdr.chan_count; ha->bus_cnt = iocr->hdr.chan_count;
...@@ -1696,13 +1673,13 @@ static int __init gdth_search_drives(int hanum) ...@@ -1696,13 +1673,13 @@ static int __init gdth_search_drives(int hanum)
chn = (gdth_getch_str *)ha->pscratch; chn = (gdth_getch_str *)ha->pscratch;
for (bus_no = 0; bus_no < MAXBUS; ++bus_no) { for (bus_no = 0; bus_no < MAXBUS; ++bus_no) {
chn->channel_no = bus_no; chn->channel_no = bus_no;
if (!gdth_internal_cmd(hanum,CACHESERVICE,GDT_IOCTL, if (!gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL,
SCSI_CHAN_CNT | L_CTRL_PATTERN, SCSI_CHAN_CNT | L_CTRL_PATTERN,
IO_CHANNEL | INVALID_CHANNEL, IO_CHANNEL | INVALID_CHANNEL,
sizeof(gdth_getch_str))) { sizeof(gdth_getch_str))) {
if (bus_no == 0) { if (bus_no == 0) {
printk("GDT-HA %d: Error detecting channel count (0x%x)\n", printk("GDT-HA %d: Error detecting channel count (0x%x)\n",
hanum, ha->status); ha->hanum, ha->status);
return 0; return 0;
} }
break; break;
...@@ -1717,10 +1694,10 @@ static int __init gdth_search_drives(int hanum) ...@@ -1717,10 +1694,10 @@ static int __init gdth_search_drives(int hanum)
TRACE2(("gdth_search_drives() %d channels\n",ha->bus_cnt)); TRACE2(("gdth_search_drives() %d channels\n",ha->bus_cnt));
/* read cache configuration */ /* read cache configuration */
if (!gdth_internal_cmd(hanum,CACHESERVICE,GDT_IOCTL,CACHE_INFO, if (!gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL, CACHE_INFO,
INVALID_CHANNEL,sizeof(gdth_cinfo_str))) { INVALID_CHANNEL,sizeof(gdth_cinfo_str))) {
printk("GDT-HA %d: Initialization error cache service (code %d)\n", printk("GDT-HA %d: Initialization error cache service (code %d)\n",
hanum, ha->status); ha->hanum, ha->status);
return 0; return 0;
} }
ha->cpar = ((gdth_cinfo_str *)ha->pscratch)->cpar; ha->cpar = ((gdth_cinfo_str *)ha->pscratch)->cpar;
...@@ -1730,11 +1707,11 @@ static int __init gdth_search_drives(int hanum) ...@@ -1730,11 +1707,11 @@ static int __init gdth_search_drives(int hanum)
/* read board info and features */ /* read board info and features */
ha->more_proc = FALSE; ha->more_proc = FALSE;
if (gdth_internal_cmd(hanum,CACHESERVICE,GDT_IOCTL,BOARD_INFO, if (gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL, BOARD_INFO,
INVALID_CHANNEL,sizeof(gdth_binfo_str))) { INVALID_CHANNEL,sizeof(gdth_binfo_str))) {
memcpy(&ha->binfo, (gdth_binfo_str *)ha->pscratch, memcpy(&ha->binfo, (gdth_binfo_str *)ha->pscratch,
sizeof(gdth_binfo_str)); sizeof(gdth_binfo_str));
if (gdth_internal_cmd(hanum,CACHESERVICE,GDT_IOCTL,BOARD_FEATURES, if (gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL, BOARD_FEATURES,
INVALID_CHANNEL,sizeof(gdth_bfeat_str))) { INVALID_CHANNEL,sizeof(gdth_bfeat_str))) {
TRACE2(("BOARD_INFO/BOARD_FEATURES supported\n")); TRACE2(("BOARD_INFO/BOARD_FEATURES supported\n"));
ha->bfeat = *(gdth_bfeat_str *)ha->pscratch; ha->bfeat = *(gdth_bfeat_str *)ha->pscratch;
...@@ -1742,7 +1719,7 @@ static int __init gdth_search_drives(int hanum) ...@@ -1742,7 +1719,7 @@ static int __init gdth_search_drives(int hanum)
} }
} else { } else {
TRACE2(("BOARD_INFO requires firmware >= 1.10/2.08\n")); TRACE2(("BOARD_INFO requires firmware >= 1.10/2.08\n"));
strcpy(ha->binfo.type_string, gdth_ctr_name(hanum)); strcpy(ha->binfo.type_string, gdth_ctr_name(ha));
} }
TRACE2(("Controller name: %s\n",ha->binfo.type_string)); TRACE2(("Controller name: %s\n",ha->binfo.type_string));
...@@ -1755,7 +1732,7 @@ static int __init gdth_search_drives(int hanum) ...@@ -1755,7 +1732,7 @@ static int __init gdth_search_drives(int hanum)
ioc->hdr.first_chan = 0; ioc->hdr.first_chan = 0;
ioc->hdr.last_chan = MAXBUS-1; ioc->hdr.last_chan = MAXBUS-1;
ioc->hdr.list_offset = GDTOFFSOF(gdth_iochan_str, list[0]); ioc->hdr.list_offset = GDTOFFSOF(gdth_iochan_str, list[0]);
if (gdth_internal_cmd(hanum,CACHESERVICE,GDT_IOCTL,IOCHAN_DESC, if (gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL, IOCHAN_DESC,
INVALID_CHANNEL,sizeof(gdth_iochan_str))) { INVALID_CHANNEL,sizeof(gdth_iochan_str))) {
for (bus_no = 0; bus_no < ha->bus_cnt; ++bus_no) { for (bus_no = 0; bus_no < ha->bus_cnt; ++bus_no) {
ha->raw[bus_no].address = ioc->list[bus_no].address; ha->raw[bus_no].address = ioc->list[bus_no].address;
...@@ -1770,7 +1747,7 @@ static int __init gdth_search_drives(int hanum) ...@@ -1770,7 +1747,7 @@ static int __init gdth_search_drives(int hanum)
for (bus_no = 0; bus_no < ha->bus_cnt; ++bus_no) { for (bus_no = 0; bus_no < ha->bus_cnt; ++bus_no) {
chn = (gdth_getch_str *)ha->pscratch; chn = (gdth_getch_str *)ha->pscratch;
chn->channel_no = ha->raw[bus_no].local_no; chn->channel_no = ha->raw[bus_no].local_no;
if (gdth_internal_cmd(hanum,CACHESERVICE,GDT_IOCTL, if (gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL,
SCSI_CHAN_CNT | L_CTRL_PATTERN, SCSI_CHAN_CNT | L_CTRL_PATTERN,
ha->raw[bus_no].address | INVALID_CHANNEL, ha->raw[bus_no].address | INVALID_CHANNEL,
sizeof(gdth_getch_str))) { sizeof(gdth_getch_str))) {
...@@ -1782,7 +1759,7 @@ static int __init gdth_search_drives(int hanum) ...@@ -1782,7 +1759,7 @@ static int __init gdth_search_drives(int hanum)
drl = (gdth_drlist_str *)ha->pscratch; drl = (gdth_drlist_str *)ha->pscratch;
drl->sc_no = ha->raw[bus_no].local_no; drl->sc_no = ha->raw[bus_no].local_no;
drl->sc_cnt = ha->raw[bus_no].pdev_cnt; drl->sc_cnt = ha->raw[bus_no].pdev_cnt;
if (gdth_internal_cmd(hanum,CACHESERVICE,GDT_IOCTL, if (gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL,
SCSI_DR_LIST | L_CTRL_PATTERN, SCSI_DR_LIST | L_CTRL_PATTERN,
ha->raw[bus_no].address | INVALID_CHANNEL, ha->raw[bus_no].address | INVALID_CHANNEL,
sizeof(gdth_drlist_str))) { sizeof(gdth_drlist_str))) {
...@@ -1795,10 +1772,10 @@ static int __init gdth_search_drives(int hanum) ...@@ -1795,10 +1772,10 @@ static int __init gdth_search_drives(int hanum)
} }
/* logical drives */ /* logical drives */
if (gdth_internal_cmd(hanum,CACHESERVICE,GDT_IOCTL,CACHE_DRV_CNT, if (gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL, CACHE_DRV_CNT,
INVALID_CHANNEL,sizeof(ulong32))) { INVALID_CHANNEL,sizeof(ulong32))) {
drv_cnt = *(ulong32 *)ha->pscratch; drv_cnt = *(ulong32 *)ha->pscratch;
if (gdth_internal_cmd(hanum,CACHESERVICE,GDT_IOCTL,CACHE_DRV_LIST, if (gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL, CACHE_DRV_LIST,
INVALID_CHANNEL,drv_cnt * sizeof(ulong32))) { INVALID_CHANNEL,drv_cnt * sizeof(ulong32))) {
for (j = 0; j < drv_cnt; ++j) { for (j = 0; j < drv_cnt; ++j) {
drv_no = ((ulong32 *)ha->pscratch)[j]; drv_no = ((ulong32 *)ha->pscratch)[j];
...@@ -1812,7 +1789,7 @@ static int __init gdth_search_drives(int hanum) ...@@ -1812,7 +1789,7 @@ static int __init gdth_search_drives(int hanum)
alst->entries_avail = MAX_LDRIVES; alst->entries_avail = MAX_LDRIVES;
alst->first_entry = 0; alst->first_entry = 0;
alst->list_offset = GDTOFFSOF(gdth_arcdl_str, list[0]); alst->list_offset = GDTOFFSOF(gdth_arcdl_str, list[0]);
if (gdth_internal_cmd(hanum,CACHESERVICE,GDT_IOCTL, if (gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL,
ARRAY_DRV_LIST2 | LA_CTRL_PATTERN, ARRAY_DRV_LIST2 | LA_CTRL_PATTERN,
INVALID_CHANNEL, sizeof(gdth_arcdl_str) + INVALID_CHANNEL, sizeof(gdth_arcdl_str) +
(alst->entries_avail-1) * sizeof(gdth_alist_str))) { (alst->entries_avail-1) * sizeof(gdth_alist_str))) {
...@@ -1823,7 +1800,7 @@ static int __init gdth_search_drives(int hanum) ...@@ -1823,7 +1800,7 @@ static int __init gdth_search_drives(int hanum)
ha->hdr[j].is_hotfix = alst->list[j].is_hotfix; ha->hdr[j].is_hotfix = alst->list[j].is_hotfix;
ha->hdr[j].master_no = alst->list[j].cd_handle; ha->hdr[j].master_no = alst->list[j].cd_handle;
} }
} else if (gdth_internal_cmd(hanum,CACHESERVICE,GDT_IOCTL, } else if (gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL,
ARRAY_DRV_LIST | LA_CTRL_PATTERN, ARRAY_DRV_LIST | LA_CTRL_PATTERN,
0, 35 * sizeof(gdth_alist_str))) { 0, 35 * sizeof(gdth_alist_str))) {
for (j = 0; j < 35; ++j) { for (j = 0; j < 35; ++j) {
...@@ -1841,24 +1818,24 @@ static int __init gdth_search_drives(int hanum) ...@@ -1841,24 +1818,24 @@ static int __init gdth_search_drives(int hanum)
/* initialize raw service */ /* initialize raw service */
ha->raw_feat = 0; ha->raw_feat = 0;
if (!force_dma32) { if (!force_dma32) {
ok = gdth_internal_cmd(hanum,SCSIRAWSERVICE,GDT_X_INIT_RAW,0,0,0); ok = gdth_internal_cmd(ha, SCSIRAWSERVICE, GDT_X_INIT_RAW, 0, 0, 0);
if (ok) if (ok)
ha->raw_feat = GDT_64BIT; ha->raw_feat = GDT_64BIT;
} }
if (force_dma32 || (!ok && ha->status == (ushort)S_NOFUNC)) if (force_dma32 || (!ok && ha->status == (ushort)S_NOFUNC))
ok = gdth_internal_cmd(hanum,SCSIRAWSERVICE,GDT_INIT,0,0,0); ok = gdth_internal_cmd(ha, SCSIRAWSERVICE, GDT_INIT, 0, 0, 0);
if (!ok) { if (!ok) {
printk("GDT-HA %d: Initialization error raw service (code %d)\n", printk("GDT-HA %d: Initialization error raw service (code %d)\n",
hanum, ha->status); ha->hanum, ha->status);
return 0; return 0;
} }
TRACE2(("gdth_search_drives(): RAWSERVICE initialized\n")); TRACE2(("gdth_search_drives(): RAWSERVICE initialized\n"));
/* set/get features raw service (scatter/gather) */ /* set/get features raw service (scatter/gather) */
if (gdth_internal_cmd(hanum,SCSIRAWSERVICE,GDT_SET_FEAT,SCATTER_GATHER, if (gdth_internal_cmd(ha, SCSIRAWSERVICE, GDT_SET_FEAT, SCATTER_GATHER,
0,0)) { 0, 0)) {
TRACE2(("gdth_search_drives(): set features RAWSERVICE OK\n")); TRACE2(("gdth_search_drives(): set features RAWSERVICE OK\n"));
if (gdth_internal_cmd(hanum,SCSIRAWSERVICE,GDT_GET_FEAT,0,0,0)) { if (gdth_internal_cmd(ha, SCSIRAWSERVICE, GDT_GET_FEAT, 0, 0, 0)) {
TRACE2(("gdth_search_dr(): get feat RAWSERVICE %d\n", TRACE2(("gdth_search_dr(): get feat RAWSERVICE %d\n",
ha->info)); ha->info));
ha->raw_feat |= (ushort)ha->info; ha->raw_feat |= (ushort)ha->info;
...@@ -1866,10 +1843,10 @@ static int __init gdth_search_drives(int hanum) ...@@ -1866,10 +1843,10 @@ static int __init gdth_search_drives(int hanum)
} }
/* set/get features cache service (equal to raw service) */ /* set/get features cache service (equal to raw service) */
if (gdth_internal_cmd(hanum,CACHESERVICE,GDT_SET_FEAT,0, if (gdth_internal_cmd(ha, CACHESERVICE, GDT_SET_FEAT, 0,
SCATTER_GATHER,0)) { SCATTER_GATHER,0)) {
TRACE2(("gdth_search_drives(): set features CACHESERVICE OK\n")); TRACE2(("gdth_search_drives(): set features CACHESERVICE OK\n"));
if (gdth_internal_cmd(hanum,CACHESERVICE,GDT_GET_FEAT,0,0,0)) { if (gdth_internal_cmd(ha, CACHESERVICE, GDT_GET_FEAT, 0, 0, 0)) {
TRACE2(("gdth_search_dr(): get feat CACHESERV. %d\n", TRACE2(("gdth_search_dr(): get feat CACHESERV. %d\n",
ha->info)); ha->info));
ha->cache_feat |= (ushort)ha->info; ha->cache_feat |= (ushort)ha->info;
...@@ -1878,22 +1855,22 @@ static int __init gdth_search_drives(int hanum) ...@@ -1878,22 +1855,22 @@ static int __init gdth_search_drives(int hanum)
/* reserve drives for raw service */ /* reserve drives for raw service */
if (reserve_mode != 0) { if (reserve_mode != 0) {
gdth_internal_cmd(hanum,SCSIRAWSERVICE,GDT_RESERVE_ALL, gdth_internal_cmd(ha, SCSIRAWSERVICE, GDT_RESERVE_ALL,
reserve_mode == 1 ? 1 : 3, 0, 0); reserve_mode == 1 ? 1 : 3, 0, 0);
TRACE2(("gdth_search_drives(): RESERVE_ALL code %d\n", TRACE2(("gdth_search_drives(): RESERVE_ALL code %d\n",
ha->status)); ha->status));
} }
for (i = 0; i < MAX_RES_ARGS; i += 4) { for (i = 0; i < MAX_RES_ARGS; i += 4) {
if (reserve_list[i] == hanum && reserve_list[i+1] < ha->bus_cnt && if (reserve_list[i] == ha->hanum && reserve_list[i+1] < ha->bus_cnt &&
reserve_list[i+2] < ha->tid_cnt && reserve_list[i+3] < MAXLUN) { reserve_list[i+2] < ha->tid_cnt && reserve_list[i+3] < MAXLUN) {
TRACE2(("gdth_search_drives(): reserve ha %d bus %d id %d lun %d\n", TRACE2(("gdth_search_drives(): reserve ha %d bus %d id %d lun %d\n",
reserve_list[i], reserve_list[i+1], reserve_list[i], reserve_list[i+1],
reserve_list[i+2], reserve_list[i+3])); reserve_list[i+2], reserve_list[i+3]));
if (!gdth_internal_cmd(hanum,SCSIRAWSERVICE,GDT_RESERVE,0, if (!gdth_internal_cmd(ha, SCSIRAWSERVICE, GDT_RESERVE, 0,
reserve_list[i+1], reserve_list[i+2] | reserve_list[i+1], reserve_list[i+2] |
(reserve_list[i+3] << 8))) { (reserve_list[i+3] << 8))) {
printk("GDT-HA %d: Error raw service (RESERVE, code %d)\n", printk("GDT-HA %d: Error raw service (RESERVE, code %d)\n",
hanum, ha->status); ha->hanum, ha->status);
} }
} }
} }
...@@ -1902,12 +1879,12 @@ static int __init gdth_search_drives(int hanum) ...@@ -1902,12 +1879,12 @@ static int __init gdth_search_drives(int hanum)
oemstr = (gdth_oem_str_ioctl *)ha->pscratch; oemstr = (gdth_oem_str_ioctl *)ha->pscratch;
oemstr->params.ctl_version = 0x01; oemstr->params.ctl_version = 0x01;
oemstr->params.buffer_size = sizeof(oemstr->text); oemstr->params.buffer_size = sizeof(oemstr->text);
if (gdth_internal_cmd(hanum,CACHESERVICE,GDT_IOCTL, if (gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL,
CACHE_READ_OEM_STRING_RECORD,INVALID_CHANNEL, CACHE_READ_OEM_STRING_RECORD,INVALID_CHANNEL,
sizeof(gdth_oem_str_ioctl))) { sizeof(gdth_oem_str_ioctl))) {
TRACE2(("gdth_search_drives(): CACHE_READ_OEM_STRING_RECORD OK\n")); TRACE2(("gdth_search_drives(): CACHE_READ_OEM_STRING_RECORD OK\n"));
printk("GDT-HA %d: Vendor: %s Name: %s\n", printk("GDT-HA %d: Vendor: %s Name: %s\n",
hanum,oemstr->text.oem_company_name,ha->binfo.type_string); ha->hanum, oemstr->text.oem_company_name, ha->binfo.type_string);
/* Save the Host Drive inquiry data */ /* Save the Host Drive inquiry data */
strlcpy(ha->oem_name,oemstr->text.scsi_host_drive_inquiry_vendor_id, strlcpy(ha->oem_name,oemstr->text.scsi_host_drive_inquiry_vendor_id,
sizeof(ha->oem_name)); sizeof(ha->oem_name));
...@@ -1915,7 +1892,7 @@ static int __init gdth_search_drives(int hanum) ...@@ -1915,7 +1892,7 @@ static int __init gdth_search_drives(int hanum)
/* Old method, based on PCI ID */ /* Old method, based on PCI ID */
TRACE2(("gdth_search_drives(): CACHE_READ_OEM_STRING_RECORD failed\n")); TRACE2(("gdth_search_drives(): CACHE_READ_OEM_STRING_RECORD failed\n"));
printk("GDT-HA %d: Name: %s\n", printk("GDT-HA %d: Name: %s\n",
hanum,ha->binfo.type_string); ha->hanum, ha->binfo.type_string);
if (ha->oem_id == OEM_ID_INTEL) if (ha->oem_id == OEM_ID_INTEL)
strlcpy(ha->oem_name,"Intel ", sizeof(ha->oem_name)); strlcpy(ha->oem_name,"Intel ", sizeof(ha->oem_name));
else else
...@@ -1924,24 +1901,22 @@ static int __init gdth_search_drives(int hanum) ...@@ -1924,24 +1901,22 @@ static int __init gdth_search_drives(int hanum)
/* scanning for host drives */ /* scanning for host drives */
for (i = 0; i < cdev_cnt; ++i) for (i = 0; i < cdev_cnt; ++i)
gdth_analyse_hdrive(hanum,i); gdth_analyse_hdrive(ha, i);
TRACE(("gdth_search_drives() OK\n")); TRACE(("gdth_search_drives() OK\n"));
return 1; return 1;
} }
static int gdth_analyse_hdrive(int hanum,ushort hdrive) static int gdth_analyse_hdrive(gdth_ha_str *ha, ushort hdrive)
{ {
register gdth_ha_str *ha;
ulong32 drv_cyls; ulong32 drv_cyls;
int drv_hds, drv_secs; int drv_hds, drv_secs;
TRACE(("gdth_analyse_hdrive() hanum %d drive %d\n",hanum,hdrive)); TRACE(("gdth_analyse_hdrive() hanum %d drive %d\n", ha->hanum, hdrive));
if (hdrive >= MAX_HDRIVES) if (hdrive >= MAX_HDRIVES)
return 0; return 0;
ha = HADATA(gdth_ctr_tab[hanum]);
if (!gdth_internal_cmd(hanum,CACHESERVICE,GDT_INFO,hdrive,0,0)) if (!gdth_internal_cmd(ha, CACHESERVICE, GDT_INFO, hdrive, 0, 0))
return 0; return 0;
ha->hdr[hdrive].present = TRUE; ha->hdr[hdrive].present = TRUE;
ha->hdr[hdrive].size = ha->info; ha->hdr[hdrive].size = ha->info;
...@@ -1961,7 +1936,7 @@ static int gdth_analyse_hdrive(int hanum,ushort hdrive) ...@@ -1961,7 +1936,7 @@ static int gdth_analyse_hdrive(int hanum,ushort hdrive)
ha->hdr[hdrive].size = drv_cyls * drv_hds * drv_secs; ha->hdr[hdrive].size = drv_cyls * drv_hds * drv_secs;
if (ha->cache_feat & GDT_64BIT) { if (ha->cache_feat & GDT_64BIT) {
if (gdth_internal_cmd(hanum,CACHESERVICE,GDT_X_INFO,hdrive,0,0) if (gdth_internal_cmd(ha, CACHESERVICE, GDT_X_INFO, hdrive, 0, 0)
&& ha->info2 != 0) { && ha->info2 != 0) {
ha->hdr[hdrive].size = ((ulong64)ha->info2 << 32) | ha->info; ha->hdr[hdrive].size = ((ulong64)ha->info2 << 32) | ha->info;
} }
...@@ -1970,14 +1945,14 @@ static int gdth_analyse_hdrive(int hanum,ushort hdrive) ...@@ -1970,14 +1945,14 @@ static int gdth_analyse_hdrive(int hanum,ushort hdrive)
hdrive,ha->hdr[hdrive].size,drv_hds,drv_secs)); hdrive,ha->hdr[hdrive].size,drv_hds,drv_secs));
/* get informations about device */ /* get informations about device */
if (gdth_internal_cmd(hanum,CACHESERVICE,GDT_DEVTYPE,hdrive,0,0)) { if (gdth_internal_cmd(ha, CACHESERVICE, GDT_DEVTYPE, hdrive, 0, 0)) {
TRACE2(("gdth_search_dr() cache drive %d devtype %d\n", TRACE2(("gdth_search_dr() cache drive %d devtype %d\n",
hdrive,ha->info)); hdrive,ha->info));
ha->hdr[hdrive].devtype = (ushort)ha->info; ha->hdr[hdrive].devtype = (ushort)ha->info;
} }
/* cluster info */ /* cluster info */
if (gdth_internal_cmd(hanum,CACHESERVICE,GDT_CLUST_INFO,hdrive,0,0)) { if (gdth_internal_cmd(ha, CACHESERVICE, GDT_CLUST_INFO, hdrive, 0, 0)) {
TRACE2(("gdth_search_dr() cache drive %d cluster info %d\n", TRACE2(("gdth_search_dr() cache drive %d cluster info %d\n",
hdrive,ha->info)); hdrive,ha->info));
if (!shared_access) if (!shared_access)
...@@ -1985,7 +1960,7 @@ static int gdth_analyse_hdrive(int hanum,ushort hdrive) ...@@ -1985,7 +1960,7 @@ static int gdth_analyse_hdrive(int hanum,ushort hdrive)
} }
/* R/W attributes */ /* R/W attributes */
if (gdth_internal_cmd(hanum,CACHESERVICE,GDT_RW_ATTRIBS,hdrive,0,0)) { if (gdth_internal_cmd(ha, CACHESERVICE, GDT_RW_ATTRIBS, hdrive, 0, 0)) {
TRACE2(("gdth_search_dr() cache drive %d r/w attrib. %d\n", TRACE2(("gdth_search_dr() cache drive %d r/w attrib. %d\n",
hdrive,ha->info)); hdrive,ha->info));
ha->hdr[hdrive].rw_attribs = (unchar)ha->info; ha->hdr[hdrive].rw_attribs = (unchar)ha->info;
...@@ -1997,16 +1972,14 @@ static int gdth_analyse_hdrive(int hanum,ushort hdrive) ...@@ -1997,16 +1972,14 @@ static int gdth_analyse_hdrive(int hanum,ushort hdrive)
/* command queueing/sending functions */ /* command queueing/sending functions */
static void gdth_putq(int hanum,Scsi_Cmnd *scp,unchar priority) static void gdth_putq(gdth_ha_str *ha, Scsi_Cmnd *scp, unchar priority)
{ {
register gdth_ha_str *ha;
register Scsi_Cmnd *pscp; register Scsi_Cmnd *pscp;
register Scsi_Cmnd *nscp; register Scsi_Cmnd *nscp;
ulong flags; ulong flags;
unchar b, t; unchar b, t;
TRACE(("gdth_putq() priority %d\n",priority)); TRACE(("gdth_putq() priority %d\n",priority));
ha = HADATA(gdth_ctr_tab[hanum]);
spin_lock_irqsave(&ha->smp_lock, flags); spin_lock_irqsave(&ha->smp_lock, flags);
if (!IS_GDTH_INTERNAL_CMD(scp)) { if (!IS_GDTH_INTERNAL_CMD(scp)) {
...@@ -2017,7 +1990,7 @@ static void gdth_putq(int hanum,Scsi_Cmnd *scp,unchar priority) ...@@ -2017,7 +1990,7 @@ static void gdth_putq(int hanum,Scsi_Cmnd *scp,unchar priority)
if ((b != ha->virt_bus && ha->raw[BUS_L2P(ha,b)].lock) || if ((b != ha->virt_bus && ha->raw[BUS_L2P(ha,b)].lock) ||
(b==ha->virt_bus && t<MAX_HDRIVES && ha->hdr[t].lock)) { (b==ha->virt_bus && t<MAX_HDRIVES && ha->hdr[t].lock)) {
TRACE2(("gdth_putq(): locked IO ->update_timeout()\n")); TRACE2(("gdth_putq(): locked IO ->update_timeout()\n"));
scp->SCp.buffers_residual = gdth_update_timeout(hanum, scp, 0); scp->SCp.buffers_residual = gdth_update_timeout(scp, 0);
} }
} }
} }
...@@ -2049,9 +2022,8 @@ static void gdth_putq(int hanum,Scsi_Cmnd *scp,unchar priority) ...@@ -2049,9 +2022,8 @@ static void gdth_putq(int hanum,Scsi_Cmnd *scp,unchar priority)
#endif #endif
} }
static void gdth_next(int hanum) static void gdth_next(gdth_ha_str *ha)
{ {
register gdth_ha_str *ha;
register Scsi_Cmnd *pscp; register Scsi_Cmnd *pscp;
register Scsi_Cmnd *nscp; register Scsi_Cmnd *nscp;
unchar b, t, l, firsttime; unchar b, t, l, firsttime;
...@@ -2059,8 +2031,7 @@ static void gdth_next(int hanum) ...@@ -2059,8 +2031,7 @@ static void gdth_next(int hanum)
ulong flags = 0; ulong flags = 0;
int cmd_index; int cmd_index;
TRACE(("gdth_next() hanum %d\n",hanum)); TRACE(("gdth_next() hanum %d\n", ha->hanum));
ha = HADATA(gdth_ctr_tab[hanum]);
if (!gdth_polling) if (!gdth_polling)
spin_lock_irqsave(&ha->smp_lock, flags); spin_lock_irqsave(&ha->smp_lock, flags);
...@@ -2085,13 +2056,13 @@ static void gdth_next(int hanum) ...@@ -2085,13 +2056,13 @@ static void gdth_next(int hanum)
b = t = l = 0; b = t = l = 0;
if (firsttime) { if (firsttime) {
if (gdth_test_busy(hanum)) { /* controller busy ? */ if (gdth_test_busy(ha)) { /* controller busy ? */
TRACE(("gdth_next() controller %d busy !\n",hanum)); TRACE(("gdth_next() controller %d busy !\n", ha->hanum));
if (!gdth_polling) { if (!gdth_polling) {
spin_unlock_irqrestore(&ha->smp_lock, flags); spin_unlock_irqrestore(&ha->smp_lock, flags);
return; return;
} }
while (gdth_test_busy(hanum)) while (gdth_test_busy(ha))
gdth_delay(1); gdth_delay(1);
} }
firsttime = FALSE; firsttime = FALSE;
...@@ -2143,11 +2114,11 @@ static void gdth_next(int hanum) ...@@ -2143,11 +2114,11 @@ static void gdth_next(int hanum)
if (nscp->SCp.sent_command != -1) { if (nscp->SCp.sent_command != -1) {
if ((nscp->SCp.phase & 0xff) == CACHESERVICE) { if ((nscp->SCp.phase & 0xff) == CACHESERVICE) {
if (!(cmd_index=gdth_fill_cache_cmd(hanum,nscp,t))) if (!(cmd_index=gdth_fill_cache_cmd(ha, nscp, t)))
this_cmd = FALSE; this_cmd = FALSE;
next_cmd = FALSE; next_cmd = FALSE;
} else if ((nscp->SCp.phase & 0xff) == SCSIRAWSERVICE) { } else if ((nscp->SCp.phase & 0xff) == SCSIRAWSERVICE) {
if (!(cmd_index=gdth_fill_raw_cmd(hanum,nscp,BUS_L2P(ha,b)))) if (!(cmd_index=gdth_fill_raw_cmd(ha, nscp, BUS_L2P(ha, b))))
this_cmd = FALSE; this_cmd = FALSE;
next_cmd = FALSE; next_cmd = FALSE;
} else { } else {
...@@ -2161,12 +2132,12 @@ static void gdth_next(int hanum) ...@@ -2161,12 +2132,12 @@ static void gdth_next(int hanum)
gdth_scsi_done(nscp); gdth_scsi_done(nscp);
} }
} else if (IS_GDTH_INTERNAL_CMD(nscp)) { } else if (IS_GDTH_INTERNAL_CMD(nscp)) {
if (!(cmd_index=gdth_special_cmd(hanum,nscp))) if (!(cmd_index=gdth_special_cmd(ha, nscp)))
this_cmd = FALSE; this_cmd = FALSE;
next_cmd = FALSE; next_cmd = FALSE;
} else if (b != ha->virt_bus) { } else if (b != ha->virt_bus) {
if (ha->raw[BUS_L2P(ha,b)].io_cnt[t] >= GDTH_MAX_RAW || if (ha->raw[BUS_L2P(ha,b)].io_cnt[t] >= GDTH_MAX_RAW ||
!(cmd_index=gdth_fill_raw_cmd(hanum,nscp,BUS_L2P(ha,b)))) !(cmd_index=gdth_fill_raw_cmd(ha, nscp, BUS_L2P(ha, b))))
this_cmd = FALSE; this_cmd = FALSE;
else else
ha->raw[BUS_L2P(ha,b)].io_cnt[t]++; ha->raw[BUS_L2P(ha,b)].io_cnt[t]++;
...@@ -2204,7 +2175,7 @@ static void gdth_next(int hanum) ...@@ -2204,7 +2175,7 @@ static void gdth_next(int hanum)
nscp->SCp.have_data_in++; nscp->SCp.have_data_in++;
else else
gdth_scsi_done(nscp); gdth_scsi_done(nscp);
} else if (gdth_internal_cache_cmd(hanum, nscp)) } else if (gdth_internal_cache_cmd(ha, nscp))
gdth_scsi_done(nscp); gdth_scsi_done(nscp);
break; break;
...@@ -2224,7 +2195,7 @@ static void gdth_next(int hanum) ...@@ -2224,7 +2195,7 @@ static void gdth_next(int hanum)
nscp->cmnd[3] = (ha->hdr[t].devtype&1) ? 1:0; nscp->cmnd[3] = (ha->hdr[t].devtype&1) ? 1:0;
TRACE(("Prevent/allow r. %d rem. drive %d\n", TRACE(("Prevent/allow r. %d rem. drive %d\n",
nscp->cmnd[4],nscp->cmnd[3])); nscp->cmnd[4],nscp->cmnd[3]));
if (!(cmd_index=gdth_fill_cache_cmd(hanum,nscp,t))) if (!(cmd_index=gdth_fill_cache_cmd(ha, nscp, t)))
this_cmd = FALSE; this_cmd = FALSE;
} }
break; break;
...@@ -2233,7 +2204,7 @@ static void gdth_next(int hanum) ...@@ -2233,7 +2204,7 @@ static void gdth_next(int hanum)
case RELEASE: case RELEASE:
TRACE2(("cache cmd %s\n",nscp->cmnd[0] == RESERVE ? TRACE2(("cache cmd %s\n",nscp->cmnd[0] == RESERVE ?
"RESERVE" : "RELEASE")); "RESERVE" : "RELEASE"));
if (!(cmd_index=gdth_fill_cache_cmd(hanum,nscp,t))) if (!(cmd_index=gdth_fill_cache_cmd(ha, nscp, t)))
this_cmd = FALSE; this_cmd = FALSE;
break; break;
...@@ -2256,7 +2227,7 @@ static void gdth_next(int hanum) ...@@ -2256,7 +2227,7 @@ static void gdth_next(int hanum)
nscp->SCp.have_data_in++; nscp->SCp.have_data_in++;
else else
gdth_scsi_done(nscp); gdth_scsi_done(nscp);
} else if (!(cmd_index=gdth_fill_cache_cmd(hanum, nscp, t))) } else if (!(cmd_index=gdth_fill_cache_cmd(ha, nscp, t)))
this_cmd = FALSE; this_cmd = FALSE;
break; break;
...@@ -2265,7 +2236,7 @@ static void gdth_next(int hanum) ...@@ -2265,7 +2236,7 @@ static void gdth_next(int hanum)
nscp->cmnd[1],nscp->cmnd[2],nscp->cmnd[3], nscp->cmnd[1],nscp->cmnd[2],nscp->cmnd[3],
nscp->cmnd[4],nscp->cmnd[5])); nscp->cmnd[4],nscp->cmnd[5]));
printk("GDT-HA %d: Unknown SCSI command 0x%x to cache service !\n", printk("GDT-HA %d: Unknown SCSI command 0x%x to cache service !\n",
hanum, nscp->cmnd[0]); ha->hanum, nscp->cmnd[0]);
nscp->result = DID_ABORT << 16; nscp->result = DID_ABORT << 16;
if (!nscp->SCp.have_data_in) if (!nscp->SCp.have_data_in)
nscp->SCp.have_data_in++; nscp->SCp.have_data_in++;
...@@ -2286,30 +2257,28 @@ static void gdth_next(int hanum) ...@@ -2286,30 +2257,28 @@ static void gdth_next(int hanum)
} }
if (ha->cmd_cnt > 0) { if (ha->cmd_cnt > 0) {
gdth_release_event(hanum); gdth_release_event(ha);
} }
if (!gdth_polling) if (!gdth_polling)
spin_unlock_irqrestore(&ha->smp_lock, flags); spin_unlock_irqrestore(&ha->smp_lock, flags);
if (gdth_polling && ha->cmd_cnt > 0) { if (gdth_polling && ha->cmd_cnt > 0) {
if (!gdth_wait(hanum,cmd_index,POLL_TIMEOUT)) if (!gdth_wait(ha, cmd_index, POLL_TIMEOUT))
printk("GDT-HA %d: Command %d timed out !\n", printk("GDT-HA %d: Command %d timed out !\n",
hanum,cmd_index); ha->hanum, cmd_index);
} }
} }
static void gdth_copy_internal_data(int hanum,Scsi_Cmnd *scp, static void gdth_copy_internal_data(gdth_ha_str *ha, Scsi_Cmnd *scp,
char *buffer,ushort count) char *buffer,ushort count)
{ {
ushort cpcount,i; ushort cpcount,i;
ushort cpsum,cpnow; ushort cpsum,cpnow;
struct scatterlist *sl; struct scatterlist *sl;
gdth_ha_str *ha;
char *address; char *address;
cpcount = count<=(ushort)scp->request_bufflen ? count:(ushort)scp->request_bufflen; cpcount = count<=(ushort)scp->request_bufflen ? count:(ushort)scp->request_bufflen;
ha = HADATA(gdth_ctr_tab[hanum]);
if (scp->use_sg) { if (scp->use_sg) {
sl = (struct scatterlist *)scp->request_buffer; sl = (struct scatterlist *)scp->request_buffer;
...@@ -2323,7 +2292,7 @@ static void gdth_copy_internal_data(int hanum,Scsi_Cmnd *scp, ...@@ -2323,7 +2292,7 @@ static void gdth_copy_internal_data(int hanum,Scsi_Cmnd *scp,
cpsum += cpnow; cpsum += cpnow;
if (!sl->page) { if (!sl->page) {
printk("GDT-HA %d: invalid sc/gt element in gdth_copy_internal_data()\n", printk("GDT-HA %d: invalid sc/gt element in gdth_copy_internal_data()\n",
hanum); ha->hanum);
return; return;
} }
local_irq_save(flags); local_irq_save(flags);
...@@ -2342,16 +2311,14 @@ static void gdth_copy_internal_data(int hanum,Scsi_Cmnd *scp, ...@@ -2342,16 +2311,14 @@ static void gdth_copy_internal_data(int hanum,Scsi_Cmnd *scp,
} }
} }
static int gdth_internal_cache_cmd(int hanum,Scsi_Cmnd *scp) static int gdth_internal_cache_cmd(gdth_ha_str *ha, Scsi_Cmnd *scp)
{ {
register gdth_ha_str *ha;
unchar t; unchar t;
gdth_inq_data inq; gdth_inq_data inq;
gdth_rdcap_data rdc; gdth_rdcap_data rdc;
gdth_sense_data sd; gdth_sense_data sd;
gdth_modep_data mpd; gdth_modep_data mpd;
ha = HADATA(gdth_ctr_tab[hanum]);
t = scp->device->id; t = scp->device->id;
TRACE(("gdth_internal_cache_cmd() cmd 0x%x hdrive %d\n", TRACE(("gdth_internal_cache_cmd() cmd 0x%x hdrive %d\n",
scp->cmnd[0],t)); scp->cmnd[0],t));
...@@ -2382,7 +2349,7 @@ static int gdth_internal_cache_cmd(int hanum,Scsi_Cmnd *scp) ...@@ -2382,7 +2349,7 @@ static int gdth_internal_cache_cmd(int hanum,Scsi_Cmnd *scp)
strcpy(inq.vendor,ha->oem_name); strcpy(inq.vendor,ha->oem_name);
sprintf(inq.product,"Host Drive #%02d",t); sprintf(inq.product,"Host Drive #%02d",t);
strcpy(inq.revision," "); strcpy(inq.revision," ");
gdth_copy_internal_data(hanum,scp,(char*)&inq,sizeof(gdth_inq_data)); gdth_copy_internal_data(ha, scp, (char*)&inq, sizeof(gdth_inq_data));
break; break;
case REQUEST_SENSE: case REQUEST_SENSE:
...@@ -2392,7 +2359,7 @@ static int gdth_internal_cache_cmd(int hanum,Scsi_Cmnd *scp) ...@@ -2392,7 +2359,7 @@ static int gdth_internal_cache_cmd(int hanum,Scsi_Cmnd *scp)
sd.key = NO_SENSE; sd.key = NO_SENSE;
sd.info = 0; sd.info = 0;
sd.add_length= 0; sd.add_length= 0;
gdth_copy_internal_data(hanum,scp,(char*)&sd,sizeof(gdth_sense_data)); gdth_copy_internal_data(ha, scp, (char*)&sd, sizeof(gdth_sense_data));
break; break;
case MODE_SENSE: case MODE_SENSE:
...@@ -2404,7 +2371,7 @@ static int gdth_internal_cache_cmd(int hanum,Scsi_Cmnd *scp) ...@@ -2404,7 +2371,7 @@ static int gdth_internal_cache_cmd(int hanum,Scsi_Cmnd *scp)
mpd.bd.block_length[0] = (SECTOR_SIZE & 0x00ff0000) >> 16; mpd.bd.block_length[0] = (SECTOR_SIZE & 0x00ff0000) >> 16;
mpd.bd.block_length[1] = (SECTOR_SIZE & 0x0000ff00) >> 8; mpd.bd.block_length[1] = (SECTOR_SIZE & 0x0000ff00) >> 8;
mpd.bd.block_length[2] = (SECTOR_SIZE & 0x000000ff); mpd.bd.block_length[2] = (SECTOR_SIZE & 0x000000ff);
gdth_copy_internal_data(hanum,scp,(char*)&mpd,sizeof(gdth_modep_data)); gdth_copy_internal_data(ha, scp, (char*)&mpd, sizeof(gdth_modep_data));
break; break;
case READ_CAPACITY: case READ_CAPACITY:
...@@ -2414,7 +2381,7 @@ static int gdth_internal_cache_cmd(int hanum,Scsi_Cmnd *scp) ...@@ -2414,7 +2381,7 @@ static int gdth_internal_cache_cmd(int hanum,Scsi_Cmnd *scp)
else else
rdc.last_block_no = cpu_to_be32(ha->hdr[t].size-1); rdc.last_block_no = cpu_to_be32(ha->hdr[t].size-1);
rdc.block_length = cpu_to_be32(SECTOR_SIZE); rdc.block_length = cpu_to_be32(SECTOR_SIZE);
gdth_copy_internal_data(hanum,scp,(char*)&rdc,sizeof(gdth_rdcap_data)); gdth_copy_internal_data(ha, scp, (char*)&rdc, sizeof(gdth_rdcap_data));
break; break;
case SERVICE_ACTION_IN: case SERVICE_ACTION_IN:
...@@ -2425,7 +2392,8 @@ static int gdth_internal_cache_cmd(int hanum,Scsi_Cmnd *scp) ...@@ -2425,7 +2392,8 @@ static int gdth_internal_cache_cmd(int hanum,Scsi_Cmnd *scp)
TRACE2(("Read capacity (16) hdrive %d\n",t)); TRACE2(("Read capacity (16) hdrive %d\n",t));
rdc16.last_block_no = cpu_to_be64(ha->hdr[t].size-1); rdc16.last_block_no = cpu_to_be64(ha->hdr[t].size-1);
rdc16.block_length = cpu_to_be32(SECTOR_SIZE); rdc16.block_length = cpu_to_be32(SECTOR_SIZE);
gdth_copy_internal_data(hanum,scp,(char*)&rdc16,sizeof(gdth_rdcap16_data)); gdth_copy_internal_data(ha, scp, (char*)&rdc16,
sizeof(gdth_rdcap16_data));
} else { } else {
scp->result = DID_ABORT << 16; scp->result = DID_ABORT << 16;
} }
...@@ -2443,10 +2411,9 @@ static int gdth_internal_cache_cmd(int hanum,Scsi_Cmnd *scp) ...@@ -2443,10 +2411,9 @@ static int gdth_internal_cache_cmd(int hanum,Scsi_Cmnd *scp)
return 0; return 0;
} }
static int gdth_fill_cache_cmd(int hanum,Scsi_Cmnd *scp,ushort hdrive) static int gdth_fill_cache_cmd(gdth_ha_str *ha, Scsi_Cmnd *scp, ushort hdrive)
{ {
register gdth_ha_str *ha;
register gdth_cmd_str *cmdp; register gdth_cmd_str *cmdp;
struct scatterlist *sl; struct scatterlist *sl;
ulong32 cnt, blockcnt; ulong32 cnt, blockcnt;
...@@ -2456,7 +2423,6 @@ static int gdth_fill_cache_cmd(int hanum,Scsi_Cmnd *scp,ushort hdrive) ...@@ -2456,7 +2423,6 @@ static int gdth_fill_cache_cmd(int hanum,Scsi_Cmnd *scp,ushort hdrive)
struct page *page; struct page *page;
ulong offset; ulong offset;
ha = HADATA(gdth_ctr_tab[hanum]);
cmdp = ha->pccb; cmdp = ha->pccb;
TRACE(("gdth_fill_cache_cmd() cmd 0x%x cmdsize %d hdrive %d\n", TRACE(("gdth_fill_cache_cmd() cmd 0x%x cmdsize %d hdrive %d\n",
scp->cmnd[0],scp->cmd_len,hdrive)); scp->cmnd[0],scp->cmd_len,hdrive));
...@@ -2472,13 +2438,13 @@ static int gdth_fill_cache_cmd(int hanum,Scsi_Cmnd *scp,ushort hdrive) ...@@ -2472,13 +2438,13 @@ static int gdth_fill_cache_cmd(int hanum,Scsi_Cmnd *scp,ushort hdrive)
cmdp->Service = CACHESERVICE; cmdp->Service = CACHESERVICE;
cmdp->RequestBuffer = scp; cmdp->RequestBuffer = scp;
/* search free command index */ /* search free command index */
if (!(cmd_index=gdth_get_cmd_index(hanum))) { if (!(cmd_index=gdth_get_cmd_index(ha))) {
TRACE(("GDT: No free command index found\n")); TRACE(("GDT: No free command index found\n"));
return 0; return 0;
} }
/* if it's the first command, set command semaphore */ /* if it's the first command, set command semaphore */
if (ha->cmd_cnt == 0) if (ha->cmd_cnt == 0)
gdth_set_sema0(hanum); gdth_set_sema0(ha);
/* fill command */ /* fill command */
read_write = 0; read_write = 0;
...@@ -2650,13 +2616,12 @@ static int gdth_fill_cache_cmd(int hanum,Scsi_Cmnd *scp,ushort hdrive) ...@@ -2650,13 +2616,12 @@ static int gdth_fill_cache_cmd(int hanum,Scsi_Cmnd *scp,ushort hdrive)
} }
/* copy command */ /* copy command */
gdth_copy_command(hanum); gdth_copy_command(ha);
return cmd_index; return cmd_index;
} }
static int gdth_fill_raw_cmd(int hanum,Scsi_Cmnd *scp,unchar b) static int gdth_fill_raw_cmd(gdth_ha_str *ha, Scsi_Cmnd *scp, unchar b)
{ {
register gdth_ha_str *ha;
register gdth_cmd_str *cmdp; register gdth_cmd_str *cmdp;
struct scatterlist *sl; struct scatterlist *sl;
ushort i; ushort i;
...@@ -2666,7 +2631,6 @@ static int gdth_fill_raw_cmd(int hanum,Scsi_Cmnd *scp,unchar b) ...@@ -2666,7 +2631,6 @@ static int gdth_fill_raw_cmd(int hanum,Scsi_Cmnd *scp,unchar b)
struct page *page; struct page *page;
ulong offset; ulong offset;
ha = HADATA(gdth_ctr_tab[hanum]);
t = scp->device->id; t = scp->device->id;
l = scp->device->lun; l = scp->device->lun;
cmdp = ha->pccb; cmdp = ha->pccb;
...@@ -2681,13 +2645,13 @@ static int gdth_fill_raw_cmd(int hanum,Scsi_Cmnd *scp,unchar b) ...@@ -2681,13 +2645,13 @@ static int gdth_fill_raw_cmd(int hanum,Scsi_Cmnd *scp,unchar b)
cmdp->Service = SCSIRAWSERVICE; cmdp->Service = SCSIRAWSERVICE;
cmdp->RequestBuffer = scp; cmdp->RequestBuffer = scp;
/* search free command index */ /* search free command index */
if (!(cmd_index=gdth_get_cmd_index(hanum))) { if (!(cmd_index=gdth_get_cmd_index(ha))) {
TRACE(("GDT: No free command index found\n")); TRACE(("GDT: No free command index found\n"));
return 0; return 0;
} }
/* if it's the first command, set command semaphore */ /* if it's the first command, set command semaphore */
if (ha->cmd_cnt == 0) if (ha->cmd_cnt == 0)
gdth_set_sema0(hanum); gdth_set_sema0(ha);
/* fill command */ /* fill command */
if (scp->SCp.sent_command != -1) { if (scp->SCp.sent_command != -1) {
...@@ -2855,17 +2819,15 @@ static int gdth_fill_raw_cmd(int hanum,Scsi_Cmnd *scp,unchar b) ...@@ -2855,17 +2819,15 @@ static int gdth_fill_raw_cmd(int hanum,Scsi_Cmnd *scp,unchar b)
} }
/* copy command */ /* copy command */
gdth_copy_command(hanum); gdth_copy_command(ha);
return cmd_index; return cmd_index;
} }
static int gdth_special_cmd(int hanum,Scsi_Cmnd *scp) static int gdth_special_cmd(gdth_ha_str *ha, Scsi_Cmnd *scp)
{ {
register gdth_ha_str *ha;
register gdth_cmd_str *cmdp; register gdth_cmd_str *cmdp;
int cmd_index; int cmd_index;
ha = HADATA(gdth_ctr_tab[hanum]);
cmdp= ha->pccb; cmdp= ha->pccb;
TRACE2(("gdth_special_cmd(): ")); TRACE2(("gdth_special_cmd(): "));
...@@ -2876,14 +2838,14 @@ static int gdth_special_cmd(int hanum,Scsi_Cmnd *scp) ...@@ -2876,14 +2838,14 @@ static int gdth_special_cmd(int hanum,Scsi_Cmnd *scp)
cmdp->RequestBuffer = scp; cmdp->RequestBuffer = scp;
/* search free command index */ /* search free command index */
if (!(cmd_index=gdth_get_cmd_index(hanum))) { if (!(cmd_index=gdth_get_cmd_index(ha))) {
TRACE(("GDT: No free command index found\n")); TRACE(("GDT: No free command index found\n"));
return 0; return 0;
} }
/* if it's the first command, set command semaphore */ /* if it's the first command, set command semaphore */
if (ha->cmd_cnt == 0) if (ha->cmd_cnt == 0)
gdth_set_sema0(hanum); gdth_set_sema0(ha);
/* evaluate command size, check space */ /* evaluate command size, check space */
if (cmdp->OpCode == GDT_IOCTL) { if (cmdp->OpCode == GDT_IOCTL) {
...@@ -2921,7 +2883,7 @@ static int gdth_special_cmd(int hanum,Scsi_Cmnd *scp) ...@@ -2921,7 +2883,7 @@ static int gdth_special_cmd(int hanum,Scsi_Cmnd *scp)
} }
/* copy command */ /* copy command */
gdth_copy_command(hanum); gdth_copy_command(ha);
return cmd_index; return cmd_index;
} }
...@@ -3087,7 +3049,7 @@ static irqreturn_t gdth_interrupt(int irq,void *dev_id) ...@@ -3087,7 +3049,7 @@ static irqreturn_t gdth_interrupt(int irq,void *dev_id)
spin_unlock_irqrestore(&ha2->smp_lock, flags); spin_unlock_irqrestore(&ha2->smp_lock, flags);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
ha = HADATA(gdth_ctr_tab[hanum]); ha = shost_priv(gdth_ctr_tab[hanum]);
#ifdef GDTH_STATISTICS #ifdef GDTH_STATISTICS
++act_ints; ++act_ints;
...@@ -3233,10 +3195,10 @@ static irqreturn_t gdth_interrupt(int irq,void *dev_id) ...@@ -3233,10 +3195,10 @@ static irqreturn_t gdth_interrupt(int irq,void *dev_id)
if (IStatus == ASYNCINDEX) { if (IStatus == ASYNCINDEX) {
TRACE2(("gdth_interrupt() async. event\n")); TRACE2(("gdth_interrupt() async. event\n"));
gdth_async_event(hanum); gdth_async_event(ha);
if (!gdth_polling) if (!gdth_polling)
spin_unlock_irqrestore(&ha2->smp_lock, flags); spin_unlock_irqrestore(&ha2->smp_lock, flags);
gdth_next(hanum); gdth_next(ha);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -3270,11 +3232,11 @@ static irqreturn_t gdth_interrupt(int irq,void *dev_id) ...@@ -3270,11 +3232,11 @@ static irqreturn_t gdth_interrupt(int irq,void *dev_id)
} }
TRACE(("gdth_interrupt() sync. status\n")); TRACE(("gdth_interrupt() sync. status\n"));
rval = gdth_sync_event(hanum,Service,IStatus,scp); rval = gdth_sync_event(ha,Service,IStatus,scp);
if (!gdth_polling) if (!gdth_polling)
spin_unlock_irqrestore(&ha2->smp_lock, flags); spin_unlock_irqrestore(&ha2->smp_lock, flags);
if (rval == 2) { if (rval == 2) {
gdth_putq(hanum,scp,scp->SCp.this_residual); gdth_putq(ha, scp,scp->SCp.this_residual);
} else if (rval == 1) { } else if (rval == 1) {
gdth_scsi_done(scp); gdth_scsi_done(scp);
} }
...@@ -3304,18 +3266,17 @@ static irqreturn_t gdth_interrupt(int irq,void *dev_id) ...@@ -3304,18 +3266,17 @@ static irqreturn_t gdth_interrupt(int irq,void *dev_id)
} }
#endif #endif
gdth_next(hanum); gdth_next(ha);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static int gdth_sync_event(int hanum,int service,unchar index,Scsi_Cmnd *scp) static int gdth_sync_event(gdth_ha_str *ha, int service, unchar index,
Scsi_Cmnd *scp)
{ {
register gdth_ha_str *ha;
gdth_msg_str *msg; gdth_msg_str *msg;
gdth_cmd_str *cmdp; gdth_cmd_str *cmdp;
unchar b, t; unchar b, t;
ha = HADATA(gdth_ctr_tab[hanum]);
cmdp = ha->pccb; cmdp = ha->pccb;
TRACE(("gdth_sync_event() serv %d status %d\n", TRACE(("gdth_sync_event() serv %d status %d\n",
service,ha->status)); service,ha->status));
...@@ -3333,12 +3294,12 @@ static int gdth_sync_event(int hanum,int service,unchar index,Scsi_Cmnd *scp) ...@@ -3333,12 +3294,12 @@ static int gdth_sync_event(int hanum,int service,unchar index,Scsi_Cmnd *scp)
} }
if (msg->msg_ext && !msg->msg_answer) { if (msg->msg_ext && !msg->msg_answer) {
while (gdth_test_busy(hanum)) while (gdth_test_busy(ha))
gdth_delay(0); gdth_delay(0);
cmdp->Service = SCREENSERVICE; cmdp->Service = SCREENSERVICE;
cmdp->RequestBuffer = SCREEN_CMND; cmdp->RequestBuffer = SCREEN_CMND;
gdth_get_cmd_index(hanum); gdth_get_cmd_index(ha);
gdth_set_sema0(hanum); gdth_set_sema0(ha);
cmdp->OpCode = GDT_READ; cmdp->OpCode = GDT_READ;
cmdp->BoardNode = LOCALBOARD; cmdp->BoardNode = LOCALBOARD;
cmdp->u.screen.reserved = 0; cmdp->u.screen.reserved = 0;
...@@ -3348,8 +3309,8 @@ static int gdth_sync_event(int hanum,int service,unchar index,Scsi_Cmnd *scp) ...@@ -3348,8 +3309,8 @@ static int gdth_sync_event(int hanum,int service,unchar index,Scsi_Cmnd *scp)
ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.screen.su.msg.msg_addr) ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.screen.su.msg.msg_addr)
+ sizeof(ulong64); + sizeof(ulong64);
ha->cmd_cnt = 0; ha->cmd_cnt = 0;
gdth_copy_command(hanum); gdth_copy_command(ha);
gdth_release_event(hanum); gdth_release_event(ha);
return 0; return 0;
} }
...@@ -3367,12 +3328,12 @@ static int gdth_sync_event(int hanum,int service,unchar index,Scsi_Cmnd *scp) ...@@ -3367,12 +3328,12 @@ static int gdth_sync_event(int hanum,int service,unchar index,Scsi_Cmnd *scp)
} }
msg->msg_ext = 0; msg->msg_ext = 0;
msg->msg_answer = 0; msg->msg_answer = 0;
while (gdth_test_busy(hanum)) while (gdth_test_busy(ha))
gdth_delay(0); gdth_delay(0);
cmdp->Service = SCREENSERVICE; cmdp->Service = SCREENSERVICE;
cmdp->RequestBuffer = SCREEN_CMND; cmdp->RequestBuffer = SCREEN_CMND;
gdth_get_cmd_index(hanum); gdth_get_cmd_index(ha);
gdth_set_sema0(hanum); gdth_set_sema0(ha);
cmdp->OpCode = GDT_WRITE; cmdp->OpCode = GDT_WRITE;
cmdp->BoardNode = LOCALBOARD; cmdp->BoardNode = LOCALBOARD;
cmdp->u.screen.reserved = 0; cmdp->u.screen.reserved = 0;
...@@ -3382,8 +3343,8 @@ static int gdth_sync_event(int hanum,int service,unchar index,Scsi_Cmnd *scp) ...@@ -3382,8 +3343,8 @@ static int gdth_sync_event(int hanum,int service,unchar index,Scsi_Cmnd *scp)
ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.screen.su.msg.msg_addr) ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.screen.su.msg.msg_addr)
+ sizeof(ulong64); + sizeof(ulong64);
ha->cmd_cnt = 0; ha->cmd_cnt = 0;
gdth_copy_command(hanum); gdth_copy_command(ha);
gdth_release_event(hanum); gdth_release_event(ha);
return 0; return 0;
} }
printk("\n"); printk("\n");
...@@ -3496,7 +3457,7 @@ static int gdth_sync_event(int hanum,int service,unchar index,Scsi_Cmnd *scp) ...@@ -3496,7 +3457,7 @@ static int gdth_sync_event(int hanum,int service,unchar index,Scsi_Cmnd *scp)
} }
if (!IS_GDTH_INTERNAL_CMD(scp)) { if (!IS_GDTH_INTERNAL_CMD(scp)) {
ha->dvr.size = sizeof(ha->dvr.eu.sync); ha->dvr.size = sizeof(ha->dvr.eu.sync);
ha->dvr.eu.sync.ionode = hanum; ha->dvr.eu.sync.ionode = ha->hanum;
ha->dvr.eu.sync.service = service; ha->dvr.eu.sync.service = service;
ha->dvr.eu.sync.status = ha->status; ha->dvr.eu.sync.status = ha->status;
ha->dvr.eu.sync.info = ha->info; ha->dvr.eu.sync.info = ha->info;
...@@ -3680,25 +3641,23 @@ static char *async_cache_tab[] = { ...@@ -3680,25 +3641,23 @@ static char *async_cache_tab[] = {
}; };
static int gdth_async_event(int hanum) static int gdth_async_event(gdth_ha_str *ha)
{ {
gdth_ha_str *ha;
gdth_cmd_str *cmdp; gdth_cmd_str *cmdp;
int cmd_index; int cmd_index;
ha = HADATA(gdth_ctr_tab[hanum]);
cmdp= ha->pccb; cmdp= ha->pccb;
TRACE2(("gdth_async_event() ha %d serv %d\n", TRACE2(("gdth_async_event() ha %d serv %d\n",
hanum,ha->service)); ha->hanum, ha->service));
if (ha->service == SCREENSERVICE) { if (ha->service == SCREENSERVICE) {
if (ha->status == MSG_REQUEST) { if (ha->status == MSG_REQUEST) {
while (gdth_test_busy(hanum)) while (gdth_test_busy(ha))
gdth_delay(0); gdth_delay(0);
cmdp->Service = SCREENSERVICE; cmdp->Service = SCREENSERVICE;
cmdp->RequestBuffer = SCREEN_CMND; cmdp->RequestBuffer = SCREEN_CMND;
cmd_index = gdth_get_cmd_index(hanum); cmd_index = gdth_get_cmd_index(ha);
gdth_set_sema0(hanum); gdth_set_sema0(ha);
cmdp->OpCode = GDT_READ; cmdp->OpCode = GDT_READ;
cmdp->BoardNode = LOCALBOARD; cmdp->BoardNode = LOCALBOARD;
cmdp->u.screen.reserved = 0; cmdp->u.screen.reserved = 0;
...@@ -3708,7 +3667,7 @@ static int gdth_async_event(int hanum) ...@@ -3708,7 +3667,7 @@ static int gdth_async_event(int hanum)
ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.screen.su.msg.msg_addr) ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.screen.su.msg.msg_addr)
+ sizeof(ulong64); + sizeof(ulong64);
ha->cmd_cnt = 0; ha->cmd_cnt = 0;
gdth_copy_command(hanum); gdth_copy_command(ha);
if (ha->type == GDT_EISA) if (ha->type == GDT_EISA)
printk("[EISA slot %d] ",(ushort)ha->brd_phys); printk("[EISA slot %d] ",(ushort)ha->brd_phys);
else if (ha->type == GDT_ISA) else if (ha->type == GDT_ISA)
...@@ -3716,19 +3675,19 @@ static int gdth_async_event(int hanum) ...@@ -3716,19 +3675,19 @@ static int gdth_async_event(int hanum)
else else
printk("[PCI %d/%d] ",(ushort)(ha->brd_phys>>8), printk("[PCI %d/%d] ",(ushort)(ha->brd_phys>>8),
(ushort)((ha->brd_phys>>3)&0x1f)); (ushort)((ha->brd_phys>>3)&0x1f));
gdth_release_event(hanum); gdth_release_event(ha);
} }
} else { } else {
if (ha->type == GDT_PCIMPR && if (ha->type == GDT_PCIMPR &&
(ha->fw_vers & 0xff) >= 0x1a) { (ha->fw_vers & 0xff) >= 0x1a) {
ha->dvr.size = 0; ha->dvr.size = 0;
ha->dvr.eu.async.ionode = hanum; ha->dvr.eu.async.ionode = ha->hanum;
ha->dvr.eu.async.status = ha->status; ha->dvr.eu.async.status = ha->status;
/* severity and event_string already set! */ /* severity and event_string already set! */
} else { } else {
ha->dvr.size = sizeof(ha->dvr.eu.async); ha->dvr.size = sizeof(ha->dvr.eu.async);
ha->dvr.eu.async.ionode = hanum; ha->dvr.eu.async.ionode = ha->hanum;
ha->dvr.eu.async.service = ha->service; ha->dvr.eu.async.service = ha->service;
ha->dvr.eu.async.status = ha->status; ha->dvr.eu.async.status = ha->status;
ha->dvr.eu.async.info = ha->info; ha->dvr.eu.async.info = ha->info;
...@@ -3810,9 +3769,8 @@ static void gdth_timeout(ulong data) ...@@ -3810,9 +3769,8 @@ static void gdth_timeout(ulong data)
Scsi_Cmnd *nscp; Scsi_Cmnd *nscp;
gdth_ha_str *ha; gdth_ha_str *ha;
ulong flags; ulong flags;
int hanum = 0;
ha = HADATA(gdth_ctr_tab[hanum]); ha = shost_priv(gdth_ctr_tab[0]);
spin_lock_irqsave(&ha->smp_lock, flags); spin_lock_irqsave(&ha->smp_lock, flags);
for (act_stats=0,i=0; i<GDTH_MAXCMDS; ++i) for (act_stats=0,i=0; i<GDTH_MAXCMDS; ++i)
...@@ -4012,17 +3970,14 @@ static int __init gdth_detect(struct scsi_host_template *shtp) ...@@ -4012,17 +3970,14 @@ static int __init gdth_detect(struct scsi_host_template *shtp)
static int gdth_release(struct Scsi_Host *shp) static int gdth_release(struct Scsi_Host *shp)
{ {
int hanum; gdth_ha_str *ha = shost_priv(shp);
gdth_ha_str *ha;
TRACE2(("gdth_release()\n")); TRACE2(("gdth_release()\n"));
hanum = NUMDATA(shp)->hanum;
ha = HADATA(gdth_ctr_tab[hanum]);
if (ha->sdev) { if (ha->sdev) {
scsi_free_host_dev(ha->sdev); scsi_free_host_dev(ha->sdev);
ha->sdev = NULL; ha->sdev = NULL;
} }
gdth_flush(hanum); gdth_flush(ha);
if (shp->irq) { if (shp->irq) {
free_irq(shp->irq,ha); free_irq(shp->irq,ha);
...@@ -4063,14 +4018,10 @@ static int gdth_release(struct Scsi_Host *shp) ...@@ -4063,14 +4018,10 @@ static int gdth_release(struct Scsi_Host *shp)
} }
static const char *gdth_ctr_name(int hanum) static const char *gdth_ctr_name(gdth_ha_str *ha)
{ {
gdth_ha_str *ha;
TRACE2(("gdth_ctr_name()\n")); TRACE2(("gdth_ctr_name()\n"));
ha = HADATA(gdth_ctr_tab[hanum]);
if (ha->type == GDT_EISA) { if (ha->type == GDT_EISA) {
switch (ha->stype) { switch (ha->stype) {
case GDT3_ID: case GDT3_ID:
...@@ -4097,29 +4048,23 @@ static const char *gdth_ctr_name(int hanum) ...@@ -4097,29 +4048,23 @@ static const char *gdth_ctr_name(int hanum)
static const char *gdth_info(struct Scsi_Host *shp) static const char *gdth_info(struct Scsi_Host *shp)
{ {
int hanum; gdth_ha_str *ha = shost_priv(shp);
gdth_ha_str *ha;
TRACE2(("gdth_info()\n")); TRACE2(("gdth_info()\n"));
hanum = NUMDATA(shp)->hanum;
ha = HADATA(gdth_ctr_tab[hanum]);
return ((const char *)ha->binfo.type_string); return ((const char *)ha->binfo.type_string);
} }
static int gdth_eh_bus_reset(Scsi_Cmnd *scp) static int gdth_eh_bus_reset(Scsi_Cmnd *scp)
{ {
int i, hanum; gdth_ha_str *ha = shost_priv(scp->device->host);
gdth_ha_str *ha; int i;
ulong flags; ulong flags;
Scsi_Cmnd *cmnd; Scsi_Cmnd *cmnd;
unchar b; unchar b;
TRACE2(("gdth_eh_bus_reset()\n")); TRACE2(("gdth_eh_bus_reset()\n"));
hanum = NUMDATA(scp->device->host)->hanum;
b = scp->device->channel; b = scp->device->channel;
ha = HADATA(gdth_ctr_tab[hanum]);
/* clear command tab */ /* clear command tab */
spin_lock_irqsave(&ha->smp_lock, flags); spin_lock_irqsave(&ha->smp_lock, flags);
...@@ -4136,9 +4081,9 @@ static int gdth_eh_bus_reset(Scsi_Cmnd *scp) ...@@ -4136,9 +4081,9 @@ static int gdth_eh_bus_reset(Scsi_Cmnd *scp)
if (ha->hdr[i].present) { if (ha->hdr[i].present) {
spin_lock_irqsave(&ha->smp_lock, flags); spin_lock_irqsave(&ha->smp_lock, flags);
gdth_polling = TRUE; gdth_polling = TRUE;
while (gdth_test_busy(hanum)) while (gdth_test_busy(ha))
gdth_delay(0); gdth_delay(0);
if (gdth_internal_cmd(hanum, CACHESERVICE, if (gdth_internal_cmd(ha, CACHESERVICE,
GDT_CLUST_RESET, i, 0, 0)) GDT_CLUST_RESET, i, 0, 0))
ha->hdr[i].cluster_type &= ~CLUSTER_RESERVED; ha->hdr[i].cluster_type &= ~CLUSTER_RESERVED;
gdth_polling = FALSE; gdth_polling = FALSE;
...@@ -4151,9 +4096,9 @@ static int gdth_eh_bus_reset(Scsi_Cmnd *scp) ...@@ -4151,9 +4096,9 @@ static int gdth_eh_bus_reset(Scsi_Cmnd *scp)
for (i = 0; i < MAXID; ++i) for (i = 0; i < MAXID; ++i)
ha->raw[BUS_L2P(ha,b)].io_cnt[i] = 0; ha->raw[BUS_L2P(ha,b)].io_cnt[i] = 0;
gdth_polling = TRUE; gdth_polling = TRUE;
while (gdth_test_busy(hanum)) while (gdth_test_busy(ha))
gdth_delay(0); gdth_delay(0);
gdth_internal_cmd(hanum, SCSIRAWSERVICE, GDT_RESET_BUS, gdth_internal_cmd(ha, SCSIRAWSERVICE, GDT_RESET_BUS,
BUS_L2P(ha,b), 0, 0); BUS_L2P(ha,b), 0, 0);
gdth_polling = FALSE; gdth_polling = FALSE;
spin_unlock_irqrestore(&ha->smp_lock, flags); spin_unlock_irqrestore(&ha->smp_lock, flags);
...@@ -4164,18 +4109,15 @@ static int gdth_eh_bus_reset(Scsi_Cmnd *scp) ...@@ -4164,18 +4109,15 @@ static int gdth_eh_bus_reset(Scsi_Cmnd *scp)
static int gdth_bios_param(struct scsi_device *sdev,struct block_device *bdev,sector_t cap,int *ip) static int gdth_bios_param(struct scsi_device *sdev,struct block_device *bdev,sector_t cap,int *ip)
{ {
unchar b, t; unchar b, t;
int hanum; gdth_ha_str *ha = shost_priv(sdev->host);
gdth_ha_str *ha;
struct scsi_device *sd; struct scsi_device *sd;
unsigned capacity; unsigned capacity;
sd = sdev; sd = sdev;
capacity = cap; capacity = cap;
hanum = NUMDATA(sd->host)->hanum;
b = sd->channel; b = sd->channel;
t = sd->id; t = sd->id;
TRACE2(("gdth_bios_param() ha %d bus %d target %d\n", hanum, b, t)); TRACE2(("gdth_bios_param() ha %d bus %d target %d\n", ha->hanum, b, t));
ha = HADATA(gdth_ctr_tab[hanum]);
if (b != ha->virt_bus || ha->hdr[t].heads == 0) { if (b != ha->virt_bus || ha->hdr[t].heads == 0) {
/* raw device or host drive without mapping information */ /* raw device or host drive without mapping information */
...@@ -4196,7 +4138,7 @@ static int gdth_bios_param(struct scsi_device *sdev,struct block_device *bdev,se ...@@ -4196,7 +4138,7 @@ static int gdth_bios_param(struct scsi_device *sdev,struct block_device *bdev,se
static int gdth_queuecommand(struct scsi_cmnd *scp, static int gdth_queuecommand(struct scsi_cmnd *scp,
void (*done)(struct scsi_cmnd *)) void (*done)(struct scsi_cmnd *))
{ {
int hanum; gdth_ha_str *ha = shost_priv(scp->device->host);
int priority; int priority;
TRACE(("gdth_queuecommand() cmd 0x%x\n", scp->cmnd[0])); TRACE(("gdth_queuecommand() cmd 0x%x\n", scp->cmnd[0]));
...@@ -4208,7 +4150,6 @@ static int gdth_queuecommand(struct scsi_cmnd *scp, ...@@ -4208,7 +4150,6 @@ static int gdth_queuecommand(struct scsi_cmnd *scp,
scp->SCp.Status = GDTH_MAP_NONE; scp->SCp.Status = GDTH_MAP_NONE;
scp->SCp.buffer = (struct scatterlist *)NULL; scp->SCp.buffer = (struct scatterlist *)NULL;
hanum = NUMDATA(scp->device->host)->hanum;
#ifdef GDTH_STATISTICS #ifdef GDTH_STATISTICS
++act_ios; ++act_ios;
#endif #endif
...@@ -4217,10 +4158,10 @@ static int gdth_queuecommand(struct scsi_cmnd *scp, ...@@ -4217,10 +4158,10 @@ static int gdth_queuecommand(struct scsi_cmnd *scp,
if (IS_GDTH_INTERNAL_CMD(scp)) if (IS_GDTH_INTERNAL_CMD(scp))
priority = scp->SCp.this_residual; priority = scp->SCp.this_residual;
else else
gdth_update_timeout(hanum, scp, scp->timeout_per_command * 6); gdth_update_timeout(scp, scp->timeout_per_command * 6);
gdth_putq( hanum, scp, priority ); gdth_putq(ha, scp, priority);
gdth_next( hanum ); gdth_next(ha);
return 0; return 0;
} }
...@@ -4231,7 +4172,7 @@ static int gdth_open(struct inode *inode, struct file *filep) ...@@ -4231,7 +4172,7 @@ static int gdth_open(struct inode *inode, struct file *filep)
int i; int i;
for (i = 0; i < gdth_ctr_count; i++) { for (i = 0; i < gdth_ctr_count; i++) {
ha = HADATA(gdth_ctr_tab[i]); ha = shost_priv(gdth_ctr_tab[i]);
if (!ha->sdev) if (!ha->sdev)
ha->sdev = scsi_get_host_dev(gdth_ctr_tab[i]); ha->sdev = scsi_get_host_dev(gdth_ctr_tab[i]);
} }
...@@ -4255,7 +4196,7 @@ static int ioc_event(void __user *arg) ...@@ -4255,7 +4196,7 @@ static int ioc_event(void __user *arg)
if (copy_from_user(&evt, arg, sizeof(gdth_ioctl_event)) || if (copy_from_user(&evt, arg, sizeof(gdth_ioctl_event)) ||
evt.ionode >= gdth_ctr_count) evt.ionode >= gdth_ctr_count)
return -EFAULT; return -EFAULT;
ha = HADATA(gdth_ctr_tab[evt.ionode]); ha = shost_priv(gdth_ctr_tab[evt.ionode]);
if (evt.erase == 0xff) { if (evt.erase == 0xff) {
if (evt.event.event_source == ES_TEST) if (evt.event.event_source == ES_TEST)
...@@ -4292,7 +4233,7 @@ static int ioc_lockdrv(void __user *arg) ...@@ -4292,7 +4233,7 @@ static int ioc_lockdrv(void __user *arg)
if (copy_from_user(&ldrv, arg, sizeof(gdth_ioctl_lockdrv)) || if (copy_from_user(&ldrv, arg, sizeof(gdth_ioctl_lockdrv)) ||
ldrv.ionode >= gdth_ctr_count) ldrv.ionode >= gdth_ctr_count)
return -EFAULT; return -EFAULT;
ha = HADATA(gdth_ctr_tab[ldrv.ionode]); ha = shost_priv(gdth_ctr_tab[ldrv.ionode]);
for (i = 0; i < ldrv.drive_cnt && i < MAX_HDRIVES; ++i) { for (i = 0; i < ldrv.drive_cnt && i < MAX_HDRIVES; ++i) {
j = ldrv.drives[i]; j = ldrv.drives[i];
...@@ -4302,14 +4243,14 @@ static int ioc_lockdrv(void __user *arg) ...@@ -4302,14 +4243,14 @@ static int ioc_lockdrv(void __user *arg)
spin_lock_irqsave(&ha->smp_lock, flags); spin_lock_irqsave(&ha->smp_lock, flags);
ha->hdr[j].lock = 1; ha->hdr[j].lock = 1;
spin_unlock_irqrestore(&ha->smp_lock, flags); spin_unlock_irqrestore(&ha->smp_lock, flags);
gdth_wait_completion(ldrv.ionode, ha->bus_cnt, j); gdth_wait_completion(ha, ha->bus_cnt, j);
gdth_stop_timeout(ldrv.ionode, ha->bus_cnt, j); gdth_stop_timeout(ha, ha->bus_cnt, j);
} else { } else {
spin_lock_irqsave(&ha->smp_lock, flags); spin_lock_irqsave(&ha->smp_lock, flags);
ha->hdr[j].lock = 0; ha->hdr[j].lock = 0;
spin_unlock_irqrestore(&ha->smp_lock, flags); spin_unlock_irqrestore(&ha->smp_lock, flags);
gdth_start_timeout(ldrv.ionode, ha->bus_cnt, j); gdth_start_timeout(ha, ha->bus_cnt, j);
gdth_next(ldrv.ionode); gdth_next(ha);
} }
} }
return 0; return 0;
...@@ -4319,16 +4260,14 @@ static int ioc_resetdrv(void __user *arg, char *cmnd) ...@@ -4319,16 +4260,14 @@ static int ioc_resetdrv(void __user *arg, char *cmnd)
{ {
gdth_ioctl_reset res; gdth_ioctl_reset res;
gdth_cmd_str cmd; gdth_cmd_str cmd;
int hanum;
gdth_ha_str *ha; gdth_ha_str *ha;
int rval; int rval;
if (copy_from_user(&res, arg, sizeof(gdth_ioctl_reset)) || if (copy_from_user(&res, arg, sizeof(gdth_ioctl_reset)) ||
res.ionode >= gdth_ctr_count || res.number >= MAX_HDRIVES) res.ionode >= gdth_ctr_count || res.number >= MAX_HDRIVES)
return -EFAULT; return -EFAULT;
hanum = res.ionode; ha = shost_priv(gdth_ctr_tab[res.ionode]);
ha = HADATA(gdth_ctr_tab[hanum]);
if (!ha->hdr[res.number].present) if (!ha->hdr[res.number].present)
return 0; return 0;
memset(&cmd, 0, sizeof(gdth_cmd_str)); memset(&cmd, 0, sizeof(gdth_cmd_str));
...@@ -4354,22 +4293,20 @@ static int ioc_general(void __user *arg, char *cmnd) ...@@ -4354,22 +4293,20 @@ static int ioc_general(void __user *arg, char *cmnd)
gdth_ioctl_general gen; gdth_ioctl_general gen;
char *buf = NULL; char *buf = NULL;
ulong64 paddr; ulong64 paddr;
int hanum;
gdth_ha_str *ha; gdth_ha_str *ha;
int rval; int rval;
if (copy_from_user(&gen, arg, sizeof(gdth_ioctl_general)) || if (copy_from_user(&gen, arg, sizeof(gdth_ioctl_general)) ||
gen.ionode >= gdth_ctr_count) gen.ionode >= gdth_ctr_count)
return -EFAULT; return -EFAULT;
hanum = gen.ionode; ha = shost_priv(gdth_ctr_tab[gen.ionode]);
ha = HADATA(gdth_ctr_tab[hanum]);
if (gen.data_len + gen.sense_len != 0) { if (gen.data_len + gen.sense_len != 0) {
if (!(buf = gdth_ioctl_alloc(hanum, gen.data_len + gen.sense_len, if (!(buf = gdth_ioctl_alloc(ha, gen.data_len + gen.sense_len,
FALSE, &paddr))) FALSE, &paddr)))
return -EFAULT; return -EFAULT;
if (copy_from_user(buf, arg + sizeof(gdth_ioctl_general), if (copy_from_user(buf, arg + sizeof(gdth_ioctl_general),
gen.data_len + gen.sense_len)) { gen.data_len + gen.sense_len)) {
gdth_ioctl_free(hanum, gen.data_len+gen.sense_len, buf, paddr); gdth_ioctl_free(ha, gen.data_len+gen.sense_len, buf, paddr);
return -EFAULT; return -EFAULT;
} }
...@@ -4443,7 +4380,7 @@ static int ioc_general(void __user *arg, char *cmnd) ...@@ -4443,7 +4380,7 @@ static int ioc_general(void __user *arg, char *cmnd)
gen.command.u.raw.sense_data = (ulong32)paddr + gen.data_len; gen.command.u.raw.sense_data = (ulong32)paddr + gen.data_len;
} }
} else { } else {
gdth_ioctl_free(hanum, gen.data_len+gen.sense_len, buf, paddr); gdth_ioctl_free(ha, gen.data_len+gen.sense_len, buf, paddr);
return -EFAULT; return -EFAULT;
} }
} }
...@@ -4455,15 +4392,15 @@ static int ioc_general(void __user *arg, char *cmnd) ...@@ -4455,15 +4392,15 @@ static int ioc_general(void __user *arg, char *cmnd)
if (copy_to_user(arg + sizeof(gdth_ioctl_general), buf, if (copy_to_user(arg + sizeof(gdth_ioctl_general), buf,
gen.data_len + gen.sense_len)) { gen.data_len + gen.sense_len)) {
gdth_ioctl_free(hanum, gen.data_len+gen.sense_len, buf, paddr); gdth_ioctl_free(ha, gen.data_len+gen.sense_len, buf, paddr);
return -EFAULT; return -EFAULT;
} }
if (copy_to_user(arg, &gen, if (copy_to_user(arg, &gen,
sizeof(gdth_ioctl_general) - sizeof(gdth_cmd_str))) { sizeof(gdth_ioctl_general) - sizeof(gdth_cmd_str))) {
gdth_ioctl_free(hanum, gen.data_len+gen.sense_len, buf, paddr); gdth_ioctl_free(ha, gen.data_len+gen.sense_len, buf, paddr);
return -EFAULT; return -EFAULT;
} }
gdth_ioctl_free(hanum, gen.data_len+gen.sense_len, buf, paddr); gdth_ioctl_free(ha, gen.data_len+gen.sense_len, buf, paddr);
return 0; return 0;
} }
...@@ -4473,7 +4410,7 @@ static int ioc_hdrlist(void __user *arg, char *cmnd) ...@@ -4473,7 +4410,7 @@ static int ioc_hdrlist(void __user *arg, char *cmnd)
gdth_cmd_str *cmd; gdth_cmd_str *cmd;
gdth_ha_str *ha; gdth_ha_str *ha;
unchar i; unchar i;
int hanum, rc = -ENOMEM; int rc = -ENOMEM;
u32 cluster_type = 0; u32 cluster_type = 0;
rsc = kmalloc(sizeof(*rsc), GFP_KERNEL); rsc = kmalloc(sizeof(*rsc), GFP_KERNEL);
...@@ -4486,8 +4423,7 @@ static int ioc_hdrlist(void __user *arg, char *cmnd) ...@@ -4486,8 +4423,7 @@ static int ioc_hdrlist(void __user *arg, char *cmnd)
rc = -EFAULT; rc = -EFAULT;
goto free_fail; goto free_fail;
} }
hanum = rsc->ionode; ha = shost_priv(gdth_ctr_tab[rsc->ionode]);
ha = HADATA(gdth_ctr_tab[hanum]);
memset(cmd, 0, sizeof(gdth_cmd_str)); memset(cmd, 0, sizeof(gdth_cmd_str));
for (i = 0; i < MAX_HDRIVES; ++i) { for (i = 0; i < MAX_HDRIVES; ++i) {
...@@ -4528,7 +4464,7 @@ static int ioc_rescan(void __user *arg, char *cmnd) ...@@ -4528,7 +4464,7 @@ static int ioc_rescan(void __user *arg, char *cmnd)
gdth_cmd_str *cmd; gdth_cmd_str *cmd;
ushort i, status, hdr_cnt; ushort i, status, hdr_cnt;
ulong32 info; ulong32 info;
int hanum, cyls, hds, secs; int cyls, hds, secs;
int rc = -ENOMEM; int rc = -ENOMEM;
ulong flags; ulong flags;
gdth_ha_str *ha; gdth_ha_str *ha;
...@@ -4543,8 +4479,7 @@ static int ioc_rescan(void __user *arg, char *cmnd) ...@@ -4543,8 +4479,7 @@ static int ioc_rescan(void __user *arg, char *cmnd)
rc = -EFAULT; rc = -EFAULT;
goto free_fail; goto free_fail;
} }
hanum = rsc->ionode; ha = shost_priv(gdth_ctr_tab[rsc->ionode]);
ha = HADATA(gdth_ctr_tab[hanum]);
memset(cmd, 0, sizeof(gdth_cmd_str)); memset(cmd, 0, sizeof(gdth_cmd_str));
if (rsc->flag == 0) { if (rsc->flag == 0) {
...@@ -4703,7 +4638,7 @@ static int gdth_ioctl(struct inode *inode, struct file *filep, ...@@ -4703,7 +4638,7 @@ static int gdth_ioctl(struct inode *inode, struct file *filep,
if (copy_from_user(&ctrt, argp, sizeof(gdth_ioctl_ctrtype)) || if (copy_from_user(&ctrt, argp, sizeof(gdth_ioctl_ctrtype)) ||
ctrt.ionode >= gdth_ctr_count) ctrt.ionode >= gdth_ctr_count)
return -EFAULT; return -EFAULT;
ha = HADATA(gdth_ctr_tab[ctrt.ionode]); ha = shost_priv(gdth_ctr_tab[ctrt.ionode]);
if (ha->type == GDT_ISA || ha->type == GDT_EISA) { if (ha->type == GDT_ISA || ha->type == GDT_EISA) {
ctrt.type = (unchar)((ha->stype>>20) - 0x10); ctrt.type = (unchar)((ha->stype>>20) - 0x10);
} else { } else {
...@@ -4744,7 +4679,7 @@ static int gdth_ioctl(struct inode *inode, struct file *filep, ...@@ -4744,7 +4679,7 @@ static int gdth_ioctl(struct inode *inode, struct file *filep,
if (copy_from_user(&lchn, argp, sizeof(gdth_ioctl_lockchn)) || if (copy_from_user(&lchn, argp, sizeof(gdth_ioctl_lockchn)) ||
lchn.ionode >= gdth_ctr_count) lchn.ionode >= gdth_ctr_count)
return -EFAULT; return -EFAULT;
ha = HADATA(gdth_ctr_tab[lchn.ionode]); ha = shost_priv(gdth_ctr_tab[lchn.ionode]);
i = lchn.channel; i = lchn.channel;
if (i < ha->bus_cnt) { if (i < ha->bus_cnt) {
...@@ -4753,16 +4688,16 @@ static int gdth_ioctl(struct inode *inode, struct file *filep, ...@@ -4753,16 +4688,16 @@ static int gdth_ioctl(struct inode *inode, struct file *filep,
ha->raw[i].lock = 1; ha->raw[i].lock = 1;
spin_unlock_irqrestore(&ha->smp_lock, flags); spin_unlock_irqrestore(&ha->smp_lock, flags);
for (j = 0; j < ha->tid_cnt; ++j) { for (j = 0; j < ha->tid_cnt; ++j) {
gdth_wait_completion(lchn.ionode, i, j); gdth_wait_completion(ha, i, j);
gdth_stop_timeout(lchn.ionode, i, j); gdth_stop_timeout(ha, i, j);
} }
} else { } else {
spin_lock_irqsave(&ha->smp_lock, flags); spin_lock_irqsave(&ha->smp_lock, flags);
ha->raw[i].lock = 0; ha->raw[i].lock = 0;
spin_unlock_irqrestore(&ha->smp_lock, flags); spin_unlock_irqrestore(&ha->smp_lock, flags);
for (j = 0; j < ha->tid_cnt; ++j) { for (j = 0; j < ha->tid_cnt; ++j) {
gdth_start_timeout(lchn.ionode, i, j); gdth_start_timeout(ha, i, j);
gdth_next(lchn.ionode); gdth_next(ha);
} }
} }
} }
...@@ -4778,13 +4713,12 @@ static int gdth_ioctl(struct inode *inode, struct file *filep, ...@@ -4778,13 +4713,12 @@ static int gdth_ioctl(struct inode *inode, struct file *filep,
case GDTIOCTL_RESET_BUS: case GDTIOCTL_RESET_BUS:
{ {
gdth_ioctl_reset res; gdth_ioctl_reset res;
int hanum, rval; int rval;
if (copy_from_user(&res, argp, sizeof(gdth_ioctl_reset)) || if (copy_from_user(&res, argp, sizeof(gdth_ioctl_reset)) ||
res.ionode >= gdth_ctr_count) res.ionode >= gdth_ctr_count)
return -EFAULT; return -EFAULT;
hanum = res.ionode; ha = shost_priv(gdth_ctr_tab[res.ionode]);
ha = HADATA(gdth_ctr_tab[hanum]);
scp = kzalloc(sizeof(*scp), GFP_KERNEL); scp = kzalloc(sizeof(*scp), GFP_KERNEL);
if (!scp) if (!scp)
...@@ -4813,16 +4747,14 @@ static int gdth_ioctl(struct inode *inode, struct file *filep, ...@@ -4813,16 +4747,14 @@ static int gdth_ioctl(struct inode *inode, struct file *filep,
/* flush routine */ /* flush routine */
static void gdth_flush(int hanum) static void gdth_flush(gdth_ha_str *ha)
{ {
int i; int i;
gdth_ha_str *ha;
gdth_cmd_str gdtcmd; gdth_cmd_str gdtcmd;
char cmnd[MAX_COMMAND_SIZE]; char cmnd[MAX_COMMAND_SIZE];
memset(cmnd, 0xff, MAX_COMMAND_SIZE); memset(cmnd, 0xff, MAX_COMMAND_SIZE);
TRACE2(("gdth_flush() hanum %d\n",hanum)); TRACE2(("gdth_flush() hanum %d\n", ha->hanum));
ha = HADATA(gdth_ctr_tab[hanum]);
for (i = 0; i < MAX_HDRIVES; ++i) { for (i = 0; i < MAX_HDRIVES; ++i) {
if (ha->hdr[i].present) { if (ha->hdr[i].present) {
...@@ -4838,9 +4770,9 @@ static void gdth_flush(int hanum) ...@@ -4838,9 +4770,9 @@ static void gdth_flush(int hanum)
gdtcmd.u.cache.BlockNo = 1; gdtcmd.u.cache.BlockNo = 1;
gdtcmd.u.cache.sg_canz = 0; gdtcmd.u.cache.sg_canz = 0;
} }
TRACE2(("gdth_flush(): flush ha %d drive %d\n", hanum, i)); TRACE2(("gdth_flush(): flush ha %d drive %d\n", ha->hanum, i));
gdth_execute(gdth_ctr_tab[hanum], &gdtcmd, cmnd, 30, NULL); gdth_execute(ha->shost, &gdtcmd, cmnd, 30, NULL);
} }
} }
} }
...@@ -4864,7 +4796,8 @@ static int gdth_halt(struct notifier_block *nb, ulong event, void *buf) ...@@ -4864,7 +4796,8 @@ static int gdth_halt(struct notifier_block *nb, ulong event, void *buf)
notifier_disabled = 1; notifier_disabled = 1;
printk("GDT-HA: Flushing all host drives .. "); printk("GDT-HA: Flushing all host drives .. ");
for (hanum = 0; hanum < gdth_ctr_count; ++hanum) { for (hanum = 0; hanum < gdth_ctr_count; ++hanum) {
gdth_flush(hanum); gdth_ha_str *ha = shost_priv(gdth_ctr_tab[hanum]);
gdth_flush(ha);
#ifndef __alpha__ #ifndef __alpha__
/* controller reset */ /* controller reset */
...@@ -4872,8 +4805,8 @@ static int gdth_halt(struct notifier_block *nb, ulong event, void *buf) ...@@ -4872,8 +4805,8 @@ static int gdth_halt(struct notifier_block *nb, ulong event, void *buf)
gdtcmd.BoardNode = LOCALBOARD; gdtcmd.BoardNode = LOCALBOARD;
gdtcmd.Service = CACHESERVICE; gdtcmd.Service = CACHESERVICE;
gdtcmd.OpCode = GDT_RESET; gdtcmd.OpCode = GDT_RESET;
TRACE2(("gdth_halt(): reset controller %d\n", hanum)); TRACE2(("gdth_halt(): reset controller %d\n", ha->hanum));
gdth_execute(gdth_ctr_tab[hanum], &gdtcmd, cmnd, 10, NULL); gdth_execute(ha->shost, &gdtcmd, cmnd, 10, NULL);
#endif #endif
} }
printk("Done.\n"); printk("Done.\n");
...@@ -4923,10 +4856,10 @@ static int gdth_isa_probe_one(struct scsi_host_template *shtp, ulong32 isa_bios) ...@@ -4923,10 +4856,10 @@ static int gdth_isa_probe_one(struct scsi_host_template *shtp, ulong32 isa_bios)
if (!gdth_search_isa(isa_bios)) if (!gdth_search_isa(isa_bios))
return -ENXIO; return -ENXIO;
shp = scsi_register(shtp, sizeof(gdth_ext_str)); shp = scsi_register(shtp, sizeof(gdth_ha_str));
if (!shp) if (!shp)
return -ENOMEM; return -ENOMEM;
ha = HADATA(shp); ha = shost_priv(shp);
error = -ENODEV; error = -ENODEV;
if (!gdth_init_isa(isa_bios,ha)) if (!gdth_init_isa(isa_bios,ha))
...@@ -4956,9 +4889,10 @@ static int gdth_isa_probe_one(struct scsi_host_template *shtp, ulong32 isa_bios) ...@@ -4956,9 +4889,10 @@ static int gdth_isa_probe_one(struct scsi_host_template *shtp, ulong32 isa_bios)
hanum = gdth_ctr_count; hanum = gdth_ctr_count;
gdth_ctr_tab[gdth_ctr_count++] = shp; gdth_ctr_tab[gdth_ctr_count++] = shp;
NUMDATA(shp)->hanum = (ushort)hanum; ha->hanum = (ushort)hanum;
ha->shost = shp;
ha->pccb = CMDDATA(shp); ha->pccb = &ha->cmdext;
ha->ccb_phys = 0L; ha->ccb_phys = 0L;
ha->pdev = NULL; ha->pdev = NULL;
...@@ -4995,7 +4929,7 @@ static int gdth_isa_probe_one(struct scsi_host_template *shtp, ulong32 isa_bios) ...@@ -4995,7 +4929,7 @@ static int gdth_isa_probe_one(struct scsi_host_template *shtp, ulong32 isa_bios)
ha->scan_mode = rescan ? 0x10 : 0; ha->scan_mode = rescan ? 0x10 : 0;
error = -ENODEV; error = -ENODEV;
if (!gdth_search_drives(hanum)) { if (!gdth_search_drives(ha)) {
printk("GDT-ISA: Error during device scan\n"); printk("GDT-ISA: Error during device scan\n");
goto out_free_coal_stat; goto out_free_coal_stat;
} }
...@@ -5012,7 +4946,7 @@ static int gdth_isa_probe_one(struct scsi_host_template *shtp, ulong32 isa_bios) ...@@ -5012,7 +4946,7 @@ static int gdth_isa_probe_one(struct scsi_host_template *shtp, ulong32 isa_bios)
shp->max_channel = ha->bus_cnt; shp->max_channel = ha->bus_cnt;
spin_lock_init(&ha->smp_lock); spin_lock_init(&ha->smp_lock);
gdth_enable_int(hanum); gdth_enable_int(ha);
return 0; return 0;
...@@ -5049,10 +4983,10 @@ static int gdth_eisa_probe_one(struct scsi_host_template *shtp, ...@@ -5049,10 +4983,10 @@ static int gdth_eisa_probe_one(struct scsi_host_template *shtp,
if (!gdth_search_eisa(eisa_slot)) if (!gdth_search_eisa(eisa_slot))
return -ENXIO; return -ENXIO;
shp = scsi_register(shtp,sizeof(gdth_ext_str)); shp = scsi_register(shtp,sizeof(gdth_ha_str));
if (!shp) if (!shp)
return -ENOMEM; return -ENOMEM;
ha = HADATA(shp); ha = shost_priv(shp);
error = -ENODEV; error = -ENODEV;
if (!gdth_init_eisa(eisa_slot,ha)) if (!gdth_init_eisa(eisa_slot,ha))
...@@ -5074,11 +5008,12 @@ static int gdth_eisa_probe_one(struct scsi_host_template *shtp, ...@@ -5074,11 +5008,12 @@ static int gdth_eisa_probe_one(struct scsi_host_template *shtp,
hanum = gdth_ctr_count; hanum = gdth_ctr_count;
gdth_ctr_tab[gdth_ctr_count++] = shp; gdth_ctr_tab[gdth_ctr_count++] = shp;
NUMDATA(shp)->hanum = (ushort)hanum; ha->hanum = (ushort)hanum;
TRACE2(("EISA detect Bus 0: hanum %d\n", ha->shost = shp;
NUMDATA(shp)->hanum));
TRACE2(("EISA detect Bus 0: hanum %d\n", ha->hanum));
ha->pccb = CMDDATA(shp); ha->pccb = &ha->cmdext;
ha->ccb_phys = 0L; ha->ccb_phys = 0L;
error = -ENOMEM; error = -ENOMEM;
...@@ -5119,7 +5054,7 @@ static int gdth_eisa_probe_one(struct scsi_host_template *shtp, ...@@ -5119,7 +5054,7 @@ static int gdth_eisa_probe_one(struct scsi_host_template *shtp,
ha->cmd_tab[i].cmnd = UNUSED_CMND; ha->cmd_tab[i].cmnd = UNUSED_CMND;
ha->scan_mode = rescan ? 0x10 : 0; ha->scan_mode = rescan ? 0x10 : 0;
if (!gdth_search_drives(hanum)) { if (!gdth_search_drives(ha)) {
printk("GDT-EISA: Error during device scan\n"); printk("GDT-EISA: Error during device scan\n");
error = -ENODEV; error = -ENODEV;
goto out_free_ccb_phys; goto out_free_ccb_phys;
...@@ -5137,7 +5072,7 @@ static int gdth_eisa_probe_one(struct scsi_host_template *shtp, ...@@ -5137,7 +5072,7 @@ static int gdth_eisa_probe_one(struct scsi_host_template *shtp,
shp->max_channel = ha->bus_cnt; shp->max_channel = ha->bus_cnt;
spin_lock_init(&ha->smp_lock); spin_lock_init(&ha->smp_lock);
gdth_enable_int(hanum); gdth_enable_int(ha);
return 0; return 0;
out_free_ccb_phys: out_free_ccb_phys:
...@@ -5172,10 +5107,10 @@ static int gdth_pci_probe_one(struct scsi_host_template *shtp, ...@@ -5172,10 +5107,10 @@ static int gdth_pci_probe_one(struct scsi_host_template *shtp,
dma_addr_t scratch_dma_handle = 0; dma_addr_t scratch_dma_handle = 0;
int error, hanum, i; int error, hanum, i;
shp = scsi_register(shtp,sizeof(gdth_ext_str)); shp = scsi_register(shtp,sizeof(gdth_ha_str));
if (!shp) if (!shp)
return -ENOMEM; return -ENOMEM;
ha = HADATA(shp); ha = shost_priv(shp);
error = -ENODEV; error = -ENODEV;
if (!gdth_init_pci(&pcistr[ctr],ha)) if (!gdth_init_pci(&pcistr[ctr],ha))
...@@ -5200,9 +5135,10 @@ static int gdth_pci_probe_one(struct scsi_host_template *shtp, ...@@ -5200,9 +5135,10 @@ static int gdth_pci_probe_one(struct scsi_host_template *shtp,
hanum = gdth_ctr_count; hanum = gdth_ctr_count;
gdth_ctr_tab[gdth_ctr_count++] = shp; gdth_ctr_tab[gdth_ctr_count++] = shp;
NUMDATA(shp)->hanum = (ushort)hanum; ha->hanum = (ushort)hanum;
ha->shost = shp;
ha->pccb = CMDDATA(shp); ha->pccb = &ha->cmdext;
ha->ccb_phys = 0L; ha->ccb_phys = 0L;
error = -ENOMEM; error = -ENOMEM;
...@@ -5238,8 +5174,8 @@ static int gdth_pci_probe_one(struct scsi_host_template *shtp, ...@@ -5238,8 +5174,8 @@ static int gdth_pci_probe_one(struct scsi_host_template *shtp,
ha->scan_mode = rescan ? 0x10 : 0; ha->scan_mode = rescan ? 0x10 : 0;
error = -ENODEV; error = -ENODEV;
if (!gdth_search_drives(hanum)) { if (!gdth_search_drives(ha)) {
printk("GDT-PCI %d: Error during device scan\n", hanum); printk("GDT-PCI %d: Error during device scan\n", ha->hanum);
goto out_free_coal_stat; goto out_free_coal_stat;
} }
...@@ -5252,16 +5188,16 @@ static int gdth_pci_probe_one(struct scsi_host_template *shtp, ...@@ -5252,16 +5188,16 @@ static int gdth_pci_probe_one(struct scsi_host_template *shtp,
!ha->dma64_support) { !ha->dma64_support) {
if (pci_set_dma_mask(pcistr[ctr].pdev, DMA_32BIT_MASK)) { if (pci_set_dma_mask(pcistr[ctr].pdev, DMA_32BIT_MASK)) {
printk(KERN_WARNING "GDT-PCI %d: " printk(KERN_WARNING "GDT-PCI %d: "
"Unable to set 32-bit DMA\n", hanum); "Unable to set 32-bit DMA\n", ha->hanum);
goto out_free_coal_stat; goto out_free_coal_stat;
} }
} else { } else {
shp->max_cmd_len = 16; shp->max_cmd_len = 16;
if (!pci_set_dma_mask(pcistr[ctr].pdev, DMA_64BIT_MASK)) { if (!pci_set_dma_mask(pcistr[ctr].pdev, DMA_64BIT_MASK)) {
printk("GDT-PCI %d: 64-bit DMA enabled\n", hanum); printk("GDT-PCI %d: 64-bit DMA enabled\n", ha->hanum);
} else if (pci_set_dma_mask(pcistr[ctr].pdev, DMA_32BIT_MASK)) { } else if (pci_set_dma_mask(pcistr[ctr].pdev, DMA_32BIT_MASK)) {
printk(KERN_WARNING "GDT-PCI %d: " printk(KERN_WARNING "GDT-PCI %d: "
"Unable to set 64/32-bit DMA\n", hanum); "Unable to set 64/32-bit DMA\n", ha->hanum);
goto out_free_coal_stat; goto out_free_coal_stat;
} }
} }
...@@ -5271,7 +5207,7 @@ static int gdth_pci_probe_one(struct scsi_host_template *shtp, ...@@ -5271,7 +5207,7 @@ static int gdth_pci_probe_one(struct scsi_host_template *shtp,
shp->max_channel = ha->bus_cnt; shp->max_channel = ha->bus_cnt;
spin_lock_init(&ha->smp_lock); spin_lock_init(&ha->smp_lock);
gdth_enable_int(hanum); gdth_enable_int(ha);
return 0; return 0;
out_free_coal_stat: out_free_coal_stat:
......
...@@ -853,6 +853,8 @@ typedef struct { ...@@ -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 { ...@@ -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 { ...@@ -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;
......
...@@ -7,31 +7,29 @@ ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length, ...@@ -668,17 +662,15 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
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, ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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;
......
...@@ -9,20 +9,20 @@ int gdth_execute(struct Scsi_Host *shost, gdth_cmd_str *gdtcmd, char *cmnd, ...@@ -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
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