]> err.no Git - linux-2.6/blobdiff - drivers/ide/ide-floppy.c
ide: add ide_host_add() helper
[linux-2.6] / drivers / ide / ide-floppy.c
index b3689437269f0586ebdfdebfa3ca53c2cd83a182..62be2b27f236fca83db7c3113c5b09ae758f0aff 100644 (file)
@@ -247,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)
-                       hwif->output_data(drive, NULL, data, count);
+                       hwif->tp_ops->output_data(drive, NULL, data, count);
                else
-                       hwif->input_data(drive, NULL, data, count);
+                       hwif->tp_ops->input_data(drive, NULL, data, count);
                bvec_kunmap_irq(data, &flags);
 
                bcount -= count;
@@ -351,10 +351,7 @@ static void ide_floppy_callback(ide_drive_t *drive)
 
 static void idefloppy_init_pc(struct ide_atapi_pc *pc)
 {
-       memset(pc->c, 0, 12);
-       pc->retries = 0;
-       pc->flags = 0;
-       pc->req_xfer = 0;
+       memset(pc, 0, sizeof(*pc));
        pc->buf = pc->pc_buf;
        pc->buf_size = IDEFLOPPY_PC_BUFFER_SIZE;
        pc->callback = ide_floppy_callback;
@@ -405,7 +402,7 @@ static int idefloppy_transfer_pc(ide_drive_t *drive)
        idefloppy_floppy_t *floppy = drive->driver_data;
 
        /* Send the actual packet */
-       drive->hwif->output_data(drive, NULL, floppy->pc->c, 12);
+       drive->hwif->tp_ops->output_data(drive, NULL, floppy->pc->c, 12);
 
        /* Timeout for the packet command */
        return IDEFLOPPY_WAIT_CMD;
@@ -561,12 +558,6 @@ static void idefloppy_create_start_stop_cmd(struct ide_atapi_pc *pc, int start)
        pc->c[4] = start;
 }
 
-static void idefloppy_create_test_unit_ready_cmd(struct ide_atapi_pc *pc)
-{
-       idefloppy_init_pc(pc);
-       pc->c[0] = GPCMD_TEST_UNIT_READY;
-}
-
 static void idefloppy_create_rw_cmd(idefloppy_floppy_t *floppy,
                                    struct ide_atapi_pc *pc, struct request *rq,
                                    unsigned long sector)
@@ -711,10 +702,10 @@ static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive)
        set_disk_ro(floppy->disk, floppy->wp);
        page = &pc.buf[8];
 
-       transfer_rate = be16_to_cpu(*(u16 *)&pc.buf[8 + 2]);
-       sector_size   = be16_to_cpu(*(u16 *)&pc.buf[8 + 6]);
-       cyls          = be16_to_cpu(*(u16 *)&pc.buf[8 + 8]);
-       rpm           = be16_to_cpu(*(u16 *)&pc.buf[8 + 28]);
+       transfer_rate = be16_to_cpup((__be16 *)&pc.buf[8 + 2]);
+       sector_size   = be16_to_cpup((__be16 *)&pc.buf[8 + 6]);
+       cyls          = be16_to_cpup((__be16 *)&pc.buf[8 + 8]);
+       rpm           = be16_to_cpup((__be16 *)&pc.buf[8 + 28]);
        heads         = pc.buf[8 + 4];
        sectors       = pc.buf[8 + 5];
 
@@ -789,8 +780,8 @@ static int ide_floppy_get_capacity(ide_drive_t *drive)
        for (i = 0; i < desc_cnt; i++) {
                unsigned int desc_start = 4 + i*8;
 
-               blocks = be32_to_cpu(*(u32 *)&pc.buf[desc_start]);
-               length = be16_to_cpu(*(u16 *)&pc.buf[desc_start + 6]);
+               blocks = be32_to_cpup((__be32 *)&pc.buf[desc_start]);
+               length = be16_to_cpup((__be16 *)&pc.buf[desc_start + 6]);
 
                debug_log("Descriptor %d: %dkB, %d blocks, %d sector size\n",
                                i, blocks * length / 1024, blocks, length);
@@ -911,8 +902,8 @@ static int ide_floppy_get_format_capacities(ide_drive_t *drive, int __user *arg)
                if (u_index >= u_array_size)
                        break;  /* User-supplied buffer too small */
 
-               blocks = be32_to_cpu(*(u32 *)&pc.buf[desc_start]);
-               length = be16_to_cpu(*(u16 *)&pc.buf[desc_start + 6]);
+               blocks = be32_to_cpup((__be32 *)&pc.buf[desc_start]);
+               length = be16_to_cpup((__be16 *)&pc.buf[desc_start + 6]);
 
                if (put_user(blocks, argp))
                        return(-EFAULT);
@@ -958,11 +949,12 @@ 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 {
+               ide_hwif_t *hwif = drive->hwif;
                unsigned long flags;
                u8 stat;
 
                local_irq_save(flags);
-               stat = ide_read_status(drive);
+               stat = hwif->tp_ops->read_status(hwif);
                local_irq_restore(flags);
 
                progress_indication = ((stat & SEEK_STAT) == 0) ? 0 : 0x10000;
@@ -1138,7 +1130,6 @@ static ide_driver_t idefloppy_driver = {
        .do_request             = idefloppy_do_request,
        .end_request            = idefloppy_end_request,
        .error                  = __ide_error,
-       .abort                  = __ide_abort,
 #ifdef CONFIG_IDE_PROC_FS
        .proc                   = idefloppy_proc,
 #endif
@@ -1166,7 +1157,9 @@ static int idefloppy_open(struct inode *inode, struct file *filp)
                floppy->flags &= ~IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS;
                /* Just in case */
 
-               idefloppy_create_test_unit_ready_cmd(&pc);
+               idefloppy_init_pc(&pc);
+               pc.c[0] = GPCMD_TEST_UNIT_READY;
+
                if (idefloppy_queue_pc_tail(drive, &pc)) {
                        idefloppy_create_start_stop_cmd(&pc, 1);
                        (void) idefloppy_queue_pc_tail(drive, &pc);