aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/atp870u.c
diff options
context:
space:
mode:
authorBoaz Harrosh <bharrosh@panasas.com>2007-09-09 14:06:23 -0400
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2008-01-11 19:22:38 -0500
commitfe7ed98fd49a28287aca8b0ba8da8fb9ca35a055 (patch)
treecac50b1b409c61b8b0a756245fa6b611cb413c4b /drivers/scsi/atp870u.c
parentc73961e563dde3239e2e5da08b25ab2832b2e840 (diff)
[SCSI] atp870u: convert to accessors and !use_sg cleanup
- convert to accessors and !use_sg cleanup - Probably not ready for sg-chaining Signed-off-by: Boaz Harrosh <bharrosh@panasas.com> Acked-by: Christoph Hellwig <hch@infradead.org> Cc: jameshsu <jameshsu@acard.com> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/scsi/atp870u.c')
-rw-r--r--drivers/scsi/atp870u.c102
1 files changed, 17 insertions, 85 deletions
diff --git a/drivers/scsi/atp870u.c b/drivers/scsi/atp870u.c
index fec58cc47f1c..db6de5e6afb3 100644
--- a/drivers/scsi/atp870u.c
+++ b/drivers/scsi/atp870u.c
@@ -471,18 +471,8 @@ go_42:
471 /* 471 /*
472 * Complete the command 472 * Complete the command
473 */ 473 */
474 if (workreq->use_sg) { 474 scsi_dma_unmap(workreq);
475 pci_unmap_sg(dev->pdev, 475
476 (struct scatterlist *)workreq->request_buffer,
477 workreq->use_sg,
478 workreq->sc_data_direction);
479 } else if (workreq->request_bufflen &&
480 workreq->sc_data_direction != DMA_NONE) {
481 pci_unmap_single(dev->pdev,
482 workreq->SCp.dma_handle,
483 workreq->request_bufflen,
484 workreq->sc_data_direction);
485 }
486 spin_lock_irqsave(dev->host->host_lock, flags); 476 spin_lock_irqsave(dev->host->host_lock, flags);
487 (*workreq->scsi_done) (workreq); 477 (*workreq->scsi_done) (workreq);
488#ifdef ED_DBGP 478#ifdef ED_DBGP
@@ -624,7 +614,7 @@ static int atp870u_queuecommand(struct scsi_cmnd * req_p,
624 614
625 c = scmd_channel(req_p); 615 c = scmd_channel(req_p);
626 req_p->sense_buffer[0]=0; 616 req_p->sense_buffer[0]=0;
627 req_p->resid = 0; 617 scsi_set_resid(req_p, 0);
628 if (scmd_channel(req_p) > 1) { 618 if (scmd_channel(req_p) > 1) {
629 req_p->result = 0x00040000; 619 req_p->result = 0x00040000;
630 done(req_p); 620 done(req_p);
@@ -722,7 +712,6 @@ static void send_s870(struct atp_unit *dev,unsigned char c)
722 unsigned short int tmpcip, w; 712 unsigned short int tmpcip, w;
723 unsigned long l, bttl = 0; 713 unsigned long l, bttl = 0;
724 unsigned int workport; 714 unsigned int workport;
725 struct scatterlist *sgpnt;
726 unsigned long sg_count; 715 unsigned long sg_count;
727 716
728 if (dev->in_snd[c] != 0) { 717 if (dev->in_snd[c] != 0) {
@@ -793,6 +782,8 @@ oktosend:
793 } 782 }
794 printk("\n"); 783 printk("\n");
795#endif 784#endif
785 l = scsi_bufflen(workreq);
786
796 if (dev->dev_id == ATP885_DEVID) { 787 if (dev->dev_id == ATP885_DEVID) {
797 j = inb(dev->baseport + 0x29) & 0xfe; 788 j = inb(dev->baseport + 0x29) & 0xfe;
798 outb(j, dev->baseport + 0x29); 789 outb(j, dev->baseport + 0x29);
@@ -800,12 +791,11 @@ oktosend:
800 } 791 }
801 792
802 if (workreq->cmnd[0] == READ_CAPACITY) { 793 if (workreq->cmnd[0] == READ_CAPACITY) {
803 if (workreq->request_bufflen > 8) { 794 if (l > 8)
804 workreq->request_bufflen = 0x08; 795 l = 8;
805 }
806 } 796 }
807 if (workreq->cmnd[0] == 0x00) { 797 if (workreq->cmnd[0] == 0x00) {
808 workreq->request_bufflen = 0; 798 l = 0;
809 } 799 }
810 800
811 tmport = workport + 0x1b; 801 tmport = workport + 0x1b;
@@ -852,40 +842,8 @@ oktosend:
852#ifdef ED_DBGP 842#ifdef ED_DBGP
853 printk("dev->id[%d][%d].devsp = %2x\n",c,target_id,dev->id[c][target_id].devsp); 843 printk("dev->id[%d][%d].devsp = %2x\n",c,target_id,dev->id[c][target_id].devsp);
854#endif 844#endif
855 /* 845
856 * Figure out the transfer size 846 sg_count = scsi_dma_map(workreq);
857 */
858 if (workreq->use_sg) {
859#ifdef ED_DBGP
860 printk("Using SGL\n");
861#endif
862 l = 0;
863
864 sgpnt = (struct scatterlist *) workreq->request_buffer;
865 sg_count = pci_map_sg(dev->pdev, sgpnt, workreq->use_sg,
866 workreq->sc_data_direction);
867
868 for (i = 0; i < workreq->use_sg; i++) {
869 if (sgpnt[i].length == 0 || workreq->use_sg > ATP870U_SCATTER) {
870 panic("Foooooooood fight!");
871 }
872 l += sgpnt[i].length;
873 }
874#ifdef ED_DBGP
875 printk( "send_s870: workreq->use_sg %d, sg_count %d l %8ld\n", workreq->use_sg, sg_count, l);
876#endif
877 } else if(workreq->request_bufflen && workreq->sc_data_direction != PCI_DMA_NONE) {
878#ifdef ED_DBGP
879 printk("Not using SGL\n");
880#endif
881 workreq->SCp.dma_handle = pci_map_single(dev->pdev, workreq->request_buffer,
882 workreq->request_bufflen,
883 workreq->sc_data_direction);
884 l = workreq->request_bufflen;
885#ifdef ED_DBGP
886 printk( "send_s870: workreq->use_sg %d, l %8ld\n", workreq->use_sg, l);
887#endif
888 } else l = 0;
889 /* 847 /*
890 * Write transfer size 848 * Write transfer size
891 */ 849 */
@@ -938,16 +896,16 @@ oktosend:
938 * a linear chain. 896 * a linear chain.
939 */ 897 */
940 898
941 if (workreq->use_sg) { 899 if (l) {
942 sgpnt = (struct scatterlist *) workreq->request_buffer; 900 struct scatterlist *sgpnt;
943 i = 0; 901 i = 0;
944 for (j = 0; j < workreq->use_sg; j++) { 902 scsi_for_each_sg(workreq, sgpnt, sg_count, j) {
945 bttl = sg_dma_address(&sgpnt[j]); 903 bttl = sg_dma_address(sgpnt);
946 l=sg_dma_len(&sgpnt[j]); 904 l=sg_dma_len(sgpnt);
947#ifdef ED_DBGP 905#ifdef ED_DBGP
948 printk("1. bttl %x, l %x\n",bttl, l); 906 printk("1. bttl %x, l %x\n",bttl, l);
949#endif 907#endif
950 while (l > 0x10000) { 908 while (l > 0x10000) {
951 (((u16 *) (prd))[i + 3]) = 0x0000; 909 (((u16 *) (prd))[i + 3]) = 0x0000;
952 (((u16 *) (prd))[i + 2]) = 0x0000; 910 (((u16 *) (prd))[i + 2]) = 0x0000;
953 (((u32 *) (prd))[i >> 1]) = cpu_to_le32(bttl); 911 (((u32 *) (prd))[i >> 1]) = cpu_to_le32(bttl);
@@ -965,32 +923,6 @@ oktosend:
965 printk("prd %4x %4x %4x %4x\n",(((unsigned short int *)prd)[0]),(((unsigned short int *)prd)[1]),(((unsigned short int *)prd)[2]),(((unsigned short int *)prd)[3])); 923 printk("prd %4x %4x %4x %4x\n",(((unsigned short int *)prd)[0]),(((unsigned short int *)prd)[1]),(((unsigned short int *)prd)[2]),(((unsigned short int *)prd)[3]));
966 printk("2. bttl %x, l %x\n",bttl, l); 924 printk("2. bttl %x, l %x\n",bttl, l);
967#endif 925#endif
968 } else {
969 /*
970 * For a linear request write a chain of blocks
971 */
972 bttl = workreq->SCp.dma_handle;
973 l = workreq->request_bufflen;
974 i = 0;
975#ifdef ED_DBGP
976 printk("3. bttl %x, l %x\n",bttl, l);
977#endif
978 while (l > 0x10000) {
979 (((u16 *) (prd))[i + 3]) = 0x0000;
980 (((u16 *) (prd))[i + 2]) = 0x0000;
981 (((u32 *) (prd))[i >> 1]) = cpu_to_le32(bttl);
982 l -= 0x10000;
983 bttl += 0x10000;
984 i += 0x04;
985 }
986 (((u16 *) (prd))[i + 3]) = cpu_to_le16(0x8000);
987 (((u16 *) (prd))[i + 2]) = cpu_to_le16(l);
988 (((u32 *) (prd))[i >> 1]) = cpu_to_le32(bttl);
989#ifdef ED_DBGP
990 printk("prd %4x %4x %4x %4x\n",(((unsigned short int *)prd)[0]),(((unsigned short int *)prd)[1]),(((unsigned short int *)prd)[2]),(((unsigned short int *)prd)[3]));
991 printk("4. bttl %x, l %x\n",bttl, l);
992#endif
993
994 } 926 }
995 tmpcip += 4; 927 tmpcip += 4;
996#ifdef ED_DBGP 928#ifdef ED_DBGP