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 | 5a5222d9fa4aa7ae3b1d5c126cb9c83124d75af5 (patch) | |
tree | a1ac9463990483fc323d99bf04877b215f5b338b | |
parent | 68661c53a2a847b9a0d6d232a85b2e063573307a (diff) |
ide-cd: add ide_cd_pad_transfer() helper
Add ide_cd_pad_transfer() helper and use it in cdrom_[new]pc_intr()
and cdrom_{read,write}_check_ireason().
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 | 51 |
1 files changed, 25 insertions, 26 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index f2b951dd1421..75539fd0829c 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -1007,6 +1007,15 @@ static ide_startstop_t cdrom_transfer_packet_command (ide_drive_t *drive, | |||
1007 | 1007 | ||
1008 | typedef void (xfer_func_t)(ide_drive_t *, void *, u32); | 1008 | typedef void (xfer_func_t)(ide_drive_t *, void *, u32); |
1009 | 1009 | ||
1010 | static void ide_cd_pad_transfer(ide_drive_t *drive, xfer_func_t *xf, int len) | ||
1011 | { | ||
1012 | while (len > 0) { | ||
1013 | int dum = 0; | ||
1014 | xf(drive, &dum, sizeof(dum)); | ||
1015 | len -= sizeof(dum); | ||
1016 | } | ||
1017 | } | ||
1018 | |||
1010 | /* | 1019 | /* |
1011 | * Buffer up to SECTORS_TO_TRANSFER sectors from the drive in our sector | 1020 | * Buffer up to SECTORS_TO_TRANSFER sectors from the drive in our sector |
1012 | * buffer. Once the first sector is added, any subsequent sectors are | 1021 | * buffer. Once the first sector is added, any subsequent sectors are |
@@ -1063,17 +1072,15 @@ int cdrom_read_check_ireason (ide_drive_t *drive, int len, int ireason) | |||
1063 | if (ireason == 2) | 1072 | if (ireason == 2) |
1064 | return 0; | 1073 | return 0; |
1065 | else if (ireason == 0) { | 1074 | else if (ireason == 0) { |
1075 | ide_hwif_t *hwif = drive->hwif; | ||
1076 | |||
1066 | /* Whoops... The drive is expecting to receive data from us! */ | 1077 | /* Whoops... The drive is expecting to receive data from us! */ |
1067 | printk(KERN_ERR "%s: %s: wrong transfer direction!\n", | 1078 | printk(KERN_ERR "%s: %s: wrong transfer direction!\n", |
1068 | drive->name, __FUNCTION__); | 1079 | drive->name, __FUNCTION__); |
1069 | 1080 | ||
1070 | /* Throw some data at the drive so it doesn't hang | 1081 | /* Throw some data at the drive so it doesn't hang |
1071 | and quit this request. */ | 1082 | and quit this request. */ |
1072 | while (len > 0) { | 1083 | ide_cd_pad_transfer(drive, hwif->atapi_output_bytes, len); |
1073 | int dum = 0; | ||
1074 | HWIF(drive)->atapi_output_bytes(drive, &dum, sizeof (dum)); | ||
1075 | len -= sizeof (dum); | ||
1076 | } | ||
1077 | } else if (ireason == 1) { | 1084 | } else if (ireason == 1) { |
1078 | /* Some drives (ASUS) seem to tell us that status | 1085 | /* Some drives (ASUS) seem to tell us that status |
1079 | * info is available. just get it and ignore. | 1086 | * info is available. just get it and ignore. |
@@ -1500,15 +1507,8 @@ static ide_startstop_t cdrom_pc_intr (ide_drive_t *drive) | |||
1500 | /* Transfer the data. */ | 1507 | /* Transfer the data. */ |
1501 | xferfunc(drive, rq->data, thislen); | 1508 | xferfunc(drive, rq->data, thislen); |
1502 | 1509 | ||
1503 | /* If we haven't moved enough data to satisfy the drive, | ||
1504 | add some padding. */ | ||
1505 | while (len > thislen) { | ||
1506 | int dum = 0; | ||
1507 | xferfunc(drive, &dum, sizeof(dum)); | ||
1508 | len -= sizeof(dum); | ||
1509 | } | ||
1510 | |||
1511 | /* Keep count of how much data we've moved. */ | 1510 | /* Keep count of how much data we've moved. */ |
1511 | len -= thislen; | ||
1512 | rq->data += thislen; | 1512 | rq->data += thislen; |
1513 | rq->data_len -= thislen; | 1513 | rq->data_len -= thislen; |
1514 | 1514 | ||
@@ -1525,6 +1525,13 @@ confused: | |||
1525 | return ide_stopped; | 1525 | return ide_stopped; |
1526 | } | 1526 | } |
1527 | 1527 | ||
1528 | /* | ||
1529 | * If we haven't moved enough data to satisfy the drive, | ||
1530 | * add some padding. | ||
1531 | */ | ||
1532 | if (len > 0) | ||
1533 | ide_cd_pad_transfer(drive, xferfunc, len); | ||
1534 | |||
1528 | /* Now we wait for another interrupt. */ | 1535 | /* Now we wait for another interrupt. */ |
1529 | ide_set_handler(drive, &cdrom_pc_intr, ATAPI_WAIT_PC, cdrom_timer_expiry); | 1536 | ide_set_handler(drive, &cdrom_pc_intr, ATAPI_WAIT_PC, cdrom_timer_expiry); |
1530 | return ide_started; | 1537 | return ide_started; |
@@ -1617,15 +1624,13 @@ static int cdrom_write_check_ireason(ide_drive_t *drive, int len, int ireason) | |||
1617 | if (ireason == 0) | 1624 | if (ireason == 0) |
1618 | return 0; | 1625 | return 0; |
1619 | else if (ireason == 2) { | 1626 | else if (ireason == 2) { |
1627 | ide_hwif_t *hwif = drive->hwif; | ||
1628 | |||
1620 | /* Whoops... The drive wants to send data. */ | 1629 | /* Whoops... The drive wants to send data. */ |
1621 | printk(KERN_ERR "%s: %s: wrong transfer direction!\n", | 1630 | printk(KERN_ERR "%s: %s: wrong transfer direction!\n", |
1622 | drive->name, __FUNCTION__); | 1631 | drive->name, __FUNCTION__); |
1623 | 1632 | ||
1624 | while (len > 0) { | 1633 | ide_cd_pad_transfer(drive, hwif->atapi_input_bytes, len); |
1625 | int dum = 0; | ||
1626 | HWIF(drive)->atapi_input_bytes(drive, &dum, sizeof(dum)); | ||
1627 | len -= sizeof(dum); | ||
1628 | } | ||
1629 | } else { | 1634 | } else { |
1630 | /* Drive wants a command packet, or invalid ireason... */ | 1635 | /* Drive wants a command packet, or invalid ireason... */ |
1631 | printk(KERN_ERR "%s: %s: bad interrupt reason 0x%02x\n", | 1636 | printk(KERN_ERR "%s: %s: bad interrupt reason 0x%02x\n", |
@@ -1783,14 +1788,8 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
1783 | /* | 1788 | /* |
1784 | * pad, if necessary | 1789 | * pad, if necessary |
1785 | */ | 1790 | */ |
1786 | if (len > 0) { | 1791 | if (len > 0) |
1787 | while (len > 0) { | 1792 | ide_cd_pad_transfer(drive, xferfunc, len); |
1788 | int pad = 0; | ||
1789 | |||
1790 | xferfunc(drive, &pad, sizeof(pad)); | ||
1791 | len -= sizeof(pad); | ||
1792 | } | ||
1793 | } | ||
1794 | 1793 | ||
1795 | BUG_ON(HWGROUP(drive)->handler != NULL); | 1794 | BUG_ON(HWGROUP(drive)->handler != NULL); |
1796 | 1795 | ||