ide: delete filenames/versions from comments
[pandora-kernel.git] / drivers / ide / ide-floppy.c
index a21f585..b6454f0 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * linux/drivers/ide/ide-floppy.c      Version 0.99    Feb 24 2002
- *
  * Copyright (C) 1996 - 1999 Gadi Oxman <gadio@netvision.net.il>
  * Copyright (C) 2000 - 2002 Paul Bristow <paul@paulbristow.net>
  */
@@ -99,6 +97,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>
@@ -367,27 +367,6 @@ typedef struct ide_floppy_obj {
 #define        IDEFLOPPY_IOCTL_FORMAT_START            0x4602
 #define IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS    0x4603
 
-#if 0
-/*
- *     Special requests for our block device strategy routine.
- */
-#define        IDEFLOPPY_FIRST_RQ      90
-
-/*
- *     IDEFLOPPY_PC_RQ is used to queue a packet command in the request queue.
- */
-#define        IDEFLOPPY_PC_RQ         90
-
-#define IDEFLOPPY_LAST_RQ      90
-
-/*
- *     A macro which can be used to check if a given request command
- *     originated in the driver or in the buffer cache layer.
- */
-#define IDEFLOPPY_RQ_CMD(cmd)  ((cmd >= IDEFLOPPY_FIRST_RQ) && (cmd <= IDEFLOPPY_LAST_RQ))
-
-#endif
-
 /*
  *     Error codes which are returned in rq->errors to the higher part
  *     of the driver.
@@ -604,26 +583,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 +614,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);
@@ -795,9 +770,8 @@ static void idefloppy_retry_pc (ide_drive_t *drive)
 {
        idefloppy_pc_t *pc;
        struct request *rq;
-       atapi_error_t error;
 
-       error.all = HWIF(drive)->INB(IDE_ERROR_REG);
+       (void)drive->hwif->INB(IDE_ERROR_REG);
        pc = idefloppy_next_pc_storage(drive);
        rq = idefloppy_next_rq_storage(drive);
        idefloppy_create_request_sense_cmd(pc);
@@ -811,12 +785,12 @@ 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;
-       atapi_status_t status;
-       atapi_bcount_t bcount;
-       atapi_ireason_t ireason;
+       ide_hwif_t *hwif = drive->hwif;
        idefloppy_pc_t *pc = floppy->pc;
        struct request *rq = pc->rq;
        unsigned int temp;
+       u16 bcount;
+       u8 stat, ireason;
 
        debug_log(KERN_INFO "ide-floppy: Reached %s interrupt handler\n",
                __FUNCTION__);
@@ -832,16 +806,16 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive)
        }
 
        /* Clear the interrupt */
-       status.all = HWIF(drive)->INB(IDE_STATUS_REG);
+       stat = drive->hwif->INB(IDE_STATUS_REG);
 
-       if (!status.b.drq) {                    /* No more interrupts */
+       if ((stat & DRQ_STAT) == 0) {           /* No more interrupts */
                debug_log(KERN_INFO "Packet command completed, %d bytes "
                        "transferred\n", pc->actually_transferred);
                clear_bit(PC_DMA_IN_PROGRESS, &pc->flags);
 
                local_irq_enable_in_hardirq();
 
-               if (status.b.check || test_bit(PC_DMA_ERROR, &pc->flags)) {
+               if ((stat & ERR_STAT) || test_bit(PC_DMA_ERROR, &pc->flags)) {
                        /* Error detected */
                        debug_log(KERN_INFO "ide-floppy: %s: I/O error\n",
                                drive->name);
@@ -872,32 +846,32 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive)
        }
 
        /* Get the number of bytes to transfer */
-       bcount.b.high = HWIF(drive)->INB(IDE_BCOUNTH_REG);
-       bcount.b.low = HWIF(drive)->INB(IDE_BCOUNTL_REG);
+       bcount = (hwif->INB(IDE_BCOUNTH_REG) << 8) |
+                 hwif->INB(IDE_BCOUNTL_REG);
        /* on this interrupt */
-       ireason.all = HWIF(drive)->INB(IDE_IREASON_REG);
+       ireason = hwif->INB(IDE_IREASON_REG);
 
-       if (ireason.b.cod) {
+       if (ireason & CD) {
                printk(KERN_ERR "ide-floppy: CoD != 0 in idefloppy_pc_intr\n");
                return ide_do_reset(drive);
        }
-       if (ireason.b.io == test_bit(PC_WRITING, &pc->flags)) {
+       if (((ireason & IO) == IO) == test_bit(PC_WRITING, &pc->flags)) {
                /* Hopefully, we will never get here */
                printk(KERN_ERR "ide-floppy: We wanted to %s, ",
-                       ireason.b.io ? "Write":"Read");
+                               (ireason & IO) ? "Write" : "Read");
                printk(KERN_ERR "but the floppy wants us to %s !\n",
-                       ireason.b.io ? "Read":"Write");
+                               (ireason & IO) ? "Read" : "Write");
                return ide_do_reset(drive);
        }
        if (!test_bit(PC_WRITING, &pc->flags)) {
                /* Reading - Check that we have enough space */
-               temp = pc->actually_transferred + bcount.all;
+               temp = pc->actually_transferred + bcount;
                if (temp > pc->request_transfer) {
                        if (temp > pc->buffer_size) {
                                printk(KERN_ERR "ide-floppy: The floppy wants "
                                        "to send us more data than expected "
                                        "- discarding data\n");
-                               idefloppy_discard_data(drive,bcount.all);
+                               idefloppy_discard_data(drive, bcount);
                                BUG_ON(HWGROUP(drive)->handler != NULL);
                                ide_set_handler(drive,
                                                &idefloppy_pc_intr,
@@ -913,23 +887,21 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive)
        if (test_bit(PC_WRITING, &pc->flags)) {
                if (pc->buffer != NULL)
                        /* Write the current buffer */
-                       HWIF(drive)->atapi_output_bytes(drive,
-                                               pc->current_position,
-                                               bcount.all);
+                       hwif->atapi_output_bytes(drive, pc->current_position,
+                                                bcount);
                else
-                       idefloppy_output_buffers(drive, pc, bcount.all);
+                       idefloppy_output_buffers(drive, pc, bcount);
        } else {
                if (pc->buffer != NULL)
                        /* Read the current buffer */
-                       HWIF(drive)->atapi_input_bytes(drive,
-                                               pc->current_position,
-                                               bcount.all);
+                       hwif->atapi_input_bytes(drive, pc->current_position,
+                                               bcount);
                else
-                       idefloppy_input_buffers(drive, pc, bcount.all);
+                       idefloppy_input_buffers(drive, pc, bcount);
        }
        /* Update the current position */
-       pc->actually_transferred += bcount.all;
-       pc->current_position += bcount.all;
+       pc->actually_transferred += bcount;
+       pc->current_position += bcount;
 
        BUG_ON(HWGROUP(drive)->handler != NULL);
        ide_set_handler(drive, &idefloppy_pc_intr, IDEFLOPPY_WAIT_CMD, NULL);           /* And set the interrupt handler again */
@@ -945,15 +917,15 @@ static ide_startstop_t idefloppy_transfer_pc (ide_drive_t *drive)
 {
        ide_startstop_t startstop;
        idefloppy_floppy_t *floppy = drive->driver_data;
-       atapi_ireason_t ireason;
+       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");
                return startstop;
        }
-       ireason.all = HWIF(drive)->INB(IDE_IREASON_REG);
-       if (!ireason.b.cod || ireason.b.io) {
+       ireason = drive->hwif->INB(IDE_IREASON_REG);
+       if ((ireason & CD) == 0 || (ireason & IO)) {
                printk(KERN_ERR "ide-floppy: (IO,CoD) != (0,1) while "
                                "issuing a packet command\n");
                return ide_do_reset(drive);
@@ -993,15 +965,15 @@ static ide_startstop_t idefloppy_transfer_pc1 (ide_drive_t *drive)
 {
        idefloppy_floppy_t *floppy = drive->driver_data;
        ide_startstop_t startstop;
-       atapi_ireason_t ireason;
+       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");
                return startstop;
        }
-       ireason.all = HWIF(drive)->INB(IDE_IREASON_REG);
-       if (!ireason.b.cod || ireason.b.io) {
+       ireason = drive->hwif->INB(IDE_IREASON_REG);
+       if ((ireason & CD) == 0 || (ireason & IO)) {
                printk(KERN_ERR "ide-floppy: (IO,CoD) != (0,1) "
                                "while issuing a packet command\n");
                return ide_do_reset(drive);
@@ -1043,21 +1015,9 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p
 {
        idefloppy_floppy_t *floppy = drive->driver_data;
        ide_hwif_t *hwif = drive->hwif;
-       atapi_feature_t feature;
-       atapi_bcount_t bcount;
        ide_handler_t *pkt_xfer_routine;
-
-#if 0 /* Accessing floppy->pc is not valid here, the previous pc may be gone
-         and have lived on another thread's stack; that stack may have become
-         unmapped meanwhile (CONFIG_DEBUG_PAGEALLOC). */
-#if IDEFLOPPY_DEBUG_BUGS
-       if (floppy->pc->c[0] == IDEFLOPPY_REQUEST_SENSE_CMD &&
-           pc->c[0] == IDEFLOPPY_REQUEST_SENSE_CMD) {
-               printk(KERN_ERR "ide-floppy: possible ide-floppy.c bug - "
-                       "Two request sense in serial were issued\n");
-       }
-#endif /* IDEFLOPPY_DEBUG_BUGS */
-#endif
+       u16 bcount;
+       u8 dma;
 
        if (floppy->failed_pc == NULL &&
            pc->c[0] != IDEFLOPPY_REQUEST_SENSE_CMD)
@@ -1095,25 +1055,20 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p
        /* We haven't transferred any data yet */
        pc->actually_transferred = 0;
        pc->current_position = pc->buffer;
-       bcount.all = min(pc->request_transfer, 63 * 1024);
+       bcount = min(pc->request_transfer, 63 * 1024);
 
        if (test_and_clear_bit(PC_DMA_ERROR, &pc->flags))
                ide_dma_off(drive);
 
-       feature.all = 0;
+       dma = 0;
 
        if (test_bit(PC_DMA_RECOMMENDED, &pc->flags) && drive->using_dma)
-               feature.b.dma = !hwif->dma_setup(drive);
+               dma = !hwif->dma_setup(drive);
 
-       if (IDE_CONTROL_REG)
-               HWIF(drive)->OUTB(drive->ctl, IDE_CONTROL_REG);
-       /* Use PIO/DMA */
-       HWIF(drive)->OUTB(feature.all, IDE_FEATURE_REG);
-       HWIF(drive)->OUTB(bcount.b.high, IDE_BCOUNTH_REG);
-       HWIF(drive)->OUTB(bcount.b.low, IDE_BCOUNTL_REG);
-       HWIF(drive)->OUTB(drive->select.all, IDE_SELECT_REG);
+       ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK |
+                          IDE_TFLAG_OUT_DEVICE, bcount, dma);
 
-       if (feature.b.dma) {    /* Begin DMA, if necessary */
+       if (dma) {      /* Begin DMA, if necessary */
                set_bit(PC_DMA_IN_PROGRESS, &pc->flags);
                hwif->dma_start(drive);
        }
@@ -1667,14 +1622,14 @@ static int idefloppy_get_format_progress(ide_drive_t *drive, int __user *arg)
                /* Else assume format_unit has finished, and we're
                ** at 0x10000 */
        } else {
-               atapi_status_t status;
                unsigned long flags;
+               u8 stat;
 
                local_irq_save(flags);
-               status.all = HWIF(drive)->INB(IDE_STATUS_REG);
+               stat = drive->hwif->INB(IDE_STATUS_REG);
                local_irq_restore(flags);
 
-               progress_indication = !status.b.dsc ? 0 : 0x10000;
+               progress_indication = ((stat & SEEK_STAT) == 0) ? 0 : 0x10000;
        }
        if (put_user(progress_indication, arg))
                return (-EFAULT);
@@ -1701,7 +1656,6 @@ static int idefloppy_identify_device (ide_drive_t *drive,struct hd_driveid *id)
 {
        struct idefloppy_id_gcw gcw;
 #if IDEFLOPPY_DEBUG_INFO
-       u16 mask,i;
        char buffer[80];
 #endif /* IDEFLOPPY_DEBUG_INFO */
 
@@ -1748,55 +1702,6 @@ static int idefloppy_identify_device (ide_drive_t *drive,struct hd_driveid *id)
                default: sprintf(buffer, "Reserved");break;
        }
        printk(KERN_INFO "Command Packet Size: %s\n", buffer);
-       printk(KERN_INFO "Model: %.40s\n",id->model);
-       printk(KERN_INFO "Firmware Revision: %.8s\n",id->fw_rev);
-       printk(KERN_INFO "Serial Number: %.20s\n",id->serial_no);
-       printk(KERN_INFO "Write buffer size(?): %d bytes\n",id->buf_size*512);
-       printk(KERN_INFO "DMA: %s",id->capability & 0x01 ? "Yes\n":"No\n");
-       printk(KERN_INFO "LBA: %s",id->capability & 0x02 ? "Yes\n":"No\n");
-       printk(KERN_INFO "IORDY can be disabled: %s",id->capability & 0x04 ? "Yes\n":"No\n");
-       printk(KERN_INFO "IORDY supported: %s",id->capability & 0x08 ? "Yes\n":"Unknown\n");
-       printk(KERN_INFO "ATAPI overlap supported: %s",id->capability & 0x20 ? "Yes\n":"No\n");
-       printk(KERN_INFO "PIO Cycle Timing Category: %d\n",id->tPIO);
-       printk(KERN_INFO "DMA Cycle Timing Category: %d\n",id->tDMA);
-       printk(KERN_INFO "Single Word DMA supported modes:\n");
-       for (i=0,mask=1;i<8;i++,mask=mask << 1) {
-               if (id->dma_1word & mask)
-                       printk(KERN_INFO "   Mode %d%s\n", i,
-                       (id->dma_1word & (mask << 8)) ? " (active)" : "");
-       }
-       printk(KERN_INFO "Multi Word DMA supported modes:\n");
-       for (i=0,mask=1;i<8;i++,mask=mask << 1) {
-               if (id->dma_mword & mask)
-                       printk(KERN_INFO "   Mode %d%s\n", i,
-                       (id->dma_mword & (mask << 8)) ? " (active)" : "");
-       }
-       if (id->field_valid & 0x0002) {
-               printk(KERN_INFO "Enhanced PIO Modes: %s\n",
-                       id->eide_pio_modes & 1 ? "Mode 3":"None");
-               if (id->eide_dma_min == 0)
-                       sprintf(buffer, "Not supported");
-               else
-                       sprintf(buffer, "%d ns",id->eide_dma_min);
-               printk(KERN_INFO "Minimum Multi-word DMA cycle per word: %s\n", buffer);
-               if (id->eide_dma_time == 0)
-                       sprintf(buffer, "Not supported");
-               else
-                       sprintf(buffer, "%d ns",id->eide_dma_time);
-               printk(KERN_INFO "Manufacturer\'s Recommended Multi-word cycle: %s\n", buffer);
-               if (id->eide_pio == 0)
-                       sprintf(buffer, "Not supported");
-               else
-                       sprintf(buffer, "%d ns",id->eide_pio);
-               printk(KERN_INFO "Minimum PIO cycle without IORDY: %s\n",
-                       buffer);
-               if (id->eide_pio_iordy == 0)
-                       sprintf(buffer, "Not supported");
-               else
-                       sprintf(buffer, "%d ns",id->eide_pio_iordy);
-               printk(KERN_INFO "Minimum PIO cycle with IORDY: %s\n", buffer);
-       } else
-               printk(KERN_INFO "According to the device, fields 64-70 are not valid.\n");
 #endif /* IDEFLOPPY_DEBUG_INFO */
 
        if (gcw.protocol != 2)
@@ -2099,7 +2004,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)