提交 2432697b 编写于 作者: T Tejun Heo

[PATCH] libata: implement ata_exec_internal_sg()

Sg'ify ata_exec_internal() and call it ata_exec_internal_sg().
Wrapper function around ata_exec_internal_sg() is implemented to
provide ata_exec_internal() interface.
Signed-off-by: NTejun Heo <htejun@gmail.com>
上级 0f0a3ad3
...@@ -1042,13 +1042,13 @@ void ata_qc_complete_internal(struct ata_queued_cmd *qc) ...@@ -1042,13 +1042,13 @@ void ata_qc_complete_internal(struct ata_queued_cmd *qc)
} }
/** /**
* ata_exec_internal - execute libata internal command * ata_exec_internal_sg - execute libata internal command
* @dev: Device to which the command is sent * @dev: Device to which the command is sent
* @tf: Taskfile registers for the command and the result * @tf: Taskfile registers for the command and the result
* @cdb: CDB for packet command * @cdb: CDB for packet command
* @dma_dir: Data tranfer direction of the command * @dma_dir: Data tranfer direction of the command
* @buf: Data buffer of the command * @sg: sg list for the data buffer of the command
* @buflen: Length of data buffer * @n_elem: Number of sg entries
* *
* Executes libata internal command with timeout. @tf contains * Executes libata internal command with timeout. @tf contains
* command on entry and result on return. Timeout and error * command on entry and result on return. Timeout and error
...@@ -1062,9 +1062,10 @@ void ata_qc_complete_internal(struct ata_queued_cmd *qc) ...@@ -1062,9 +1062,10 @@ void ata_qc_complete_internal(struct ata_queued_cmd *qc)
* RETURNS: * RETURNS:
* Zero on success, AC_ERR_* mask on failure * Zero on success, AC_ERR_* mask on failure
*/ */
unsigned ata_exec_internal(struct ata_device *dev, unsigned ata_exec_internal_sg(struct ata_device *dev,
struct ata_taskfile *tf, const u8 *cdb, struct ata_taskfile *tf, const u8 *cdb,
int dma_dir, void *buf, unsigned int buflen) int dma_dir, struct scatterlist *sg,
unsigned int n_elem)
{ {
struct ata_port *ap = dev->ap; struct ata_port *ap = dev->ap;
u8 command = tf->command; u8 command = tf->command;
...@@ -1120,7 +1121,12 @@ unsigned ata_exec_internal(struct ata_device *dev, ...@@ -1120,7 +1121,12 @@ unsigned ata_exec_internal(struct ata_device *dev,
qc->flags |= ATA_QCFLAG_RESULT_TF; qc->flags |= ATA_QCFLAG_RESULT_TF;
qc->dma_dir = dma_dir; qc->dma_dir = dma_dir;
if (dma_dir != DMA_NONE) { if (dma_dir != DMA_NONE) {
ata_sg_init_one(qc, buf, buflen); unsigned int i, buflen = 0;
for (i = 0; i < n_elem; i++)
buflen += sg[i].length;
ata_sg_init(qc, sg, n_elem);
qc->nsect = buflen / ATA_SECT_SIZE; qc->nsect = buflen / ATA_SECT_SIZE;
} }
...@@ -1203,6 +1209,35 @@ unsigned ata_exec_internal(struct ata_device *dev, ...@@ -1203,6 +1209,35 @@ unsigned ata_exec_internal(struct ata_device *dev,
return err_mask; return err_mask;
} }
/**
* ata_exec_internal_sg - execute libata internal command
* @dev: Device to which the command is sent
* @tf: Taskfile registers for the command and the result
* @cdb: CDB for packet command
* @dma_dir: Data tranfer direction of the command
* @buf: Data buffer of the command
* @buflen: Length of data buffer
*
* Wrapper around ata_exec_internal_sg() which takes simple
* buffer instead of sg list.
*
* LOCKING:
* None. Should be called with kernel context, might sleep.
*
* RETURNS:
* Zero on success, AC_ERR_* mask on failure
*/
unsigned ata_exec_internal(struct ata_device *dev,
struct ata_taskfile *tf, const u8 *cdb,
int dma_dir, void *buf, unsigned int buflen)
{
struct scatterlist sg;
sg_init_one(&sg, buf, buflen);
return ata_exec_internal_sg(dev, tf, cdb, dma_dir, &sg, 1);
}
/** /**
* ata_do_simple_cmd - execute simple internal command * ata_do_simple_cmd - execute simple internal command
* @dev: Device to which the command is sent * @dev: Device to which the command is sent
......
...@@ -58,6 +58,10 @@ extern void ata_port_flush_task(struct ata_port *ap); ...@@ -58,6 +58,10 @@ extern void ata_port_flush_task(struct ata_port *ap);
extern unsigned ata_exec_internal(struct ata_device *dev, extern unsigned ata_exec_internal(struct ata_device *dev,
struct ata_taskfile *tf, const u8 *cdb, struct ata_taskfile *tf, const u8 *cdb,
int dma_dir, void *buf, unsigned int buflen); int dma_dir, void *buf, unsigned int buflen);
extern unsigned ata_exec_internal_sg(struct ata_device *dev,
struct ata_taskfile *tf, const u8 *cdb,
int dma_dir, struct scatterlist *sg,
unsigned int n_elem);
extern unsigned int ata_do_simple_cmd(struct ata_device *dev, u8 cmd); extern unsigned int ata_do_simple_cmd(struct ata_device *dev, u8 cmd);
extern int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, extern int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
unsigned int flags, u16 *id); unsigned int flags, u16 *id);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册