Commit 3949e2f0 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Martin K. Petersen

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: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 74a78ebd
...@@ -215,8 +215,9 @@ void scsi_queue_insert(struct scsi_cmnd *cmd, int reason) ...@@ -215,8 +215,9 @@ void scsi_queue_insert(struct scsi_cmnd *cmd, int reason)
static int __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, static int __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
int data_direction, void *buffer, unsigned bufflen, int data_direction, void *buffer, unsigned bufflen,
unsigned char *sense, int timeout, int retries, u64 flags, unsigned char *sense, struct scsi_sense_hdr *sshdr,
req_flags_t rq_flags, int *resid) int timeout, int retries, u64 flags, req_flags_t rq_flags,
int *resid)
{ {
struct request *req; struct request *req;
struct scsi_request *rq; struct scsi_request *rq;
...@@ -259,6 +260,8 @@ static int __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, ...@@ -259,6 +260,8 @@ static int __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
*resid = rq->resid_len; *resid = rq->resid_len;
if (sense && rq->sense_len) if (sense && rq->sense_len)
memcpy(sense, rq->sense, SCSI_SENSE_BUFFERSIZE); memcpy(sense, rq->sense, SCSI_SENSE_BUFFERSIZE);
if (sshdr)
scsi_normalize_sense(rq->sense, rq->sense_len, sshdr);
ret = req->errors; ret = req->errors;
out: out:
blk_put_request(req); blk_put_request(req);
...@@ -288,7 +291,7 @@ int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, ...@@ -288,7 +291,7 @@ int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
int *resid) int *resid)
{ {
return __scsi_execute(sdev, cmd, data_direction, buffer, bufflen, sense, return __scsi_execute(sdev, cmd, data_direction, buffer, bufflen, sense,
timeout, retries, flags, 0, resid); NULL, timeout, retries, flags, 0, resid);
} }
EXPORT_SYMBOL(scsi_execute); EXPORT_SYMBOL(scsi_execute);
...@@ -297,21 +300,9 @@ int scsi_execute_req_flags(struct scsi_device *sdev, const unsigned char *cmd, ...@@ -297,21 +300,9 @@ int scsi_execute_req_flags(struct scsi_device *sdev, const unsigned char *cmd,
struct scsi_sense_hdr *sshdr, int timeout, int retries, struct scsi_sense_hdr *sshdr, int timeout, int retries,
int *resid, u64 flags, req_flags_t rq_flags) int *resid, u64 flags, req_flags_t rq_flags)
{ {
char *sense = NULL; return __scsi_execute(sdev, cmd, data_direction, buffer, bufflen,
int result; NULL, sshdr, timeout, retries, flags, rq_flags,
resid);
if (sshdr) {
sense = kzalloc(SCSI_SENSE_BUFFERSIZE, GFP_NOIO);
if (!sense)
return DRIVER_ERROR << 24;
}
result = __scsi_execute(sdev, cmd, data_direction, buffer, bufflen,
sense, timeout, retries, flags, rq_flags, resid);
if (sshdr)
scsi_normalize_sense(sense, SCSI_SENSE_BUFFERSIZE, sshdr);
kfree(sense);
return result;
} }
EXPORT_SYMBOL(scsi_execute_req_flags); EXPORT_SYMBOL(scsi_execute_req_flags);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment