#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.
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;
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;
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;
*/
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;
}
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);
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? */
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);
**
*/
-static int idefloppy_get_format_capacities(ide_drive_t *drive, int *arg)
+static int idefloppy_get_format_capacities(ide_drive_t *drive, int __user *arg)
{
idefloppy_pc_t pc;
idefloppy_capacity_header_t *header;
int i, descriptors, blocks, length;
int u_array_size;
int u_index;
- int *argp;
+ int __user *argp;
if (get_user(u_array_size, arg))
return (-EFAULT);
** 0x01 - verify media after format.
*/
-static int idefloppy_begin_format(ide_drive_t *drive, int *arg)
+static int idefloppy_begin_format(ide_drive_t *drive, int __user *arg)
{
int blocks;
int length;
** the dsc bit, and return either 0 or 65536.
*/
-static int idefloppy_get_format_progress(ide_drive_t *drive, int *arg)
+static int idefloppy_get_format_progress(ide_drive_t *drive, int __user *arg)
{
idefloppy_floppy_t *floppy = drive->driver_data;
idefloppy_pc_t pc;
}
/*
- * Return the current floppy capacity to ide.c.
+ * Return the current floppy capacity.
*/
static sector_t idefloppy_capacity (ide_drive_t *drive)
{
struct block_device *bdev = inode->i_bdev;
ide_drive_t *drive = bdev->bd_disk->private_data;
idefloppy_floppy_t *floppy = drive->driver_data;
- int err = generic_ide_ioctl(bdev, cmd, arg);
+ void __user *argp = (void __user *)arg;
+ int err = generic_ide_ioctl(file, bdev, cmd, arg);
int prevent = (arg) ? 1 : 0;
idefloppy_pc_t pc;
if (err != -EINVAL)
case IDEFLOPPY_IOCTL_FORMAT_SUPPORTED:
return 0;
case IDEFLOPPY_IOCTL_FORMAT_GET_CAPACITY:
- return idefloppy_get_format_capacities(drive, (int *)arg);
+ return idefloppy_get_format_capacities(drive, argp);
case IDEFLOPPY_IOCTL_FORMAT_START:
if (!(file->f_mode & 2))
set_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags);
- err = idefloppy_begin_format(drive, (int *)arg);
+ err = idefloppy_begin_format(drive, argp);
if (err)
clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags);
return err;
** format progress reporting.
*/
case IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS:
- return idefloppy_get_format_progress(drive, (int *)arg);
+ return idefloppy_get_format_progress(drive, argp);
}
return -EINVAL;
}
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;
}