aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2006-11-14 08:47:09 -0500
committerTejun Heo <htejun@gmail.com>2006-12-03 03:56:24 -0500
commit2432697ba0ce312d60be5009ffe1fa054a761bb9 (patch)
tree8fe745ffb50986bee7d0cab5281278c7f77f983c
parent0f0a3ad3741fd93461fcfb85dc577103c58d9be8 (diff)
[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: Tejun Heo <htejun@gmail.com>
-rw-r--r--drivers/ata/libata-core.c49
-rw-r--r--drivers/ata/libata.h4
2 files changed, 46 insertions, 7 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 47c70392ec4..0a5103b707c 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -1042,13 +1042,13 @@ void ata_qc_complete_internal(struct ata_queued_cmd *qc)
1042} 1042}
1043 1043
1044/** 1044/**
1045 * ata_exec_internal - execute libata internal command 1045 * ata_exec_internal_sg - execute libata internal command
1046 * @dev: Device to which the command is sent 1046 * @dev: Device to which the command is sent
1047 * @tf: Taskfile registers for the command and the result 1047 * @tf: Taskfile registers for the command and the result
1048 * @cdb: CDB for packet command 1048 * @cdb: CDB for packet command
1049 * @dma_dir: Data tranfer direction of the command 1049 * @dma_dir: Data tranfer direction of the command
1050 * @buf: Data buffer of the command 1050 * @sg: sg list for the data buffer of the command
1051 * @buflen: Length of data buffer 1051 * @n_elem: Number of sg entries
1052 * 1052 *
1053 * Executes libata internal command with timeout. @tf contains 1053 * Executes libata internal command with timeout. @tf contains
1054 * command on entry and result on return. Timeout and error 1054 * 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 * RETURNS: 1062 * RETURNS:
1063 * Zero on success, AC_ERR_* mask on failure 1063 * Zero on success, AC_ERR_* mask on failure
1064 */ 1064 */
1065unsigned ata_exec_internal(struct ata_device *dev, 1065unsigned ata_exec_internal_sg(struct ata_device *dev,
1066 struct ata_taskfile *tf, const u8 *cdb, 1066 struct ata_taskfile *tf, const u8 *cdb,
1067 int dma_dir, void *buf, unsigned int buflen) 1067 int dma_dir, struct scatterlist *sg,
1068 unsigned int n_elem)
1068{ 1069{
1069 struct ata_port *ap = dev->ap; 1070 struct ata_port *ap = dev->ap;
1070 u8 command = tf->command; 1071 u8 command = tf->command;
@@ -1120,7 +1121,12 @@ unsigned ata_exec_internal(struct ata_device *dev,
1120 qc->flags |= ATA_QCFLAG_RESULT_TF; 1121 qc->flags |= ATA_QCFLAG_RESULT_TF;
1121 qc->dma_dir = dma_dir; 1122 qc->dma_dir = dma_dir;
1122 if (dma_dir != DMA_NONE) { 1123 if (dma_dir != DMA_NONE) {
1123 ata_sg_init_one(qc, buf, buflen); 1124 unsigned int i, buflen = 0;
1125
1126 for (i = 0; i < n_elem; i++)
1127 buflen += sg[i].length;
1128
1129 ata_sg_init(qc, sg, n_elem);
1124 qc->nsect = buflen / ATA_SECT_SIZE; 1130 qc->nsect = buflen / ATA_SECT_SIZE;
1125 } 1131 }
1126 1132
@@ -1204,6 +1210,35 @@ unsigned ata_exec_internal(struct ata_device *dev,
1204} 1210}
1205 1211
1206/** 1212/**
1213 * ata_exec_internal_sg - execute libata internal command
1214 * @dev: Device to which the command is sent
1215 * @tf: Taskfile registers for the command and the result
1216 * @cdb: CDB for packet command
1217 * @dma_dir: Data tranfer direction of the command
1218 * @buf: Data buffer of the command
1219 * @buflen: Length of data buffer
1220 *
1221 * Wrapper around ata_exec_internal_sg() which takes simple
1222 * buffer instead of sg list.
1223 *
1224 * LOCKING:
1225 * None. Should be called with kernel context, might sleep.
1226 *
1227 * RETURNS:
1228 * Zero on success, AC_ERR_* mask on failure
1229 */
1230unsigned ata_exec_internal(struct ata_device *dev,
1231 struct ata_taskfile *tf, const u8 *cdb,
1232 int dma_dir, void *buf, unsigned int buflen)
1233{
1234 struct scatterlist sg;
1235
1236 sg_init_one(&sg, buf, buflen);
1237
1238 return ata_exec_internal_sg(dev, tf, cdb, dma_dir, &sg, 1);
1239}
1240
1241/**
1207 * ata_do_simple_cmd - execute simple internal command 1242 * ata_do_simple_cmd - execute simple internal command
1208 * @dev: Device to which the command is sent 1243 * @dev: Device to which the command is sent
1209 * @cmd: Opcode to execute 1244 * @cmd: Opcode to execute
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
index 2d532da8c39..ca6f36c1311 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -58,6 +58,10 @@ extern void ata_port_flush_task(struct ata_port *ap);
58extern unsigned ata_exec_internal(struct ata_device *dev, 58extern unsigned ata_exec_internal(struct ata_device *dev,
59 struct ata_taskfile *tf, const u8 *cdb, 59 struct ata_taskfile *tf, const u8 *cdb,
60 int dma_dir, void *buf, unsigned int buflen); 60 int dma_dir, void *buf, unsigned int buflen);
61extern unsigned ata_exec_internal_sg(struct ata_device *dev,
62 struct ata_taskfile *tf, const u8 *cdb,
63 int dma_dir, struct scatterlist *sg,
64 unsigned int n_elem);
61extern unsigned int ata_do_simple_cmd(struct ata_device *dev, u8 cmd); 65extern unsigned int ata_do_simple_cmd(struct ata_device *dev, u8 cmd);
62extern int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, 66extern int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
63 unsigned int flags, u16 *id); 67 unsigned int flags, u16 *id);