Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 745483f1 authored by Sergei Shtylyov's avatar Sergei Shtylyov Committed by Bartlomiej Zolnierkiewicz
Browse files

ide: simplify 'struct ide_taskfile'



Make 'struct ide_taskfile' cover only 8 register values and thus put two such
fields ('tf' and 'hob') into 'struct ide_cmd', dropping unnecessary 'tf_array'
field from it.

This required changing the prototype of ide_get_lba_addr() and ide_tf_dump().

Signed-off-by: default avatarSergei Shtylyov <sshtylyov@ru.mvista.com>
[bart: fix setting of ATA_LBA bit for LBA48 commands in __ide_do_rw_disk()]
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 60f85019
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -318,7 +318,7 @@ static int do_drive_set_taskfiles(ide_drive_t *drive,

		/* convert GTF to taskfile */
		memset(&cmd, 0, sizeof(cmd));
		memcpy(&cmd.tf_array[7], gtf, REGS_PER_GTF);
		memcpy(&cmd.tf.feature, gtf, REGS_PER_GTF);
		cmd.valid.out.tf = IDE_VALID_OUT_TF | IDE_VALID_DEVICE;
		cmd.valid.in.tf  = IDE_VALID_IN_TF  | IDE_VALID_DEVICE;

+15 −15
Original line number Diff line number Diff line
@@ -105,17 +105,19 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
			pr_debug("%s: LBA=0x%012llx\n", drive->name,
					(unsigned long long)block);

			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);
			tf->device = ATA_LBA;

			tf = &cmd.hob;
			tf->nsect = (nsectors >> 8) & 0xff;
			tf->lbal  = (u8)(block >> 24);
			if (sizeof(block) != 4) {
				tf->lbam = (u8)((u64)block >> 32);
				tf->lbah = (u8)((u64)block >> 40);
			}

			cmd.valid.out.hob = IDE_VALID_OUT_HOB;
			cmd.valid.in.hob  = IDE_VALID_IN_HOB;
@@ -125,10 +127,8 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
			tf->lbal   = block;
			tf->lbam   = block >>= 8;
			tf->lbah   = block >>= 8;
			tf->device = (block >> 8) & 0xf;
			tf->device = ((block >> 8) & 0xf) | ATA_LBA;
		}

		tf->device |= ATA_LBA;
	} else {
		unsigned int sect, head, cyl, track;

@@ -235,7 +235,7 @@ static u64 idedisk_read_native_max_address(ide_drive_t *drive, int lba48)

	/* if OK, compute maximum address value */
	if (!(tf->status & ATA_ERR))
		addr = ide_get_lba_addr(tf, lba48) + 1;
		addr = ide_get_lba_addr(&cmd, lba48) + 1;

	return addr;
}
@@ -257,9 +257,9 @@ static u64 idedisk_set_max_address(ide_drive_t *drive, u64 addr_req, int lba48)
	tf->lbam     = (addr_req >>= 8) & 0xff;
	tf->lbah     = (addr_req >>= 8) & 0xff;
	if (lba48) {
		tf->hob_lbal = (addr_req >>= 8) & 0xff;
		tf->hob_lbam = (addr_req >>= 8) & 0xff;
		tf->hob_lbah = (addr_req >>= 8) & 0xff;
		cmd.hob.lbal = (addr_req >>= 8) & 0xff;
		cmd.hob.lbam = (addr_req >>= 8) & 0xff;
		cmd.hob.lbah = (addr_req >>= 8) & 0xff;
		tf->command  = ATA_CMD_SET_MAX_EXT;
	} else {
		tf->device   = (addr_req >>= 8) & 0x0f;
@@ -279,7 +279,7 @@ static u64 idedisk_set_max_address(ide_drive_t *drive, u64 addr_req, int lba48)

	/* if OK, compute maximum address value */
	if (!(tf->status & ATA_ERR))
		addr_set = ide_get_lba_addr(tf, lba48) + 1;
		addr_set = ide_get_lba_addr(&cmd, lba48) + 1;

	return addr_set;
}
+13 −11
Original line number Diff line number Diff line
@@ -89,7 +89,7 @@ void ide_tf_load(ide_drive_t *drive, struct ide_cmd *cmd)
{
	ide_hwif_t *hwif = drive->hwif;
	struct ide_io_ports *io_ports = &hwif->io_ports;
	struct ide_taskfile *tf = &cmd->tf;
	struct ide_taskfile *tf = &cmd->hob;
	void (*tf_outb)(u8 addr, unsigned long port);
	u8 valid = cmd->valid.out.hob;
	u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0;
@@ -104,16 +104,17 @@ void ide_tf_load(ide_drive_t *drive, struct ide_cmd *cmd)
		HIHI = 0xFF;

	if (valid & IDE_VALID_FEATURE)
		tf_outb(tf->hob_feature, io_ports->feature_addr);
		tf_outb(tf->feature, io_ports->feature_addr);
	if (valid & IDE_VALID_NSECT)
		tf_outb(tf->hob_nsect, io_ports->nsect_addr);
		tf_outb(tf->nsect, io_ports->nsect_addr);
	if (valid & IDE_VALID_LBAL)
		tf_outb(tf->hob_lbal, io_ports->lbal_addr);
		tf_outb(tf->lbal, io_ports->lbal_addr);
	if (valid & IDE_VALID_LBAM)
		tf_outb(tf->hob_lbam, io_ports->lbam_addr);
		tf_outb(tf->lbam, io_ports->lbam_addr);
	if (valid & IDE_VALID_LBAH)
		tf_outb(tf->hob_lbah, io_ports->lbah_addr);
		tf_outb(tf->lbah, io_ports->lbah_addr);

	tf = &cmd->tf;
	valid = cmd->valid.out.tf;

	if (valid & IDE_VALID_FEATURE)
@@ -170,18 +171,19 @@ void ide_tf_read(ide_drive_t *drive, struct ide_cmd *cmd)
	if (cmd->tf_flags & IDE_TFLAG_LBA48) {
		tf_outb(ATA_HOB | ATA_DEVCTL_OBS, io_ports->ctl_addr);

		tf = &cmd->hob;
		valid = cmd->valid.in.hob;

		if (valid & IDE_VALID_ERROR)
			tf->hob_error = tf_inb(io_ports->feature_addr);
			tf->error = tf_inb(io_ports->feature_addr);
		if (valid & IDE_VALID_NSECT)
			tf->hob_nsect = tf_inb(io_ports->nsect_addr);
			tf->nsect = tf_inb(io_ports->nsect_addr);
		if (valid & IDE_VALID_LBAL)
			tf->hob_lbal  = tf_inb(io_ports->lbal_addr);
			tf->lbal  = tf_inb(io_ports->lbal_addr);
		if (valid & IDE_VALID_LBAM)
			tf->hob_lbam  = tf_inb(io_ports->lbam_addr);
			tf->lbam  = tf_inb(io_ports->lbam_addr);
		if (valid & IDE_VALID_LBAH)
			tf->hob_lbah  = tf_inb(io_ports->lbah_addr);
			tf->lbah  = tf_inb(io_ports->lbah_addr);
	}
}
EXPORT_SYMBOL_GPL(ide_tf_read);
+3 −3
Original line number Diff line number Diff line
@@ -86,8 +86,8 @@ void ide_complete_cmd(ide_drive_t *drive, struct ide_cmd *cmd, u8 stat, u8 err)

		tp_ops->input_data(drive, cmd, data, 2);

		tf->data = data[0];
		tf->hob_data = data[1];
		cmd->tf.data  = data[0];
		cmd->hob.data = data[1];
	}

	tp_ops->tf_read(drive, cmd);
@@ -97,7 +97,7 @@ void ide_complete_cmd(ide_drive_t *drive, struct ide_cmd *cmd, u8 stat, u8 err)
		if (tf->lbal != 0xc4) {
			printk(KERN_ERR "%s: head unload failed!\n",
			       drive->name);
			ide_tf_dump(drive->name, tf);
			ide_tf_dump(drive->name, cmd);
		} else
			drive->dev_flags |= IDE_DFLAG_PARKED;
	}
+2 −2
Original line number Diff line number Diff line
@@ -206,7 +206,7 @@ static int ide_task_ioctl(ide_drive_t *drive, unsigned long arg)
		return -EFAULT;

	memset(&cmd, 0, sizeof(cmd));
	memcpy(&cmd.tf_array[7], &args[1], 6);
	memcpy(&cmd.tf.feature, &args[1], 6);
	cmd.tf.command = args[0];
	cmd.valid.out.tf = IDE_VALID_OUT_TF | IDE_VALID_DEVICE;
	cmd.valid.in.tf  = IDE_VALID_IN_TF  | IDE_VALID_DEVICE;
@@ -214,7 +214,7 @@ static int ide_task_ioctl(ide_drive_t *drive, unsigned long arg)
	err = ide_no_data_taskfile(drive, &cmd);

	args[0] = cmd.tf.command;
	memcpy(&args[1], &cmd.tf_array[7], 6);
	memcpy(&args[1], &cmd.tf.feature, 6);

	if (copy_to_user(p, args, 7))
		err = -EFAULT;
Loading