aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-cd.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/ide-cd.c')
-rw-r--r--drivers/ide/ide-cd.c64
1 files changed, 21 insertions, 43 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index a75e4ee1cd17..424140c6c400 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -182,7 +182,7 @@ static void cdrom_analyze_sense_data(ide_drive_t *drive,
182 (sense->information[2] << 8) | 182 (sense->information[2] << 8) |
183 (sense->information[3]); 183 (sense->information[3]);
184 184
185 if (drive->queue->hardsect_size == 2048) 185 if (queue_logical_block_size(drive->queue) == 2048)
186 /* device sector size is 2K */ 186 /* device sector size is 2K */
187 sector <<= 2; 187 sector <<= 2;
188 188
@@ -404,15 +404,7 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat)
404 404
405end_request: 405end_request:
406 if (stat & ATA_ERR) { 406 if (stat & ATA_ERR) {
407 struct request_queue *q = drive->queue;
408 unsigned long flags;
409
410 spin_lock_irqsave(q->queue_lock, flags);
411 blkdev_dequeue_request(rq);
412 spin_unlock_irqrestore(q->queue_lock, flags);
413
414 hwif->rq = NULL; 407 hwif->rq = NULL;
415
416 return ide_queue_sense_rq(drive, rq) ? 2 : 1; 408 return ide_queue_sense_rq(drive, rq) ? 2 : 1;
417 } else 409 } else
418 return 2; 410 return 2;
@@ -518,7 +510,7 @@ int ide_cd_queue_pc(ide_drive_t *drive, const unsigned char *cmd,
518 error = blk_execute_rq(drive->queue, info->disk, rq, 0); 510 error = blk_execute_rq(drive->queue, info->disk, rq, 0);
519 511
520 if (buffer) 512 if (buffer)
521 *bufflen = rq->data_len; 513 *bufflen = rq->resid_len;
522 514
523 flags = rq->cmd_flags; 515 flags = rq->cmd_flags;
524 blk_put_request(rq); 516 blk_put_request(rq);
@@ -576,7 +568,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
576 struct request *rq = hwif->rq; 568 struct request *rq = hwif->rq;
577 ide_expiry_t *expiry = NULL; 569 ide_expiry_t *expiry = NULL;
578 int dma_error = 0, dma, thislen, uptodate = 0; 570 int dma_error = 0, dma, thislen, uptodate = 0;
579 int write = (rq_data_dir(rq) == WRITE) ? 1 : 0, rc = 0, nsectors; 571 int write = (rq_data_dir(rq) == WRITE) ? 1 : 0, rc = 0;
580 int sense = blk_sense_request(rq); 572 int sense = blk_sense_request(rq);
581 unsigned int timeout; 573 unsigned int timeout;
582 u16 len; 574 u16 len;
@@ -706,13 +698,8 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
706 698
707out_end: 699out_end:
708 if (blk_pc_request(rq) && rc == 0) { 700 if (blk_pc_request(rq) && rc == 0) {
709 unsigned int dlen = rq->data_len; 701 rq->resid_len = 0;
710 702 blk_end_request_all(rq, 0);
711 rq->data_len = 0;
712
713 if (blk_end_request(rq, 0, dlen))
714 BUG();
715
716 hwif->rq = NULL; 703 hwif->rq = NULL;
717 } else { 704 } else {
718 if (sense && uptodate) 705 if (sense && uptodate)
@@ -730,21 +717,13 @@ out_end:
730 ide_cd_error_cmd(drive, cmd); 717 ide_cd_error_cmd(drive, cmd);
731 718
732 /* make sure it's fully ended */ 719 /* make sure it's fully ended */
733 if (blk_pc_request(rq))
734 nsectors = (rq->data_len + 511) >> 9;
735 else
736 nsectors = rq->hard_nr_sectors;
737
738 if (nsectors == 0)
739 nsectors = 1;
740
741 if (blk_fs_request(rq) == 0) { 720 if (blk_fs_request(rq) == 0) {
742 rq->data_len -= (cmd->nbytes - cmd->nleft); 721 rq->resid_len -= cmd->nbytes - cmd->nleft;
743 if (uptodate == 0 && (cmd->tf_flags & IDE_TFLAG_WRITE)) 722 if (uptodate == 0 && (cmd->tf_flags & IDE_TFLAG_WRITE))
744 rq->data_len += cmd->last_xfer_len; 723 rq->resid_len += cmd->last_xfer_len;
745 } 724 }
746 725
747 ide_complete_rq(drive, uptodate ? 0 : -EIO, nsectors << 9); 726 ide_complete_rq(drive, uptodate ? 0 : -EIO, blk_rq_bytes(rq));
748 727
749 if (sense && rc == 2) 728 if (sense && rc == 2)
750 ide_error(drive, "request sense failure", stat); 729 ide_error(drive, "request sense failure", stat);
@@ -758,7 +737,7 @@ static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq)
758 struct request_queue *q = drive->queue; 737 struct request_queue *q = drive->queue;
759 int write = rq_data_dir(rq) == WRITE; 738 int write = rq_data_dir(rq) == WRITE;
760 unsigned short sectors_per_frame = 739 unsigned short sectors_per_frame =
761 queue_hardsect_size(q) >> SECTOR_BITS; 740 queue_logical_block_size(q) >> SECTOR_BITS;
762 741
763 ide_debug_log(IDE_DBG_RQ, "rq->cmd[0]: 0x%x, rq->cmd_flags: 0x%x, " 742 ide_debug_log(IDE_DBG_RQ, "rq->cmd[0]: 0x%x, rq->cmd_flags: 0x%x, "
764 "secs_per_frame: %u", 743 "secs_per_frame: %u",
@@ -777,8 +756,8 @@ static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq)
777 } 756 }
778 757
779 /* fs requests *must* be hardware frame aligned */ 758 /* fs requests *must* be hardware frame aligned */
780 if ((rq->nr_sectors & (sectors_per_frame - 1)) || 759 if ((blk_rq_sectors(rq) & (sectors_per_frame - 1)) ||
781 (rq->sector & (sectors_per_frame - 1))) 760 (blk_rq_pos(rq) & (sectors_per_frame - 1)))
782 return ide_stopped; 761 return ide_stopped;
783 762
784 /* use DMA, if possible */ 763 /* use DMA, if possible */
@@ -821,7 +800,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
821 */ 800 */
822 alignment = queue_dma_alignment(q) | q->dma_pad_mask; 801 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
823 if ((unsigned long)buf & alignment 802 if ((unsigned long)buf & alignment
824 || rq->data_len & q->dma_pad_mask 803 || blk_rq_bytes(rq) & q->dma_pad_mask
825 || object_is_on_stack(buf)) 804 || object_is_on_stack(buf))
826 drive->dma = 0; 805 drive->dma = 0;
827 } 806 }
@@ -869,15 +848,14 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
869 848
870 cmd.rq = rq; 849 cmd.rq = rq;
871 850
872 if (blk_fs_request(rq) || rq->data_len) { 851 if (blk_fs_request(rq) || blk_rq_bytes(rq)) {
873 ide_init_sg_cmd(&cmd, blk_fs_request(rq) ? (rq->nr_sectors << 9) 852 ide_init_sg_cmd(&cmd, blk_rq_bytes(rq));
874 : rq->data_len);
875 ide_map_sg(drive, &cmd); 853 ide_map_sg(drive, &cmd);
876 } 854 }
877 855
878 return ide_issue_pc(drive, &cmd); 856 return ide_issue_pc(drive, &cmd);
879out_end: 857out_end:
880 nsectors = rq->hard_nr_sectors; 858 nsectors = blk_rq_sectors(rq);
881 859
882 if (nsectors == 0) 860 if (nsectors == 0)
883 nsectors = 1; 861 nsectors = 1;
@@ -1043,8 +1021,8 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense)
1043 /* save a private copy of the TOC capacity for error handling */ 1021 /* save a private copy of the TOC capacity for error handling */
1044 drive->probed_capacity = toc->capacity * sectors_per_frame; 1022 drive->probed_capacity = toc->capacity * sectors_per_frame;
1045 1023
1046 blk_queue_hardsect_size(drive->queue, 1024 blk_queue_logical_block_size(drive->queue,
1047 sectors_per_frame << SECTOR_BITS); 1025 sectors_per_frame << SECTOR_BITS);
1048 1026
1049 /* first read just the header, so we know how long the TOC is */ 1027 /* first read just the header, so we know how long the TOC is */
1050 stat = cdrom_read_tocentry(drive, 0, 1, 0, (char *) &toc->hdr, 1028 stat = cdrom_read_tocentry(drive, 0, 1, 0, (char *) &toc->hdr,
@@ -1360,9 +1338,9 @@ static int ide_cdrom_probe_capabilities(ide_drive_t *drive)
1360/* standard prep_rq_fn that builds 10 byte cmds */ 1338/* standard prep_rq_fn that builds 10 byte cmds */
1361static int ide_cdrom_prep_fs(struct request_queue *q, struct request *rq) 1339static int ide_cdrom_prep_fs(struct request_queue *q, struct request *rq)
1362{ 1340{
1363 int hard_sect = queue_hardsect_size(q); 1341 int hard_sect = queue_logical_block_size(q);
1364 long block = (long)rq->hard_sector / (hard_sect >> 9); 1342 long block = (long)blk_rq_pos(rq) / (hard_sect >> 9);
1365 unsigned long blocks = rq->hard_nr_sectors / (hard_sect >> 9); 1343 unsigned long blocks = blk_rq_sectors(rq) / (hard_sect >> 9);
1366 1344
1367 memset(rq->cmd, 0, BLK_MAX_CDB); 1345 memset(rq->cmd, 0, BLK_MAX_CDB);
1368 1346
@@ -1565,7 +1543,7 @@ static int ide_cdrom_setup(ide_drive_t *drive)
1565 1543
1566 nslots = ide_cdrom_probe_capabilities(drive); 1544 nslots = ide_cdrom_probe_capabilities(drive);
1567 1545
1568 blk_queue_hardsect_size(q, CD_FRAMESIZE); 1546 blk_queue_logical_block_size(q, CD_FRAMESIZE);
1569 1547
1570 if (ide_cdrom_register(drive, nslots)) { 1548 if (ide_cdrom_register(drive, nslots)) {
1571 printk(KERN_ERR PFX "%s: %s failed to register device with the" 1549 printk(KERN_ERR PFX "%s: %s failed to register device with the"