diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2007-05-14 06:22:21 -0400 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.localdomain> | 2007-07-15 11:03:03 -0400 |
commit | 69eca4f52b044edd9890aaa25d74f52e5fcd170e (patch) | |
tree | 0ac480b4d538537b0d853cc7c23cc354779edab3 /drivers | |
parent | 938febd62b860447247eb9b1c3b6bbc99d2c7f81 (diff) |
[SCSI] ncr53c8xx: convert to use the data buffer accessors
- remove the unnecessary map_single path.
- convert to use the new accessors for the sg lists and the
parameters.
Jens Axboe <jens.axboe@oracle.com> did the for_each_sg cleanup.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Matthew Wilcox <matthew@wil.cx>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/scsi/ncr53c8xx.c | 70 |
1 files changed, 11 insertions, 59 deletions
diff --git a/drivers/scsi/ncr53c8xx.c b/drivers/scsi/ncr53c8xx.c index bbf521cbc55d..030ba49f33ff 100644 --- a/drivers/scsi/ncr53c8xx.c +++ b/drivers/scsi/ncr53c8xx.c | |||
@@ -529,43 +529,20 @@ static void __unmap_scsi_data(struct device *dev, struct scsi_cmnd *cmd) | |||
529 | { | 529 | { |
530 | switch(cmd->__data_mapped) { | 530 | switch(cmd->__data_mapped) { |
531 | case 2: | 531 | case 2: |
532 | dma_unmap_sg(dev, cmd->request_buffer, cmd->use_sg, | 532 | scsi_dma_unmap(cmd); |
533 | cmd->sc_data_direction); | ||
534 | break; | ||
535 | case 1: | ||
536 | dma_unmap_single(dev, cmd->__data_mapping, | ||
537 | cmd->request_bufflen, | ||
538 | cmd->sc_data_direction); | ||
539 | break; | 533 | break; |
540 | } | 534 | } |
541 | cmd->__data_mapped = 0; | 535 | cmd->__data_mapped = 0; |
542 | } | 536 | } |
543 | 537 | ||
544 | static u_long __map_scsi_single_data(struct device *dev, struct scsi_cmnd *cmd) | ||
545 | { | ||
546 | dma_addr_t mapping; | ||
547 | |||
548 | if (cmd->request_bufflen == 0) | ||
549 | return 0; | ||
550 | |||
551 | mapping = dma_map_single(dev, cmd->request_buffer, | ||
552 | cmd->request_bufflen, | ||
553 | cmd->sc_data_direction); | ||
554 | cmd->__data_mapped = 1; | ||
555 | cmd->__data_mapping = mapping; | ||
556 | |||
557 | return mapping; | ||
558 | } | ||
559 | |||
560 | static int __map_scsi_sg_data(struct device *dev, struct scsi_cmnd *cmd) | 538 | static int __map_scsi_sg_data(struct device *dev, struct scsi_cmnd *cmd) |
561 | { | 539 | { |
562 | int use_sg; | 540 | int use_sg; |
563 | 541 | ||
564 | if (cmd->use_sg == 0) | 542 | use_sg = scsi_dma_map(cmd); |
543 | if (!use_sg) | ||
565 | return 0; | 544 | return 0; |
566 | 545 | ||
567 | use_sg = dma_map_sg(dev, cmd->request_buffer, cmd->use_sg, | ||
568 | cmd->sc_data_direction); | ||
569 | cmd->__data_mapped = 2; | 546 | cmd->__data_mapped = 2; |
570 | cmd->__data_mapping = use_sg; | 547 | cmd->__data_mapping = use_sg; |
571 | 548 | ||
@@ -573,7 +550,6 @@ static int __map_scsi_sg_data(struct device *dev, struct scsi_cmnd *cmd) | |||
573 | } | 550 | } |
574 | 551 | ||
575 | #define unmap_scsi_data(np, cmd) __unmap_scsi_data(np->dev, cmd) | 552 | #define unmap_scsi_data(np, cmd) __unmap_scsi_data(np->dev, cmd) |
576 | #define map_scsi_single_data(np, cmd) __map_scsi_single_data(np->dev, cmd) | ||
577 | #define map_scsi_sg_data(np, cmd) __map_scsi_sg_data(np->dev, cmd) | 553 | #define map_scsi_sg_data(np, cmd) __map_scsi_sg_data(np->dev, cmd) |
578 | 554 | ||
579 | /*========================================================== | 555 | /*========================================================== |
@@ -7667,39 +7643,16 @@ fail: | |||
7667 | ** sizes to the data segment array. | 7643 | ** sizes to the data segment array. |
7668 | */ | 7644 | */ |
7669 | 7645 | ||
7670 | static int ncr_scatter_no_sglist(struct ncb *np, struct ccb *cp, struct scsi_cmnd *cmd) | ||
7671 | { | ||
7672 | struct scr_tblmove *data = &cp->phys.data[MAX_SCATTER - 1]; | ||
7673 | int segment; | ||
7674 | |||
7675 | cp->data_len = cmd->request_bufflen; | ||
7676 | |||
7677 | if (cmd->request_bufflen) { | ||
7678 | dma_addr_t baddr = map_scsi_single_data(np, cmd); | ||
7679 | if (baddr) { | ||
7680 | ncr_build_sge(np, data, baddr, cmd->request_bufflen); | ||
7681 | segment = 1; | ||
7682 | } else { | ||
7683 | segment = -2; | ||
7684 | } | ||
7685 | } else { | ||
7686 | segment = 0; | ||
7687 | } | ||
7688 | |||
7689 | return segment; | ||
7690 | } | ||
7691 | |||
7692 | static int ncr_scatter(struct ncb *np, struct ccb *cp, struct scsi_cmnd *cmd) | 7646 | static int ncr_scatter(struct ncb *np, struct ccb *cp, struct scsi_cmnd *cmd) |
7693 | { | 7647 | { |
7694 | int segment = 0; | 7648 | int segment = 0; |
7695 | int use_sg = (int) cmd->use_sg; | 7649 | int use_sg = scsi_sg_count(cmd); |
7696 | 7650 | ||
7697 | cp->data_len = 0; | 7651 | cp->data_len = 0; |
7698 | 7652 | ||
7699 | if (!use_sg) | 7653 | use_sg = map_scsi_sg_data(np, cmd); |
7700 | segment = ncr_scatter_no_sglist(np, cp, cmd); | 7654 | if (use_sg > 0) { |
7701 | else if ((use_sg = map_scsi_sg_data(np, cmd)) > 0) { | 7655 | struct scatterlist *sg; |
7702 | struct scatterlist *scatter = (struct scatterlist *)cmd->request_buffer; | ||
7703 | struct scr_tblmove *data; | 7656 | struct scr_tblmove *data; |
7704 | 7657 | ||
7705 | if (use_sg > MAX_SCATTER) { | 7658 | if (use_sg > MAX_SCATTER) { |
@@ -7709,16 +7662,15 @@ static int ncr_scatter(struct ncb *np, struct ccb *cp, struct scsi_cmnd *cmd) | |||
7709 | 7662 | ||
7710 | data = &cp->phys.data[MAX_SCATTER - use_sg]; | 7663 | data = &cp->phys.data[MAX_SCATTER - use_sg]; |
7711 | 7664 | ||
7712 | for (segment = 0; segment < use_sg; segment++) { | 7665 | scsi_for_each_sg(cmd, sg, use_sg, segment) { |
7713 | dma_addr_t baddr = sg_dma_address(&scatter[segment]); | 7666 | dma_addr_t baddr = sg_dma_address(sg); |
7714 | unsigned int len = sg_dma_len(&scatter[segment]); | 7667 | unsigned int len = sg_dma_len(sg); |
7715 | 7668 | ||
7716 | ncr_build_sge(np, &data[segment], baddr, len); | 7669 | ncr_build_sge(np, &data[segment], baddr, len); |
7717 | cp->data_len += len; | 7670 | cp->data_len += len; |
7718 | } | 7671 | } |
7719 | } else { | 7672 | } else |
7720 | segment = -2; | 7673 | segment = -2; |
7721 | } | ||
7722 | 7674 | ||
7723 | return segment; | 7675 | return segment; |
7724 | } | 7676 | } |