aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-02-01 17:09:26 -0500
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-02-01 17:09:26 -0500
commitb4ab726c92f8a2c1635958212e8933309de0a37a (patch)
tree2eb39fc968ad279b1199615061c8d21757b4a571 /drivers/ide
parentc9f56a801a3a9d76119868a687bc220d29055625 (diff)
ide-cd: add ide_cd_drain_data() helper
Add ide_cd_drain_data() and use it in cdrom_{buffer_sectors,read_intr}() (as a nice side-effect this cuts 0.5kB of code from ide-cd.o). There should be no functionality changes caused by this patch. Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide')
-rw-r--r--drivers/ide/ide-cd.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 6c31ce15210d..f0191f061775 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -626,6 +626,16 @@ static void ide_cd_pad_transfer(ide_drive_t *drive, xfer_func_t *xf, int len)
626 } 626 }
627} 627}
628 628
629static void ide_cd_drain_data(ide_drive_t *drive, int nsects)
630{
631 while (nsects > 0) {
632 static char dum[SECTOR_SIZE];
633
634 drive->hwif->atapi_input_bytes(drive, dum, sizeof(dum));
635 nsects--;
636 }
637}
638
629/* 639/*
630 * Buffer up to SECTORS_TO_TRANSFER sectors from the drive in our sector 640 * Buffer up to SECTORS_TO_TRANSFER sectors from the drive in our sector
631 * buffer. Once the first sector is added, any subsequent sectors are 641 * buffer. Once the first sector is added, any subsequent sectors are
@@ -664,11 +674,7 @@ static void cdrom_buffer_sectors (ide_drive_t *drive, unsigned long sector,
664 } 674 }
665 675
666 /* Throw away any remaining data. */ 676 /* Throw away any remaining data. */
667 while (sectors_to_transfer > 0) { 677 ide_cd_drain_data(drive, sectors_to_transfer);
668 static char dum[SECTOR_SIZE];
669 HWIF(drive)->atapi_input_bytes(drive, dum, sizeof (dum));
670 --sectors_to_transfer;
671 }
672} 678}
673 679
674/* 680/*
@@ -791,14 +797,10 @@ static ide_startstop_t cdrom_read_intr (ide_drive_t *drive)
791 any of the leading sectors. */ 797 any of the leading sectors. */
792 nskip = min_t(int, rq->current_nr_sectors - bio_cur_sectors(rq->bio), sectors_to_transfer); 798 nskip = min_t(int, rq->current_nr_sectors - bio_cur_sectors(rq->bio), sectors_to_transfer);
793 799
794 while (nskip > 0) { 800 if (nskip > 0) {
795 /* We need to throw away a sector. */ 801 ide_cd_drain_data(drive, nskip);
796 static char dum[SECTOR_SIZE]; 802 rq->current_nr_sectors -= nskip;
797 HWIF(drive)->atapi_input_bytes(drive, dum, sizeof (dum)); 803 sectors_to_transfer -= nskip;
798
799 --rq->current_nr_sectors;
800 --nskip;
801 --sectors_to_transfer;
802 } 804 }
803 805
804 /* Now loop while we still have data to read from the drive. */ 806 /* Now loop while we still have data to read from the drive. */