]> err.no Git - linux-2.6/blobdiff - drivers/ide/ide-floppy.c
Merge branch 'core/rcu' into core/rcu-for-linus
[linux-2.6] / drivers / ide / ide-floppy.c
index 502ef9dcc5b9da25fcbafc3f45e1bf7439eff146..b3689437269f0586ebdfdebfa3ca53c2cd83a182 100644 (file)
@@ -388,132 +388,10 @@ static void idefloppy_retry_pc(ide_drive_t *drive)
 static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive)
 {
        idefloppy_floppy_t *floppy = drive->driver_data;
-       ide_hwif_t *hwif = drive->hwif;
-       struct ide_atapi_pc *pc = floppy->pc;
-       struct request *rq = pc->rq;
-       xfer_func_t *xferfunc;
-       unsigned int temp;
-       int dma_error = 0;
-       u16 bcount;
-       u8 stat, ireason;
-
-       debug_log("Enter %s - interrupt handler\n", __func__);
-
-       if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) {
-               dma_error = hwif->dma_ops->dma_end(drive);
-               if (dma_error) {
-                       printk(KERN_ERR "%s: DMA %s error\n", drive->name,
-                                       rq_data_dir(rq) ? "write" : "read");
-                       pc->flags |= PC_FLAG_DMA_ERROR;
-               } else {
-                       pc->xferred = pc->req_xfer;
-                       idefloppy_update_buffers(drive, pc);
-               }
-               debug_log("%s: DMA finished\n", drive->name);
-       }
-
-       /* Clear the interrupt */
-       stat = ide_read_status(drive);
-
-       /* No more interrupts */
-       if ((stat & DRQ_STAT) == 0) {
-               debug_log("Packet command completed, %d bytes transferred\n",
-                               pc->xferred);
-               pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS;
-
-               local_irq_enable_in_hardirq();
-
-               if ((stat & ERR_STAT) || (pc->flags & PC_FLAG_DMA_ERROR)) {
-                       /* Error detected */
-                       debug_log("%s: I/O error\n", drive->name);
-                       rq->errors++;
-                       if (pc->c[0] == GPCMD_REQUEST_SENSE) {
-                               printk(KERN_ERR "%s: I/O error in request sense"
-                                               " command\n", drive->name);
-                               return ide_do_reset(drive);
-                       }
-
-                       debug_log("[cmd %x]: check condition\n", pc->c[0]);
-
-                       /* Retry operation */
-                       idefloppy_retry_pc(drive);
-                       /* queued, but not started */
-                       return ide_stopped;
-               }
-               pc->error = 0;
-               /* Command finished - Call the callback function */
-               pc->callback(drive);
-               return ide_stopped;
-       }
-
-       if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) {
-               pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS;
-               printk(KERN_ERR "%s: The device wants to issue more interrupts "
-                               "in DMA mode\n", drive->name);
-               ide_dma_off(drive);
-               return ide_do_reset(drive);
-       }
-
-       /* Get the number of bytes to transfer */
-       bcount = (hwif->INB(hwif->io_ports.lbah_addr) << 8) |
-                 hwif->INB(hwif->io_ports.lbam_addr);
-       /* on this interrupt */
-       ireason = hwif->INB(hwif->io_ports.nsect_addr);
 
-       if (ireason & CD) {
-               printk(KERN_ERR "%s: CoD != 0 in %s\n", drive->name, __func__);
-               return ide_do_reset(drive);
-       }
-       if (((ireason & IO) == IO) == !!(pc->flags & PC_FLAG_WRITING)) {
-               /* Hopefully, we will never get here */
-               printk(KERN_ERR "%s: We wanted to %s, but the device wants us "
-                               "to %s!\n", drive->name,
-                               (ireason & IO) ? "Write" : "Read",
-                               (ireason & IO) ? "Read" : "Write");
-               return ide_do_reset(drive);
-       }
-       if (!(pc->flags & PC_FLAG_WRITING)) {
-               /* Reading - Check that we have enough space */
-               temp = pc->xferred + bcount;
-               if (temp > pc->req_xfer) {
-                       if (temp > pc->buf_size) {
-                               printk(KERN_ERR "%s: The device wants to send "
-                                               "us more data than expected - "
-                                               "discarding data\n",
-                                               drive->name);
-                               ide_pad_transfer(drive, 0, bcount);
-
-                               ide_set_handler(drive,
-                                               &idefloppy_pc_intr,
-                                               IDEFLOPPY_WAIT_CMD,
-                                               NULL);
-                               return ide_started;
-                       }
-                       debug_log("The device wants to send us more data than "
-                                 "expected - allowing transfer\n");
-               }
-       }
-       if (pc->flags & PC_FLAG_WRITING)
-               xferfunc = hwif->output_data;
-       else
-               xferfunc = hwif->input_data;
-
-       if (pc->buf)
-               xferfunc(drive, NULL, pc->cur_pos, bcount);
-       else
-               ide_floppy_io_buffers(drive, pc, bcount,
-                                     !!(pc->flags & PC_FLAG_WRITING));
-
-       /* Update the current position */
-       pc->xferred += bcount;
-       pc->cur_pos += bcount;
-
-       debug_log("[cmd %x] transferred %d bytes on that intr.\n",
-                 pc->c[0], bcount);
-
-       /* And set the interrupt handler again */
-       ide_set_handler(drive, &idefloppy_pc_intr, IDEFLOPPY_WAIT_CMD, NULL);
-       return ide_started;
+       return ide_pc_intr(drive, floppy->pc, idefloppy_pc_intr,
+                          IDEFLOPPY_WAIT_CMD, NULL, idefloppy_update_buffers,
+                          idefloppy_retry_pc, NULL, ide_floppy_io_buffers);
 }
 
 /*
@@ -521,12 +399,8 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive)
  * service routine. In interrupt mode, the device sends an interrupt to signal
  * that it is ready to receive a packet. However, we need to delay about 2-3
  * ticks before issuing the packet or we gets in trouble.
- *
- * So, follow carefully. transfer_pc1 is called as an interrupt (or directly).
- * In either case, when the device says it's ready for a packet, we schedule
- * the packet transfer to occur about 2-3 ticks later in transfer_pc2.
  */
-static int idefloppy_transfer_pc2(ide_drive_t *drive)
+static int idefloppy_transfer_pc(ide_drive_t *drive)
 {
        idefloppy_floppy_t *floppy = drive->driver_data;
 
@@ -537,7 +411,13 @@ static int idefloppy_transfer_pc2(ide_drive_t *drive)
        return IDEFLOPPY_WAIT_CMD;
 }
 
-static ide_startstop_t idefloppy_transfer_pc1(ide_drive_t *drive)
+
+/*
+ * Called as an interrupt (or directly). When the device says it's ready for a
+ * packet, we schedule the packet transfer to occur about 2-3 ticks later in
+ * transfer_pc.
+ */
+static ide_startstop_t idefloppy_start_pc_transfer(ide_drive_t *drive)
 {
        idefloppy_floppy_t *floppy = drive->driver_data;
        struct ide_atapi_pc *pc = floppy->pc;
@@ -554,7 +434,7 @@ static ide_startstop_t idefloppy_transfer_pc1(ide_drive_t *drive)
         */
        if (pc->flags & PC_FLAG_ZIP_DRIVE) {
                timeout = floppy->ticks;
-               expiry = &idefloppy_transfer_pc2;
+               expiry = &idefloppy_transfer_pc;
        } else {
                timeout = IDEFLOPPY_WAIT_CMD;
                expiry = NULL;
@@ -605,7 +485,7 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive,
 
        pc->retries++;
 
-       return ide_issue_pc(drive, pc, idefloppy_transfer_pc1,
+       return ide_issue_pc(drive, pc, idefloppy_start_pc_transfer,
                            IDEFLOPPY_WAIT_CMD, NULL);
 }