]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - drivers/ide/ide-disk.c
ide: remove ata_nsector_t, ata_data_t and atapi_bcount_t
[mirror_ubuntu-bionic-kernel.git] / drivers / ide / ide-disk.c
index 9b63e15d67e29efeed769a6e331a029a04c388cc..747dc602334676ca0cb9b9c2e1459a440a2e6386 100644 (file)
@@ -137,11 +137,11 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
 {
        ide_hwif_t *hwif        = HWIF(drive);
        unsigned int dma        = drive->using_dma;
+       u16 nsectors            = (u16)rq->nr_sectors;
        u8 lba48                = (drive->addressing == 1) ? 1 : 0;
        u8 command              = WIN_NOP;
-       ata_nsector_t           nsectors;
-
-       nsectors.all            = (u16) rq->nr_sectors;
+       ide_task_t              task;
+       struct ide_taskfile     *tf = &task.tf;
 
        if ((hwif->host_flags & IDE_HFLAG_NO_LBA48_DMA) && lba48 && dma) {
                if (block + rq->nr_sectors > 1ULL << 28)
@@ -155,58 +155,39 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
                ide_map_sg(drive, rq);
        }
 
-       if (IDE_CONTROL_REG)
-               hwif->OUTB(drive->ctl, IDE_CONTROL_REG);
-
-       /* FIXME: SELECT_MASK(drive, 0) ? */
+       memset(&task, 0, sizeof(task));
+       task.tf_flags = IDE_TFLAG_NO_SELECT_MASK;  /* FIXME? */
+       task.tf_flags |= (IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE);
 
        if (drive->select.b.lba) {
                if (lba48) {
-                       u8 tasklets[10];
-
                        pr_debug("%s: LBA=0x%012llx\n", drive->name,
                                        (unsigned long long)block);
 
-                       tasklets[0] = 0;
-                       tasklets[1] = 0;
-                       tasklets[2] = nsectors.b.low;
-                       tasklets[3] = nsectors.b.high;
-                       tasklets[4] = (u8) block;
-                       tasklets[5] = (u8)(block >>  8);
-                       tasklets[6] = (u8)(block >> 16);
-                       tasklets[7] = (u8)(block >> 24);
-                       if (sizeof(block) == 4) {
-                               tasklets[8] = 0;
-                               tasklets[9] = 0;
-                       } else {
-                               tasklets[8] = (u8)((u64)block >> 32);
-                               tasklets[9] = (u8)((u64)block >> 40);
+                       tf->hob_nsect = (nsectors >> 8) & 0xff;
+                       tf->hob_lbal  = (u8)(block >> 24);
+                       if (sizeof(block) != 4) {
+                               tf->hob_lbam = (u8)((u64)block >> 32);
+                               tf->hob_lbah = (u8)((u64)block >> 40);
                        }
+
+                       tf->nsect  = nsectors & 0xff;
+                       tf->lbal   = (u8) block;
+                       tf->lbam   = (u8)(block >>  8);
+                       tf->lbah   = (u8)(block >> 16);
 #ifdef DEBUG
                        printk("%s: 0x%02x%02x 0x%02x%02x%02x%02x%02x%02x\n",
-                               drive->name, tasklets[3], tasklets[2],
-                               tasklets[9], tasklets[8], tasklets[7],
-                               tasklets[6], tasklets[5], tasklets[4]);
+                               drive->name, tf->hob_nsect, tf->nsect,
+                               tf->hob_lbah, tf->hob_lbam, tf->hob_lbal,
+                               tf->lbah, tf->lbam, tf->lbal);
 #endif
-                       hwif->OUTB(tasklets[1], IDE_FEATURE_REG);
-                       hwif->OUTB(tasklets[3], IDE_NSECTOR_REG);
-                       hwif->OUTB(tasklets[7], IDE_SECTOR_REG);
-                       hwif->OUTB(tasklets[8], IDE_LCYL_REG);
-                       hwif->OUTB(tasklets[9], IDE_HCYL_REG);
-
-                       hwif->OUTB(tasklets[0], IDE_FEATURE_REG);
-                       hwif->OUTB(tasklets[2], IDE_NSECTOR_REG);
-                       hwif->OUTB(tasklets[4], IDE_SECTOR_REG);
-                       hwif->OUTB(tasklets[5], IDE_LCYL_REG);
-                       hwif->OUTB(tasklets[6], IDE_HCYL_REG);
-                       hwif->OUTB(0x00|drive->select.all,IDE_SELECT_REG);
+                       task.tf_flags |= (IDE_TFLAG_LBA48 | IDE_TFLAG_OUT_HOB);
                } else {
-                       hwif->OUTB(0x00, IDE_FEATURE_REG);
-                       hwif->OUTB(nsectors.b.low, IDE_NSECTOR_REG);
-                       hwif->OUTB(block, IDE_SECTOR_REG);
-                       hwif->OUTB(block>>=8, IDE_LCYL_REG);
-                       hwif->OUTB(block>>=8, IDE_HCYL_REG);
-                       hwif->OUTB(((block>>8)&0x0f)|drive->select.all,IDE_SELECT_REG);
+                       tf->nsect  = nsectors & 0xff;
+                       tf->lbal   = block;
+                       tf->lbam   = block >>= 8;
+                       tf->lbah   = block >>= 8;
+                       tf->device = (block >> 8) & 0xf;
                }
        } else {
                unsigned int sect,head,cyl,track;
@@ -217,14 +198,15 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
 
                pr_debug("%s: CHS=%u/%u/%u\n", drive->name, cyl, head, sect);
 
-               hwif->OUTB(0x00, IDE_FEATURE_REG);
-               hwif->OUTB(nsectors.b.low, IDE_NSECTOR_REG);
-               hwif->OUTB(sect, IDE_SECTOR_REG);
-               hwif->OUTB(cyl, IDE_LCYL_REG);
-               hwif->OUTB(cyl>>8, IDE_HCYL_REG);
-               hwif->OUTB(head|drive->select.all,IDE_SELECT_REG);
+               tf->nsect  = nsectors & 0xff;
+               tf->lbal   = sect;
+               tf->lbam   = cyl;
+               tf->lbah   = cyl >> 8;
+               tf->device = head;
        }
 
+       ide_tf_load(drive, &task);
+
        if (dma) {
                if (!hwif->dma_setup(drive)) {
                        if (rq_data_dir(rq)) {
@@ -320,10 +302,11 @@ static u64 idedisk_read_native_max_address(ide_drive_t *drive, int lba48)
        else
                tf->command = WIN_READ_NATIVE_MAX;
        tf->device  = ATA_LBA;
-       args.command_type                       = IDE_DRIVE_TASK_NO_DATA;
-       args.handler                            = &task_no_data_intr;
+       args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE;
+       if (lba48)
+               args.tf_flags |= (IDE_TFLAG_LBA48 | IDE_TFLAG_OUT_HOB);
        /* submit command request */
-       ide_raw_taskfile(drive, &args, NULL);
+       ide_no_data_taskfile(drive, &args);
 
        /* if OK, compute maximum address value */
        if ((tf->status & 0x01) == 0) {
@@ -367,10 +350,11 @@ static u64 idedisk_set_max_address(ide_drive_t *drive, u64 addr_req, int lba48)
                tf->command  = WIN_SET_MAX;
        }
        tf->device |= ATA_LBA;
-       args.command_type                       = IDE_DRIVE_TASK_NO_DATA;
-       args.handler                            = &task_no_data_intr;
+       args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE;
+       if (lba48)
+               args.tf_flags |= (IDE_TFLAG_LBA48 | IDE_TFLAG_OUT_HOB);
        /* submit command request */
-       ide_raw_taskfile(drive, &args, NULL);
+       ide_no_data_taskfile(drive, &args);
        /* if OK, compute maximum address value */
        if ((tf->status & 0x01) == 0) {
                u32 high, low;
@@ -517,9 +501,8 @@ static int smart_enable(ide_drive_t *drive)
        tf->lbam    = SMART_LCYL_PASS;
        tf->lbah    = SMART_HCYL_PASS;
        tf->command = WIN_SMART;
-       args.command_type                       = IDE_DRIVE_TASK_NO_DATA;
-       args.handler                            = &task_no_data_intr;
-       return ide_raw_taskfile(drive, &args, NULL);
+       args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE;
+       return ide_no_data_taskfile(drive, &args);
 }
 
 static int get_smart_data(ide_drive_t *drive, u8 *buf, u8 sub_cmd)
@@ -533,6 +516,7 @@ static int get_smart_data(ide_drive_t *drive, u8 *buf, u8 sub_cmd)
        tf->lbam    = SMART_LCYL_PASS;
        tf->lbah    = SMART_HCYL_PASS;
        tf->command = WIN_SMART;
+       args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE;
        args.command_type                       = IDE_DRIVE_TASK_IN;
        args.data_phase                         = TASKFILE_IN;
        args.handler                            = &task_in_intr;
@@ -615,19 +599,21 @@ static ide_proc_entry_t idedisk_proc[] = {
 static void idedisk_prepare_flush(struct request_queue *q, struct request *rq)
 {
        ide_drive_t *drive = q->queuedata;
+       ide_task_t task;
 
-       memset(rq->cmd, 0, sizeof(rq->cmd));
-
+       memset(&task, 0, sizeof(task));
        if (ide_id_has_flush_cache_ext(drive->id) &&
            (drive->capacity64 >= (1UL << 28)))
-               rq->cmd[0] = WIN_FLUSH_CACHE_EXT;
+               task.tf.command = WIN_FLUSH_CACHE_EXT;
        else
-               rq->cmd[0] = WIN_FLUSH_CACHE;
-
+               task.tf.command = WIN_FLUSH_CACHE;
+       task.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE;
+       task.command_type = IDE_DRIVE_TASK_NO_DATA;
+       task.handler = task_no_data_intr;
 
-       rq->cmd_type = REQ_TYPE_ATA_TASK;
+       rq->cmd_type = REQ_TYPE_ATA_TASKFILE;
        rq->cmd_flags |= REQ_SOFTBARRIER;
-       rq->buffer = rq->cmd;
+       rq->special = &task;
 }
 
 /*
@@ -712,9 +698,8 @@ static int write_cache(ide_drive_t *drive, int arg)
                args.tf.feature = arg ?
                        SETFEATURES_EN_WCACHE : SETFEATURES_DIS_WCACHE;
                args.tf.command = WIN_SETFEATURES;
-               args.command_type               = IDE_DRIVE_TASK_NO_DATA;
-               args.handler                    = &task_no_data_intr;
-               err = ide_raw_taskfile(drive, &args, NULL);
+               args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE;
+               err = ide_no_data_taskfile(drive, &args);
                if (err == 0)
                        drive->wcache = arg;
        }
@@ -733,9 +718,8 @@ static int do_idedisk_flushcache (ide_drive_t *drive)
                args.tf.command = WIN_FLUSH_CACHE_EXT;
        else
                args.tf.command = WIN_FLUSH_CACHE;
-       args.command_type                       = IDE_DRIVE_TASK_NO_DATA;
-       args.handler                            = &task_no_data_intr;
-       return ide_raw_taskfile(drive, &args, NULL);
+       args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE;
+       return ide_no_data_taskfile(drive, &args);
 }
 
 static int set_acoustic (ide_drive_t *drive, int arg)
@@ -749,9 +733,8 @@ static int set_acoustic (ide_drive_t *drive, int arg)
        args.tf.feature = arg ? SETFEATURES_EN_AAM : SETFEATURES_DIS_AAM;
        args.tf.nsect   = arg;
        args.tf.command = WIN_SETFEATURES;
-       args.command_type = IDE_DRIVE_TASK_NO_DATA;
-       args.handler      = &task_no_data_intr;
-       ide_raw_taskfile(drive, &args, NULL);
+       args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE;
+       ide_no_data_taskfile(drive, &args);
        drive->acoustic = arg;
        return 0;
 }
@@ -1013,15 +996,14 @@ static int idedisk_open(struct inode *inode, struct file *filp)
                ide_task_t args;
                memset(&args, 0, sizeof(ide_task_t));
                args.tf.command = WIN_DOORLOCK;
-               args.command_type = IDE_DRIVE_TASK_NO_DATA;
-               args.handler      = &task_no_data_intr;
+               args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE;
                check_disk_change(inode->i_bdev);
                /*
                 * Ignore the return code from door_lock,
                 * since the open() has already succeeded,
                 * and the door_lock is irrelevant at this point.
                 */
-               if (drive->doorlocking && ide_raw_taskfile(drive, &args, NULL))
+               if (drive->doorlocking && ide_no_data_taskfile(drive, &args))
                        drive->doorlocking = 0;
        }
        return 0;
@@ -1040,9 +1022,8 @@ static int idedisk_release(struct inode *inode, struct file *filp)
                ide_task_t args;
                memset(&args, 0, sizeof(ide_task_t));
                args.tf.command = WIN_DOORUNLOCK;
-               args.command_type = IDE_DRIVE_TASK_NO_DATA;
-               args.handler      = &task_no_data_intr;
-               if (drive->doorlocking && ide_raw_taskfile(drive, &args, NULL))
+               args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE;
+               if (drive->doorlocking && ide_no_data_taskfile(drive, &args))
                        drive->doorlocking = 0;
        }