Merge tag 'trace-fixes-3.9-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git...
[cascardo/linux.git] / drivers / target / target_core_ua.c
index 6666a0c..bf0e390 100644 (file)
@@ -3,8 +3,7 @@
  *
  * This file contains logic for SPC-3 Unit Attention emulation
  *
- * Copyright (c) 2009,2010 Rising Tide Systems
- * Copyright (c) 2009,2010 Linux-iSCSI.org
+ * (c) Copyright 2009-2012 RisingTide Systems LLC.
  *
  * Nicholas A. Bellinger <nab@kernel.org>
  *
@@ -38,9 +37,8 @@
 #include "target_core_pr.h"
 #include "target_core_ua.h"
 
-int core_scsi3_ua_check(
-       struct se_cmd *cmd,
-       unsigned char *cdb)
+sense_reason_t
+target_scsi3_ua_check(struct se_cmd *cmd)
 {
        struct se_dev_entry *deve;
        struct se_session *sess = cmd->se_sess;
@@ -71,16 +69,14 @@ int core_scsi3_ua_check(
         *    was received, then the device server shall process the command
         *    and either:
         */
-       switch (cdb[0]) {
+       switch (cmd->t_task_cdb[0]) {
        case INQUIRY:
        case REPORT_LUNS:
        case REQUEST_SENSE:
                return 0;
        default:
-               return -EINVAL;
+               return TCM_CHECK_CONDITION_UNIT_ATTENTION;
        }
-
-       return -EINVAL;
 }
 
 int core_scsi3_ua_allocate(
@@ -237,7 +233,7 @@ void core_scsi3_ua_for_check_condition(
                 * highest priority UNIT_ATTENTION and ASC/ASCQ without
                 * clearing it.
                 */
-               if (dev->se_sub_dev->se_dev_attrib.emulate_ua_intlck_ctrl != 0) {
+               if (dev->dev_attrib.emulate_ua_intlck_ctrl != 0) {
                        *asc = ua->ua_asc;
                        *ascq = ua->ua_ascq;
                        break;
@@ -265,8 +261,8 @@ void core_scsi3_ua_for_check_condition(
                " INTLCK_CTRL: %d, mapped LUN: %u, got CDB: 0x%02x"
                " reported ASC: 0x%02x, ASCQ: 0x%02x\n",
                nacl->se_tpg->se_tpg_tfo->get_fabric_name(),
-               (dev->se_sub_dev->se_dev_attrib.emulate_ua_intlck_ctrl != 0) ? "Reporting" :
-               "Releasing", dev->se_sub_dev->se_dev_attrib.emulate_ua_intlck_ctrl,
+               (dev->dev_attrib.emulate_ua_intlck_ctrl != 0) ? "Reporting" :
+               "Releasing", dev->dev_attrib.emulate_ua_intlck_ctrl,
                cmd->orig_fe_lun, cmd->t_task_cdb[0], *asc, *ascq);
 }