]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/ide/ide-floppy.c
ide-floppy: merge callbacks
[linux-2.6-omap-h63xx.git] / drivers / ide / ide-floppy.c
index 8dbb340dbfc02137b139b0e1ca50fe95c2608926..2058a6f3f3316b2fbd9c615fe2e0dc3254389f1d 100644 (file)
@@ -312,50 +312,38 @@ static struct request *idefloppy_next_rq_storage(ide_drive_t *drive)
        return (&floppy->rq_stack[floppy->rq_stack_index++]);
 }
 
-static void idefloppy_request_sense_callback(ide_drive_t *drive)
+static void ide_floppy_callback(ide_drive_t *drive)
 {
        idefloppy_floppy_t *floppy = drive->driver_data;
-       u8 *buf = floppy->pc->buf;
+       struct ide_atapi_pc *pc = floppy->pc;
+       int uptodate = pc->error ? 0 : 1;
 
        debug_log("Reached %s\n", __func__);
 
-       if (!floppy->pc->error) {
-               floppy->sense_key = buf[2] & 0x0F;
-               floppy->asc = buf[12];
-               floppy->ascq = buf[13];
-               floppy->progress_indication = buf[15] & 0x80 ?
-                       (u16)get_unaligned((u16 *)&buf[16]) : 0x10000;
+       if (pc->c[0] == GPCMD_READ_10 || pc->c[0] == GPCMD_WRITE_10 ||
+           (pc->rq && blk_pc_request(pc->rq)))
+               uptodate = 1; /* FIXME */
+       else if (pc->c[0] == GPCMD_REQUEST_SENSE) {
+               u8 *buf = floppy->pc->buf;
 
-               if (floppy->failed_pc)
-                       debug_log("pc = %x, sense key = %x, asc = %x,"
-                                       " ascq = %x\n",
-                                       floppy->failed_pc->c[0],
-                                       floppy->sense_key,
-                                       floppy->asc,
-                                       floppy->ascq);
-               else
-                       debug_log("sense key = %x, asc = %x, ascq = %x\n",
-                                       floppy->sense_key,
-                                       floppy->asc,
-                                       floppy->ascq);
+               if (!pc->error) {
+                       floppy->sense_key = buf[2] & 0x0F;
+                       floppy->asc = buf[12];
+                       floppy->ascq = buf[13];
+                       floppy->progress_indication = buf[15] & 0x80 ?
+                               (u16)get_unaligned((u16 *)&buf[16]) : 0x10000;
 
+                       if (floppy->failed_pc)
+                               debug_log("pc = %x, ", floppy->failed_pc->c[0]);
 
-               idefloppy_end_request(drive, 1, 0);
-       } else {
-               printk(KERN_ERR "Error in REQUEST SENSE itself - Aborting"
-                               " request!\n");
-               idefloppy_end_request(drive, 0, 0);
+                       debug_log("sense key = %x, asc = %x, ascq = %x\n",
+                                 floppy->sense_key, floppy->asc, floppy->ascq);
+               } else
+                       printk(KERN_ERR "Error in REQUEST SENSE itself - "
+                                       "Aborting request!\n");
        }
-}
-
-/* General packet command callback function. */
-static void idefloppy_pc_callback(ide_drive_t *drive)
-{
-       idefloppy_floppy_t *floppy = drive->driver_data;
 
-       debug_log("Reached %s\n", __func__);
-
-       idefloppy_end_request(drive, floppy->pc->error ? 0 : 1, 0);
+       idefloppy_end_request(drive, uptodate, 0);
 }
 
 static void idefloppy_init_pc(struct ide_atapi_pc *pc)
@@ -366,7 +354,7 @@ static void idefloppy_init_pc(struct ide_atapi_pc *pc)
        pc->req_xfer = 0;
        pc->buf = pc->pc_buf;
        pc->buf_size = IDEFLOPPY_PC_BUFFER_SIZE;
-       pc->idefloppy_callback = &idefloppy_pc_callback;
+       pc->idefloppy_callback = &ide_floppy_callback;
 }
 
 static void idefloppy_create_request_sense_cmd(struct ide_atapi_pc *pc)
@@ -375,7 +363,6 @@ static void idefloppy_create_request_sense_cmd(struct ide_atapi_pc *pc)
        pc->c[0] = GPCMD_REQUEST_SENSE;
        pc->c[4] = 255;
        pc->req_xfer = 18;
-       pc->idefloppy_callback = &idefloppy_request_sense_callback;
 }
 
 /*
@@ -438,8 +425,8 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive)
                        debug_log("%s: I/O error\n", drive->name);
                        rq->errors++;
                        if (pc->c[0] == GPCMD_REQUEST_SENSE) {
-                               printk(KERN_ERR "ide-floppy: I/O error in "
-                                       "request sense command\n");
+                               printk(KERN_ERR "%s: I/O error in request sense"
+                                               " command\n", drive->name);
                                return ide_do_reset(drive);
                        }
                        /* Retry operation */
@@ -457,8 +444,8 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive)
 
        if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) {
                pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS;
-               printk(KERN_ERR "ide-floppy: The floppy wants to issue "
-                       "more interrupts in DMA mode\n");
+               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);
        }
@@ -470,14 +457,14 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive)
        ireason = hwif->INB(hwif->io_ports.nsect_addr);
 
        if (ireason & CD) {
-               printk(KERN_ERR "ide-floppy: CoD != 0 in %s\n", __func__);
+               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 "ide-floppy: We wanted to %s, ",
-                               (ireason & IO) ? "Write" : "Read");
-               printk(KERN_ERR "but the floppy wants us to %s !\n",
+               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);
        }
@@ -486,9 +473,10 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive)
                temp = pc->xferred + bcount;
                if (temp > pc->req_xfer) {
                        if (temp > pc->buf_size) {
-                               printk(KERN_ERR "ide-floppy: The floppy wants "
-                                       "to send us more data than expected "
-                                       "- discarding data\n");
+                               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,
@@ -497,8 +485,8 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive)
                                                NULL);
                                return ide_started;
                        }
-                       debug_log("The floppy wants to send us more data than"
-                                       " expected - allowing transfer\n");
+                       debug_log("The device wants to send us more data than "
+                                 "expected - allowing transfer\n");
                }
        }
        if (pc->flags & PC_FLAG_WRITING)
@@ -552,14 +540,14 @@ static ide_startstop_t idefloppy_transfer_pc1(ide_drive_t *drive)
        u8 ireason;
 
        if (ide_wait_stat(&startstop, drive, DRQ_STAT, BUSY_STAT, WAIT_READY)) {
-               printk(KERN_ERR "ide-floppy: Strange, packet command "
-                               "initiated yet DRQ isn't asserted\n");
+               printk(KERN_ERR "%s: Strange, packet command initiated yet "
+                               "DRQ isn't asserted\n", drive->name);
                return startstop;
        }
        ireason = hwif->INB(hwif->io_ports.nsect_addr);
        if ((ireason & CD) == 0 || (ireason & IO)) {
-               printk(KERN_ERR "ide-floppy: (IO,CoD) != (0,1) "
-                               "while issuing a packet command\n");
+               printk(KERN_ERR "%s: (IO,CoD) != (0,1) while issuing "
+                               "a packet command\n", drive->name);
                return ide_do_reset(drive);
        }
        /*
@@ -667,14 +655,6 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive,
        }
 }
 
-static void idefloppy_rw_callback(ide_drive_t *drive)
-{
-       debug_log("Reached %s\n", __func__);
-
-       idefloppy_end_request(drive, 1, 0);
-       return;
-}
-
 static void idefloppy_create_prevent_cmd(struct ide_atapi_pc *pc, int prevent)
 {
        debug_log("creating prevent removal command, prevent = %d\n", prevent);
@@ -769,7 +749,6 @@ static void idefloppy_create_rw_cmd(idefloppy_floppy_t *floppy,
        put_unaligned(cpu_to_be16(blocks), (unsigned short *)&pc->c[7]);
        put_unaligned(cpu_to_be32(block), (unsigned int *) &pc->c[2]);
 
-       pc->idefloppy_callback = &idefloppy_rw_callback;
        pc->rq = rq;
        pc->b_count = cmd == READ ? 0 : rq->bio->bi_size;
        if (rq->cmd_flags & REQ_RW)
@@ -783,7 +762,6 @@ static void idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy,
                struct ide_atapi_pc *pc, struct request *rq)
 {
        idefloppy_init_pc(pc);
-       pc->idefloppy_callback = &idefloppy_rw_callback;
        memcpy(pc->c, rq->cmd, sizeof(pc->c));
        pc->rq = rq;
        pc->b_count = rq->data_len;