diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2007-05-25 12:55:14 -0400 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.il.steeleye.com> | 2007-05-26 17:30:08 -0400 |
commit | 3a57c4a5aaee8d9d61b05d95d96f3fc4068b0518 (patch) | |
tree | 6c1dad5f5120406303c45ebdd915f6b02563ca08 /drivers/scsi | |
parent | 3258a4d5690880a62121553b604893ecaca7d042 (diff) |
[SCSI] aic7xxx: 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.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/aic7xxx/aic7xxx_osm.c | 59 | ||||
-rw-r--r-- | drivers/scsi/aic7xxx/aic7xxx_osm.h | 4 |
2 files changed, 12 insertions, 51 deletions
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c index 660f26e23a38..1803ab6fc21c 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_osm.c +++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c | |||
@@ -402,18 +402,8 @@ ahc_linux_unmap_scb(struct ahc_softc *ahc, struct scb *scb) | |||
402 | 402 | ||
403 | cmd = scb->io_ctx; | 403 | cmd = scb->io_ctx; |
404 | ahc_sync_sglist(ahc, scb, BUS_DMASYNC_POSTWRITE); | 404 | ahc_sync_sglist(ahc, scb, BUS_DMASYNC_POSTWRITE); |
405 | if (cmd->use_sg != 0) { | 405 | |
406 | struct scatterlist *sg; | 406 | scsi_dma_unmap(cmd); |
407 | |||
408 | sg = (struct scatterlist *)cmd->request_buffer; | ||
409 | pci_unmap_sg(ahc->dev_softc, sg, cmd->use_sg, | ||
410 | cmd->sc_data_direction); | ||
411 | } else if (cmd->request_bufflen != 0) { | ||
412 | pci_unmap_single(ahc->dev_softc, | ||
413 | scb->platform_data->buf_busaddr, | ||
414 | cmd->request_bufflen, | ||
415 | cmd->sc_data_direction); | ||
416 | } | ||
417 | } | 407 | } |
418 | 408 | ||
419 | static __inline int | 409 | static __inline int |
@@ -1381,6 +1371,7 @@ ahc_linux_run_command(struct ahc_softc *ahc, struct ahc_linux_device *dev, | |||
1381 | struct ahc_tmode_tstate *tstate; | 1371 | struct ahc_tmode_tstate *tstate; |
1382 | uint16_t mask; | 1372 | uint16_t mask; |
1383 | struct scb_tailq *untagged_q = NULL; | 1373 | struct scb_tailq *untagged_q = NULL; |
1374 | int nseg; | ||
1384 | 1375 | ||
1385 | /* | 1376 | /* |
1386 | * Schedule us to run later. The only reason we are not | 1377 | * Schedule us to run later. The only reason we are not |
@@ -1472,23 +1463,21 @@ ahc_linux_run_command(struct ahc_softc *ahc, struct ahc_linux_device *dev, | |||
1472 | ahc_set_residual(scb, 0); | 1463 | ahc_set_residual(scb, 0); |
1473 | ahc_set_sense_residual(scb, 0); | 1464 | ahc_set_sense_residual(scb, 0); |
1474 | scb->sg_count = 0; | 1465 | scb->sg_count = 0; |
1475 | if (cmd->use_sg != 0) { | 1466 | |
1467 | nseg = scsi_dma_map(cmd); | ||
1468 | BUG_ON(nseg < 0); | ||
1469 | if (nseg > 0) { | ||
1476 | struct ahc_dma_seg *sg; | 1470 | struct ahc_dma_seg *sg; |
1477 | struct scatterlist *cur_seg; | 1471 | struct scatterlist *cur_seg; |
1478 | struct scatterlist *end_seg; | 1472 | int i; |
1479 | int nseg; | ||
1480 | 1473 | ||
1481 | cur_seg = (struct scatterlist *)cmd->request_buffer; | ||
1482 | nseg = pci_map_sg(ahc->dev_softc, cur_seg, cmd->use_sg, | ||
1483 | cmd->sc_data_direction); | ||
1484 | end_seg = cur_seg + nseg; | ||
1485 | /* Copy the segments into the SG list. */ | 1474 | /* Copy the segments into the SG list. */ |
1486 | sg = scb->sg_list; | 1475 | sg = scb->sg_list; |
1487 | /* | 1476 | /* |
1488 | * The sg_count may be larger than nseg if | 1477 | * The sg_count may be larger than nseg if |
1489 | * a transfer crosses a 32bit page. | 1478 | * a transfer crosses a 32bit page. |
1490 | */ | 1479 | */ |
1491 | while (cur_seg < end_seg) { | 1480 | scsi_for_each_sg(cmd, cur_seg, nseg, i) { |
1492 | dma_addr_t addr; | 1481 | dma_addr_t addr; |
1493 | bus_size_t len; | 1482 | bus_size_t len; |
1494 | int consumed; | 1483 | int consumed; |
@@ -1499,7 +1488,6 @@ ahc_linux_run_command(struct ahc_softc *ahc, struct ahc_linux_device *dev, | |||
1499 | sg, addr, len); | 1488 | sg, addr, len); |
1500 | sg += consumed; | 1489 | sg += consumed; |
1501 | scb->sg_count += consumed; | 1490 | scb->sg_count += consumed; |
1502 | cur_seg++; | ||
1503 | } | 1491 | } |
1504 | sg--; | 1492 | sg--; |
1505 | sg->len |= ahc_htole32(AHC_DMA_LAST_SEG); | 1493 | sg->len |= ahc_htole32(AHC_DMA_LAST_SEG); |
@@ -1516,33 +1504,6 @@ ahc_linux_run_command(struct ahc_softc *ahc, struct ahc_linux_device *dev, | |||
1516 | */ | 1504 | */ |
1517 | scb->hscb->dataptr = scb->sg_list->addr; | 1505 | scb->hscb->dataptr = scb->sg_list->addr; |
1518 | scb->hscb->datacnt = scb->sg_list->len; | 1506 | scb->hscb->datacnt = scb->sg_list->len; |
1519 | } else if (cmd->request_bufflen != 0) { | ||
1520 | struct ahc_dma_seg *sg; | ||
1521 | dma_addr_t addr; | ||
1522 | |||
1523 | sg = scb->sg_list; | ||
1524 | addr = pci_map_single(ahc->dev_softc, | ||
1525 | cmd->request_buffer, | ||
1526 | cmd->request_bufflen, | ||
1527 | cmd->sc_data_direction); | ||
1528 | scb->platform_data->buf_busaddr = addr; | ||
1529 | scb->sg_count = ahc_linux_map_seg(ahc, scb, | ||
1530 | sg, addr, | ||
1531 | cmd->request_bufflen); | ||
1532 | sg->len |= ahc_htole32(AHC_DMA_LAST_SEG); | ||
1533 | |||
1534 | /* | ||
1535 | * Reset the sg list pointer. | ||
1536 | */ | ||
1537 | scb->hscb->sgptr = | ||
1538 | ahc_htole32(scb->sg_list_phys | SG_FULL_RESID); | ||
1539 | |||
1540 | /* | ||
1541 | * Copy the first SG into the "current" | ||
1542 | * data pointer area. | ||
1543 | */ | ||
1544 | scb->hscb->dataptr = sg->addr; | ||
1545 | scb->hscb->datacnt = sg->len; | ||
1546 | } else { | 1507 | } else { |
1547 | scb->hscb->sgptr = ahc_htole32(SG_LIST_NULL); | 1508 | scb->hscb->sgptr = ahc_htole32(SG_LIST_NULL); |
1548 | scb->hscb->dataptr = 0; | 1509 | scb->hscb->dataptr = 0; |
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.h b/drivers/scsi/aic7xxx/aic7xxx_osm.h index 8fee7edc6eb3..b48dab447bde 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_osm.h +++ b/drivers/scsi/aic7xxx/aic7xxx_osm.h | |||
@@ -751,7 +751,7 @@ int ahc_get_transfer_dir(struct scb *scb) | |||
751 | static __inline | 751 | static __inline |
752 | void ahc_set_residual(struct scb *scb, u_long resid) | 752 | void ahc_set_residual(struct scb *scb, u_long resid) |
753 | { | 753 | { |
754 | scb->io_ctx->resid = resid; | 754 | scsi_set_resid(scb->io_ctx, resid); |
755 | } | 755 | } |
756 | 756 | ||
757 | static __inline | 757 | static __inline |
@@ -763,7 +763,7 @@ void ahc_set_sense_residual(struct scb *scb, u_long resid) | |||
763 | static __inline | 763 | static __inline |
764 | u_long ahc_get_residual(struct scb *scb) | 764 | u_long ahc_get_residual(struct scb *scb) |
765 | { | 765 | { |
766 | return (scb->io_ctx->resid); | 766 | return scsi_get_resid(scb->io_ctx); |
767 | } | 767 | } |
768 | 768 | ||
769 | static __inline | 769 | static __inline |