@@ -519,6 +519,22 @@ static inline void set_scsi_ml_byte(struct scsi_cmnd *cmd, u8 status)
cmd->result = (cmd->result & 0xffff00ff) | (status << 8);
}
+static enum scsi_disposition scsi_prep_sense(struct scsi_cmnd *scmd,
+ struct scsi_sense_hdr *sshdr)
+{
+ struct scsi_device *sdev = scmd->device;
+
+ if (!scsi_command_normalize_sense(scmd, sshdr))
+ return FAILED; /* no valid sense data */
+
+ scsi_report_sense(sdev, sshdr);
+
+ if (scsi_sense_is_deferred(sshdr))
+ return NEEDS_RETRY;
+
+ return SUCCESS;
+}
+
/**
* scsi_check_sense - Examine scsi cmd sense
* @scmd: Cmd to have sense checked.
@@ -534,14 +550,11 @@ enum scsi_disposition scsi_check_sense(struct scsi_cmnd *scmd)
{
struct scsi_device *sdev = scmd->device;
struct scsi_sense_hdr sshdr;
+ enum scsi_disposition ret;
- if (! scsi_command_normalize_sense(scmd, &sshdr))
- return FAILED; /* no valid sense data */
-
- scsi_report_sense(sdev, &sshdr);
-
- if (scsi_sense_is_deferred(&sshdr))
- return NEEDS_RETRY;
+ ret = scsi_prep_sense(scmd, &sshdr);
+ if (ret != SUCCESS)
+ return ret;
if (sdev->handler && sdev->handler->check_sense) {
enum scsi_disposition rc;
This breaks out the sense prep so it can be used in helper that will be added in this patchset for passthrough commands. Signed-off-by: Mike Christie <michael.christie@oracle.com> --- drivers/scsi/scsi_error.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-)