Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=21ea1f0f011a5bbfbc3f5c134a4e537e5f5c1c50
Commit:     21ea1f0f011a5bbfbc3f5c134a4e537e5f5c1c50
Parent:     29f3aaca3c134d14309f6b0254edcfce54a0b00c
Author:     Bartlomiej Zolnierkiewicz <[EMAIL PROTECTED]>
AuthorDate: Fri Feb 1 23:09:27 2008 +0100
Committer:  Bartlomiej Zolnierkiewicz <[EMAIL PROTECTED]>
CommitDate: Fri Feb 1 23:09:27 2008 +0100

    ide-cd: merge cdrom_start_read() and cdrom_start_write()
    
    Add handling of read requests to cdrom_start_write(), rename it
    to cdrom_start_rw() and remove no longer needed cdrom_start_read().
    
    There should be no functionality changes caused by this patch.
    
    Signed-off-by: Bartlomiej Zolnierkiewicz <[EMAIL PROTECTED]>
---
 drivers/ide/ide-cd.c |  101 ++++++++++++++++++++------------------------------
 1 files changed, 40 insertions(+), 61 deletions(-)

diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index edcdc74..4b395e0 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -918,38 +918,6 @@ static void restore_request (struct request *rq)
        rq->q->prep_rq_fn(rq->q, rq);
 }
 
-/*
- * Start a read request from the CD-ROM.
- */
-static ide_startstop_t cdrom_start_read (ide_drive_t *drive, unsigned int 
block)
-{
-       struct cdrom_info *info = drive->driver_data;
-       struct request *rq = HWGROUP(drive)->rq;
-       unsigned short sectors_per_frame;
-
-       sectors_per_frame = queue_hardsect_size(drive->queue) >> SECTOR_BITS;
-
-       /* We may be retrying this request after an error.  Fix up
-          any weirdness which might be present in the request packet. */
-       restore_request(rq);
-
-       /* Satisfy whatever we can of this request from our cached sector. */
-       if (cdrom_read_from_buffer(drive))
-               return ide_stopped;
-
-       /* Clear the local sector buffer. */
-       info->nsectors_buffered = 0;
-
-       /* use dma, if possible. */
-       info->dma = drive->using_dma;
-       if ((rq->sector & (sectors_per_frame - 1)) ||
-           (rq->nr_sectors & (sectors_per_frame - 1)))
-               info->dma = 0;
-
-       /* Start sending the read request to the drive. */
-       return cdrom_start_packet_command(drive, 32768, cdrom_start_rw_cont);
-}
-
 /****************************************************************************
  * Execute all other packet commands.
  */
@@ -1383,38 +1351,53 @@ static ide_startstop_t cdrom_rw_intr(ide_drive_t *drive)
        return ide_started;
 }
 
-static ide_startstop_t cdrom_start_write(ide_drive_t *drive, struct request 
*rq)
+static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq)
 {
-       struct cdrom_info *info = drive->driver_data;
-       struct gendisk *g = info->disk;
-       unsigned short sectors_per_frame = queue_hardsect_size(drive->queue) >> 
SECTOR_BITS;
+       struct cdrom_info *cd = drive->driver_data;
+       int write = rq_data_dir(rq) == WRITE;
+       unsigned short sectors_per_frame =
+               queue_hardsect_size(drive->queue) >> SECTOR_BITS;
 
-       /*
-        * writes *must* be hardware frame aligned
-        */
-       if ((rq->nr_sectors & (sectors_per_frame - 1)) ||
-           (rq->sector & (sectors_per_frame - 1))) {
-               cdrom_end_request(drive, 0);
-               return ide_stopped;
+       if (write) {
+               /*
+                * disk has become write protected
+                */
+               if (cd->disk->policy) {
+                       cdrom_end_request(drive, 0);
+                       return ide_stopped;
+               }
+       } else {
+               /*
+                * We may be retrying this request after an error.  Fix up any
+                * weirdness which might be present in the request packet.
+                */
+               restore_request(rq);
+
+               /* Satisfy whatever we can of this request from our cache. */
+               if (cdrom_read_from_buffer(drive))
+                       return ide_stopped;
        }
 
        /*
-        * disk has become write protected
+        * use DMA, if possible / writes *must* be hardware frame aligned
         */
-       if (g->policy) {
-               cdrom_end_request(drive, 0);
-               return ide_stopped;
-       }
-
-       info->nsectors_buffered = 0;
+       if ((rq->nr_sectors & (sectors_per_frame - 1)) ||
+           (rq->sector & (sectors_per_frame - 1))) {
+               if (write) {
+                       cdrom_end_request(drive, 0);
+                       return ide_stopped;
+               }
+               cd->dma = 0;
+       } else
+               cd->dma = drive->using_dma;
 
-       /* use dma, if possible. we don't need to check more, since we
-        * know that the transfer is always (at least!) frame aligned */
-       info->dma = drive->using_dma ? 1 : 0;
+       /* Clear the local sector buffer. */
+       cd->nsectors_buffered = 0;
 
-       info->devinfo.media_written = 1;
+       if (write)
+               cd->devinfo.media_written = 1;
 
-       /* Start sending the write request to the drive. */
+       /* Start sending the read/write request to the drive. */
        return cdrom_start_packet_command(drive, 32768, cdrom_start_rw_cont);
 }
 
@@ -1487,12 +1470,8 @@ ide_do_rw_cdrom (ide_drive_t *drive, struct request *rq, 
sector_t block)
                }
                if ((rq_data_dir(rq) == READ) && 
IDE_LARGE_SEEK(info->last_block, block, IDECD_SEEK_THRESHOLD) && 
drive->dsc_overlap) {
                        action = cdrom_start_seek(drive, block);
-               } else {
-                       if (rq_data_dir(rq) == READ)
-                               action = cdrom_start_read(drive, block);
-                       else
-                               action = cdrom_start_write(drive, rq);
-               }
+               } else
+                       action = cdrom_start_rw(drive, rq);
                info->last_block = block;
                return action;
        } else if (blk_sense_request(rq) || blk_pc_request(rq) ||
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to