diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-02-01 17:09:17 -0500 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-02-01 17:09:17 -0500 |
commit | 68661c53a2a847b9a0d6d232a85b2e063573307a (patch) | |
tree | 6acdde3d562a9e310d598f475ecaeccd3f08c9fd | |
parent | 468e468139ffbc4f0ce44862eec6dd0f5ac80945 (diff) |
ide-cd: use xfer_func_t in cdrom_pc_intr()
Unify writing and reading handling in cdrom_pc_intr() using xfer_func_t.
There should be no functionality changes caused by this patch.
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
-rw-r--r-- | drivers/ide/ide-cd.c | 47 |
1 files changed, 17 insertions, 30 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index bee05a3f52ae..f2b951dd1421 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -1005,6 +1005,8 @@ static ide_startstop_t cdrom_transfer_packet_command (ide_drive_t *drive, | |||
1005 | * Block read functions. | 1005 | * Block read functions. |
1006 | */ | 1006 | */ |
1007 | 1007 | ||
1008 | typedef void (xfer_func_t)(ide_drive_t *, void *, u32); | ||
1009 | |||
1008 | /* | 1010 | /* |
1009 | * Buffer up to SECTORS_TO_TRANSFER sectors from the drive in our sector | 1011 | * Buffer up to SECTORS_TO_TRANSFER sectors from the drive in our sector |
1010 | * buffer. Once the first sector is added, any subsequent sectors are | 1012 | * buffer. Once the first sector is added, any subsequent sectors are |
@@ -1430,10 +1432,10 @@ static ide_startstop_t cdrom_start_read (ide_drive_t *drive, unsigned int block) | |||
1430 | /* Interrupt routine for packet command completion. */ | 1432 | /* Interrupt routine for packet command completion. */ |
1431 | static ide_startstop_t cdrom_pc_intr (ide_drive_t *drive) | 1433 | static ide_startstop_t cdrom_pc_intr (ide_drive_t *drive) |
1432 | { | 1434 | { |
1433 | int ireason, len, thislen; | ||
1434 | struct request *rq = HWGROUP(drive)->rq; | 1435 | struct request *rq = HWGROUP(drive)->rq; |
1436 | xfer_func_t *xferfunc = NULL; | ||
1437 | int stat, ireason, len, thislen, write; | ||
1435 | u8 lowcyl = 0, highcyl = 0; | 1438 | u8 lowcyl = 0, highcyl = 0; |
1436 | int stat; | ||
1437 | 1439 | ||
1438 | /* Check for errors. */ | 1440 | /* Check for errors. */ |
1439 | if (cdrom_decode_status(drive, 0, &stat)) | 1441 | if (cdrom_decode_status(drive, 0, &stat)) |
@@ -1478,44 +1480,31 @@ static ide_startstop_t cdrom_pc_intr (ide_drive_t *drive) | |||
1478 | 1480 | ||
1479 | /* Figure out how much data to transfer. */ | 1481 | /* Figure out how much data to transfer. */ |
1480 | thislen = rq->data_len; | 1482 | thislen = rq->data_len; |
1481 | if (thislen > len) thislen = len; | 1483 | if (thislen > len) |
1484 | thislen = len; | ||
1482 | 1485 | ||
1483 | /* The drive wants to be written to. */ | ||
1484 | if (ireason == 0) { | 1486 | if (ireason == 0) { |
1485 | if (!rq->data) { | 1487 | write = 1; |
1486 | blk_dump_rq_flags(rq, "cdrom_pc_intr, write"); | 1488 | xferfunc = HWIF(drive)->atapi_output_bytes; |
1487 | goto confused; | 1489 | } else if (ireason == 2) { |
1488 | } | 1490 | write = 0; |
1489 | /* Transfer the data. */ | 1491 | xferfunc = HWIF(drive)->atapi_input_bytes; |
1490 | HWIF(drive)->atapi_output_bytes(drive, rq->data, thislen); | ||
1491 | |||
1492 | /* If we haven't moved enough data to satisfy the drive, | ||
1493 | add some padding. */ | ||
1494 | while (len > thislen) { | ||
1495 | int dum = 0; | ||
1496 | HWIF(drive)->atapi_output_bytes(drive, &dum, sizeof(dum)); | ||
1497 | len -= sizeof(dum); | ||
1498 | } | ||
1499 | |||
1500 | /* Keep count of how much data we've moved. */ | ||
1501 | rq->data += thislen; | ||
1502 | rq->data_len -= thislen; | ||
1503 | } | 1492 | } |
1504 | 1493 | ||
1505 | /* Same drill for reading. */ | 1494 | if (xferfunc) { |
1506 | else if (ireason == 2) { | ||
1507 | if (!rq->data) { | 1495 | if (!rq->data) { |
1508 | blk_dump_rq_flags(rq, "cdrom_pc_intr, read"); | 1496 | blk_dump_rq_flags(rq, write ? "cdrom_pc_intr, write" |
1497 | : "cdrom_pc_intr, read"); | ||
1509 | goto confused; | 1498 | goto confused; |
1510 | } | 1499 | } |
1511 | /* Transfer the data. */ | 1500 | /* Transfer the data. */ |
1512 | HWIF(drive)->atapi_input_bytes(drive, rq->data, thislen); | 1501 | xferfunc(drive, rq->data, thislen); |
1513 | 1502 | ||
1514 | /* If we haven't moved enough data to satisfy the drive, | 1503 | /* If we haven't moved enough data to satisfy the drive, |
1515 | add some padding. */ | 1504 | add some padding. */ |
1516 | while (len > thislen) { | 1505 | while (len > thislen) { |
1517 | int dum = 0; | 1506 | int dum = 0; |
1518 | HWIF(drive)->atapi_input_bytes(drive, &dum, sizeof(dum)); | 1507 | xferfunc(drive, &dum, sizeof(dum)); |
1519 | len -= sizeof(dum); | 1508 | len -= sizeof(dum); |
1520 | } | 1509 | } |
1521 | 1510 | ||
@@ -1523,7 +1512,7 @@ static ide_startstop_t cdrom_pc_intr (ide_drive_t *drive) | |||
1523 | rq->data += thislen; | 1512 | rq->data += thislen; |
1524 | rq->data_len -= thislen; | 1513 | rq->data_len -= thislen; |
1525 | 1514 | ||
1526 | if (blk_sense_request(rq)) | 1515 | if (write && blk_sense_request(rq)) |
1527 | rq->sense_len += thislen; | 1516 | rq->sense_len += thislen; |
1528 | } else { | 1517 | } else { |
1529 | confused: | 1518 | confused: |
@@ -1658,8 +1647,6 @@ static int cdrom_newpc_intr_dummy_cb(struct request *rq) | |||
1658 | return 1; | 1647 | return 1; |
1659 | } | 1648 | } |
1660 | 1649 | ||
1661 | typedef void (xfer_func_t)(ide_drive_t *, void *, u32); | ||
1662 | |||
1663 | /* | 1650 | /* |
1664 | * best way to deal with dma that is not sector aligned right now... note | 1651 | * best way to deal with dma that is not sector aligned right now... note |
1665 | * that in this path we are not using ->data or ->buffer at all. this irs | 1652 | * that in this path we are not using ->data or ->buffer at all. this irs |