diff options
Diffstat (limited to 'drivers/ata/libata-core.c')
-rw-r--r-- | drivers/ata/libata-core.c | 49 |
1 files changed, 42 insertions, 7 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 47c70392ec4d..0a5103b707c6 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 | */ |
1065 | unsigned ata_exec_internal(struct ata_device *dev, | 1065 | unsigned 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 | */ | ||
1230 | unsigned 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 |