]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/ide/ide-disk.c
Merge branch 'kmemtrace-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-omap-h63xx.git] / drivers / ide / ide-disk.c
index dae9d988de10c142e03c48e031e80397fb687b5f..c998cf8e971a3f7bfbf70e7e42f40091349619eb 100644 (file)
@@ -99,11 +99,6 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
        memset(&cmd, 0, sizeof(cmd));
        cmd.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE;
 
-       if (dma == 0) {
-               ide_init_sg_cmd(&cmd, nsectors);
-               ide_map_sg(drive, rq);
-       }
-
        if (drive->dev_flags & IDE_DFLAG_LBA) {
                if (lba48) {
                        pr_debug("%s: LBA=0x%012llx\n", drive->name,
@@ -156,13 +151,18 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
        ide_tf_set_cmd(drive, &cmd, dma);
        cmd.rq = rq;
 
+       if (dma == 0) {
+               ide_init_sg_cmd(&cmd, nsectors << 9);
+               ide_map_sg(drive, &cmd);
+       }
+
        rc = do_rw_taskfile(drive, &cmd);
 
        if (rc == ide_stopped && dma) {
                /* fallback to PIO */
                cmd.tf_flags |= IDE_TFLAG_DMA_PIO_FALLBACK;
                ide_tf_set_cmd(drive, &cmd, 0);
-               ide_init_sg_cmd(&cmd, nsectors);
+               ide_init_sg_cmd(&cmd, nsectors << 9);
                rc = do_rw_taskfile(drive, &cmd);
        }
 
@@ -184,7 +184,9 @@ static ide_startstop_t ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
 
        if (!blk_fs_request(rq)) {
                blk_dump_rq_flags(rq, "ide_do_rw_disk - bad command");
-               ide_end_request(drive, 0, 0);
+               if (rq->errors == 0)
+                       rq->errors = -EIO;
+               ide_complete_rq(drive, -EIO, ide_rq_bytes(rq));
                return ide_stopped;
        }
 
@@ -225,7 +227,7 @@ static u64 idedisk_read_native_max_address(ide_drive_t *drive, int lba48)
        ide_no_data_taskfile(drive, &cmd);
 
        /* if OK, compute maximum address value */
-       if ((tf->status & 0x01) == 0)
+       if (!(tf->status & ATA_ERR))
                addr = ide_get_lba_addr(tf, lba48) + 1;
 
        return addr;
@@ -265,7 +267,7 @@ static u64 idedisk_set_max_address(ide_drive_t *drive, u64 addr_req, int lba48)
        ide_no_data_taskfile(drive, &cmd);
 
        /* if OK, compute maximum address value */
-       if ((tf->status & 0x01) == 0)
+       if (!(tf->status & ATA_ERR))
                addr_set = ide_get_lba_addr(tf, lba48) + 1;
 
        return addr_set;