ata: libata-core: Simplify ata_build_rw_tf()
Since ata_build_rw_tf() is only called from ata_scsi_rw_xlat() with the tf, dev and tag arguments obtained from the queued command structure, we can simplify the interface of ata_build_rw_tf() by passing directly the qc structure as argument. Furthermore, since ata_scsi_rw_xlat() is never used for internal commands, we can also remove the internal tag check for the NCQ case. Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
This commit is contained in:
Родитель
e00923c59e
Коммит
066de3b9d9
|
@ -665,33 +665,33 @@ u64 ata_tf_read_block(const struct ata_taskfile *tf, struct ata_device *dev)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ata_build_rw_tf - Build ATA taskfile for given read/write request
|
* ata_build_rw_tf - Build ATA taskfile for given read/write request
|
||||||
* @tf: Target ATA taskfile
|
* @qc: Metadata associated with the taskfile to build
|
||||||
* @dev: ATA device @tf belongs to
|
|
||||||
* @block: Block address
|
* @block: Block address
|
||||||
* @n_block: Number of blocks
|
* @n_block: Number of blocks
|
||||||
* @tf_flags: RW/FUA etc...
|
* @tf_flags: RW/FUA etc...
|
||||||
* @tag: tag
|
|
||||||
* @class: IO priority class
|
* @class: IO priority class
|
||||||
*
|
*
|
||||||
* LOCKING:
|
* LOCKING:
|
||||||
* None.
|
* None.
|
||||||
*
|
*
|
||||||
* Build ATA taskfile @tf for read/write request described by
|
* Build ATA taskfile for the command @qc for read/write request described
|
||||||
* @block, @n_block, @tf_flags and @tag on @dev.
|
* by @block, @n_block, @tf_flags and @class.
|
||||||
*
|
*
|
||||||
* RETURNS:
|
* RETURNS:
|
||||||
*
|
*
|
||||||
* 0 on success, -ERANGE if the request is too large for @dev,
|
* 0 on success, -ERANGE if the request is too large for @dev,
|
||||||
* -EINVAL if the request is invalid.
|
* -EINVAL if the request is invalid.
|
||||||
*/
|
*/
|
||||||
int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev,
|
int ata_build_rw_tf(struct ata_queued_cmd *qc, u64 block, u32 n_block,
|
||||||
u64 block, u32 n_block, unsigned int tf_flags,
|
unsigned int tf_flags, int class)
|
||||||
unsigned int tag, int class)
|
|
||||||
{
|
{
|
||||||
|
struct ata_taskfile *tf = &qc->tf;
|
||||||
|
struct ata_device *dev = qc->dev;
|
||||||
|
|
||||||
tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
|
tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
|
||||||
tf->flags |= tf_flags;
|
tf->flags |= tf_flags;
|
||||||
|
|
||||||
if (ata_ncq_enabled(dev) && !ata_tag_internal(tag)) {
|
if (ata_ncq_enabled(dev)) {
|
||||||
/* yay, NCQ */
|
/* yay, NCQ */
|
||||||
if (!lba_48_ok(block, n_block))
|
if (!lba_48_ok(block, n_block))
|
||||||
return -ERANGE;
|
return -ERANGE;
|
||||||
|
@ -704,7 +704,7 @@ int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev,
|
||||||
else
|
else
|
||||||
tf->command = ATA_CMD_FPDMA_READ;
|
tf->command = ATA_CMD_FPDMA_READ;
|
||||||
|
|
||||||
tf->nsect = tag << 3;
|
tf->nsect = qc->hw_tag << 3;
|
||||||
tf->hob_feature = (n_block >> 8) & 0xff;
|
tf->hob_feature = (n_block >> 8) & 0xff;
|
||||||
tf->feature = n_block & 0xff;
|
tf->feature = n_block & 0xff;
|
||||||
|
|
||||||
|
|
|
@ -1605,9 +1605,7 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc)
|
||||||
qc->flags |= ATA_QCFLAG_IO;
|
qc->flags |= ATA_QCFLAG_IO;
|
||||||
qc->nbytes = n_block * scmd->device->sector_size;
|
qc->nbytes = n_block * scmd->device->sector_size;
|
||||||
|
|
||||||
rc = ata_build_rw_tf(&qc->tf, qc->dev, block, n_block, tf_flags,
|
rc = ata_build_rw_tf(qc, block, n_block, tf_flags, class);
|
||||||
qc->hw_tag, class);
|
|
||||||
|
|
||||||
if (likely(rc == 0))
|
if (likely(rc == 0))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
|
@ -44,9 +44,8 @@ static inline void ata_force_cbl(struct ata_port *ap) { }
|
||||||
#endif
|
#endif
|
||||||
extern u64 ata_tf_to_lba(const struct ata_taskfile *tf);
|
extern u64 ata_tf_to_lba(const struct ata_taskfile *tf);
|
||||||
extern u64 ata_tf_to_lba48(const struct ata_taskfile *tf);
|
extern u64 ata_tf_to_lba48(const struct ata_taskfile *tf);
|
||||||
extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev,
|
extern int ata_build_rw_tf(struct ata_queued_cmd *qc, u64 block, u32 n_block,
|
||||||
u64 block, u32 n_block, unsigned int tf_flags,
|
unsigned int tf_flags, int class);
|
||||||
unsigned int tag, int class);
|
|
||||||
extern u64 ata_tf_read_block(const struct ata_taskfile *tf,
|
extern u64 ata_tf_read_block(const struct ata_taskfile *tf,
|
||||||
struct ata_device *dev);
|
struct ata_device *dev);
|
||||||
extern unsigned ata_exec_internal(struct ata_device *dev,
|
extern unsigned ata_exec_internal(struct ata_device *dev,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче