@@ -722,23 +722,19 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
sense_deferred = scsi_sense_is_deferred(&sshdr);
}
- if (blk_pc_request(req)) { /* SG_IO ioctl from block level */
- req->errors = result;
- if (result) {
- if (sense_valid && req->sense) {
- /*
- * SG_IO wants current and deferred errors
- */
- int len = 8 + cmd->sense_buffer[7];
+ req->errors = result;
+ if (sense_valid && req->sense) {
+ int len = 8 + cmd->sense_buffer[7];
+
+ if (len > SCSI_SENSE_BUFFERSIZE)
+ len = SCSI_SENSE_BUFFERSIZE;
+ memcpy(req->sense, cmd->sense_buffer, len);
+ req->sense_len = len;
+ }
- if (len > SCSI_SENSE_BUFFERSIZE)
- len = SCSI_SENSE_BUFFERSIZE;
- memcpy(req->sense, cmd->sense_buffer, len);
- req->sense_len = len;
- }
- if (!sense_deferred)
- error = -EIO;
- }
+ if (blk_pc_request(req)) { /* SG_IO ioctl from block level */
+ if ((result) && (!sense_deferred))
+ error = -EIO;
req->resid_len = scsi_get_resid(cmd);