]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/ide/ide-io.c
x86: if we cannot calibrate the TSC, we panic.
[linux-2.6-omap-h63xx.git] / drivers / ide / ide-io.c
index 6f8f544392a82a5e4fdd90af36539694fd2d1037..715379605a7bb55f887eb887832c4765eccab485 100644 (file)
@@ -58,15 +58,19 @@ static int __ide_end_request(ide_drive_t *drive, struct request *rq,
                             int uptodate, unsigned int nr_bytes, int dequeue)
 {
        int ret = 1;
+       int error = 0;
+
+       if (uptodate <= 0)
+               error = uptodate ? uptodate : -EIO;
 
        /*
         * if failfast is set on a request, override number of sectors and
         * complete the whole request right now
         */
-       if (blk_noretry_request(rq) && end_io_error(uptodate))
+       if (blk_noretry_request(rq) && error)
                nr_bytes = rq->hard_nr_sectors << 9;
 
-       if (!blk_fs_request(rq) && end_io_error(uptodate) && !rq->errors)
+       if (!blk_fs_request(rq) && error && !rq->errors)
                rq->errors = -EIO;
 
        /*
@@ -78,14 +82,9 @@ static int __ide_end_request(ide_drive_t *drive, struct request *rq,
                ide_dma_on(drive);
        }
 
-       if (!end_that_request_chunk(rq, uptodate, nr_bytes)) {
-               add_disk_randomness(rq->rq_disk);
-               if (dequeue) {
-                       if (!list_empty(&rq->queuelist))
-                               blkdev_dequeue_request(rq);
+       if (!__blk_end_request(rq, error, nr_bytes)) {
+               if (dequeue)
                        HWGROUP(drive)->rq = NULL;
-               }
-               end_that_request_last(rq, uptodate);
                ret = 0;
        }
 
@@ -290,9 +289,9 @@ static void ide_complete_pm_request (ide_drive_t *drive, struct request *rq)
                drive->blocked = 0;
                blk_start_queue(drive->queue);
        }
-       blkdev_dequeue_request(rq);
        HWGROUP(drive)->rq = NULL;
-       end_that_request_last(rq, 1);
+       if (__blk_end_request(rq, 0, 0))
+               BUG();
        spin_unlock_irqrestore(&ide_lock, flags);
 }
 
@@ -362,17 +361,21 @@ void ide_end_drive_cmd (ide_drive_t *drive, u8 stat, u8 err)
        spin_unlock_irqrestore(&ide_lock, flags);
 
        if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE) {
-               ide_task_t *args = (ide_task_t *) rq->special;
+               ide_task_t *task = (ide_task_t *)rq->special;
+
                if (rq->errors == 0)
-                       rq->errors = !OK_STAT(stat,READY_STAT,BAD_STAT);
-                       
-               if (args) {
-                       struct ide_taskfile *tf = &args->tf;
+                       rq->errors = !OK_STAT(stat, READY_STAT, BAD_STAT);
+
+               if (task) {
+                       struct ide_taskfile *tf = &task->tf;
 
                        tf->error = err;
                        tf->status = stat;
 
-                       ide_tf_read(drive, args);
+                       ide_tf_read(drive, task);
+
+                       if (task->tf_flags & IDE_TFLAG_DYN)
+                               kfree(task);
                }
        } else if (blk_pm_request(rq)) {
                struct request_pm_state *pm = rq->data;
@@ -387,10 +390,11 @@ void ide_end_drive_cmd (ide_drive_t *drive, u8 stat, u8 err)
        }
 
        spin_lock_irqsave(&ide_lock, flags);
-       blkdev_dequeue_request(rq);
        HWGROUP(drive)->rq = NULL;
        rq->errors = err;
-       end_that_request_last(rq, !rq->errors);
+       if (unlikely(__blk_end_request(rq, (rq->errors ? -EIO : 0),
+                                      blk_rq_bytes(rq))))
+               BUG();
        spin_unlock_irqrestore(&ide_lock, flags);
 }
 
@@ -467,7 +471,7 @@ static ide_startstop_t ide_ata_error(ide_drive_t *drive, struct request *rq, u8
                return ide_stopped;
        }
 
-       if (hwif->INB(IDE_STATUS_REG) & (BUSY_STAT|DRQ_STAT))
+       if (ide_read_status(drive) & (BUSY_STAT | DRQ_STAT))
                rq->errors |= ERROR_RESET;
 
        if ((rq->errors & ERROR_RESET) == ERROR_RESET) {
@@ -494,7 +498,7 @@ static ide_startstop_t ide_atapi_error(ide_drive_t *drive, struct request *rq, u
                /* add decoding error stuff */
        }
 
-       if (hwif->INB(IDE_STATUS_REG) & (BUSY_STAT|DRQ_STAT))
+       if (ide_read_status(drive) & (BUSY_STAT | DRQ_STAT))
                /* force an abort */
                hwif->OUTB(WIN_IDLEIMMEDIATE, IDE_COMMAND_REG);
 
@@ -822,9 +826,8 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive,
 #ifdef DEBUG
        printk("%s: DRIVE_CMD (null)\n", drive->name);
 #endif
-       ide_end_drive_cmd(drive,
-                       hwif->INB(IDE_STATUS_REG),
-                       hwif->INB(IDE_ERROR_REG));
+       ide_end_drive_cmd(drive, ide_read_status(drive), ide_read_error(drive));
+
        return ide_stopped;
 }
 
@@ -1232,7 +1235,7 @@ static ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error)
                printk(KERN_WARNING "%s: DMA timeout error\n", drive->name);
                (void)HWIF(drive)->ide_dma_end(drive);
                ret = ide_error(drive, "dma timeout error",
-                                               hwif->INB(IDE_STATUS_REG));
+                               ide_read_status(drive));
        } else {
                printk(KERN_WARNING "%s: DMA timeout retry\n", drive->name);
                hwif->dma_timeout(drive);
@@ -1356,7 +1359,8 @@ void ide_timer_expiry (unsigned long data)
                                        startstop = ide_dma_timeout_retry(drive, wait);
                                } else
                                        startstop =
-                                       ide_error(drive, "irq timeout", hwif->INB(IDE_STATUS_REG));
+                                       ide_error(drive, "irq timeout",
+                                                 ide_read_status(drive));
                        }
                        drive->service_time = jiffies - drive->service_start;
                        spin_lock_irq(&ide_lock);
@@ -1488,7 +1492,7 @@ irqreturn_t ide_intr (int irq, void *dev_id)
                 * remove all the ifdef PCI crap
                 */
 #ifdef CONFIG_BLK_DEV_IDEPCI
-               if (hwif->pci_dev && !hwif->pci_dev->vendor)
+               if (hwif->chipset != ide_pci)
 #endif /* CONFIG_BLK_DEV_IDEPCI */
                {
                        /*