aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/gdth_proc.c
diff options
context:
space:
mode:
authorBoaz Harrosh <bharrosh@panasas.com>2007-10-02 17:05:53 -0400
committerJames Bottomley <jejb@mulgrave.localdomain>2007-10-12 14:55:46 -0400
commit45f1a41b2b2e02e91d29bde66a8da4d050959f65 (patch)
tree6515b852df3f5cdb090c5604af9bd38fee4a2816 /drivers/scsi/gdth_proc.c
parent52759e6abc88fe007a080772ee01ef1154f96f30 (diff)
[SCSI] gdth: clean up host private data
- Based on same patch from Christoph Hellwig <hch@lst.de> - Get rid of all the indirection in the Scsi_Host private data and always put the gdth_ha_str directly into it. - Change all internal functions prototype to recieve an "gdth_ha_str *ha" pointer directlly and kill all that redundent access to the "gdth_ctr_tab[]" controller-table. Signed-off-by: Boaz Harrosh <bharrosh@panasas.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/gdth_proc.c')
-rw-r--r--drivers/scsi/gdth_proc.c80
1 files changed, 31 insertions, 49 deletions
diff --git a/drivers/scsi/gdth_proc.c b/drivers/scsi/gdth_proc.c
index b060bd6ffe17..fe070ab991a0 100644
--- a/drivers/scsi/gdth_proc.c
+++ b/drivers/scsi/gdth_proc.c
@@ -7,31 +7,29 @@
7int gdth_proc_info(struct Scsi_Host *host, char *buffer,char **start,off_t offset,int length, 7int gdth_proc_info(struct Scsi_Host *host, char *buffer,char **start,off_t offset,int length,
8 int inout) 8 int inout)
9{ 9{
10 int hanum; 10 gdth_ha_str *ha = shost_priv(host);
11 11
12 TRACE2(("gdth_proc_info() length %d offs %d inout %d\n", 12 TRACE2(("gdth_proc_info() length %d offs %d inout %d\n",
13 length,(int)offset,inout)); 13 length,(int)offset,inout));
14 14
15 hanum = NUMDATA(host)->hanum;
16
17 if (inout) 15 if (inout)
18 return(gdth_set_info(buffer,length,host,hanum)); 16 return(gdth_set_info(buffer,length,host,ha));
19 else 17 else
20 return(gdth_get_info(buffer,start,offset,length,host,hanum)); 18 return(gdth_get_info(buffer,start,offset,length,host,ha));
21} 19}
22 20
23static int gdth_set_info(char *buffer,int length,struct Scsi_Host *host, 21static int gdth_set_info(char *buffer,int length,struct Scsi_Host *host,
24 int hanum) 22 gdth_ha_str *ha)
25{ 23{
26 int ret_val = -EINVAL; 24 int ret_val = -EINVAL;
27 25
28 TRACE2(("gdth_set_info() ha %d\n",hanum,)); 26 TRACE2(("gdth_set_info() ha %d\n",ha->hanum,));
29 27
30 if (length >= 4) { 28 if (length >= 4) {
31 if (strncmp(buffer,"gdth",4) == 0) { 29 if (strncmp(buffer,"gdth",4) == 0) {
32 buffer += 5; 30 buffer += 5;
33 length -= 5; 31 length -= 5;
34 ret_val = gdth_set_asc_info(host, buffer, length, hanum); 32 ret_val = gdth_set_asc_info(host, buffer, length, ha);
35 } 33 }
36 } 34 }
37 35
@@ -39,11 +37,10 @@ static int gdth_set_info(char *buffer,int length,struct Scsi_Host *host,
39} 37}
40 38
41static int gdth_set_asc_info(struct Scsi_Host *host, char *buffer, 39static int gdth_set_asc_info(struct Scsi_Host *host, char *buffer,
42 int length,int hanum) 40 int length, gdth_ha_str *ha)
43{ 41{
44 int orig_length, drive, wb_mode; 42 int orig_length, drive, wb_mode;
45 int i, found; 43 int i, found;
46 gdth_ha_str *ha;
47 gdth_cmd_str gdtcmd; 44 gdth_cmd_str gdtcmd;
48 gdth_cpar_str *pcpar; 45 gdth_cpar_str *pcpar;
49 ulong64 paddr; 46 ulong64 paddr;
@@ -52,8 +49,7 @@ static int gdth_set_asc_info(struct Scsi_Host *host, char *buffer,
52 memset(cmnd, 0xff, 12); 49 memset(cmnd, 0xff, 12);
53 memset(&gdtcmd, 0, sizeof(gdth_cmd_str)); 50 memset(&gdtcmd, 0, sizeof(gdth_cmd_str));
54 51
55 TRACE2(("gdth_set_asc_info() ha %d\n",hanum)); 52 TRACE2(("gdth_set_asc_info() ha %d\n",ha->hanum));
56 ha = HADATA(gdth_ctr_tab[hanum]);
57 orig_length = length + 5; 53 orig_length = length + 5;
58 drive = -1; 54 drive = -1;
59 wb_mode = 0; 55 wb_mode = 0;
@@ -129,7 +125,7 @@ static int gdth_set_asc_info(struct Scsi_Host *host, char *buffer,
129 } 125 }
130 126
131 if (wb_mode) { 127 if (wb_mode) {
132 if (!gdth_ioctl_alloc(hanum, sizeof(gdth_cpar_str), TRUE, &paddr)) 128 if (!gdth_ioctl_alloc(ha, sizeof(gdth_cpar_str), TRUE, &paddr))
133 return(-EBUSY); 129 return(-EBUSY);
134 pcpar = (gdth_cpar_str *)ha->pscratch; 130 pcpar = (gdth_cpar_str *)ha->pscratch;
135 memcpy( pcpar, &ha->cpar, sizeof(gdth_cpar_str) ); 131 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 139
144 gdth_execute(host, &gdtcmd, cmnd, 30, NULL); 140 gdth_execute(host, &gdtcmd, cmnd, 30, NULL);
145 141
146 gdth_ioctl_free(hanum, GDTH_SCRATCH, ha->pscratch, paddr); 142 gdth_ioctl_free(ha, GDTH_SCRATCH, ha->pscratch, paddr);
147 printk("Done.\n"); 143 printk("Done.\n");
148 return(orig_length); 144 return(orig_length);
149 } 145 }
@@ -153,11 +149,10 @@ static int gdth_set_asc_info(struct Scsi_Host *host, char *buffer,
153} 149}
154 150
155static int gdth_get_info(char *buffer,char **start,off_t offset,int length, 151static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
156 struct Scsi_Host *host,int hanum) 152 struct Scsi_Host *host, gdth_ha_str *ha)
157{ 153{
158 int size = 0,len = 0; 154 int size = 0,len = 0;
159 off_t begin = 0,pos = 0; 155 off_t begin = 0,pos = 0;
160 gdth_ha_str *ha;
161 int id, i, j, k, sec, flag; 156 int id, i, j, k, sec, flag;
162 int no_mdrv = 0, drv_no, is_mirr; 157 int no_mdrv = 0, drv_no, is_mirr;
163 ulong32 cnt; 158 ulong32 cnt;
@@ -186,8 +181,7 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
186 memset(cmnd, 0xff, 12); 181 memset(cmnd, 0xff, 12);
187 memset(gdtcmd, 0, sizeof(gdth_cmd_str)); 182 memset(gdtcmd, 0, sizeof(gdth_cmd_str));
188 183
189 TRACE2(("gdth_get_info() ha %d\n",hanum)); 184 TRACE2(("gdth_get_info() ha %d\n",ha->hanum));
190 ha = HADATA(gdth_ctr_tab[hanum]);
191 185
192 186
193 /* request is i.e. "cat /proc/scsi/gdth/0" */ 187 /* 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 strcpy(hrec, ha->binfo.type_string); 214 strcpy(hrec, ha->binfo.type_string);
221 size = sprintf(buffer+len, 215 size = sprintf(buffer+len,
222 " Number: \t%d \tName: \t%s\n", 216 " Number: \t%d \tName: \t%s\n",
223 hanum, hrec); 217 ha->hanum, hrec);
224 len += size; pos = begin + len; 218 len += size; pos = begin + len;
225 219
226 if (ha->more_proc) 220 if (ha->more_proc)
@@ -270,7 +264,7 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
270 len += size; pos = begin + len; 264 len += size; pos = begin + len;
271 flag = FALSE; 265 flag = FALSE;
272 266
273 buf = gdth_ioctl_alloc(hanum, GDTH_SCRATCH, FALSE, &paddr); 267 buf = gdth_ioctl_alloc(ha, GDTH_SCRATCH, FALSE, &paddr);
274 if (!buf) 268 if (!buf)
275 goto stop_output; 269 goto stop_output;
276 for (i = 0; i < ha->bus_cnt; ++i) { 270 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 goto stop_output; 367 goto stop_output;
374 } 368 }
375 } 369 }
376 gdth_ioctl_free(hanum, GDTH_SCRATCH, buf, paddr); 370 gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr);
377 371
378 if (!flag) { 372 if (!flag) {
379 size = sprintf(buffer+len, "\n --\n"); 373 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 len += size; pos = begin + len; 379 len += size; pos = begin + len;
386 flag = FALSE; 380 flag = FALSE;
387 381
388 buf = gdth_ioctl_alloc(hanum, GDTH_SCRATCH, FALSE, &paddr); 382 buf = gdth_ioctl_alloc(ha, GDTH_SCRATCH, FALSE, &paddr);
389 if (!buf) 383 if (!buf)
390 goto stop_output; 384 goto stop_output;
391 for (i = 0; i < MAX_LDRIVES; ++i) { 385 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 if (pos > offset + length) 473 if (pos > offset + length)
480 goto stop_output; 474 goto stop_output;
481 } 475 }
482 gdth_ioctl_free(hanum, GDTH_SCRATCH, buf, paddr); 476 gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr);
483 477
484 if (!flag) { 478 if (!flag) {
485 size = sprintf(buffer+len, "\n --\n"); 479 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 len += size; pos = begin + len; 485 len += size; pos = begin + len;
492 flag = FALSE; 486 flag = FALSE;
493 487
494 buf = gdth_ioctl_alloc(hanum, GDTH_SCRATCH, FALSE, &paddr); 488 buf = gdth_ioctl_alloc(ha, GDTH_SCRATCH, FALSE, &paddr);
495 if (!buf) 489 if (!buf)
496 goto stop_output; 490 goto stop_output;
497 for (i = 0; i < MAX_LDRIVES; ++i) { 491 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 goto stop_output; 544 goto stop_output;
551 } 545 }
552 } 546 }
553 gdth_ioctl_free(hanum, GDTH_SCRATCH, buf, paddr); 547 gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr);
554 548
555 if (!flag) { 549 if (!flag) {
556 size = sprintf(buffer+len, "\n --\n"); 550 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 len += size; pos = begin + len; 556 len += size; pos = begin + len;
563 flag = FALSE; 557 flag = FALSE;
564 558
565 buf = gdth_ioctl_alloc(hanum, sizeof(gdth_hget_str), FALSE, &paddr); 559 buf = gdth_ioctl_alloc(ha, sizeof(gdth_hget_str), FALSE, &paddr);
566 if (!buf) 560 if (!buf)
567 goto stop_output; 561 goto stop_output;
568 for (i = 0; i < MAX_LDRIVES; ++i) { 562 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 } 589 }
596 } 590 }
597 } 591 }
598 gdth_ioctl_free(hanum, sizeof(gdth_hget_str), buf, paddr); 592 gdth_ioctl_free(ha, sizeof(gdth_hget_str), buf, paddr);
599 593
600 for (i = 0; i < MAX_HDRIVES; ++i) { 594 for (i = 0; i < MAX_HDRIVES; ++i) {
601 if (!(ha->hdr[i].present)) 595 if (!(ha->hdr[i].present))
@@ -633,7 +627,7 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
633 id = gdth_read_event(ha, id, estr); 627 id = gdth_read_event(ha, id, estr);
634 if (estr->event_source == 0) 628 if (estr->event_source == 0)
635 break; 629 break;
636 if (estr->event_data.eu.driver.ionode == hanum && 630 if (estr->event_data.eu.driver.ionode == ha->hanum &&
637 estr->event_source == ES_ASYNC) { 631 estr->event_source == ES_ASYNC) {
638 gdth_log_event(&estr->event_data, hrec); 632 gdth_log_event(&estr->event_data, hrec);
639 do_gettimeofday(&tv); 633 do_gettimeofday(&tv);
@@ -668,17 +662,15 @@ free_fail:
668 return rc; 662 return rc;
669} 663}
670 664
671static char *gdth_ioctl_alloc(int hanum, int size, int scratch, 665static char *gdth_ioctl_alloc(gdth_ha_str *ha, int size, int scratch,
672 ulong64 *paddr) 666 ulong64 *paddr)
673{ 667{
674 gdth_ha_str *ha;
675 ulong flags; 668 ulong flags;
676 char *ret_val; 669 char *ret_val;
677 670
678 if (size == 0) 671 if (size == 0)
679 return NULL; 672 return NULL;
680 673
681 ha = HADATA(gdth_ctr_tab[hanum]);
682 spin_lock_irqsave(&ha->smp_lock, flags); 674 spin_lock_irqsave(&ha->smp_lock, flags);
683 675
684 if (!ha->scratch_busy && size <= GDTH_SCRATCH) { 676 if (!ha->scratch_busy && size <= GDTH_SCRATCH) {
@@ -698,12 +690,10 @@ static char *gdth_ioctl_alloc(int hanum, int size, int scratch,
698 return ret_val; 690 return ret_val;
699} 691}
700 692
701static void gdth_ioctl_free(int hanum, int size, char *buf, ulong64 paddr) 693static void gdth_ioctl_free(gdth_ha_str *ha, int size, char *buf, ulong64 paddr)
702{ 694{
703 gdth_ha_str *ha;
704 ulong flags; 695 ulong flags;
705 696
706 ha = HADATA(gdth_ctr_tab[hanum]);
707 spin_lock_irqsave(&ha->smp_lock, flags); 697 spin_lock_irqsave(&ha->smp_lock, flags);
708 698
709 if (buf == ha->pscratch) { 699 if (buf == ha->pscratch) {
@@ -716,13 +706,11 @@ static void gdth_ioctl_free(int hanum, int size, char *buf, ulong64 paddr)
716} 706}
717 707
718#ifdef GDTH_IOCTL_PROC 708#ifdef GDTH_IOCTL_PROC
719static int gdth_ioctl_check_bin(int hanum, ushort size) 709static int gdth_ioctl_check_bin(gdth_ha_str *ha, ushort size)
720{ 710{
721 gdth_ha_str *ha;
722 ulong flags; 711 ulong flags;
723 int ret_val; 712 int ret_val;
724 713
725 ha = HADATA(gdth_ctr_tab[hanum]);
726 spin_lock_irqsave(&ha->smp_lock, flags); 714 spin_lock_irqsave(&ha->smp_lock, flags);
727 715
728 ret_val = FALSE; 716 ret_val = FALSE;
@@ -735,15 +723,13 @@ static int gdth_ioctl_check_bin(int hanum, ushort size)
735} 723}
736#endif 724#endif
737 725
738static void gdth_wait_completion(int hanum, int busnum, int id) 726static void gdth_wait_completion(gdth_ha_str *ha, int busnum, int id)
739{ 727{
740 gdth_ha_str *ha;
741 ulong flags; 728 ulong flags;
742 int i; 729 int i;
743 Scsi_Cmnd *scp; 730 Scsi_Cmnd *scp;
744 unchar b, t; 731 unchar b, t;
745 732
746 ha = HADATA(gdth_ctr_tab[hanum]);
747 spin_lock_irqsave(&ha->smp_lock, flags); 733 spin_lock_irqsave(&ha->smp_lock, flags);
748 734
749 for (i = 0; i < GDTH_MAXCMDS; ++i) { 735 for (i = 0; i < GDTH_MAXCMDS; ++i) {
@@ -763,14 +749,12 @@ static void gdth_wait_completion(int hanum, int busnum, int id)
763 spin_unlock_irqrestore(&ha->smp_lock, flags); 749 spin_unlock_irqrestore(&ha->smp_lock, flags);
764} 750}
765 751
766static void gdth_stop_timeout(int hanum, int busnum, int id) 752static void gdth_stop_timeout(gdth_ha_str *ha, int busnum, int id)
767{ 753{
768 gdth_ha_str *ha;
769 ulong flags; 754 ulong flags;
770 Scsi_Cmnd *scp; 755 Scsi_Cmnd *scp;
771 unchar b, t; 756 unchar b, t;
772 757
773 ha = HADATA(gdth_ctr_tab[hanum]);
774 spin_lock_irqsave(&ha->smp_lock, flags); 758 spin_lock_irqsave(&ha->smp_lock, flags);
775 759
776 for (scp = ha->req_first; scp; scp = (Scsi_Cmnd *)scp->SCp.ptr) { 760 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 t = scp->device->id; 763 t = scp->device->id;
780 if (t == (unchar)id && b == (unchar)busnum) { 764 if (t == (unchar)id && b == (unchar)busnum) {
781 TRACE2(("gdth_stop_timeout(): update_timeout()\n")); 765 TRACE2(("gdth_stop_timeout(): update_timeout()\n"));
782 scp->SCp.buffers_residual = gdth_update_timeout(hanum, scp, 0); 766 scp->SCp.buffers_residual = gdth_update_timeout(scp, 0);
783 } 767 }
784 } 768 }
785 } 769 }
786 spin_unlock_irqrestore(&ha->smp_lock, flags); 770 spin_unlock_irqrestore(&ha->smp_lock, flags);
787} 771}
788 772
789static void gdth_start_timeout(int hanum, int busnum, int id) 773static void gdth_start_timeout(gdth_ha_str *ha, int busnum, int id)
790{ 774{
791 gdth_ha_str *ha;
792 ulong flags; 775 ulong flags;
793 Scsi_Cmnd *scp; 776 Scsi_Cmnd *scp;
794 unchar b, t; 777 unchar b, t;
795 778
796 ha = HADATA(gdth_ctr_tab[hanum]);
797 spin_lock_irqsave(&ha->smp_lock, flags); 779 spin_lock_irqsave(&ha->smp_lock, flags);
798 780
799 for (scp = ha->req_first; scp; scp = (Scsi_Cmnd *)scp->SCp.ptr) { 781 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 t = scp->device->id; 784 t = scp->device->id;
803 if (t == (unchar)id && b == (unchar)busnum) { 785 if (t == (unchar)id && b == (unchar)busnum) {
804 TRACE2(("gdth_start_timeout(): update_timeout()\n")); 786 TRACE2(("gdth_start_timeout(): update_timeout()\n"));
805 gdth_update_timeout(hanum, scp, scp->SCp.buffers_residual); 787 gdth_update_timeout(scp, scp->SCp.buffers_residual);
806 } 788 }
807 } 789 }
808 } 790 }
809 spin_unlock_irqrestore(&ha->smp_lock, flags); 791 spin_unlock_irqrestore(&ha->smp_lock, flags);
810} 792}
811 793
812static int gdth_update_timeout(int hanum, Scsi_Cmnd *scp, int timeout) 794static int gdth_update_timeout(Scsi_Cmnd *scp, int timeout)
813{ 795{
814 int oldto; 796 int oldto;
815 797