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

Commit 3153c26b authored by Sergei Shtylyov's avatar Sergei Shtylyov Committed by Bartlomiej Zolnierkiewicz
Browse files

ide: refactor tf_read() method



Simplify tf_read() method, making it deal only with 'struct ide_taskfile' and
the validity flags that the upper layer passes, and factoring out the code that
deals with the high order bytes into ide_tf_readback() to be called from the
only two functions interested, ide_complete_cmd() and ide_dump_sector().

This should stop the needless code duplication in this method and so make
it about twice smaller than it was; along with simplifying the setup for
the method call, this should save both time and space...

Signed-off-by: default avatarSergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent c9ff9e7b
Loading
Loading
Loading
Loading
+8 −13
Original line number Diff line number Diff line
@@ -254,15 +254,13 @@ EXPORT_SYMBOL_GPL(ide_cd_get_xferlen);

void ide_read_bcount_and_ireason(ide_drive_t *drive, u16 *bcount, u8 *ireason)
{
	struct ide_cmd cmd;
	struct ide_taskfile tf;

	memset(&cmd, 0, sizeof(cmd));
	cmd.valid.in.tf = IDE_VALID_LBAH | IDE_VALID_LBAM | IDE_VALID_NSECT;
	drive->hwif->tp_ops->tf_read(drive, &tf, IDE_VALID_NSECT |
				     IDE_VALID_LBAM | IDE_VALID_LBAH);

	drive->hwif->tp_ops->tf_read(drive, &cmd);

	*bcount = (cmd.tf.lbah << 8) | cmd.tf.lbam;
	*ireason = cmd.tf.nsect & 3;
	*bcount = (tf.lbah << 8) | tf.lbam;
	*ireason = tf.nsect & 3;
}
EXPORT_SYMBOL_GPL(ide_read_bcount_and_ireason);

@@ -452,14 +450,11 @@ static void ide_init_packet_cmd(struct ide_cmd *cmd, u8 valid_tf,

static u8 ide_read_ireason(ide_drive_t *drive)
{
	struct ide_cmd cmd;

	memset(&cmd, 0, sizeof(cmd));
	cmd.valid.in.tf = IDE_VALID_NSECT;
	struct ide_taskfile tf;

	drive->hwif->tp_ops->tf_read(drive, &cmd);
	drive->hwif->tp_ops->tf_read(drive, &tf, IDE_VALID_NSECT);

	return cmd.tf.nsect & 3;
	return tf.nsect & 3;
}

static u8 ide_wait_ireason(ide_drive_t *drive, u8 ireason)
+1 −24
Original line number Diff line number Diff line
@@ -112,13 +112,11 @@ void ide_tf_load(ide_drive_t *drive, struct ide_taskfile *tf, u8 valid)
}
EXPORT_SYMBOL_GPL(ide_tf_load);

void ide_tf_read(ide_drive_t *drive, struct ide_cmd *cmd)
void ide_tf_read(ide_drive_t *drive, struct ide_taskfile *tf, u8 valid)
{
	ide_hwif_t *hwif = drive->hwif;
	struct ide_io_ports *io_ports = &hwif->io_ports;
	struct ide_taskfile *tf = &cmd->tf;
	u8 (*tf_inb)(unsigned long port);
	u8 valid = cmd->valid.in.tf;
	u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0;

	if (mmio)
@@ -126,9 +124,6 @@ void ide_tf_read(ide_drive_t *drive, struct ide_cmd *cmd)
	else
		tf_inb  = ide_inb;

	/* be sure we're looking at the low order bits */
	hwif->tp_ops->write_devctl(hwif, ATA_DEVCTL_OBS);

	if (valid & IDE_VALID_ERROR)
		tf->error  = tf_inb(io_ports->feature_addr);
	if (valid & IDE_VALID_NSECT)
@@ -141,24 +136,6 @@ void ide_tf_read(ide_drive_t *drive, struct ide_cmd *cmd)
		tf->lbah   = tf_inb(io_ports->lbah_addr);
	if (valid & IDE_VALID_DEVICE)
		tf->device = tf_inb(io_ports->device_addr);

	if (cmd->tf_flags & IDE_TFLAG_LBA48) {
		hwif->tp_ops->write_devctl(hwif, ATA_HOB | ATA_DEVCTL_OBS);

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

		if (valid & IDE_VALID_ERROR)
			tf->error = tf_inb(io_ports->feature_addr);
		if (valid & IDE_VALID_NSECT)
			tf->nsect = tf_inb(io_ports->nsect_addr);
		if (valid & IDE_VALID_LBAL)
			tf->lbal  = tf_inb(io_ports->lbal_addr);
		if (valid & IDE_VALID_LBAM)
			tf->lbam  = tf_inb(io_ports->lbam_addr);
		if (valid & IDE_VALID_LBAH)
			tf->lbah  = tf_inb(io_ports->lbah_addr);
	}
}
EXPORT_SYMBOL_GPL(ide_tf_read);

+1 −1
Original line number Diff line number Diff line
@@ -90,7 +90,7 @@ void ide_complete_cmd(ide_drive_t *drive, struct ide_cmd *cmd, u8 stat, u8 err)
		cmd->hob.data = data[1];
	}

	tp_ops->tf_read(drive, cmd);
	ide_tf_readback(drive, cmd);

	if ((cmd->tf_flags & IDE_TFLAG_CUSTOM_HANDLER) &&
	    tf_cmd == ATA_CMD_IDLEIMMEDIATE) {
+3 −6
Original line number Diff line number Diff line
@@ -37,14 +37,11 @@ void SELECT_MASK(ide_drive_t *drive, int mask)

u8 ide_read_error(ide_drive_t *drive)
{
	struct ide_cmd cmd;

	memset(&cmd, 0, sizeof(cmd));
	cmd.valid.in.tf = IDE_VALID_ERROR;
	struct ide_taskfile tf;

	drive->hwif->tp_ops->tf_read(drive, &cmd);
	drive->hwif->tp_ops->tf_read(drive, &tf, IDE_VALID_ERROR);

	return cmd.tf.error;
	return tf.error;
}
EXPORT_SYMBOL_GPL(ide_read_error);

+1 −1
Original line number Diff line number Diff line
@@ -79,7 +79,7 @@ static void ide_dump_sector(ide_drive_t *drive)
	} else
		cmd.valid.in.tf  = IDE_VALID_LBA | IDE_VALID_DEVICE;

	drive->hwif->tp_ops->tf_read(drive, &cmd);
	ide_tf_readback(drive, &cmd);

	if (lba48 || (tf->device & ATA_LBA))
		printk(KERN_CONT ", LBAsect=%llu",
Loading