Commit fc3fdfcc8bb0e069a2d172e745664fa2c1f1b0ca
Committed by
James Bottomley
1 parent
cc0455fac0
Exists in
master
and in
39 other branches
[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>
Showing 1 changed file with 10 additions and 35 deletions Side-by-side Diff
drivers/scsi/aha1542.c
... | ... | @@ -51,15 +51,6 @@ |
51 | 51 | #define SCSI_BUF_PA(address) isa_virt_to_bus(address) |
52 | 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 | 54 | static void BAD_SG_DMA(Scsi_Cmnd * SCpnt, |
64 | 55 | struct scatterlist *sgp, |
65 | 56 | int nseg, |
... | ... | @@ -597,8 +588,7 @@ |
597 | 588 | unchar target = SCpnt->device->id; |
598 | 589 | unchar lun = SCpnt->device->lun; |
599 | 590 | unsigned long flags; |
600 | - void *buff = SCpnt->request_buffer; | |
601 | - int bufflen = SCpnt->request_bufflen; | |
591 | + int bufflen = scsi_bufflen(SCpnt); | |
602 | 592 | int mbo; |
603 | 593 | struct mailbox *mb; |
604 | 594 | struct ccb *ccb; |
605 | 595 | |
606 | 596 | |
607 | 597 | |
608 | 598 | |
609 | 599 | |
... | ... | @@ -689,42 +679,29 @@ |
689 | 679 | |
690 | 680 | memcpy(ccb[mbo].cdb, cmd, ccb[mbo].cdblen); |
691 | 681 | |
692 | - if (SCpnt->use_sg) { | |
682 | + if (bufflen) { | |
693 | 683 | struct scatterlist *sg; |
694 | 684 | struct chain *cptr; |
695 | 685 | #ifdef DEBUG |
696 | 686 | unsigned char *ptr; |
697 | 687 | #endif |
698 | - int i; | |
688 | + int i, sg_count = scsi_sg_count(SCpnt); | |
699 | 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 | 692 | cptr = (struct chain *) SCpnt->host_scribble; |
702 | 693 | if (cptr == NULL) { |
703 | 694 | /* free the claimed mailbox slot */ |
704 | 695 | HOSTDATA(SCpnt->device->host)->SCint[mbo] = NULL; |
705 | 696 | return SCSI_MLQUEUE_HOST_BUSY; |
706 | 697 | } |
707 | - scsi_for_each_sg(SCpnt, sg, SCpnt->use_sg, 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 | - }; | |
698 | + scsi_for_each_sg(SCpnt, sg, sg_count, i) { | |
722 | 699 | any2scsi(cptr[i].dataptr, SCSI_SG_PA(sg)); |
723 | 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 | 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 | 705 | any2scsi(ccb[mbo].dataptr, SCSI_BUF_PA(cptr)); |
729 | 706 | #ifdef DEBUG |
730 | 707 | printk("cptr %x: ", cptr); |
... | ... | @@ -735,10 +712,8 @@ |
735 | 712 | } else { |
736 | 713 | ccb[mbo].op = 0; /* SCSI Initiator Command */ |
737 | 714 | SCpnt->host_scribble = NULL; |
738 | - any2scsi(ccb[mbo].datalen, bufflen); | |
739 | - if (buff && SCSI_BUF_PA(buff + bufflen - 1) > ISA_DMA_THRESHOLD) | |
740 | - BAD_DMA(buff, bufflen); | |
741 | - any2scsi(ccb[mbo].dataptr, SCSI_BUF_PA(buff)); | |
715 | + any2scsi(ccb[mbo].datalen, 0); | |
716 | + any2scsi(ccb[mbo].dataptr, 0); | |
742 | 717 | }; |
743 | 718 | ccb[mbo].idlun = (target & 7) << 5 | direction | (lun & 7); /*SCSI Target Id */ |
744 | 719 | ccb[mbo].rsalen = 16; |