Commit 3949e2f04262495f6c8795b148aa26dffccba646
Committed by
Martin K. Petersen
1 parent
74a78ebda4
scsi: simplify scsi_execute_req_flags
Add a sshdr argument to __scsi_execute so that we can decode the sense data directly into the sense header instead of needing a copy of it. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Showing 1 changed file with 9 additions and 18 deletions Side-by-side Diff
drivers/scsi/scsi_lib.c
... | ... | @@ -215,8 +215,9 @@ |
215 | 215 | |
216 | 216 | static int __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, |
217 | 217 | int data_direction, void *buffer, unsigned bufflen, |
218 | - unsigned char *sense, int timeout, int retries, u64 flags, | |
219 | - req_flags_t rq_flags, int *resid) | |
218 | + unsigned char *sense, struct scsi_sense_hdr *sshdr, | |
219 | + int timeout, int retries, u64 flags, req_flags_t rq_flags, | |
220 | + int *resid) | |
220 | 221 | { |
221 | 222 | struct request *req; |
222 | 223 | struct scsi_request *rq; |
... | ... | @@ -259,6 +260,8 @@ |
259 | 260 | *resid = rq->resid_len; |
260 | 261 | if (sense && rq->sense_len) |
261 | 262 | memcpy(sense, rq->sense, SCSI_SENSE_BUFFERSIZE); |
263 | + if (sshdr) | |
264 | + scsi_normalize_sense(rq->sense, rq->sense_len, sshdr); | |
262 | 265 | ret = req->errors; |
263 | 266 | out: |
264 | 267 | blk_put_request(req); |
... | ... | @@ -288,7 +291,7 @@ |
288 | 291 | int *resid) |
289 | 292 | { |
290 | 293 | return __scsi_execute(sdev, cmd, data_direction, buffer, bufflen, sense, |
291 | - timeout, retries, flags, 0, resid); | |
294 | + NULL, timeout, retries, flags, 0, resid); | |
292 | 295 | } |
293 | 296 | EXPORT_SYMBOL(scsi_execute); |
294 | 297 | |
... | ... | @@ -297,21 +300,9 @@ |
297 | 300 | struct scsi_sense_hdr *sshdr, int timeout, int retries, |
298 | 301 | int *resid, u64 flags, req_flags_t rq_flags) |
299 | 302 | { |
300 | - char *sense = NULL; | |
301 | - int result; | |
302 | - | |
303 | - if (sshdr) { | |
304 | - sense = kzalloc(SCSI_SENSE_BUFFERSIZE, GFP_NOIO); | |
305 | - if (!sense) | |
306 | - return DRIVER_ERROR << 24; | |
307 | - } | |
308 | - result = __scsi_execute(sdev, cmd, data_direction, buffer, bufflen, | |
309 | - sense, timeout, retries, flags, rq_flags, resid); | |
310 | - if (sshdr) | |
311 | - scsi_normalize_sense(sense, SCSI_SENSE_BUFFERSIZE, sshdr); | |
312 | - | |
313 | - kfree(sense); | |
314 | - return result; | |
303 | + return __scsi_execute(sdev, cmd, data_direction, buffer, bufflen, | |
304 | + NULL, sshdr, timeout, retries, flags, rq_flags, | |
305 | + resid); | |
315 | 306 | } |
316 | 307 | EXPORT_SYMBOL(scsi_execute_req_flags); |
317 | 308 |