if (cmnd) {
                cmnd->result |= rsp->status;
-               if (((cmnd->result >> 1) & 0x1f) == CHECK_CONDITION)
+               if (scsi_status_is_check_condition(cmnd->result))
                        memcpy(cmnd->sense_buffer,
                               rsp->data,
                               be32_to_cpu(rsp->sense_data_len));
 
                    (level > 1)) {
                        scsi_print_result(cmd, "Done", disposition);
                        scsi_print_command(cmd);
-                       if (status_byte(cmd->result) == CHECK_CONDITION)
+                       if (scsi_status_is_check_condition(cmd->result))
                                scsi_print_sense(cmd);
                        if (level > 3)
                                scmd_printk(KERN_INFO, cmd,
 
                                             current->comm));
                        break;
                }
-               if (status_byte(scmd->result) != CHECK_CONDITION)
+               if (!scsi_status_is_check_condition(scmd->result))
                        /*
                         * don't request sense if there's no check condition
                         * status because the error we're processing isn't one
                return (scmd->request->cmd_flags & REQ_FAILFAST_DRIVER);
        }
 
-       if (status_byte(scmd->result) != CHECK_CONDITION)
+       if (!scsi_status_is_check_condition(scmd->result))
                return 0;
 
 check_type:
 
                                        goto retry;
                                }
                        }
-                       if ((status_byte(result) == CHECK_CONDITION) &&
+                       if (scsi_status_is_check_condition(result) &&
                            sshdr->sense_key == UNIT_ATTENTION &&
                            retry_count) {
                                retry_count--;
 
        return (lun & 0xff00) == SCSI_W_LUN_BASE;
 }
 
+/**
+ * scsi_status_is_check_condition - check the status return.
+ *
+ * @status: the status passed up from the driver (including host and
+ *          driver components)
+ *
+ * This returns true if the status code is SAM_STAT_CHECK_CONDITION.
+ */
+static inline int scsi_status_is_check_condition(int status)
+{
+       if (status < 0)
+               return false;
+       status &= 0xfe;
+       return status == SAM_STAT_CHECK_CONDITION;
+}
 
 /*
  *  MESSAGE CODES