]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/ide/ide-io.c
ide: remove now redundant ->cur_dev checks
[linux-2.6-omap-h63xx.git] / drivers / ide / ide-io.c
index 6ff82d7055b942d14fcef613dc6684448b2511a1..cc163319dfbdbe1812cb00c6a9fb0e72b957eda6 100644 (file)
@@ -199,9 +199,9 @@ EXPORT_SYMBOL(ide_end_drive_cmd);
 static void ide_kill_rq(ide_drive_t *drive, struct request *rq)
 {
        if (rq->rq_disk) {
-               ide_driver_t *drv;
+               struct ide_driver *drv;
 
-               drv = *(ide_driver_t **)rq->rq_disk->private_data;
+               drv = *(struct ide_driver **)rq->rq_disk->private_data;
                drv->end_request(drive, 0, 0);
        } else
                ide_end_request(drive, 0, 0);
@@ -291,7 +291,7 @@ static ide_startstop_t ide_atapi_error(ide_drive_t *drive, struct request *rq, u
        return ide_stopped;
 }
 
-ide_startstop_t
+static ide_startstop_t
 __ide_error(ide_drive_t *drive, struct request *rq, u8 stat, u8 err)
 {
        if (drive->media == ide_disk)
@@ -299,8 +299,6 @@ __ide_error(ide_drive_t *drive, struct request *rq, u8 stat, u8 err)
        return ide_atapi_error(drive, rq, stat, err);
 }
 
-EXPORT_SYMBOL_GPL(__ide_error);
-
 /**
  *     ide_error       -       handle an error on the IDE
  *     @drive: drive the error occurred on
@@ -332,15 +330,8 @@ ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, u8 stat)
                return ide_stopped;
        }
 
-       if (rq->rq_disk) {
-               ide_driver_t *drv;
-
-               drv = *(ide_driver_t **)rq->rq_disk->private_data;
-               return drv->error(drive, rq, stat, err);
-       } else
-               return __ide_error(drive, rq, stat, err);
+       return __ide_error(drive, rq, stat, err);
 }
-
 EXPORT_SYMBOL_GPL(ide_error);
 
 static void ide_tf_set_specify_cmd(ide_drive_t *drive, struct ide_taskfile *tf)
@@ -463,7 +454,7 @@ EXPORT_SYMBOL_GPL(ide_init_sg_cmd);
 static ide_startstop_t execute_drive_cmd (ide_drive_t *drive,
                struct request *rq)
 {
-       ide_hwif_t *hwif = HWIF(drive);
+       ide_hwif_t *hwif = drive->hwif;
        ide_task_t *task = rq->special;
 
        if (task) {
@@ -587,7 +578,7 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq)
 
 #ifdef DEBUG
        printk("%s: start_request: current=0x%08lx\n",
-               HWIF(drive)->name, (unsigned long) rq);
+               drive->hwif->name, (unsigned long) rq);
 #endif
 
        /* bail early if we've exceeded max_failures */
@@ -606,7 +597,7 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq)
                return startstop;
        }
        if (!drive->special.all) {
-               ide_driver_t *drv;
+               struct ide_driver *drv;
 
                /*
                 * We reset the drive so we need to issue a SETFEATURES.
@@ -639,7 +630,7 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq)
                         */
                        return ide_special_rq(drive, rq);
 
-               drv = *(ide_driver_t **)rq->rq_disk->private_data;
+               drv = *(struct ide_driver **)rq->rq_disk->private_data;
 
                return drv->do_request(drive, rq, rq->sector);
        }
@@ -833,7 +824,7 @@ plug_device_2:
  */
 static ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error)
 {
-       ide_hwif_t *hwif = HWIF(drive);
+       ide_hwif_t *hwif = drive->hwif;
        struct request *rq;
        ide_startstop_t ret = ide_stopped;
 
@@ -929,61 +920,55 @@ void ide_timer_expiry (unsigned long data)
                 * Either way, we don't really want to complain about anything.
                 */
        } else {
+               ide_expiry_t *expiry = hwif->expiry;
+               ide_startstop_t startstop = ide_stopped;
+
                drive = hwif->cur_dev;
-               if (!drive) {
-                       printk(KERN_ERR "%s: ->cur_dev was NULL\n", __func__);
-                       hwif->handler = NULL;
-               } else {
-                       ide_expiry_t *expiry = hwif->expiry;
-                       ide_startstop_t startstop = ide_stopped;
-
-                       if (expiry) {
-                               /* continue */
-                               if ((wait = expiry(drive)) > 0) {
-                                       /* reset timer */
-                                       hwif->timer.expires  = jiffies + wait;
-                                       hwif->req_gen_timer = hwif->req_gen;
-                                       add_timer(&hwif->timer);
-                                       spin_unlock_irqrestore(&hwif->lock, flags);
-                                       return;
-                               }
-                       }
-                       hwif->handler = NULL;
-                       /*
-                        * We need to simulate a real interrupt when invoking
-                        * the handler() function, which means we need to
-                        * globally mask the specific IRQ:
-                        */
-                       spin_unlock(&hwif->lock);
-                       hwif  = HWIF(drive);
-                       /* disable_irq_nosync ?? */
-                       disable_irq(hwif->irq);
-                       /* local CPU only,
-                        * as if we were handling an interrupt */
-                       local_irq_disable();
-                       if (hwif->polling) {
-                               startstop = handler(drive);
-                       } else if (drive_is_ready(drive)) {
-                               if (drive->waiting_for_dma)
-                                       hwif->dma_ops->dma_lost_irq(drive);
-                               (void)ide_ack_intr(hwif);
-                               printk(KERN_WARNING "%s: lost interrupt\n", drive->name);
-                               startstop = handler(drive);
-                       } else {
-                               if (drive->waiting_for_dma) {
-                                       startstop = ide_dma_timeout_retry(drive, wait);
-                               } else
-                                       startstop =
-                                       ide_error(drive, "irq timeout",
-                                                 hwif->tp_ops->read_status(hwif));
-                       }
-                       spin_lock_irq(&hwif->lock);
-                       enable_irq(hwif->irq);
-                       if (startstop == ide_stopped) {
-                               ide_unlock_port(hwif);
-                               plug_device = 1;
+
+               if (expiry) {
+                       wait = expiry(drive);
+                       if (wait > 0) { /* continue */
+                               /* reset timer */
+                               hwif->timer.expires = jiffies + wait;
+                               hwif->req_gen_timer = hwif->req_gen;
+                               add_timer(&hwif->timer);
+                               spin_unlock_irqrestore(&hwif->lock, flags);
+                               return;
                        }
                }
+               hwif->handler = NULL;
+               /*
+                * We need to simulate a real interrupt when invoking
+                * the handler() function, which means we need to
+                * globally mask the specific IRQ:
+                */
+               spin_unlock(&hwif->lock);
+               /* disable_irq_nosync ?? */
+               disable_irq(hwif->irq);
+               /* local CPU only, as if we were handling an interrupt */
+               local_irq_disable();
+               if (hwif->polling) {
+                       startstop = handler(drive);
+               } else if (drive_is_ready(drive)) {
+                       if (drive->waiting_for_dma)
+                               hwif->dma_ops->dma_lost_irq(drive);
+                       (void)ide_ack_intr(hwif);
+                       printk(KERN_WARNING "%s: lost interrupt\n",
+                               drive->name);
+                       startstop = handler(drive);
+               } else {
+                       if (drive->waiting_for_dma)
+                               startstop = ide_dma_timeout_retry(drive, wait);
+                       else
+                               startstop = ide_error(drive, "irq timeout",
+                                       hwif->tp_ops->read_status(hwif));
+               }
+               spin_lock_irq(&hwif->lock);
+               enable_irq(hwif->irq);
+               if (startstop == ide_stopped) {
+                       ide_unlock_port(hwif);
+                       plug_device = 1;
+               }
        }
        spin_unlock_irqrestore(&hwif->lock, flags);
 
@@ -1125,15 +1110,6 @@ irqreturn_t ide_intr (int irq, void *dev_id)
        }
 
        drive = hwif->cur_dev;
-       if (!drive) {
-               /*
-                * This should NEVER happen, and there isn't much
-                * we could do about it here.
-                *
-                * [Note - this can occur if the drive is hot unplugged]
-                */
-               goto out_handled;
-       }
 
        if (!drive_is_ready(drive))
                /*
@@ -1168,14 +1144,10 @@ irqreturn_t ide_intr (int irq, void *dev_id)
         * won't allow another of the same (on any CPU) until we return.
         */
        if (startstop == ide_stopped) {
-               if (hwif->handler == NULL) {    /* paranoia */
-                       ide_unlock_port(hwif);
-                       plug_device = 1;
-               } else
-                       printk(KERN_ERR "%s: %s: huh? expected NULL handler "
-                                       "on exit\n", __func__, drive->name);
+               BUG_ON(hwif->handler);
+               ide_unlock_port(hwif);
+               plug_device = 1;
        }
-out_handled:
        irq_ret = IRQ_HANDLED;
 out:
        spin_unlock_irqrestore(&hwif->lock, flags);