aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-cd.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-02-01 17:09:27 -0500
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-02-01 17:09:27 -0500
commit21ea1f0f011a5bbfbc3f5c134a4e537e5f5c1c50 (patch)
tree77d9b2ec9667c37ba99a8666f3ac160c87502d74 /drivers/ide/ide-cd.c
parent29f3aaca3c134d14309f6b0254edcfce54a0b00c (diff)
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 <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-cd.c')
-rw-r--r--drivers/ide/ide-cd.c101
1 files changed, 40 insertions, 61 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index edcdc7432ddf..4b395e015e76 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -918,38 +918,6 @@ static void restore_request (struct request *rq)
918 rq->q->prep_rq_fn(rq->q, rq); 918 rq->q->prep_rq_fn(rq->q, rq);
919} 919}
920 920
921/*
922 * Start a read request from the CD-ROM.
923 */
924static ide_startstop_t cdrom_start_read (ide_drive_t *drive, unsigned int block)
925{
926 struct cdrom_info *info = drive->driver_data;
927 struct request *rq = HWGROUP(drive)->rq;
928 unsigned short sectors_per_frame;
929
930 sectors_per_frame = queue_hardsect_size(drive->queue) >> SECTOR_BITS;
931
932 /* We may be retrying this request after an error. Fix up
933 any weirdness which might be present in the request packet. */
934 restore_request(rq);
935
936 /* Satisfy whatever we can of this request from our cached sector. */
937 if (cdrom_read_from_buffer(drive))
938 return ide_stopped;
939
940 /* Clear the local sector buffer. */
941 info->nsectors_buffered = 0;
942
943 /* use dma, if possible. */
944 info->dma = drive->using_dma;
945 if ((rq->sector & (sectors_per_frame - 1)) ||
946 (rq->nr_sectors & (sectors_per_frame - 1)))
947 info->dma = 0;
948
949 /* Start sending the read request to the drive. */
950 return cdrom_start_packet_command(drive, 32768, cdrom_start_rw_cont);
951}
952
953/**************************************************************************** 921/****************************************************************************
954 * Execute all other packet commands. 922 * Execute all other packet commands.
955 */ 923 */
@@ -1383,38 +1351,53 @@ static ide_startstop_t cdrom_rw_intr(ide_drive_t *drive)
1383 return ide_started; 1351 return ide_started;
1384} 1352}
1385 1353
1386static ide_startstop_t cdrom_start_write(ide_drive_t *drive, struct request *rq) 1354static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq)
1387{ 1355{
1388 struct cdrom_info *info = drive->driver_data; 1356 struct cdrom_info *cd = drive->driver_data;
1389 struct gendisk *g = info->disk; 1357 int write = rq_data_dir(rq) == WRITE;
1390 unsigned short sectors_per_frame = queue_hardsect_size(drive->queue) >> SECTOR_BITS; 1358 unsigned short sectors_per_frame =
1359 queue_hardsect_size(drive->queue) >> SECTOR_BITS;
1391 1360
1392 /* 1361 if (write) {
1393 * writes *must* be hardware frame aligned 1362 /*
1394 */ 1363 * disk has become write protected
1395 if ((rq->nr_sectors & (sectors_per_frame - 1)) || 1364 */
1396 (rq->sector & (sectors_per_frame - 1))) { 1365 if (cd->disk->policy) {
1397 cdrom_end_request(drive, 0); 1366 cdrom_end_request(drive, 0);
1398 return ide_stopped; 1367 return ide_stopped;
1368 }
1369 } else {
1370 /*
1371 * We may be retrying this request after an error. Fix up any
1372 * weirdness which might be present in the request packet.
1373 */
1374 restore_request(rq);
1375
1376 /* Satisfy whatever we can of this request from our cache. */
1377 if (cdrom_read_from_buffer(drive))
1378 return ide_stopped;
1399 } 1379 }
1400 1380
1401 /* 1381 /*
1402 * disk has become write protected 1382 * use DMA, if possible / writes *must* be hardware frame aligned
1403 */ 1383 */
1404 if (g->policy) { 1384 if ((rq->nr_sectors & (sectors_per_frame - 1)) ||
1405 cdrom_end_request(drive, 0); 1385 (rq->sector & (sectors_per_frame - 1))) {
1406 return ide_stopped; 1386 if (write) {
1407 } 1387 cdrom_end_request(drive, 0);
1408 1388 return ide_stopped;
1409 info->nsectors_buffered = 0; 1389 }
1390 cd->dma = 0;
1391 } else
1392 cd->dma = drive->using_dma;
1410 1393
1411 /* use dma, if possible. we don't need to check more, since we 1394 /* Clear the local sector buffer. */
1412 * know that the transfer is always (at least!) frame aligned */ 1395 cd->nsectors_buffered = 0;
1413 info->dma = drive->using_dma ? 1 : 0;
1414 1396
1415 info->devinfo.media_written = 1; 1397 if (write)
1398 cd->devinfo.media_written = 1;
1416 1399
1417 /* Start sending the write request to the drive. */ 1400 /* Start sending the read/write request to the drive. */
1418 return cdrom_start_packet_command(drive, 32768, cdrom_start_rw_cont); 1401 return cdrom_start_packet_command(drive, 32768, cdrom_start_rw_cont);
1419} 1402}
1420 1403
@@ -1487,12 +1470,8 @@ ide_do_rw_cdrom (ide_drive_t *drive, struct request *rq, sector_t block)
1487 } 1470 }
1488 if ((rq_data_dir(rq) == READ) && IDE_LARGE_SEEK(info->last_block, block, IDECD_SEEK_THRESHOLD) && drive->dsc_overlap) { 1471 if ((rq_data_dir(rq) == READ) && IDE_LARGE_SEEK(info->last_block, block, IDECD_SEEK_THRESHOLD) && drive->dsc_overlap) {
1489 action = cdrom_start_seek(drive, block); 1472 action = cdrom_start_seek(drive, block);
1490 } else { 1473 } else
1491 if (rq_data_dir(rq) == READ) 1474 action = cdrom_start_rw(drive, rq);
1492 action = cdrom_start_read(drive, block);
1493 else
1494 action = cdrom_start_write(drive, rq);
1495 }
1496 info->last_block = block; 1475 info->last_block = block;
1497 return action; 1476 return action;
1498 } else if (blk_sense_request(rq) || blk_pc_request(rq) || 1477 } else if (blk_sense_request(rq) || blk_pc_request(rq) ||