X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fide%2Fide-floppy.c;h=f05fbc2bd7a89ac597c1261acfc143f6df21d173;hb=be305042b7a01a1ab03a8adfa95f57bc63e012e1;hp=7e62dfc186f68829ae5e2b54086173c184889b85;hpb=8e555123911cc912427bd25b52ebfb7b6c08e39a;p=linux-2.6 diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 7e62dfc186..f05fbc2bd7 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c @@ -78,20 +78,6 @@ */ #define IDEFLOPPY_PC_STACK (10 + IDEFLOPPY_MAX_PC_RETRIES) -/* Packet command flag bits. */ -enum { - /* 1 when we prefer to use DMA if possible */ - PC_FLAG_DMA_RECOMMENDED = (1 << 0), - /* 1 while DMA in progress */ - PC_FLAG_DMA_IN_PROGRESS = (1 << 1), - /* 1 when encountered problem during DMA */ - PC_FLAG_DMA_ERROR = (1 << 2), - /* Data direction */ - PC_FLAG_WRITING = (1 << 3), - /* Suppress error reporting */ - PC_FLAG_SUPPRESS_ERROR = (1 << 4), -}; - /* format capacities descriptor codes */ #define CAPACITY_INVALID 0x00 #define CAPACITY_UNFORMATTED 0x01 @@ -213,7 +199,7 @@ static void ide_floppy_put(struct ide_floppy_obj *floppy) * Used to finish servicing a request. For read/write requests, we will call * ide_end_request to pass to the next buffer. */ -static int idefloppy_do_end_request(ide_drive_t *drive, int uptodate, int nsecs) +static int idefloppy_end_request(ide_drive_t *drive, int uptodate, int nsecs) { idefloppy_floppy_t *floppy = drive->driver_data; struct request *rq = HWGROUP(drive)->rq; @@ -245,6 +231,7 @@ static int idefloppy_do_end_request(ide_drive_t *drive, int uptodate, int nsecs) static void ide_floppy_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, unsigned int bcount, int direction) { + ide_hwif_t *hwif = drive->hwif; struct request *rq = pc->rq; struct req_iterator iter; struct bio_vec *bvec; @@ -260,9 +247,9 @@ static void ide_floppy_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, data = bvec_kmap_irq(bvec, &flags); if (direction) - drive->hwif->atapi_output_bytes(drive, data, count); + hwif->output_data(drive, NULL, data, count); else - drive->hwif->atapi_input_bytes(drive, data, count); + hwif->input_data(drive, NULL, data, count); bvec_kunmap_irq(data, &flags); bcount -= count; @@ -270,15 +257,12 @@ static void ide_floppy_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, done += count; } - idefloppy_do_end_request(drive, 1, done >> 9); + idefloppy_end_request(drive, 1, done >> 9); if (bcount) { printk(KERN_ERR "%s: leftover data in %s, bcount == %d\n", drive->name, __func__, bcount); - if (direction) - ide_atapi_write_zeros(drive, bcount); - else - ide_atapi_discard_data(drive, bcount); + ide_pad_transfer(drive, direction, bcount); } } @@ -289,7 +273,7 @@ static void idefloppy_update_buffers(ide_drive_t *drive, struct bio *bio = rq->bio; while ((bio = rq->bio) != NULL) - idefloppy_do_end_request(drive, 1, 0); + idefloppy_end_request(drive, 1, 0); } /* @@ -355,11 +339,11 @@ static void idefloppy_request_sense_callback(ide_drive_t *drive) floppy->ascq); - idefloppy_do_end_request(drive, 1, 0); + idefloppy_end_request(drive, 1, 0); } else { printk(KERN_ERR "Error in REQUEST SENSE itself - Aborting" " request!\n"); - idefloppy_do_end_request(drive, 0, 0); + idefloppy_end_request(drive, 0, 0); } } @@ -370,7 +354,7 @@ static void idefloppy_pc_callback(ide_drive_t *drive) debug_log("Reached %s\n", __func__); - idefloppy_do_end_request(drive, floppy->pc->error ? 0 : 1, 0); + idefloppy_end_request(drive, floppy->pc->error ? 0 : 1, 0); } static void idefloppy_init_pc(struct ide_atapi_pc *pc) @@ -410,7 +394,7 @@ static void idefloppy_retry_pc(ide_drive_t *drive) } /* The usual interrupt handler called during a packet command. */ -static ide_startstop_t idefloppy_pc_intr (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; @@ -425,7 +409,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) debug_log("Reached %s interrupt handler\n", __func__); if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { - dma_error = hwif->ide_dma_end(drive); + 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"); @@ -479,10 +463,10 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) } /* Get the number of bytes to transfer */ - bcount = (hwif->INB(hwif->io_ports[IDE_BCOUNTH_OFFSET]) << 8) | - hwif->INB(hwif->io_ports[IDE_BCOUNTL_OFFSET]); + 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[IDE_IREASON_OFFSET]); + ireason = hwif->INB(hwif->io_ports.nsect_addr); if (ireason & CD) { printk(KERN_ERR "ide-floppy: CoD != 0 in %s\n", __func__); @@ -504,7 +488,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) printk(KERN_ERR "ide-floppy: The floppy wants " "to send us more data than expected " "- discarding data\n"); - ide_atapi_discard_data(drive, bcount); + ide_pad_transfer(drive, 0, bcount); ide_set_handler(drive, &idefloppy_pc_intr, @@ -517,12 +501,12 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) } } if (pc->flags & PC_FLAG_WRITING) - xferfunc = hwif->atapi_output_bytes; + xferfunc = hwif->output_data; else - xferfunc = hwif->atapi_input_bytes; + xferfunc = hwif->input_data; if (pc->buf) - xferfunc(drive, pc->cur_pos, bcount); + xferfunc(drive, NULL, pc->cur_pos, bcount); else ide_floppy_io_buffers(drive, pc, bcount, !!(pc->flags & PC_FLAG_WRITING)); @@ -553,7 +537,7 @@ static ide_startstop_t idefloppy_transfer_pc(ide_drive_t *drive) "initiated yet DRQ isn't asserted\n"); return startstop; } - ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]); + 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"); @@ -562,8 +546,10 @@ static ide_startstop_t idefloppy_transfer_pc(ide_drive_t *drive) /* Set the interrupt routine */ ide_set_handler(drive, &idefloppy_pc_intr, IDEFLOPPY_WAIT_CMD, NULL); + /* Send the actual packet */ - HWIF(drive)->atapi_output_bytes(drive, floppy->pc->c, 12); + hwif->output_data(drive, NULL, floppy->pc->c, 12); + return ide_started; } @@ -583,7 +569,8 @@ static int idefloppy_transfer_pc2(ide_drive_t *drive) idefloppy_floppy_t *floppy = drive->driver_data; /* Send the actual packet */ - HWIF(drive)->atapi_output_bytes(drive, floppy->pc->c, 12); + drive->hwif->output_data(drive, NULL, floppy->pc->c, 12); + /* Timeout for the packet command */ return IDEFLOPPY_WAIT_CMD; } @@ -600,7 +587,7 @@ static ide_startstop_t idefloppy_transfer_pc1(ide_drive_t *drive) "initiated yet DRQ isn't asserted\n"); return startstop; } - ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]); + 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"); @@ -677,7 +664,7 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive, dma = 0; if ((pc->flags & PC_FLAG_DMA_RECOMMENDED) && drive->using_dma) - dma = !hwif->dma_setup(drive); + dma = !hwif->dma_ops->dma_setup(drive); ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK | IDE_TFLAG_OUT_DEVICE, bcount, dma); @@ -685,7 +672,7 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive, if (dma) { /* Begin DMA, if necessary */ pc->flags |= PC_FLAG_DMA_IN_PROGRESS; - hwif->dma_start(drive); + hwif->dma_ops->dma_start(drive); } /* Can we transfer the packet when we get the interrupt or wait? */ @@ -706,7 +693,7 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive, return ide_started; } else { /* Issue the packet command */ - hwif->OUTB(WIN_PACKETCMD, hwif->io_ports[IDE_COMMAND_OFFSET]); + ide_execute_pkt_cmd(drive); return (*pkt_xfer_routine) (drive); } } @@ -715,7 +702,7 @@ static void idefloppy_rw_callback(ide_drive_t *drive) { debug_log("Reached %s\n", __func__); - idefloppy_do_end_request(drive, 1, 0); + idefloppy_end_request(drive, 1, 0); return; } @@ -863,7 +850,7 @@ static ide_startstop_t idefloppy_do_request(ide_drive_t *drive, else printk(KERN_ERR "ide-floppy: %s: I/O error\n", drive->name); - idefloppy_do_end_request(drive, 0, 0); + idefloppy_end_request(drive, 0, 0); return ide_stopped; } if (blk_fs_request(rq)) { @@ -871,7 +858,7 @@ static ide_startstop_t idefloppy_do_request(ide_drive_t *drive, (rq->nr_sectors % floppy->bs_factor)) { printk(KERN_ERR "%s: unsupported r/w request size\n", drive->name); - idefloppy_do_end_request(drive, 0, 0); + idefloppy_end_request(drive, 0, 0); return ide_stopped; } pc = idefloppy_next_pc_storage(drive); @@ -884,7 +871,7 @@ static ide_startstop_t idefloppy_do_request(ide_drive_t *drive, } else { blk_dump_rq_flags(rq, "ide-floppy: unsupported command in queue"); - idefloppy_do_end_request(drive, 0, 0); + idefloppy_end_request(drive, 0, 0); return ide_stopped; } @@ -1359,7 +1346,7 @@ static ide_driver_t idefloppy_driver = { .media = ide_floppy, .supports_dsc_overlap = 0, .do_request = idefloppy_do_request, - .end_request = idefloppy_do_end_request, + .end_request = idefloppy_end_request, .error = __ide_error, .abort = __ide_abort, #ifdef CONFIG_IDE_PROC_FS @@ -1610,13 +1597,13 @@ static int idefloppy_revalidate_disk(struct gendisk *disk) } static struct block_device_operations idefloppy_ops = { - .owner = THIS_MODULE, - .open = idefloppy_open, - .release = idefloppy_release, - .ioctl = idefloppy_ioctl, - .getgeo = idefloppy_getgeo, - .media_changed = idefloppy_media_changed, - .revalidate_disk= idefloppy_revalidate_disk + .owner = THIS_MODULE, + .open = idefloppy_open, + .release = idefloppy_release, + .ioctl = idefloppy_ioctl, + .getgeo = idefloppy_getgeo, + .media_changed = idefloppy_media_changed, + .revalidate_disk = idefloppy_revalidate_disk }; static int ide_floppy_probe(ide_drive_t *drive)