aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/gdth_proc.c
diff options
context:
space:
mode:
authorLeubner, Achim <Achim_Leubner@adaptec.com>2006-06-09 14:34:29 -0400
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>2006-06-10 11:24:40 -0400
commitcbd5f69b98bb5d7a0d207230bcf8fa51fca3f3cf (patch)
treef828a83b0e8006316b6b7a61819f4ef4ce6eac04 /drivers/scsi/gdth_proc.c
parent5d5ff44fe6775ccb922fd1f7d478b2ba9ca95068 (diff)
[SCSI] remove the scsi_request interface from the gdth driver
Initial pass at converting the gdth driver away from the scsi_request interface so that the request interface can be removed post 2.6.18 without breaking gdth. Based on changes from Christoph Hellwig <hch@lst.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/gdth_proc.c')
-rw-r--r--drivers/scsi/gdth_proc.c245
1 files changed, 40 insertions, 205 deletions
diff --git a/drivers/scsi/gdth_proc.c b/drivers/scsi/gdth_proc.c
index 5e8657f9cdf6..32982eb75c84 100644
--- a/drivers/scsi/gdth_proc.c
+++ b/drivers/scsi/gdth_proc.c
@@ -1,5 +1,5 @@
1/* gdth_proc.c 1/* gdth_proc.c
2 * $Id: gdth_proc.c,v 1.42 2004/03/05 15:50:20 achim Exp $ 2 * $Id: gdth_proc.c,v 1.43 2006/01/11 16:15:00 achim Exp $
3 */ 3 */
4 4
5#include <linux/completion.h> 5#include <linux/completion.h>
@@ -51,57 +51,26 @@ int gdth_proc_info(char *buffer,char **start,off_t offset,int length,int hostno,
51static int gdth_set_info(char *buffer,int length,struct Scsi_Host *host, 51static int gdth_set_info(char *buffer,int length,struct Scsi_Host *host,
52 int hanum,int busnum) 52 int hanum,int busnum)
53{ 53{
54 int ret_val = -EINVAL; 54 int ret_val = -EINVAL;
55#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
56 Scsi_Request *scp;
57 struct scsi_device *sdev;
58#else
59 Scsi_Cmnd *scp;
60 struct scsi_device *sdev;
61#endif
62 TRACE2(("gdth_set_info() ha %d bus %d\n",hanum,busnum));
63 55
64#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 56 TRACE2(("gdth_set_info() ha %d bus %d\n",hanum,busnum));
65 sdev = scsi_get_host_dev(host);
66 scp = scsi_allocate_request(sdev, GFP_KERNEL);
67 if (!scp)
68 return -ENOMEM;
69 scp->sr_cmd_len = 12;
70 scp->sr_use_sg = 0;
71#else
72 sdev = scsi_get_host_dev(host);
73 scp = scsi_allocate_device(sdev, 1, FALSE);
74 if (!scp)
75 return -ENOMEM;
76 scp->cmd_len = 12;
77 scp->use_sg = 0;
78#endif
79 57
80 if (length >= 4) { 58 if (length >= 4) {
81 if (strncmp(buffer,"gdth",4) == 0) { 59 if (strncmp(buffer,"gdth",4) == 0) {
82 buffer += 5; 60 buffer += 5;
83 length -= 5; 61 length -= 5;
84 ret_val = gdth_set_asc_info( buffer, length, hanum, scp ); 62 ret_val = gdth_set_asc_info(host, buffer, length, hanum);
85 } 63 }
86 } 64 }
87#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 65
88 scsi_release_request(scp);
89 scsi_free_host_dev(sdev);
90#else
91 scsi_release_command(scp);
92 scsi_free_host_dev(sdev);
93#endif
94 return ret_val; 66 return ret_val;
95} 67}
96 68
97#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 69static int gdth_set_asc_info(struct Scsi_Host *host, char *buffer,
98static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Request *scp) 70 int length,int hanum)
99#else
100static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Cmnd *scp)
101#endif
102{ 71{
103 int orig_length, drive, wb_mode; 72 int orig_length, drive, wb_mode;
104 int i, found; 73 int i, found;
105 gdth_ha_str *ha; 74 gdth_ha_str *ha;
106 gdth_cmd_str gdtcmd; 75 gdth_cmd_str gdtcmd;
107 gdth_cpar_str *pcpar; 76 gdth_cpar_str *pcpar;
@@ -146,11 +115,8 @@ static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Cmnd *scp)
146 gdtcmd.u.cache.DeviceNo = i; 115 gdtcmd.u.cache.DeviceNo = i;
147 gdtcmd.u.cache.BlockNo = 1; 116 gdtcmd.u.cache.BlockNo = 1;
148 } 117 }
149#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 118
150 gdth_do_req(scp, &gdtcmd, cmnd, 30); 119 gdth_execute(host, &gdtcmd, cmnd, 30, NULL);
151#else
152 gdth_do_cmd(scp, &gdtcmd, cmnd, 30);
153#endif
154 } 120 }
155 } 121 }
156 if (!found) 122 if (!found)
@@ -202,11 +168,9 @@ static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Cmnd *scp)
202 gdtcmd.u.ioctl.subfunc = CACHE_CONFIG; 168 gdtcmd.u.ioctl.subfunc = CACHE_CONFIG;
203 gdtcmd.u.ioctl.channel = INVALID_CHANNEL; 169 gdtcmd.u.ioctl.channel = INVALID_CHANNEL;
204 pcpar->write_back = wb_mode==1 ? 0:1; 170 pcpar->write_back = wb_mode==1 ? 0:1;
205#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 171
206 gdth_do_req(scp, &gdtcmd, cmnd, 30); 172 gdth_execute(host, &gdtcmd, cmnd, 30, NULL);
207#else 173
208 gdth_do_cmd(scp, &gdtcmd, cmnd, 30);
209#endif
210 gdth_ioctl_free(hanum, GDTH_SCRATCH, ha->pscratch, paddr); 174 gdth_ioctl_free(hanum, GDTH_SCRATCH, ha->pscratch, paddr);
211 printk("Done.\n"); 175 printk("Done.\n");
212 return(orig_length); 176 return(orig_length);
@@ -230,13 +194,6 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
230 194
231 gdth_cmd_str *gdtcmd; 195 gdth_cmd_str *gdtcmd;
232 gdth_evt_str *estr; 196 gdth_evt_str *estr;
233#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
234 Scsi_Request *scp;
235 struct scsi_device *sdev;
236#else
237 Scsi_Cmnd *scp;
238 struct scsi_device *sdev;
239#endif
240 char hrec[161]; 197 char hrec[161];
241 struct timeval tv; 198 struct timeval tv;
242 199
@@ -252,7 +209,7 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
252 gdtcmd = kmalloc(sizeof(*gdtcmd), GFP_KERNEL); 209 gdtcmd = kmalloc(sizeof(*gdtcmd), GFP_KERNEL);
253 estr = kmalloc(sizeof(*estr), GFP_KERNEL); 210 estr = kmalloc(sizeof(*estr), GFP_KERNEL);
254 if (!gdtcmd || !estr) 211 if (!gdtcmd || !estr)
255 goto free_fail; 212 goto free_fail;
256 213
257 memset(cmnd, 0xff, 12); 214 memset(cmnd, 0xff, 12);
258 memset(gdtcmd, 0, sizeof(gdth_cmd_str)); 215 memset(gdtcmd, 0, sizeof(gdth_cmd_str));
@@ -260,28 +217,6 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
260 TRACE2(("gdth_get_info() ha %d bus %d\n",hanum,busnum)); 217 TRACE2(("gdth_get_info() ha %d bus %d\n",hanum,busnum));
261 ha = HADATA(gdth_ctr_tab[hanum]); 218 ha = HADATA(gdth_ctr_tab[hanum]);
262 219
263#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
264 sdev = scsi_get_host_dev(host);
265 scp = scsi_allocate_request(sdev, GFP_KERNEL);
266 if (!scp)
267 goto free_fail;
268 scp->sr_cmd_len = 12;
269 scp->sr_use_sg = 0;
270#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
271 sdev = scsi_get_host_dev(host);
272 scp = scsi_allocate_device(sdev, 1, FALSE);
273 if (!scp)
274 goto free_fail;
275 scp->cmd_len = 12;
276 scp->use_sg = 0;
277#else
278 memset(&sdev,0,sizeof(struct scsi_device));
279 memset(&scp, 0,sizeof(Scsi_Cmnd));
280 sdev.host = scp.host = host;
281 sdev.id = scp.target = sdev.host->this_id;
282 scp.device = &sdev;
283#endif
284
285 220
286 /* request is i.e. "cat /proc/scsi/gdth/0" */ 221 /* request is i.e. "cat /proc/scsi/gdth/0" */
287 /* format: %-15s\t%-10s\t%-15s\t%s */ 222 /* format: %-15s\t%-10s\t%-15s\t%s */
@@ -386,16 +321,9 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
386 sizeof(pds->list[0]); 321 sizeof(pds->list[0]);
387 if (pds->entries > cnt) 322 if (pds->entries > cnt)
388 pds->entries = cnt; 323 pds->entries = cnt;
389#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 324
390 gdth_do_req(scp, gdtcmd, cmnd, 30); 325 if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) != S_OK)
391 if (scp->sr_command->SCp.Status != S_OK)
392#else
393 gdth_do_cmd(scp, gdtcmd, cmnd, 30);
394 if (scp->SCp.Status != S_OK)
395#endif
396 {
397 pds->count = 0; 326 pds->count = 0;
398 }
399 327
400 /* other IOCTLs must fit into area GDTH_SCRATCH/4 */ 328 /* other IOCTLs must fit into area GDTH_SCRATCH/4 */
401 for (j = 0; j < ha->raw[i].pdev_cnt; ++j) { 329 for (j = 0; j < ha->raw[i].pdev_cnt; ++j) {
@@ -410,14 +338,8 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
410 gdtcmd->u.ioctl.subfunc = SCSI_DR_INFO | L_CTRL_PATTERN; 338 gdtcmd->u.ioctl.subfunc = SCSI_DR_INFO | L_CTRL_PATTERN;
411 gdtcmd->u.ioctl.channel = 339 gdtcmd->u.ioctl.channel =
412 ha->raw[i].address | ha->raw[i].id_list[j]; 340 ha->raw[i].address | ha->raw[i].id_list[j];
413#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 341
414 gdth_do_req(scp, gdtcmd, cmnd, 30); 342 if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) == S_OK) {
415 if (scp->sr_command->SCp.Status == S_OK)
416#else
417 gdth_do_cmd(scp, gdtcmd, cmnd, 30);
418 if (scp->SCp.Status == S_OK)
419#endif
420 {
421 strncpy(hrec,pdi->vendor,8); 343 strncpy(hrec,pdi->vendor,8);
422 strncpy(hrec+8,pdi->product,16); 344 strncpy(hrec+8,pdi->product,16);
423 strncpy(hrec+24,pdi->revision,4); 345 strncpy(hrec+24,pdi->revision,4);
@@ -466,14 +388,8 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
466 gdtcmd->u.ioctl.channel = 388 gdtcmd->u.ioctl.channel =
467 ha->raw[i].address | ha->raw[i].id_list[j]; 389 ha->raw[i].address | ha->raw[i].id_list[j];
468 pdef->sddc_type = 0x08; 390 pdef->sddc_type = 0x08;
469#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 391
470 gdth_do_req(scp, gdtcmd, cmnd, 30); 392 if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) == S_OK) {
471 if (scp->sr_command->SCp.Status == S_OK)
472#else
473 gdth_do_cmd(scp, gdtcmd, cmnd, 30);
474 if (scp->SCp.Status == S_OK)
475#endif
476 {
477 size = sprintf(buffer+len, 393 size = sprintf(buffer+len,
478 " Grown Defects:\t%d\n", 394 " Grown Defects:\t%d\n",
479 pdef->sddc_cnt); 395 pdef->sddc_cnt);
@@ -519,16 +435,8 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
519 gdtcmd->u.ioctl.param_size = sizeof(gdth_cdrinfo_str); 435 gdtcmd->u.ioctl.param_size = sizeof(gdth_cdrinfo_str);
520 gdtcmd->u.ioctl.subfunc = CACHE_DRV_INFO; 436 gdtcmd->u.ioctl.subfunc = CACHE_DRV_INFO;
521 gdtcmd->u.ioctl.channel = drv_no; 437 gdtcmd->u.ioctl.channel = drv_no;
522#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 438 if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) != S_OK)
523 gdth_do_req(scp, gdtcmd, cmnd, 30);
524 if (scp->sr_command->SCp.Status != S_OK)
525#else
526 gdth_do_cmd(scp, gdtcmd, cmnd, 30);
527 if (scp->SCp.Status != S_OK)
528#endif
529 {
530 break; 439 break;
531 }
532 pcdi->ld_dtype >>= 16; 440 pcdi->ld_dtype >>= 16;
533 j++; 441 j++;
534 if (pcdi->ld_dtype > 2) { 442 if (pcdi->ld_dtype > 2) {
@@ -629,14 +537,7 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
629 gdtcmd->u.ioctl.param_size = sizeof(gdth_arrayinf_str); 537 gdtcmd->u.ioctl.param_size = sizeof(gdth_arrayinf_str);
630 gdtcmd->u.ioctl.subfunc = ARRAY_INFO | LA_CTRL_PATTERN; 538 gdtcmd->u.ioctl.subfunc = ARRAY_INFO | LA_CTRL_PATTERN;
631 gdtcmd->u.ioctl.channel = i; 539 gdtcmd->u.ioctl.channel = i;
632#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 540 if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) == S_OK) {
633 gdth_do_req(scp, gdtcmd, cmnd, 30);
634 if (scp->sr_command->SCp.Status == S_OK)
635#else
636 gdth_do_cmd(scp, gdtcmd, cmnd, 30);
637 if (scp->SCp.Status == S_OK)
638#endif
639 {
640 if (pai->ai_state == 0) 541 if (pai->ai_state == 0)
641 strcpy(hrec, "idle"); 542 strcpy(hrec, "idle");
642 else if (pai->ai_state == 2) 543 else if (pai->ai_state == 2)
@@ -710,14 +611,7 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
710 gdtcmd->u.ioctl.channel = i; 611 gdtcmd->u.ioctl.channel = i;
711 phg->entries = MAX_HDRIVES; 612 phg->entries = MAX_HDRIVES;
712 phg->offset = GDTOFFSOF(gdth_hget_str, entry[0]); 613 phg->offset = GDTOFFSOF(gdth_hget_str, entry[0]);
713#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 614 if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) == S_OK) {
714 gdth_do_req(scp, gdtcmd, cmnd, 30);
715 if (scp->sr_command->SCp.Status != S_OK)
716#else
717 gdth_do_cmd(scp, gdtcmd, cmnd, 30);
718 if (scp->SCp.Status != S_OK)
719#endif
720 {
721 ha->hdr[i].ldr_no = i; 615 ha->hdr[i].ldr_no = i;
722 ha->hdr[i].rw_attribs = 0; 616 ha->hdr[i].rw_attribs = 0;
723 ha->hdr[i].start_sec = 0; 617 ha->hdr[i].start_sec = 0;
@@ -791,13 +685,6 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
791 } 685 }
792 686
793stop_output: 687stop_output:
794#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
795 scsi_release_request(scp);
796 scsi_free_host_dev(sdev);
797#else
798 scsi_release_command(scp);
799 scsi_free_host_dev(sdev);
800#endif
801 *start = buffer +(offset-begin); 688 *start = buffer +(offset-begin);
802 len -= (offset-begin); 689 len -= (offset-begin);
803 if (len > length) 690 if (len > length)
@@ -812,64 +699,6 @@ free_fail:
812 return rc; 699 return rc;
813} 700}
814 701
815
816#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
817static void gdth_do_req(Scsi_Request *scp, gdth_cmd_str *gdtcmd,
818 char *cmnd, int timeout)
819{
820 unsigned bufflen;
821 DECLARE_COMPLETION(wait);
822
823 TRACE2(("gdth_do_req()\n"));
824 if (gdtcmd != NULL) {
825 bufflen = sizeof(gdth_cmd_str);
826 } else {
827 bufflen = 0;
828 }
829 scp->sr_request->rq_status = RQ_SCSI_BUSY;
830 scp->sr_request->waiting = &wait;
831 scsi_do_req(scp, cmnd, gdtcmd, bufflen, gdth_scsi_done, timeout*HZ, 1);
832 wait_for_completion(&wait);
833}
834
835#else
836static void gdth_do_cmd(Scsi_Cmnd *scp, gdth_cmd_str *gdtcmd,
837 char *cmnd, int timeout)
838{
839 unsigned bufflen;
840 DECLARE_COMPLETION(wait);
841
842 TRACE2(("gdth_do_cmd()\n"));
843 if (gdtcmd != NULL) {
844 scp->SCp.this_residual = IOCTL_PRI;
845 bufflen = sizeof(gdth_cmd_str);
846 } else {
847 scp->SCp.this_residual = DEFAULT_PRI;
848 bufflen = 0;
849 }
850
851 scp->request.rq_status = RQ_SCSI_BUSY;
852 scp->request.waiting = &wait;
853 scsi_do_cmd(scp, cmnd, gdtcmd, bufflen, gdth_scsi_done, timeout*HZ, 1);
854 wait_for_completion(&wait);
855}
856#endif
857
858void gdth_scsi_done(Scsi_Cmnd *scp)
859{
860 TRACE2(("gdth_scsi_done()\n"));
861
862#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
863 scp->request->rq_status = RQ_SCSI_DONE;
864 if (scp->request->waiting != NULL)
865 complete(scp->request->waiting);
866#else
867 scp->request.rq_status = RQ_SCSI_DONE;
868 if (scp->request.waiting != NULL)
869 complete(scp->request.waiting);
870#endif
871}
872
873static char *gdth_ioctl_alloc(int hanum, int size, int scratch, 702static char *gdth_ioctl_alloc(int hanum, int size, int scratch,
874 ulong64 *paddr) 703 ulong64 *paddr)
875{ 704{
@@ -976,11 +805,14 @@ static void gdth_stop_timeout(int hanum, int busnum, int id)
976 spin_lock_irqsave(&ha->smp_lock, flags); 805 spin_lock_irqsave(&ha->smp_lock, flags);
977 806
978 for (scp = ha->req_first; scp; scp = (Scsi_Cmnd *)scp->SCp.ptr) { 807 for (scp = ha->req_first; scp; scp = (Scsi_Cmnd *)scp->SCp.ptr) {
979 b = virt_ctr ? NUMDATA(scp->device->host)->busnum : scp->device->channel; 808 if (scp->done != gdth_scsi_done) {
980 t = scp->device->id; 809 b = virt_ctr ?
981 if (t == (unchar)id && b == (unchar)busnum) { 810 NUMDATA(scp->device->host)->busnum : scp->device->channel;
982 TRACE2(("gdth_stop_timeout(): update_timeout()\n")); 811 t = scp->device->id;
983 scp->SCp.buffers_residual = gdth_update_timeout(hanum, scp, 0); 812 if (t == (unchar)id && b == (unchar)busnum) {
813 TRACE2(("gdth_stop_timeout(): update_timeout()\n"));
814 scp->SCp.buffers_residual = gdth_update_timeout(hanum, scp, 0);
815 }
984 } 816 }
985 } 817 }
986 spin_unlock_irqrestore(&ha->smp_lock, flags); 818 spin_unlock_irqrestore(&ha->smp_lock, flags);
@@ -997,11 +829,14 @@ static void gdth_start_timeout(int hanum, int busnum, int id)
997 spin_lock_irqsave(&ha->smp_lock, flags); 829 spin_lock_irqsave(&ha->smp_lock, flags);
998 830
999 for (scp = ha->req_first; scp; scp = (Scsi_Cmnd *)scp->SCp.ptr) { 831 for (scp = ha->req_first; scp; scp = (Scsi_Cmnd *)scp->SCp.ptr) {
1000 b = virt_ctr ? NUMDATA(scp->device->host)->busnum : scp->device->channel; 832 if (scp->done != gdth_scsi_done) {
1001 t = scp->device->id; 833 b = virt_ctr ?
1002 if (t == (unchar)id && b == (unchar)busnum) { 834 NUMDATA(scp->device->host)->busnum : scp->device->channel;
1003 TRACE2(("gdth_start_timeout(): update_timeout()\n")); 835 t = scp->device->id;
1004 gdth_update_timeout(hanum, scp, scp->SCp.buffers_residual); 836 if (t == (unchar)id && b == (unchar)busnum) {
837 TRACE2(("gdth_start_timeout(): update_timeout()\n"));
838 gdth_update_timeout(hanum, scp, scp->SCp.buffers_residual);
839 }
1005 } 840 }
1006 } 841 }
1007 spin_unlock_irqrestore(&ha->smp_lock, flags); 842 spin_unlock_irqrestore(&ha->smp_lock, flags);