]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/ide/ide-floppy.c
[POWERPC] Don't special case pci_domain_nr() for iSeries
[linux-2.6-omap-h63xx.git] / drivers / ide / ide-floppy.c
index f429be88c4f9d568846baeb765181ccefc479ddd..04a357808f2e82a883770292bf00c5bd3e4f48cb 100644 (file)
@@ -99,6 +99,8 @@
 #include <linux/bitops.h>
 #include <linux/mutex.h>
 
+#include <scsi/scsi_ioctl.h>
+
 #include <asm/byteorder.h>
 #include <asm/irq.h>
 #include <asm/uaccess.h>
@@ -604,26 +606,24 @@ static void idefloppy_input_buffers (ide_drive_t *drive, idefloppy_pc_t *pc, uns
 {
        struct request *rq = pc->rq;
        struct bio_vec *bvec;
-       struct bio *bio;
+       struct req_iterator iter;
        unsigned long flags;
        char *data;
-       int count, i, done = 0;
+       int count, done = 0;
 
-       rq_for_each_bio(bio, rq) {
-               bio_for_each_segment(bvec, bio, i) {
-                       if (!bcount)
-                               break;
+       rq_for_each_segment(bvec, rq, iter) {
+               if (!bcount)
+                       break;
 
-                       count = min(bvec->bv_len, bcount);
+               count = min(bvec->bv_len, bcount);
 
-                       data = bvec_kmap_irq(bvec, &flags);
-                       drive->hwif->atapi_input_bytes(drive, data, count);
-                       bvec_kunmap_irq(data, &flags);
+               data = bvec_kmap_irq(bvec, &flags);
+               drive->hwif->atapi_input_bytes(drive, data, count);
+               bvec_kunmap_irq(data, &flags);
 
-                       bcount -= count;
-                       pc->b_count += count;
-                       done += count;
-               }
+               bcount -= count;
+               pc->b_count += count;
+               done += count;
        }
 
        idefloppy_do_end_request(drive, 1, done >> 9);
@@ -637,27 +637,25 @@ static void idefloppy_input_buffers (ide_drive_t *drive, idefloppy_pc_t *pc, uns
 static void idefloppy_output_buffers (ide_drive_t *drive, idefloppy_pc_t *pc, unsigned int bcount)
 {
        struct request *rq = pc->rq;
-       struct bio *bio;
+       struct req_iterator iter;
        struct bio_vec *bvec;
        unsigned long flags;
-       int count, i, done = 0;
+       int count, done = 0;
        char *data;
 
-       rq_for_each_bio(bio, rq) {
-               bio_for_each_segment(bvec, bio, i) {
-                       if (!bcount)
-                               break;
+       rq_for_each_segment(bvec, rq, iter) {
+               if (!bcount)
+                       break;
 
-                       count = min(bvec->bv_len, bcount);
+               count = min(bvec->bv_len, bcount);
 
-                       data = bvec_kmap_irq(bvec, &flags);
-                       drive->hwif->atapi_output_bytes(drive, data, count);
-                       bvec_kunmap_irq(data, &flags);
+               data = bvec_kmap_irq(bvec, &flags);
+               drive->hwif->atapi_output_bytes(drive, data, count);
+               bvec_kunmap_irq(data, &flags);
 
-                       bcount -= count;
-                       pc->b_count += count;
-                       done += count;
-               }
+               bcount -= count;
+               pc->b_count += count;
+               done += count;
        }
 
        idefloppy_do_end_request(drive, 1, done >> 9);
@@ -1258,19 +1256,25 @@ static void idefloppy_create_rw_cmd (idefloppy_floppy_t *floppy, idefloppy_pc_t
        set_bit(PC_DMA_RECOMMENDED, &pc->flags);
 }
 
-static int
+static void
 idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy, idefloppy_pc_t *pc, struct request *rq)
 {
-       /*
-        * just support eject for now, it would not be hard to make the
-        * REQ_BLOCK_PC support fully-featured
-        */
-       if (rq->cmd[0] != IDEFLOPPY_START_STOP_CMD)
-               return 1;
-
        idefloppy_init_pc(pc);
+       pc->callback = &idefloppy_rw_callback;
        memcpy(pc->c, rq->cmd, sizeof(pc->c));
-       return 0;
+       pc->rq = rq;
+       pc->b_count = rq->data_len;
+       if (rq->data_len && rq_data_dir(rq) == WRITE)
+               set_bit(PC_WRITING, &pc->flags);
+       pc->buffer = rq->data;
+       if (rq->bio)
+               set_bit(PC_DMA_RECOMMENDED, &pc->flags);
+               
+       /*
+        * possibly problematic, doesn't look like ide-floppy correctly
+        * handled scattered requests if dma fails...
+        */
+       pc->request_transfer = pc->buffer_size = rq->data_len;
 }
 
 /*
@@ -1317,10 +1321,7 @@ static ide_startstop_t idefloppy_do_request (ide_drive_t *drive, struct request
                pc = (idefloppy_pc_t *) rq->buffer;
        } else if (blk_pc_request(rq)) {
                pc = idefloppy_next_pc_storage(drive);
-               if (idefloppy_blockpc_cmd(floppy, pc, rq)) {
-                       idefloppy_do_end_request(drive, 0, 0);
-                       return ide_stopped;
-               }
+               idefloppy_blockpc_cmd(floppy, pc, rq);
        } else {
                blk_dump_rq_flags(rq,
                        "ide-floppy: unsupported command in queue");
@@ -2096,7 +2097,21 @@ static int idefloppy_ioctl(struct inode *inode, struct file *file,
        case IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS:
                return idefloppy_get_format_progress(drive, argp);
        }
-       return generic_ide_ioctl(drive, file, bdev, cmd, arg);
+
+       /*
+        * skip SCSI_IOCTL_SEND_COMMAND (deprecated)
+        * and CDROM_SEND_PACKET (legacy) ioctls
+        */
+       if (cmd != CDROM_SEND_PACKET && cmd != SCSI_IOCTL_SEND_COMMAND)
+               err = scsi_cmd_ioctl(file, bdev->bd_disk->queue,
+                                       bdev->bd_disk, cmd, argp);
+       else
+               err = -ENOTTY;
+
+       if (err == -ENOTTY)
+               err = generic_ide_ioctl(drive, file, bdev, cmd, arg);
+
+       return err;
 }
 
 static int idefloppy_media_changed(struct gendisk *disk)