Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Leubner, Achim and committed by
James Bottomley
cbd5f69b 5d5ff44f

+297 -497
+236 -275
drivers/scsi/gdth.c
··· 4 4 * Intel Corporation: Storage RAID Controllers * 5 5 * * 6 6 * gdth.c * 7 - * Copyright (C) 1995-04 ICP vortex GmbH, Achim Leubner * 7 + * Copyright (C) 1995-06 ICP vortex GmbH, Achim Leubner * 8 8 * Copyright (C) 2002-04 Intel Corporation * 9 - * Copyright (C) 2003-04 Adaptec Inc. * 9 + * Copyright (C) 2003-06 Adaptec Inc. * 10 10 * <achim_leubner@adaptec.com> * 11 11 * * 12 12 * Additions/Fixes: * ··· 27 27 * along with this kernel; if not, write to the Free Software * 28 28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 29 29 * * 30 - * Linux kernel 2.2.x, 2.4.x, 2.6.x supported * 30 + * Linux kernel 2.4.x, 2.6.x supported * 31 31 * * 32 32 * $Log: gdth.c,v $ 33 + * Revision 1.74 2006/04/10 13:44:47 achim 34 + * Community changes for 2.6.x 35 + * Kernel 2.2.x no longer supported 36 + * scsi_request interface removed, thanks to Christoph Hellwig 37 + * 33 38 * Revision 1.73 2004/03/31 13:33:03 achim 34 39 * Special command 0xfd implemented to detect 64-bit DMA support 35 40 * ··· 99 94 * Bugfix free_irq() 100 95 * 101 96 * Revision 1.56 2001/08/09 11:19:39 achim 102 - * struct scsi_host_template changes 97 + * Scsi_Host_Template changes 103 98 * 104 99 * Revision 1.55 2001/08/09 10:11:28 achim 105 100 * Command HOST_UNFREEZE_IO before cache service init. ··· 393 388 #include <linux/proc_fs.h> 394 389 #include <linux/time.h> 395 390 #include <linux/timer.h> 391 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,6) 396 392 #include <linux/dma-mapping.h> 393 + #else 394 + #define DMA_32BIT_MASK 0x00000000ffffffffULL 395 + #define DMA_64BIT_MASK 0xffffffffffffffffULL 396 + #endif 397 + 397 398 #ifdef GDTH_RTC 398 399 #include <linux/mc146818rtc.h> 399 400 #endif ··· 419 408 420 409 #include "scsi.h" 421 410 #include <scsi/scsi_host.h> 422 - #include "gdth.h" 423 411 #include "gdth_kcompat.h" 412 + #include "gdth.h" 424 413 425 414 static void gdth_delay(int milliseconds); 426 415 static void gdth_eval_mapping(ulong32 size, ulong32 *cyls, int *heads, int *secs); ··· 475 464 476 465 static void gdth_flush(int hanum); 477 466 static int gdth_halt(struct notifier_block *nb, ulong event, void *buf); 467 + static int gdth_queuecommand(Scsi_Cmnd *scp,void (*done)(Scsi_Cmnd *)); 468 + static void gdth_scsi_done(struct scsi_cmnd *scp); 478 469 479 470 #ifdef DEBUG_GDTH 480 471 static unchar DebugState = DEBUG_GDTH; ··· 656 643 static int force_dma32 = 0; 657 644 658 645 /* parameters for modprobe/insmod */ 646 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11) 659 647 module_param_array(irq, int, NULL, 0); 660 648 module_param(disable, int, 0); 661 649 module_param(reserve_mode, int, 0); ··· 669 655 module_param(shared_access, int, 0); 670 656 module_param(probe_eisa_isa, int, 0); 671 657 module_param(force_dma32, int, 0); 658 + #else 659 + MODULE_PARM(irq, "i"); 660 + MODULE_PARM(disable, "i"); 661 + MODULE_PARM(reserve_mode, "i"); 662 + MODULE_PARM(reserve_list, "4-" __MODULE_STRING(MAX_RES_ARGS) "i"); 663 + MODULE_PARM(reverse_scan, "i"); 664 + MODULE_PARM(hdr_channel, "i"); 665 + MODULE_PARM(max_ids, "i"); 666 + MODULE_PARM(rescan, "i"); 667 + MODULE_PARM(virt_ctr, "i"); 668 + MODULE_PARM(shared_access, "i"); 669 + MODULE_PARM(probe_eisa_isa, "i"); 670 + MODULE_PARM(force_dma32, "i"); 671 + #endif 672 672 MODULE_AUTHOR("Achim Leubner"); 673 673 MODULE_LICENSE("GPL"); 674 674 ··· 709 681 } else { 710 682 mdelay(milliseconds); 711 683 } 684 + } 685 + 686 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 687 + static void gdth_scsi_done(struct scsi_cmnd *scp) 688 + { 689 + TRACE2(("gdth_scsi_done()\n")); 690 + 691 + if (scp->sc_request) 692 + complete((struct completion *)scp->sc_request); 693 + } 694 + 695 + int __gdth_execute(struct scsi_device *sdev, gdth_cmd_str *gdtcmd, char *cmnd, 696 + int timeout, u32 *info) 697 + { 698 + Scsi_Cmnd *scp; 699 + DECLARE_COMPLETION(wait); 700 + int rval; 701 + 702 + scp = kmalloc(sizeof(*scp), GFP_KERNEL); 703 + if (!scp) 704 + return -ENOMEM; 705 + memset(scp, 0, sizeof(*scp)); 706 + scp->device = sdev; 707 + /* use sc_request field to save the ptr. to completion struct. */ 708 + scp->sc_request = (struct scsi_request *)&wait; 709 + scp->timeout_per_command = timeout*HZ; 710 + scp->request_buffer = gdtcmd; 711 + scp->cmd_len = 12; 712 + memcpy(scp->cmnd, cmnd, 12); 713 + scp->SCp.this_residual = IOCTL_PRI; /* priority */ 714 + scp->done = gdth_scsi_done; /* some fn. test this */ 715 + gdth_queuecommand(scp, gdth_scsi_done); 716 + wait_for_completion(&wait); 717 + 718 + rval = scp->SCp.Status; 719 + if (info) 720 + *info = scp->SCp.Message; 721 + kfree(scp); 722 + return rval; 723 + } 724 + #else 725 + static void gdth_scsi_done(Scsi_Cmnd *scp) 726 + { 727 + TRACE2(("gdth_scsi_done()\n")); 728 + 729 + scp->request.rq_status = RQ_SCSI_DONE; 730 + if (scp->request.waiting) 731 + complete(scp->request.waiting); 732 + } 733 + 734 + int __gdth_execute(struct scsi_device *sdev, gdth_cmd_str *gdtcmd, char *cmnd, 735 + int timeout, u32 *info) 736 + { 737 + Scsi_Cmnd *scp = scsi_allocate_device(sdev, 1, FALSE); 738 + unsigned bufflen = gdtcmd ? sizeof(gdth_cmd_str) : 0; 739 + DECLARE_COMPLETION(wait); 740 + int rval; 741 + 742 + if (!scp) 743 + return -ENOMEM; 744 + scp->cmd_len = 12; 745 + scp->use_sg = 0; 746 + scp->SCp.this_residual = IOCTL_PRI; /* priority */ 747 + scp->request.rq_status = RQ_SCSI_BUSY; 748 + scp->request.waiting = &wait; 749 + scsi_do_cmd(scp, cmnd, gdtcmd, bufflen, gdth_scsi_done, timeout*HZ, 1); 750 + wait_for_completion(&wait); 751 + 752 + rval = scp->SCp.Status; 753 + if (info) 754 + *info = scp->SCp.Message; 755 + 756 + scsi_release_command(scp); 757 + return rval; 758 + } 759 + #endif 760 + 761 + int gdth_execute(struct Scsi_Host *shost, gdth_cmd_str *gdtcmd, char *cmnd, 762 + int timeout, u32 *info) 763 + { 764 + struct scsi_device *sdev = scsi_get_host_dev(shost); 765 + int rval = __gdth_execute(sdev, gdtcmd, cmnd, timeout, info); 766 + 767 + scsi_free_host_dev(sdev); 768 + return rval; 712 769 } 713 770 714 771 static void gdth_eval_mapping(ulong32 size, ulong32 *cyls, int *heads, int *secs) ··· 886 773 MODULE_DEVICE_TABLE(pci,gdthtable); 887 774 888 775 static void __init gdth_search_dev(gdth_pci_str *pcistr, ushort *cnt, 889 - ushort vendor, ushort device) 776 + ushort vendor, ushort device) 890 777 { 891 778 ulong base0, base1, base2; 892 779 struct pci_dev *pdev; ··· 2361 2248 ha = HADATA(gdth_ctr_tab[hanum]); 2362 2249 spin_lock_irqsave(&ha->smp_lock, flags); 2363 2250 2364 - scp->SCp.this_residual = (int)priority; 2365 - b = virt_ctr ? NUMDATA(scp->device->host)->busnum : scp->device->channel; 2366 - t = scp->device->id; 2367 - if (priority >= DEFAULT_PRI) { 2368 - if ((b != ha->virt_bus && ha->raw[BUS_L2P(ha,b)].lock) || 2369 - (b == ha->virt_bus && t < MAX_HDRIVES && ha->hdr[t].lock)) { 2370 - TRACE2(("gdth_putq(): locked IO -> update_timeout()\n")); 2371 - scp->SCp.buffers_residual = gdth_update_timeout(hanum, scp, 0); 2251 + if (scp->done != gdth_scsi_done) { 2252 + scp->SCp.this_residual = (int)priority; 2253 + b = virt_ctr ? NUMDATA(scp->device->host)->busnum:scp->device->channel; 2254 + t = scp->device->id; 2255 + if (priority >= DEFAULT_PRI) { 2256 + if ((b != ha->virt_bus && ha->raw[BUS_L2P(ha,b)].lock) || 2257 + (b==ha->virt_bus && t<MAX_HDRIVES && ha->hdr[t].lock)) { 2258 + TRACE2(("gdth_putq(): locked IO ->update_timeout()\n")); 2259 + scp->SCp.buffers_residual = gdth_update_timeout(hanum, scp, 0); 2260 + } 2372 2261 } 2373 2262 } 2374 2263 ··· 2424 2309 for (nscp = pscp = ha->req_first; nscp; nscp = (Scsi_Cmnd *)nscp->SCp.ptr) { 2425 2310 if (nscp != pscp && nscp != (Scsi_Cmnd *)pscp->SCp.ptr) 2426 2311 pscp = (Scsi_Cmnd *)pscp->SCp.ptr; 2427 - b = virt_ctr ? NUMDATA(nscp->device->host)->busnum : nscp->device->channel; 2428 - t = nscp->device->id; 2429 - l = nscp->device->lun; 2430 - if (nscp->SCp.this_residual >= DEFAULT_PRI) { 2431 - if ((b != ha->virt_bus && ha->raw[BUS_L2P(ha,b)].lock) || 2432 - (b == ha->virt_bus && t < MAX_HDRIVES && ha->hdr[t].lock)) 2433 - continue; 2434 - } 2312 + if (nscp->done != gdth_scsi_done) { 2313 + b = virt_ctr ? 2314 + NUMDATA(nscp->device->host)->busnum : nscp->device->channel; 2315 + t = nscp->device->id; 2316 + l = nscp->device->lun; 2317 + if (nscp->SCp.this_residual >= DEFAULT_PRI) { 2318 + if ((b != ha->virt_bus && ha->raw[BUS_L2P(ha,b)].lock) || 2319 + (b == ha->virt_bus && t < MAX_HDRIVES && ha->hdr[t].lock)) 2320 + continue; 2321 + } 2322 + } else 2323 + b = t = l = 0; 2435 2324 2436 2325 if (firsttime) { 2437 2326 if (gdth_test_busy(hanum)) { /* controller busy ? */ ··· 2450 2331 firsttime = FALSE; 2451 2332 } 2452 2333 2453 - if (nscp->done != gdth_scsi_done || nscp->cmnd[0] != 0xff) { 2334 + if (nscp->done != gdth_scsi_done) { 2454 2335 if (nscp->SCp.phase == -1) { 2455 2336 nscp->SCp.phase = CACHESERVICE; /* default: cache svc. */ 2456 2337 if (nscp->cmnd[0] == TEST_UNIT_READY) { ··· 2513 2394 else 2514 2395 nscp->scsi_done(nscp); 2515 2396 } 2516 - } else if (nscp->done == gdth_scsi_done && nscp->cmnd[0] == 0xff) { 2397 + } else if (nscp->done == gdth_scsi_done) { 2517 2398 if (!(cmd_index=gdth_special_cmd(hanum,nscp))) 2518 2399 this_cmd = FALSE; 2519 2400 next_cmd = FALSE; ··· 2667 2548 if (scp->use_sg) { 2668 2549 sl = (struct scatterlist *)scp->request_buffer; 2669 2550 for (i=0,cpsum=0; i<scp->use_sg; ++i,++sl) { 2670 - unsigned long flags; 2551 + unsigned long flags; 2671 2552 cpnow = (ushort)sl->length; 2672 2553 TRACE(("copy_internal() now %d sum %d count %d %d\n", 2673 2554 cpnow,cpsum,cpcount,(ushort)scp->bufflen)); ··· 2679 2560 hanum); 2680 2561 return; 2681 2562 } 2682 - local_irq_save(flags); 2683 - address = kmap_atomic(sl->page, KM_BIO_SRC_IRQ) + sl->offset; 2563 + local_irq_save(flags); 2564 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 2565 + address = kmap_atomic(sl->page, KM_BIO_SRC_IRQ) + sl->offset; 2684 2566 memcpy(address,buffer,cpnow); 2685 - flush_dcache_page(sl->page); 2686 - kunmap_atomic(address, KM_BIO_SRC_IRQ); 2687 - local_irq_restore(flags); 2567 + flush_dcache_page(sl->page); 2568 + kunmap_atomic(address, KM_BIO_SRC_IRQ); 2569 + #else 2570 + address = kmap_atomic(sl->page, KM_BH_IRQ) + sl->offset; 2571 + memcpy(address,buffer,cpnow); 2572 + flush_dcache_page(sl->page); 2573 + kunmap_atomic(address, KM_BH_IRQ); 2574 + #endif 2575 + local_irq_restore(flags); 2688 2576 if (cpsum == cpcount) 2689 2577 break; 2690 2578 buffer += cpnow; ··· 3072 2946 offset = (ulong)scp->sense_buffer & ~PAGE_MASK; 3073 2947 sense_paddr = pci_map_page(ha->pdev,page,offset, 3074 2948 16,PCI_DMA_FROMDEVICE); 3075 - scp->SCp.buffer = (struct scatterlist *)((ulong32)sense_paddr); 2949 + *(ulong32 *)&scp->SCp.buffer = (ulong32)sense_paddr; 3076 2950 /* high part, if 64bit */ 3077 - scp->host_scribble = (char *)(ulong32)((ulong64)sense_paddr >> 32); 2951 + *(ulong32 *)&scp->host_scribble = (ulong32)((ulong64)sense_paddr >> 32); 3078 2952 cmdp->OpCode = GDT_WRITE; /* always */ 3079 2953 cmdp->BoardNode = LOCALBOARD; 3080 2954 if (mode64) { ··· 3148 3022 } 3149 3023 #endif 3150 3024 3151 - } else { 3025 + } else if (scp->request_bufflen) { 3152 3026 scp->SCp.Status = GDTH_MAP_SINGLE; 3153 3027 scp->SCp.Message = PCI_DMA_BIDIRECTIONAL; 3154 3028 page = virt_to_page(scp->request_buffer); ··· 3435 3309 } 3436 3310 3437 3311 if (!gdth_polling) 3438 - spin_lock_irqsave(&ha2->smp_lock, flags); 3312 + spin_lock_irqsave(&ha2->smp_lock, flags); 3439 3313 wait_index = 0; 3440 3314 3441 3315 /* search controller */ ··· 3768 3642 scp->request_bufflen,scp->SCp.Message); 3769 3643 if (scp->SCp.buffer) { 3770 3644 dma_addr_t addr; 3771 - addr = (dma_addr_t)(ulong32)scp->SCp.buffer; 3645 + addr = (dma_addr_t)*(ulong32 *)&scp->SCp.buffer; 3772 3646 if (scp->host_scribble) 3773 - addr += (dma_addr_t)((ulong64)(ulong32)scp->host_scribble << 32); 3647 + addr += (dma_addr_t) 3648 + ((ulong64)(*(ulong32 *)&scp->host_scribble) << 32); 3774 3649 pci_unmap_page(ha->pdev,addr,16,PCI_DMA_FROMDEVICE); 3775 3650 } 3776 3651 ··· 4281 4154 return 1; 4282 4155 } 4283 4156 4157 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 4284 4158 static int __init gdth_detect(struct scsi_host_template *shtp) 4159 + #else 4160 + static int __init gdth_detect(Scsi_Host_Template *shtp) 4161 + #endif 4285 4162 { 4286 4163 struct Scsi_Host *shp; 4287 4164 gdth_pci_str pcistr[MAXHA]; ··· 4319 4188 return 0; 4320 4189 } 4321 4190 4322 - printk("GDT-HA: Storage RAID Controller Driver. Version: %s \n",GDTH_VERSION_STR); 4191 + printk("GDT-HA: Storage RAID Controller Driver. Version: %s\n",GDTH_VERSION_STR); 4323 4192 /* initializations */ 4324 4193 gdth_polling = TRUE; b = 0; 4325 4194 gdth_clear_events(); ··· 4882 4751 gdth_internal_cmd(hanum, SCSIRAWSERVICE, GDT_RESET_BUS, 4883 4752 BUS_L2P(ha,b), 0, 0); 4884 4753 gdth_polling = FALSE; 4885 - spin_unlock_irqrestore(&ha->smp_lock, flags); 4754 + spin_unlock_irqrestore(&ha->smp_lock, flags); 4886 4755 } 4887 4756 return SUCCESS; 4888 4757 } ··· 4950 4819 priority = DEFAULT_PRI; 4951 4820 if (scp->done == gdth_scsi_done) 4952 4821 priority = scp->SCp.this_residual; 4953 - gdth_update_timeout(hanum, scp, scp->timeout_per_command * 6); 4822 + else 4823 + gdth_update_timeout(hanum, scp, scp->timeout_per_command * 6); 4824 + 4954 4825 gdth_putq( hanum, scp, priority ); 4955 4826 gdth_next( hanum ); 4956 4827 return 0; ··· 5055 4922 gdth_cmd_str cmd; 5056 4923 int hanum; 5057 4924 gdth_ha_str *ha; 5058 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 5059 - Scsi_Request *srp; 5060 - #else 5061 - Scsi_Cmnd *scp; 5062 - #endif 4925 + int rval; 5063 4926 5064 4927 if (copy_from_user(&res, arg, sizeof(gdth_ioctl_reset)) || 5065 4928 res.ionode >= gdth_ctr_count || res.number >= MAX_HDRIVES) ··· 5072 4943 cmd.u.cache64.DeviceNo = res.number; 5073 4944 else 5074 4945 cmd.u.cache.DeviceNo = res.number; 5075 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 5076 - srp = scsi_allocate_request(ha->sdev, GFP_KERNEL); 5077 - if (!srp) 5078 - return -ENOMEM; 5079 - srp->sr_cmd_len = 12; 5080 - srp->sr_use_sg = 0; 5081 - gdth_do_req(srp, &cmd, cmnd, 30); 5082 - res.status = (ushort)srp->sr_command->SCp.Status; 5083 - scsi_release_request(srp); 5084 - #else 5085 - scp = scsi_allocate_device(ha->sdev, 1, FALSE); 5086 - if (!scp) 5087 - return -ENOMEM; 5088 - scp->cmd_len = 12; 5089 - scp->use_sg = 0; 5090 - gdth_do_cmd(scp, &cmd, cmnd, 30); 5091 - res.status = (ushort)scp->SCp.Status; 5092 - scsi_release_command(scp); 5093 - #endif 4946 + 4947 + rval = __gdth_execute(ha->sdev, &cmd, cmnd, 30, NULL); 4948 + if (rval < 0) 4949 + return rval; 4950 + res.status = rval; 5094 4951 5095 4952 if (copy_to_user(arg, &res, sizeof(gdth_ioctl_reset))) 5096 4953 return -EFAULT; ··· 5089 4974 char *buf = NULL; 5090 4975 ulong64 paddr; 5091 4976 int hanum; 5092 - gdth_ha_str *ha; 5093 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 5094 - Scsi_Request *srp; 5095 - #else 5096 - Scsi_Cmnd *scp; 5097 - #endif 4977 + gdth_ha_str *ha; 4978 + int rval; 5098 4979 5099 4980 if (copy_from_user(&gen, arg, sizeof(gdth_ioctl_general)) || 5100 4981 gen.ionode >= gdth_ctr_count) ··· 5182 5071 } 5183 5072 } 5184 5073 5185 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 5186 - srp = scsi_allocate_request(ha->sdev, GFP_KERNEL); 5187 - if (!srp) 5188 - return -ENOMEM; 5189 - srp->sr_cmd_len = 12; 5190 - srp->sr_use_sg = 0; 5191 - gdth_do_req(srp, &gen.command, cmnd, gen.timeout); 5192 - gen.status = srp->sr_command->SCp.Status; 5193 - gen.info = srp->sr_command->SCp.Message; 5194 - scsi_release_request(srp); 5195 - #else 5196 - scp = scsi_allocate_device(ha->sdev, 1, FALSE); 5197 - if (!scp) 5198 - return -ENOMEM; 5199 - scp->cmd_len = 12; 5200 - scp->use_sg = 0; 5201 - gdth_do_cmd(scp, &gen.command, cmnd, gen.timeout); 5202 - gen.status = scp->SCp.Status; 5203 - gen.info = scp->SCp.Message; 5204 - scsi_release_command(scp); 5205 - #endif 5074 + rval = __gdth_execute(ha->sdev, &gen.command, cmnd, gen.timeout, &gen.info); 5075 + if (rval < 0) 5076 + return rval; 5077 + gen.status = rval; 5206 5078 5207 5079 if (copy_to_user(arg + sizeof(gdth_ioctl_general), buf, 5208 5080 gen.data_len + gen.sense_len)) { ··· 5208 5114 gdth_ha_str *ha; 5209 5115 unchar i; 5210 5116 int hanum, rc = -ENOMEM; 5211 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 5212 - Scsi_Request *srp; 5213 - #else 5214 - Scsi_Cmnd *scp; 5215 - #endif 5216 - 5117 + u32 cluster_type = 0; 5118 + 5217 5119 rsc = kmalloc(sizeof(*rsc), GFP_KERNEL); 5218 5120 cmd = kmalloc(sizeof(*cmd), GFP_KERNEL); 5219 5121 if (!rsc || !cmd) 5220 - goto free_fail; 5122 + goto free_fail; 5221 5123 5222 5124 if (copy_from_user(rsc, arg, sizeof(gdth_ioctl_rescan)) || 5223 5125 rsc->ionode >= gdth_ctr_count) { 5224 5126 rc = -EFAULT; 5225 - goto free_fail; 5127 + goto free_fail; 5226 5128 } 5227 5129 hanum = rsc->ionode; 5228 5130 ha = HADATA(gdth_ctr_tab[hanum]); 5229 5131 memset(cmd, 0, sizeof(gdth_cmd_str)); 5230 5132 5231 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 5232 - srp = scsi_allocate_request(ha->sdev, GFP_KERNEL); 5233 - if (!srp) 5234 - goto free_fail; 5235 - srp->sr_cmd_len = 12; 5236 - srp->sr_use_sg = 0; 5237 - #else 5238 - scp = scsi_allocate_device(ha->sdev, 1, FALSE); 5239 - if (!scp) 5240 - goto free_fail; 5241 - scp->cmd_len = 12; 5242 - scp->use_sg = 0; 5243 - #endif 5244 - 5245 5133 for (i = 0; i < MAX_HDRIVES; ++i) { 5246 5134 if (!ha->hdr[i].present) { 5247 5135 rsc->hdr_list[i].bus = 0xff; ··· 5240 5164 cmd->u.cache64.DeviceNo = i; 5241 5165 else 5242 5166 cmd->u.cache.DeviceNo = i; 5243 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 5244 - gdth_do_req(srp, cmd, cmnd, 30); 5245 - if (srp->sr_command->SCp.Status == S_OK) 5246 - rsc->hdr_list[i].cluster_type = srp->sr_command->SCp.Message; 5247 - #else 5248 - gdth_do_cmd(scp, cmd, cmnd, 30); 5249 - if (scp->SCp.Status == S_OK) 5250 - rsc->hdr_list[i].cluster_type = scp->SCp.Message; 5251 - #endif 5167 + if (__gdth_execute(ha->sdev, cmd, cmnd, 30, &cluster_type) == S_OK) 5168 + rsc->hdr_list[i].cluster_type = cluster_type; 5252 5169 } 5253 5170 } 5254 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 5255 - scsi_release_request(srp); 5256 - #else 5257 - scsi_release_command(scp); 5258 - #endif 5259 - 5171 + 5260 5172 if (copy_to_user(arg, rsc, sizeof(gdth_ioctl_rescan))) 5261 5173 rc = -EFAULT; 5262 5174 else 5263 - rc = 0; 5175 + rc = 0; 5264 5176 5265 5177 free_fail: 5266 5178 kfree(rsc); ··· 5266 5202 int rc = -ENOMEM; 5267 5203 ulong flags; 5268 5204 gdth_ha_str *ha; 5269 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 5270 - Scsi_Request *srp; 5271 - #else 5272 - Scsi_Cmnd *scp; 5273 - #endif 5274 5205 5275 5206 rsc = kmalloc(sizeof(*rsc), GFP_KERNEL); 5276 5207 cmd = kmalloc(sizeof(*cmd), GFP_KERNEL); 5277 5208 if (!cmd || !rsc) 5278 - goto free_fail; 5209 + goto free_fail; 5279 5210 5280 5211 if (copy_from_user(rsc, arg, sizeof(gdth_ioctl_rescan)) || 5281 5212 rsc->ionode >= gdth_ctr_count) { 5282 - rc = -EFAULT; 5283 - goto free_fail; 5213 + rc = -EFAULT; 5214 + goto free_fail; 5284 5215 } 5285 5216 hanum = rsc->ionode; 5286 5217 ha = HADATA(gdth_ctr_tab[hanum]); 5287 5218 memset(cmd, 0, sizeof(gdth_cmd_str)); 5288 5219 5289 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 5290 - srp = scsi_allocate_request(ha->sdev, GFP_KERNEL); 5291 - if (!srp) 5292 - goto free_fail; 5293 - srp->sr_cmd_len = 12; 5294 - srp->sr_use_sg = 0; 5295 - #else 5296 - scp = scsi_allocate_device(ha->sdev, 1, FALSE); 5297 - if (!scp) 5298 - goto free_fail; 5299 - scp->cmd_len = 12; 5300 - scp->use_sg = 0; 5301 - #endif 5302 - 5303 5220 if (rsc->flag == 0) { 5304 5221 /* old method: re-init. cache service */ 5305 5222 cmd->Service = CACHESERVICE; ··· 5291 5246 cmd->OpCode = GDT_INIT; 5292 5247 cmd->u.cache.DeviceNo = LINUX_OS; 5293 5248 } 5294 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 5295 - gdth_do_req(srp, cmd, cmnd, 30); 5296 - status = (ushort)srp->sr_command->SCp.Status; 5297 - info = (ulong32)srp->sr_command->SCp.Message; 5298 - #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) 5299 - gdth_do_cmd(scp, cmd, cmnd, 30); 5300 - status = (ushort)scp->SCp.Status; 5301 - info = (ulong32)scp->SCp.Message; 5302 - #else 5303 - gdth_do_cmd(&scp, cmd, cmnd, 30); 5304 - status = (ushort)scp.SCp.Status; 5305 - info = (ulong32)scp.SCp.Message; 5306 - #endif 5249 + 5250 + status = __gdth_execute(ha->sdev, cmd, cmnd, 30, &info); 5307 5251 i = 0; 5308 5252 hdr_cnt = (status == S_OK ? (ushort)info : 0); 5309 5253 } else { ··· 5307 5273 cmd->u.cache64.DeviceNo = i; 5308 5274 else 5309 5275 cmd->u.cache.DeviceNo = i; 5310 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 5311 - gdth_do_req(srp, cmd, cmnd, 30); 5312 - status = (ushort)srp->sr_command->SCp.Status; 5313 - info = (ulong32)srp->sr_command->SCp.Message; 5314 - #else 5315 - gdth_do_cmd(scp, cmd, cmnd, 30); 5316 - status = (ushort)scp->SCp.Status; 5317 - info = (ulong32)scp->SCp.Message; 5318 - #endif 5276 + 5277 + status = __gdth_execute(ha->sdev, cmd, cmnd, 30, &info); 5278 + 5319 5279 spin_lock_irqsave(&ha->smp_lock, flags); 5320 5280 rsc->hdr_list[i].bus = ha->virt_bus; 5321 5281 rsc->hdr_list[i].target = i; ··· 5341 5313 cmd->u.cache64.DeviceNo = i; 5342 5314 else 5343 5315 cmd->u.cache.DeviceNo = i; 5344 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 5345 - gdth_do_req(srp, cmd, cmnd, 30); 5346 - status = (ushort)srp->sr_command->SCp.Status; 5347 - info = (ulong32)srp->sr_command->SCp.Message; 5348 - #else 5349 - gdth_do_cmd(scp, cmd, cmnd, 30); 5350 - status = (ushort)scp->SCp.Status; 5351 - info = (ulong32)scp->SCp.Message; 5352 - #endif 5316 + 5317 + status = __gdth_execute(ha->sdev, cmd, cmnd, 30, &info); 5318 + 5353 5319 spin_lock_irqsave(&ha->smp_lock, flags); 5354 5320 ha->hdr[i].devtype = (status == S_OK ? (ushort)info : 0); 5355 5321 spin_unlock_irqrestore(&ha->smp_lock, flags); ··· 5354 5332 cmd->u.cache64.DeviceNo = i; 5355 5333 else 5356 5334 cmd->u.cache.DeviceNo = i; 5357 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 5358 - gdth_do_req(srp, cmd, cmnd, 30); 5359 - status = (ushort)srp->sr_command->SCp.Status; 5360 - info = (ulong32)srp->sr_command->SCp.Message; 5361 - #else 5362 - gdth_do_cmd(scp, cmd, cmnd, 30); 5363 - status = (ushort)scp->SCp.Status; 5364 - info = (ulong32)scp->SCp.Message; 5365 - #endif 5335 + 5336 + status = __gdth_execute(ha->sdev, cmd, cmnd, 30, &info); 5337 + 5366 5338 spin_lock_irqsave(&ha->smp_lock, flags); 5367 5339 ha->hdr[i].cluster_type = 5368 5340 ((status == S_OK && !shared_access) ? (ushort)info : 0); ··· 5369 5353 cmd->u.cache64.DeviceNo = i; 5370 5354 else 5371 5355 cmd->u.cache.DeviceNo = i; 5372 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 5373 - gdth_do_req(srp, cmd, cmnd, 30); 5374 - status = (ushort)srp->sr_command->SCp.Status; 5375 - info = (ulong32)srp->sr_command->SCp.Message; 5376 - #else 5377 - gdth_do_cmd(scp, cmd, cmnd, 30); 5378 - status = (ushort)scp->SCp.Status; 5379 - info = (ulong32)scp->SCp.Message; 5380 - #endif 5356 + 5357 + status = __gdth_execute(ha->sdev, cmd, cmnd, 30, &info); 5358 + 5381 5359 spin_lock_irqsave(&ha->smp_lock, flags); 5382 5360 ha->hdr[i].rw_attribs = (status == S_OK ? (ushort)info : 0); 5383 5361 spin_unlock_irqrestore(&ha->smp_lock, flags); 5384 5362 } 5385 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 5386 - scsi_release_request(srp); 5387 - #else 5388 - scsi_release_command(scp); 5389 - #endif 5390 5363 5391 5364 if (copy_to_user(arg, rsc, sizeof(gdth_ioctl_rescan))) 5392 5365 rc = -EFAULT; 5393 5366 else 5394 - rc = 0; 5367 + rc = 0; 5395 5368 5396 5369 free_fail: 5397 5370 kfree(rsc); ··· 5520 5515 hanum = res.ionode; 5521 5516 ha = HADATA(gdth_ctr_tab[hanum]); 5522 5517 5523 - /* Because we need a Scsi_Cmnd struct., we make a scsi_allocate device also for kernels >=2.6.x */ 5524 5518 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 5525 - scp = scsi_get_command(ha->sdev, GFP_KERNEL); 5519 + scp = kmalloc(sizeof(*scp), GFP_KERNEL); 5526 5520 if (!scp) 5527 5521 return -ENOMEM; 5522 + memset(scp, 0, sizeof(*scp)); 5523 + scp->device = ha->sdev; 5528 5524 scp->cmd_len = 12; 5529 5525 scp->use_sg = 0; 5530 5526 scp->device->channel = virt_ctr ? 0 : res.number; 5531 5527 rval = gdth_eh_bus_reset(scp); 5532 5528 res.status = (rval == SUCCESS ? S_OK : S_GENERR); 5533 - scsi_put_command(scp); 5529 + kfree(scp); 5534 5530 #else 5535 5531 scp = scsi_allocate_device(ha->sdev, 1, FALSE); 5536 5532 if (!scp) ··· 5564 5558 int i; 5565 5559 gdth_ha_str *ha; 5566 5560 gdth_cmd_str gdtcmd; 5567 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 5568 - Scsi_Request *srp; 5569 - #else 5570 - Scsi_Cmnd *scp; 5571 - #endif 5572 - struct scsi_device *sdev; 5573 5561 char cmnd[MAX_COMMAND_SIZE]; 5574 5562 memset(cmnd, 0xff, MAX_COMMAND_SIZE); 5575 5563 5576 5564 TRACE2(("gdth_flush() hanum %d\n",hanum)); 5577 5565 ha = HADATA(gdth_ctr_tab[hanum]); 5578 - 5579 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 5580 - sdev = scsi_get_host_dev(gdth_ctr_tab[hanum]); 5581 - srp = scsi_allocate_request(sdev, GFP_KERNEL); 5582 - if (!srp) 5583 - return; 5584 - srp->sr_cmd_len = 12; 5585 - srp->sr_use_sg = 0; 5586 - #else 5587 - sdev = scsi_get_host_dev(gdth_ctr_tab[hanum]); 5588 - scp = scsi_allocate_device(sdev, 1, FALSE); 5589 - if (!scp) 5590 - return; 5591 - scp->cmd_len = 12; 5592 - scp->use_sg = 0; 5593 - #endif 5594 5566 5595 5567 for (i = 0; i < MAX_HDRIVES; ++i) { 5596 5568 if (ha->hdr[i].present) { ··· 5585 5601 gdtcmd.u.cache.sg_canz = 0; 5586 5602 } 5587 5603 TRACE2(("gdth_flush(): flush ha %d drive %d\n", hanum, i)); 5588 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 5589 - gdth_do_req(srp, &gdtcmd, cmnd, 30); 5590 - #else 5591 - gdth_do_cmd(scp, &gdtcmd, cmnd, 30); 5592 - #endif 5604 + 5605 + gdth_execute(gdth_ctr_tab[hanum], &gdtcmd, cmnd, 30, NULL); 5593 5606 } 5594 5607 } 5595 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 5596 - scsi_release_request(srp); 5597 - scsi_free_host_dev(sdev); 5598 - #else 5599 - scsi_release_command(scp); 5600 - scsi_free_host_dev(sdev); 5601 - #endif 5602 5608 } 5603 5609 5604 5610 /* shutdown routine */ ··· 5597 5623 int hanum; 5598 5624 #ifndef __alpha__ 5599 5625 gdth_cmd_str gdtcmd; 5600 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 5601 - Scsi_Request *srp; 5602 - struct scsi_device *sdev; 5603 - #else 5604 - Scsi_Cmnd *scp; 5605 - struct scsi_device *sdev; 5606 - #endif 5607 5626 char cmnd[MAX_COMMAND_SIZE]; 5608 5627 #endif 5609 5628 5610 5629 if (notifier_disabled) 5611 - return NOTIFY_OK; 5630 + return NOTIFY_OK; 5612 5631 5613 5632 TRACE2(("gdth_halt() event %d\n",(int)event)); 5614 5633 if (event != SYS_RESTART && event != SYS_HALT && event != SYS_POWER_OFF) ··· 5619 5652 gdtcmd.Service = CACHESERVICE; 5620 5653 gdtcmd.OpCode = GDT_RESET; 5621 5654 TRACE2(("gdth_halt(): reset controller %d\n", hanum)); 5622 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 5623 - sdev = scsi_get_host_dev(gdth_ctr_tab[hanum]); 5624 - srp = scsi_allocate_request(sdev, GFP_KERNEL); 5625 - if (!srp) { 5626 - unregister_reboot_notifier(&gdth_notifier); 5627 - return NOTIFY_OK; 5628 - } 5629 - srp->sr_cmd_len = 12; 5630 - srp->sr_use_sg = 0; 5631 - gdth_do_req(srp, &gdtcmd, cmnd, 10); 5632 - scsi_release_request(srp); 5633 - scsi_free_host_dev(sdev); 5634 - #else 5635 - sdev = scsi_get_host_dev(gdth_ctr_tab[hanum]); 5636 - scp = scsi_allocate_device(sdev, 1, FALSE); 5637 - if (!scp) { 5638 - unregister_reboot_notifier(&gdth_notifier); 5639 - return NOTIFY_OK; 5640 - } 5641 - scp->cmd_len = 12; 5642 - scp->use_sg = 0; 5643 - gdth_do_cmd(scp, &gdtcmd, cmnd, 10); 5644 - scsi_release_command(scp); 5645 - scsi_free_host_dev(sdev); 5646 - #endif 5655 + gdth_execute(gdth_ctr_tab[hanum], &gdtcmd, cmnd, 10, NULL); 5647 5656 #endif 5648 5657 } 5649 5658 printk("Done.\n"); ··· 5630 5687 return NOTIFY_OK; 5631 5688 } 5632 5689 5690 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 5691 + /* configure lun */ 5692 + static int gdth_slave_configure(struct scsi_device *sdev) 5693 + { 5694 + scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun); 5695 + sdev->skip_ms_page_3f = 1; 5696 + sdev->skip_ms_page_8 = 1; 5697 + return 0; 5698 + } 5699 + #endif 5700 + 5701 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 5633 5702 static struct scsi_host_template driver_template = { 5703 + #else 5704 + static Scsi_Host_Template driver_template = { 5705 + #endif 5634 5706 .proc_name = "gdth", 5635 5707 .proc_info = gdth_proc_info, 5636 5708 .name = "GDT SCSI Disk Array Controller", ··· 5656 5698 .eh_bus_reset_handler = gdth_eh_bus_reset, 5657 5699 .bios_param = gdth_bios_param, 5658 5700 .can_queue = GDTH_MAXCMDS, 5701 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 5702 + .slave_configure = gdth_slave_configure, 5703 + #endif 5659 5704 .this_id = -1, 5660 5705 .sg_tablesize = GDTH_MAXSG, 5661 5706 .cmd_per_lun = GDTH_MAXC_P_L,
+4 -4
drivers/scsi/gdth.h
··· 4 4 /* 5 5 * Header file for the GDT Disk Array/Storage RAID controllers driver for Linux 6 6 * 7 - * gdth.h Copyright (C) 1995-03 ICP vortex, Achim Leubner 7 + * gdth.h Copyright (C) 1995-06 ICP vortex, Achim Leubner 8 8 * See gdth.c for further informations and 9 9 * below for supported controller types 10 10 * 11 11 * <achim_leubner@adaptec.com> 12 12 * 13 - * $Id: gdth.h,v 1.57 2004/03/31 11:52:09 achim Exp $ 13 + * $Id: gdth.h,v 1.58 2006/01/11 16:14:09 achim Exp $ 14 14 */ 15 15 16 16 #include <linux/version.h> ··· 26 26 /* defines, macros */ 27 27 28 28 /* driver version */ 29 - #define GDTH_VERSION_STR "3.04" 29 + #define GDTH_VERSION_STR "3.05" 30 30 #define GDTH_VERSION 3 31 - #define GDTH_SUBVERSION 4 31 + #define GDTH_SUBVERSION 5 32 32 33 33 /* protocol version */ 34 34 #define PROTOCOL_VERSION 1
+12 -2
drivers/scsi/gdth_kcompat.h
··· 1 - 2 - 3 1 #ifndef IRQ_HANDLED 4 2 typedef void irqreturn_t; 5 3 #define IRQ_NONE ··· 6 8 7 9 #ifndef MODULE_LICENSE 8 10 #define MODULE_LICENSE(x) 11 + #endif 12 + 13 + #ifndef __iomem 14 + #define __iomem 15 + #endif 16 + 17 + #ifndef __attribute_used__ 18 + #define __attribute_used__ __devinitdata 19 + #endif 20 + 21 + #ifndef __user 22 + #define __user 9 23 #endif 10 24 11 25 #ifndef SERVICE_ACTION_IN
+40 -205
drivers/scsi/gdth_proc.c
··· 1 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 5 #include <linux/completion.h> ··· 51 51 static int gdth_set_info(char *buffer,int length,struct Scsi_Host *host, 52 52 int hanum,int busnum) 53 53 { 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)); 54 + int ret_val = -EINVAL; 63 55 64 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 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 56 + TRACE2(("gdth_set_info() ha %d bus %d\n",hanum,busnum)); 79 57 80 58 if (length >= 4) { 81 59 if (strncmp(buffer,"gdth",4) == 0) { 82 60 buffer += 5; 83 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) 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 65 + 94 66 return ret_val; 95 67 } 96 68 97 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 98 - static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Request *scp) 99 - #else 100 - static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Cmnd *scp) 101 - #endif 69 + static int gdth_set_asc_info(struct Scsi_Host *host, char *buffer, 70 + int length,int hanum) 102 71 { 103 - int orig_length, drive, wb_mode; 104 - int i, found; 72 + int orig_length, drive, wb_mode; 73 + int i, found; 105 74 gdth_ha_str *ha; 106 75 gdth_cmd_str gdtcmd; 107 76 gdth_cpar_str *pcpar; ··· 115 146 gdtcmd.u.cache.DeviceNo = i; 116 147 gdtcmd.u.cache.BlockNo = 1; 117 148 } 118 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 119 - gdth_do_req(scp, &gdtcmd, cmnd, 30); 120 - #else 121 - gdth_do_cmd(scp, &gdtcmd, cmnd, 30); 122 - #endif 149 + 150 + gdth_execute(host, &gdtcmd, cmnd, 30, NULL); 123 151 } 124 152 } 125 153 if (!found) ··· 168 202 gdtcmd.u.ioctl.subfunc = CACHE_CONFIG; 169 203 gdtcmd.u.ioctl.channel = INVALID_CHANNEL; 170 204 pcpar->write_back = wb_mode==1 ? 0:1; 171 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 172 - gdth_do_req(scp, &gdtcmd, cmnd, 30); 173 - #else 174 - gdth_do_cmd(scp, &gdtcmd, cmnd, 30); 175 - #endif 205 + 206 + gdth_execute(host, &gdtcmd, cmnd, 30, NULL); 207 + 176 208 gdth_ioctl_free(hanum, GDTH_SCRATCH, ha->pscratch, paddr); 177 209 printk("Done.\n"); 178 210 return(orig_length); ··· 194 230 195 231 gdth_cmd_str *gdtcmd; 196 232 gdth_evt_str *estr; 197 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 198 - Scsi_Request *scp; 199 - struct scsi_device *sdev; 200 - #else 201 - Scsi_Cmnd *scp; 202 - struct scsi_device *sdev; 203 - #endif 204 233 char hrec[161]; 205 234 struct timeval tv; 206 235 ··· 209 252 gdtcmd = kmalloc(sizeof(*gdtcmd), GFP_KERNEL); 210 253 estr = kmalloc(sizeof(*estr), GFP_KERNEL); 211 254 if (!gdtcmd || !estr) 212 - goto free_fail; 255 + goto free_fail; 213 256 214 257 memset(cmnd, 0xff, 12); 215 258 memset(gdtcmd, 0, sizeof(gdth_cmd_str)); ··· 217 260 TRACE2(("gdth_get_info() ha %d bus %d\n",hanum,busnum)); 218 261 ha = HADATA(gdth_ctr_tab[hanum]); 219 262 220 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 221 - sdev = scsi_get_host_dev(host); 222 - scp = scsi_allocate_request(sdev, GFP_KERNEL); 223 - if (!scp) 224 - goto free_fail; 225 - scp->sr_cmd_len = 12; 226 - scp->sr_use_sg = 0; 227 - #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) 228 - sdev = scsi_get_host_dev(host); 229 - scp = scsi_allocate_device(sdev, 1, FALSE); 230 - if (!scp) 231 - goto free_fail; 232 - scp->cmd_len = 12; 233 - scp->use_sg = 0; 234 - #else 235 - memset(&sdev,0,sizeof(struct scsi_device)); 236 - memset(&scp, 0,sizeof(Scsi_Cmnd)); 237 - sdev.host = scp.host = host; 238 - sdev.id = scp.target = sdev.host->this_id; 239 - scp.device = &sdev; 240 - #endif 241 - 242 263 243 264 /* request is i.e. "cat /proc/scsi/gdth/0" */ 244 265 /* format: %-15s\t%-10s\t%-15s\t%s */ ··· 321 386 sizeof(pds->list[0]); 322 387 if (pds->entries > cnt) 323 388 pds->entries = cnt; 324 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 325 - gdth_do_req(scp, gdtcmd, cmnd, 30); 326 - if (scp->sr_command->SCp.Status != S_OK) 327 - #else 328 - gdth_do_cmd(scp, gdtcmd, cmnd, 30); 329 - if (scp->SCp.Status != S_OK) 330 - #endif 331 - { 389 + 390 + if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) != S_OK) 332 391 pds->count = 0; 333 - } 334 392 335 393 /* other IOCTLs must fit into area GDTH_SCRATCH/4 */ 336 394 for (j = 0; j < ha->raw[i].pdev_cnt; ++j) { ··· 338 410 gdtcmd->u.ioctl.subfunc = SCSI_DR_INFO | L_CTRL_PATTERN; 339 411 gdtcmd->u.ioctl.channel = 340 412 ha->raw[i].address | ha->raw[i].id_list[j]; 341 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 342 - gdth_do_req(scp, gdtcmd, cmnd, 30); 343 - if (scp->sr_command->SCp.Status == S_OK) 344 - #else 345 - gdth_do_cmd(scp, gdtcmd, cmnd, 30); 346 - if (scp->SCp.Status == S_OK) 347 - #endif 348 - { 413 + 414 + if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) == S_OK) { 349 415 strncpy(hrec,pdi->vendor,8); 350 416 strncpy(hrec+8,pdi->product,16); 351 417 strncpy(hrec+24,pdi->revision,4); ··· 388 466 gdtcmd->u.ioctl.channel = 389 467 ha->raw[i].address | ha->raw[i].id_list[j]; 390 468 pdef->sddc_type = 0x08; 391 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 392 - gdth_do_req(scp, gdtcmd, cmnd, 30); 393 - if (scp->sr_command->SCp.Status == S_OK) 394 - #else 395 - gdth_do_cmd(scp, gdtcmd, cmnd, 30); 396 - if (scp->SCp.Status == S_OK) 397 - #endif 398 - { 469 + 470 + if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) == S_OK) { 399 471 size = sprintf(buffer+len, 400 472 " Grown Defects:\t%d\n", 401 473 pdef->sddc_cnt); ··· 435 519 gdtcmd->u.ioctl.param_size = sizeof(gdth_cdrinfo_str); 436 520 gdtcmd->u.ioctl.subfunc = CACHE_DRV_INFO; 437 521 gdtcmd->u.ioctl.channel = drv_no; 438 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 439 - gdth_do_req(scp, gdtcmd, cmnd, 30); 440 - if (scp->sr_command->SCp.Status != S_OK) 441 - #else 442 - gdth_do_cmd(scp, gdtcmd, cmnd, 30); 443 - if (scp->SCp.Status != S_OK) 444 - #endif 445 - { 522 + if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) != S_OK) 446 523 break; 447 - } 448 524 pcdi->ld_dtype >>= 16; 449 525 j++; 450 526 if (pcdi->ld_dtype > 2) { ··· 537 629 gdtcmd->u.ioctl.param_size = sizeof(gdth_arrayinf_str); 538 630 gdtcmd->u.ioctl.subfunc = ARRAY_INFO | LA_CTRL_PATTERN; 539 631 gdtcmd->u.ioctl.channel = i; 540 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 541 - gdth_do_req(scp, gdtcmd, cmnd, 30); 542 - if (scp->sr_command->SCp.Status == S_OK) 543 - #else 544 - gdth_do_cmd(scp, gdtcmd, cmnd, 30); 545 - if (scp->SCp.Status == S_OK) 546 - #endif 547 - { 632 + if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) == S_OK) { 548 633 if (pai->ai_state == 0) 549 634 strcpy(hrec, "idle"); 550 635 else if (pai->ai_state == 2) ··· 611 710 gdtcmd->u.ioctl.channel = i; 612 711 phg->entries = MAX_HDRIVES; 613 712 phg->offset = GDTOFFSOF(gdth_hget_str, entry[0]); 614 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 615 - gdth_do_req(scp, gdtcmd, cmnd, 30); 616 - if (scp->sr_command->SCp.Status != S_OK) 617 - #else 618 - gdth_do_cmd(scp, gdtcmd, cmnd, 30); 619 - if (scp->SCp.Status != S_OK) 620 - #endif 621 - { 713 + if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) == S_OK) { 622 714 ha->hdr[i].ldr_no = i; 623 715 ha->hdr[i].rw_attribs = 0; 624 716 ha->hdr[i].start_sec = 0; ··· 685 791 } 686 792 687 793 stop_output: 688 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 689 - scsi_release_request(scp); 690 - scsi_free_host_dev(sdev); 691 - #else 692 - scsi_release_command(scp); 693 - scsi_free_host_dev(sdev); 694 - #endif 695 794 *start = buffer +(offset-begin); 696 795 len -= (offset-begin); 697 796 if (len > length) ··· 697 810 kfree(gdtcmd); 698 811 kfree(estr); 699 812 return rc; 700 - } 701 - 702 - 703 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 704 - static void gdth_do_req(Scsi_Request *scp, gdth_cmd_str *gdtcmd, 705 - char *cmnd, int timeout) 706 - { 707 - unsigned bufflen; 708 - DECLARE_COMPLETION(wait); 709 - 710 - TRACE2(("gdth_do_req()\n")); 711 - if (gdtcmd != NULL) { 712 - bufflen = sizeof(gdth_cmd_str); 713 - } else { 714 - bufflen = 0; 715 - } 716 - scp->sr_request->rq_status = RQ_SCSI_BUSY; 717 - scp->sr_request->waiting = &wait; 718 - scsi_do_req(scp, cmnd, gdtcmd, bufflen, gdth_scsi_done, timeout*HZ, 1); 719 - wait_for_completion(&wait); 720 - } 721 - 722 - #else 723 - static void gdth_do_cmd(Scsi_Cmnd *scp, gdth_cmd_str *gdtcmd, 724 - char *cmnd, int timeout) 725 - { 726 - unsigned bufflen; 727 - DECLARE_COMPLETION(wait); 728 - 729 - TRACE2(("gdth_do_cmd()\n")); 730 - if (gdtcmd != NULL) { 731 - scp->SCp.this_residual = IOCTL_PRI; 732 - bufflen = sizeof(gdth_cmd_str); 733 - } else { 734 - scp->SCp.this_residual = DEFAULT_PRI; 735 - bufflen = 0; 736 - } 737 - 738 - scp->request.rq_status = RQ_SCSI_BUSY; 739 - scp->request.waiting = &wait; 740 - scsi_do_cmd(scp, cmnd, gdtcmd, bufflen, gdth_scsi_done, timeout*HZ, 1); 741 - wait_for_completion(&wait); 742 - } 743 - #endif 744 - 745 - void gdth_scsi_done(Scsi_Cmnd *scp) 746 - { 747 - TRACE2(("gdth_scsi_done()\n")); 748 - 749 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 750 - scp->request->rq_status = RQ_SCSI_DONE; 751 - if (scp->request->waiting != NULL) 752 - complete(scp->request->waiting); 753 - #else 754 - scp->request.rq_status = RQ_SCSI_DONE; 755 - if (scp->request.waiting != NULL) 756 - complete(scp->request.waiting); 757 - #endif 758 813 } 759 814 760 815 static char *gdth_ioctl_alloc(int hanum, int size, int scratch, ··· 805 976 spin_lock_irqsave(&ha->smp_lock, flags); 806 977 807 978 for (scp = ha->req_first; scp; scp = (Scsi_Cmnd *)scp->SCp.ptr) { 808 - b = virt_ctr ? NUMDATA(scp->device->host)->busnum : scp->device->channel; 809 - t = scp->device->id; 810 - if (t == (unchar)id && b == (unchar)busnum) { 811 - TRACE2(("gdth_stop_timeout(): update_timeout()\n")); 812 - scp->SCp.buffers_residual = gdth_update_timeout(hanum, scp, 0); 979 + if (scp->done != gdth_scsi_done) { 980 + b = virt_ctr ? 981 + NUMDATA(scp->device->host)->busnum : scp->device->channel; 982 + t = scp->device->id; 983 + if (t == (unchar)id && b == (unchar)busnum) { 984 + TRACE2(("gdth_stop_timeout(): update_timeout()\n")); 985 + scp->SCp.buffers_residual = gdth_update_timeout(hanum, scp, 0); 986 + } 813 987 } 814 988 } 815 989 spin_unlock_irqrestore(&ha->smp_lock, flags); ··· 829 997 spin_lock_irqsave(&ha->smp_lock, flags); 830 998 831 999 for (scp = ha->req_first; scp; scp = (Scsi_Cmnd *)scp->SCp.ptr) { 832 - b = virt_ctr ? NUMDATA(scp->device->host)->busnum : scp->device->channel; 833 - t = scp->device->id; 834 - if (t == (unchar)id && b == (unchar)busnum) { 835 - TRACE2(("gdth_start_timeout(): update_timeout()\n")); 836 - gdth_update_timeout(hanum, scp, scp->SCp.buffers_residual); 1000 + if (scp->done != gdth_scsi_done) { 1001 + b = virt_ctr ? 1002 + NUMDATA(scp->device->host)->busnum : scp->device->channel; 1003 + t = scp->device->id; 1004 + if (t == (unchar)id && b == (unchar)busnum) { 1005 + TRACE2(("gdth_start_timeout(): update_timeout()\n")); 1006 + gdth_update_timeout(hanum, scp, scp->SCp.buffers_residual); 1007 + } 837 1008 } 838 1009 } 839 1010 spin_unlock_irqrestore(&ha->smp_lock, flags);
+5 -11
drivers/scsi/gdth_proc.h
··· 5 5 * $Id: gdth_proc.h,v 1.16 2004/01/14 13:09:01 achim Exp $ 6 6 */ 7 7 8 + int gdth_execute(struct Scsi_Host *shost, gdth_cmd_str *gdtcmd, char *cmnd, 9 + int timeout, u32 *info); 10 + 8 11 static int gdth_set_info(char *buffer,int length,struct Scsi_Host *host, 9 12 int hanum,int busnum); 10 13 static int gdth_get_info(char *buffer,char **start,off_t offset,int length, 11 14 struct Scsi_Host *host,int hanum,int busnum); 12 15 13 - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 14 - static void gdth_do_req(Scsi_Request *srp, gdth_cmd_str *cmd, 15 - char *cmnd, int timeout); 16 - static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Request *scp); 17 - #else 18 - static void gdth_do_cmd(Scsi_Cmnd *scp, gdth_cmd_str *cmd, 19 - char *cmnd, int timeout); 20 - static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Cmnd *scp); 21 - #endif 16 + static int gdth_set_asc_info(struct Scsi_Host *host, char *buffer, 17 + int length, int hanum); 22 18 23 19 static char *gdth_ioctl_alloc(int hanum, int size, int scratch, 24 20 ulong64 *paddr); ··· 23 27 static void gdth_stop_timeout(int hanum, int busnum, int id); 24 28 static void gdth_start_timeout(int hanum, int busnum, int id); 25 29 static int gdth_update_timeout(int hanum, Scsi_Cmnd *scp, int timeout); 26 - 27 - void gdth_scsi_done(Scsi_Cmnd *scp); 28 30 29 31 #endif 30 32