diff options
author | Boaz Harrosh <bharrosh@panasas.com> | 2007-09-09 14:02:45 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2008-01-11 19:22:35 -0500 |
commit | fc3fdfcc8bb0e069a2d172e745664fa2c1f1b0ca (patch) | |
tree | 07042269a9f4215346ea03b5e653fefd74d2de12 /drivers/scsi/aha1542.c | |
parent | cc0455fac06f0539277d7b724dbc513284629069 (diff) |
[SCSI] aha1542: convert to accessors and !use_sg cleanup
- convert to accessors and !use_sg cleanup
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/scsi/aha1542.c')
-rw-r--r-- | drivers/scsi/aha1542.c | 45 |
1 files changed, 10 insertions, 35 deletions
diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index bbcc2c52d79f..5b69a88d0e4c 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c | |||
@@ -51,15 +51,6 @@ | |||
51 | #define SCSI_BUF_PA(address) isa_virt_to_bus(address) | 51 | #define SCSI_BUF_PA(address) isa_virt_to_bus(address) |
52 | #define SCSI_SG_PA(sgent) (isa_page_to_bus(sg_page((sgent))) + (sgent)->offset) | 52 | #define SCSI_SG_PA(sgent) (isa_page_to_bus(sg_page((sgent))) + (sgent)->offset) |
53 | 53 | ||
54 | static void BAD_DMA(void *address, unsigned int length) | ||
55 | { | ||
56 | printk(KERN_CRIT "buf vaddress %p paddress 0x%lx length %d\n", | ||
57 | address, | ||
58 | SCSI_BUF_PA(address), | ||
59 | length); | ||
60 | panic("Buffer at physical address > 16Mb used for aha1542"); | ||
61 | } | ||
62 | |||
63 | static void BAD_SG_DMA(Scsi_Cmnd * SCpnt, | 54 | static void BAD_SG_DMA(Scsi_Cmnd * SCpnt, |
64 | struct scatterlist *sgp, | 55 | struct scatterlist *sgp, |
65 | int nseg, | 56 | int nseg, |
@@ -597,8 +588,7 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) | |||
597 | unchar target = SCpnt->device->id; | 588 | unchar target = SCpnt->device->id; |
598 | unchar lun = SCpnt->device->lun; | 589 | unchar lun = SCpnt->device->lun; |
599 | unsigned long flags; | 590 | unsigned long flags; |
600 | void *buff = SCpnt->request_buffer; | 591 | int bufflen = scsi_bufflen(SCpnt); |
601 | int bufflen = SCpnt->request_bufflen; | ||
602 | int mbo; | 592 | int mbo; |
603 | struct mailbox *mb; | 593 | struct mailbox *mb; |
604 | struct ccb *ccb; | 594 | struct ccb *ccb; |
@@ -689,42 +679,29 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) | |||
689 | 679 | ||
690 | memcpy(ccb[mbo].cdb, cmd, ccb[mbo].cdblen); | 680 | memcpy(ccb[mbo].cdb, cmd, ccb[mbo].cdblen); |
691 | 681 | ||
692 | if (SCpnt->use_sg) { | 682 | if (bufflen) { |
693 | struct scatterlist *sg; | 683 | struct scatterlist *sg; |
694 | struct chain *cptr; | 684 | struct chain *cptr; |
695 | #ifdef DEBUG | 685 | #ifdef DEBUG |
696 | unsigned char *ptr; | 686 | unsigned char *ptr; |
697 | #endif | 687 | #endif |
698 | int i; | 688 | int i, sg_count = scsi_sg_count(SCpnt); |
699 | ccb[mbo].op = 2; /* SCSI Initiator Command w/scatter-gather */ | 689 | ccb[mbo].op = 2; /* SCSI Initiator Command w/scatter-gather */ |
700 | SCpnt->host_scribble = kmalloc(512, GFP_KERNEL | GFP_DMA); | 690 | SCpnt->host_scribble = kmalloc(sizeof(*cptr)*sg_count, |
691 | GFP_KERNEL | GFP_DMA); | ||
701 | cptr = (struct chain *) SCpnt->host_scribble; | 692 | cptr = (struct chain *) SCpnt->host_scribble; |
702 | if (cptr == NULL) { | 693 | if (cptr == NULL) { |
703 | /* free the claimed mailbox slot */ | 694 | /* free the claimed mailbox slot */ |
704 | HOSTDATA(SCpnt->device->host)->SCint[mbo] = NULL; | 695 | HOSTDATA(SCpnt->device->host)->SCint[mbo] = NULL; |
705 | return SCSI_MLQUEUE_HOST_BUSY; | 696 | return SCSI_MLQUEUE_HOST_BUSY; |
706 | } | 697 | } |
707 | scsi_for_each_sg(SCpnt, sg, SCpnt->use_sg, i) { | 698 | scsi_for_each_sg(SCpnt, sg, sg_count, i) { |
708 | if (sg->length == 0 || SCpnt->use_sg > 16 || | ||
709 | (((int) sg->offset) & 1) || (sg->length & 1)) { | ||
710 | unsigned char *ptr; | ||
711 | printk(KERN_CRIT "Bad segment list supplied to aha1542.c (%d, %d)\n", SCpnt->use_sg, i); | ||
712 | scsi_for_each_sg(SCpnt, sg, SCpnt->use_sg, i) { | ||
713 | printk(KERN_CRIT "%d: %p %d\n", i, | ||
714 | sg_virt(sg), sg->length); | ||
715 | }; | ||
716 | printk(KERN_CRIT "cptr %x: ", (unsigned int) cptr); | ||
717 | ptr = (unsigned char *) &cptr[i]; | ||
718 | for (i = 0; i < 18; i++) | ||
719 | printk("%02x ", ptr[i]); | ||
720 | panic("Foooooooood fight!"); | ||
721 | }; | ||
722 | any2scsi(cptr[i].dataptr, SCSI_SG_PA(sg)); | 699 | any2scsi(cptr[i].dataptr, SCSI_SG_PA(sg)); |
723 | if (SCSI_SG_PA(sg) + sg->length - 1 > ISA_DMA_THRESHOLD) | 700 | if (SCSI_SG_PA(sg) + sg->length - 1 > ISA_DMA_THRESHOLD) |
724 | BAD_SG_DMA(SCpnt, sg, SCpnt->use_sg, i); | 701 | BAD_SG_DMA(SCpnt, scsi_sglist(SCpnt), sg_count, i); |
725 | any2scsi(cptr[i].datalen, sg->length); | 702 | any2scsi(cptr[i].datalen, sg->length); |
726 | }; | 703 | }; |
727 | any2scsi(ccb[mbo].datalen, SCpnt->use_sg * sizeof(struct chain)); | 704 | any2scsi(ccb[mbo].datalen, sg_count * sizeof(struct chain)); |
728 | any2scsi(ccb[mbo].dataptr, SCSI_BUF_PA(cptr)); | 705 | any2scsi(ccb[mbo].dataptr, SCSI_BUF_PA(cptr)); |
729 | #ifdef DEBUG | 706 | #ifdef DEBUG |
730 | printk("cptr %x: ", cptr); | 707 | printk("cptr %x: ", cptr); |
@@ -735,10 +712,8 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) | |||
735 | } else { | 712 | } else { |
736 | ccb[mbo].op = 0; /* SCSI Initiator Command */ | 713 | ccb[mbo].op = 0; /* SCSI Initiator Command */ |
737 | SCpnt->host_scribble = NULL; | 714 | SCpnt->host_scribble = NULL; |
738 | any2scsi(ccb[mbo].datalen, bufflen); | 715 | any2scsi(ccb[mbo].datalen, 0); |
739 | if (buff && SCSI_BUF_PA(buff + bufflen - 1) > ISA_DMA_THRESHOLD) | 716 | any2scsi(ccb[mbo].dataptr, 0); |
740 | BAD_DMA(buff, bufflen); | ||
741 | any2scsi(ccb[mbo].dataptr, SCSI_BUF_PA(buff)); | ||
742 | }; | 717 | }; |
743 | ccb[mbo].idlun = (target & 7) << 5 | direction | (lun & 7); /*SCSI Target Id */ | 718 | ccb[mbo].idlun = (target & 7) << 5 | direction | (lun & 7); /*SCSI Target Id */ |
744 | ccb[mbo].rsalen = 16; | 719 | ccb[mbo].rsalen = 16; |