vserver 1.9.5.x5
[linux-2.6.git] / drivers / ide / ide-floppy.c
index 7383f44..416a8a4 100644 (file)
 #include <linux/slab.h>
 #include <linux/cdrom.h>
 #include <linux/ide.h>
+#include <linux/bitops.h>
 
 #include <asm/byteorder.h>
 #include <asm/irq.h>
 #include <asm/uaccess.h>
 #include <asm/io.h>
 #include <asm/unaligned.h>
-#include <asm/bitops.h>
 
 /*
  *     The following are used to debug the driver.
@@ -585,7 +585,7 @@ static void idefloppy_input_buffers (ide_drive_t *drive, idefloppy_pc_t *pc, uns
                        count = min(bvec->bv_len, bcount);
 
                        data = bvec_kmap_irq(bvec, &flags);
-                       atapi_input_bytes(drive, data, count);
+                       drive->hwif->atapi_input_bytes(drive, data, count);
                        bvec_kunmap_irq(data, &flags);
 
                        bcount -= count;
@@ -619,7 +619,7 @@ static void idefloppy_output_buffers (ide_drive_t *drive, idefloppy_pc_t *pc, un
                        count = min(bvec->bv_len, bcount);
 
                        data = bvec_kmap_irq(bvec, &flags);
-                       atapi_output_bytes(drive, data, count);
+                       drive->hwif->atapi_output_bytes(drive, data, count);
                        bvec_kunmap_irq(data, &flags);
 
                        bcount -= count;
@@ -989,12 +989,27 @@ static ide_startstop_t idefloppy_transfer_pc1 (ide_drive_t *drive)
        return ide_started;
 }
 
+/**
+ * idefloppy_should_report_error()
+ *
+ * Supresses error messages resulting from Medium not present
+ */
+static inline int idefloppy_should_report_error(idefloppy_floppy_t *floppy)
+{
+       if (floppy->sense_key == 0x02 &&
+           floppy->asc       == 0x3a &&
+           floppy->ascq      == 0x00)
+               return 0;
+       return 1;
+}
+
 /*
  *     Issue a packet command
  */
 static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *pc)
 {
        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;
@@ -1021,12 +1036,13 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p
                 */
                if (!test_bit(PC_ABORT, &pc->flags)) {
                        if (!test_bit(PC_SUPPRESS_ERROR, &pc->flags)) {
-                               printk(KERN_ERR "ide-floppy: %s: I/O error, "
-                                               "pc = %2x, key = %2x, "
-                                               "asc = %2x, ascq = %2x\n",
-                                               drive->name, pc->c[0],
-                                               floppy->sense_key,
-                                               floppy->asc, floppy->ascq);
+                               if (idefloppy_should_report_error(floppy))
+                                       printk(KERN_ERR "ide-floppy: %s: I/O error, "
+                                              "pc = %2x, key = %2x, "
+                                              "asc = %2x, ascq = %2x\n",
+                                              drive->name, pc->c[0],
+                                              floppy->sense_key,
+                                              floppy->asc, floppy->ascq);
                        }
                        /* Giving up */
                        pc->error = IDEFLOPPY_ERROR_GENERAL;
@@ -1049,13 +1065,8 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p
        }
        feature.all = 0;
 
-       if (test_bit(PC_DMA_RECOMMENDED, &pc->flags) && drive->using_dma) {
-               if (test_bit(PC_WRITING, &pc->flags)) {
-                       feature.b.dma = !HWIF(drive)->ide_dma_write(drive);
-               } else {
-                       feature.b.dma = !HWIF(drive)->ide_dma_read(drive);
-               }
-       }
+       if (test_bit(PC_DMA_RECOMMENDED, &pc->flags) && drive->using_dma)
+               feature.b.dma = !hwif->dma_setup(drive);
 
        if (IDE_CONTROL_REG)
                HWIF(drive)->OUTB(drive->ctl, IDE_CONTROL_REG);
@@ -1067,7 +1078,7 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p
 
        if (feature.b.dma) {    /* Begin DMA, if necessary */
                set_bit(PC_DMA_IN_PROGRESS, &pc->flags);
-               (void) (HWIF(drive)->ide_dma_begin(drive));
+               hwif->dma_start(drive);
        }
 
        /* Can we transfer the packet when we get the interrupt or wait? */
@@ -1242,11 +1253,13 @@ static ide_startstop_t idefloppy_do_request (ide_drive_t *drive, struct request
                        rq->nr_sectors, rq->current_nr_sectors);
 
        if (rq->errors >= ERROR_MAX) {
-               if (floppy->failed_pc != NULL)
-                       printk(KERN_ERR "ide-floppy: %s: I/O error, pc = %2x,"
-                                       " key = %2x, asc = %2x, ascq = %2x\n",
-                               drive->name, floppy->failed_pc->c[0],
-                               floppy->sense_key, floppy->asc, floppy->ascq);
+               if (floppy->failed_pc != NULL) {
+                       if (idefloppy_should_report_error(floppy))
+                               printk(KERN_ERR "ide-floppy: %s: I/O error, pc = %2x,"
+                                      " key = %2x, asc = %2x, ascq = %2x\n",
+                                      drive->name, floppy->failed_pc->c[0],
+                                      floppy->sense_key, floppy->asc, floppy->ascq);
+               }
                else
                        printk(KERN_ERR "ide-floppy: %s: I/O error\n",
                                drive->name);
@@ -1627,7 +1640,7 @@ static int idefloppy_get_format_progress(ide_drive_t *drive, int __user *arg)
 }
 
 /*
- *     Return the current floppy capacity to ide.c.
+ *     Return the current floppy capacity.
  */
 static sector_t idefloppy_capacity (ide_drive_t *drive)
 {
@@ -2021,7 +2034,7 @@ static int idefloppy_media_changed(struct gendisk *disk)
 static int idefloppy_revalidate_disk(struct gendisk *disk)
 {
        ide_drive_t *drive = disk->private_data;
-       set_capacity(disk, current_capacity(drive));
+       set_capacity(disk, idefloppy_capacity(drive));
        return 0;
 }