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: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 29f3aaca
...@@ -918,38 +918,6 @@ static void restore_request (struct request *rq) ...@@ -918,38 +918,6 @@ static void restore_request (struct request *rq)
rq->q->prep_rq_fn(rq->q, 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. * Execute all other packet commands.
*/ */
...@@ -1383,38 +1351,53 @@ static ide_startstop_t cdrom_rw_intr(ide_drive_t *drive) ...@@ -1383,38 +1351,53 @@ static ide_startstop_t cdrom_rw_intr(ide_drive_t *drive)
return ide_started; 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 cdrom_info *cd = drive->driver_data;
struct gendisk *g = info->disk; int write = rq_data_dir(rq) == WRITE;
unsigned short sectors_per_frame = queue_hardsect_size(drive->queue) >> SECTOR_BITS; unsigned short sectors_per_frame =
queue_hardsect_size(drive->queue) >> SECTOR_BITS;
/* if (write) {
* writes *must* be hardware frame aligned /*
*/ * disk has become write protected
if ((rq->nr_sectors & (sectors_per_frame - 1)) || */
(rq->sector & (sectors_per_frame - 1))) { if (cd->disk->policy) {
cdrom_end_request(drive, 0); cdrom_end_request(drive, 0);
return ide_stopped; 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) { if ((rq->nr_sectors & (sectors_per_frame - 1)) ||
cdrom_end_request(drive, 0); (rq->sector & (sectors_per_frame - 1))) {
return ide_stopped; if (write) {
} cdrom_end_request(drive, 0);
return ide_stopped;
info->nsectors_buffered = 0; }
cd->dma = 0;
} else
cd->dma = drive->using_dma;
/* use dma, if possible. we don't need to check more, since we /* Clear the local sector buffer. */
* know that the transfer is always (at least!) frame aligned */ cd->nsectors_buffered = 0;
info->dma = drive->using_dma ? 1 : 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); 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) ...@@ -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) { 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); action = cdrom_start_seek(drive, block);
} else { } else
if (rq_data_dir(rq) == READ) action = cdrom_start_rw(drive, rq);
action = cdrom_start_read(drive, block);
else
action = cdrom_start_write(drive, rq);
}
info->last_block = block; info->last_block = block;
return action; return action;
} else if (blk_sense_request(rq) || blk_pc_request(rq) || } else if (blk_sense_request(rq) || blk_pc_request(rq) ||
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment