Merge branch 'sh-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[pandora-kernel.git] / drivers / target / target_core_device.c
index fc10ed4..ba698ea 100644 (file)
@@ -38,6 +38,7 @@
 #include <net/sock.h>
 #include <net/tcp.h>
 #include <scsi/scsi.h>
+#include <scsi/scsi_device.h>
 
 #include <target/target_core_base.h>
 #include <target/target_core_device.h>
@@ -191,7 +192,7 @@ int transport_get_lun_for_tmr(
                        &SE_NODE_ACL(se_sess)->device_list[unpacked_lun];
        if (deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS) {
                se_lun = se_cmd->se_lun = se_tmr->tmr_lun = deve->se_lun;
-               dev = se_tmr->tmr_dev = se_lun->lun_se_dev;
+               dev = se_lun->lun_se_dev;
                se_cmd->pr_res_key = deve->pr_res_key;
                se_cmd->orig_fe_lun = unpacked_lun;
                se_cmd->se_orig_obj_ptr = SE_LUN(se_cmd)->lun_se_dev;
@@ -215,6 +216,7 @@ int transport_get_lun_for_tmr(
                se_cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
                return -1;
        }
+       se_tmr->tmr_dev = dev;
 
        spin_lock(&dev->se_tmr_lock);
        list_add_tail(&se_tmr->tmr_list, &dev->dev_tmr_list);
@@ -658,8 +660,7 @@ int transport_core_report_lun_response(struct se_cmd *se_cmd)
        struct se_session *se_sess = SE_SESS(se_cmd);
        struct se_task *se_task;
        unsigned char *buf = (unsigned char *)T_TASK(se_cmd)->t_task_buf;
-       u32 cdb_offset = 0, lun_count = 0, offset = 8;
-       u64 i, lun;
+       u32 cdb_offset = 0, lun_count = 0, offset = 8, i;
 
        list_for_each_entry(se_task, &T_TASK(se_cmd)->t_task_list, t_list)
                break;
@@ -675,15 +676,7 @@ int transport_core_report_lun_response(struct se_cmd *se_cmd)
         * a $FABRIC_MOD.  In that case, report LUN=0 only.
         */
        if (!(se_sess)) {
-               lun = 0;
-               buf[offset++] = ((lun >> 56) & 0xff);
-               buf[offset++] = ((lun >> 48) & 0xff);
-               buf[offset++] = ((lun >> 40) & 0xff);
-               buf[offset++] = ((lun >> 32) & 0xff);
-               buf[offset++] = ((lun >> 24) & 0xff);
-               buf[offset++] = ((lun >> 16) & 0xff);
-               buf[offset++] = ((lun >> 8) & 0xff);
-               buf[offset++] = (lun & 0xff);
+               int_to_scsilun(0, (struct scsi_lun *)&buf[offset]);
                lun_count = 1;
                goto done;
        }
@@ -703,15 +696,8 @@ int transport_core_report_lun_response(struct se_cmd *se_cmd)
                if ((cdb_offset + 8) >= se_cmd->data_length)
                        continue;
 
-               lun = cpu_to_be64(CMD_TFO(se_cmd)->pack_lun(deve->mapped_lun));
-               buf[offset++] = ((lun >> 56) & 0xff);
-               buf[offset++] = ((lun >> 48) & 0xff);
-               buf[offset++] = ((lun >> 40) & 0xff);
-               buf[offset++] = ((lun >> 32) & 0xff);
-               buf[offset++] = ((lun >> 24) & 0xff);
-               buf[offset++] = ((lun >> 16) & 0xff);
-               buf[offset++] = ((lun >> 8) & 0xff);
-               buf[offset++] = (lun & 0xff);
+               int_to_scsilun(deve->mapped_lun, (struct scsi_lun *)&buf[offset]);
+               offset += 8;
                cdb_offset += 8;
        }
        spin_unlock_irq(&SE_NODE_ACL(se_sess)->device_list_lock);
@@ -1445,7 +1431,7 @@ struct se_lun_acl *core_dev_init_initiator_node_lun_acl(
        struct se_lun_acl *lacl;
        struct se_node_acl *nacl;
 
-       if (strlen(initiatorname) > TRANSPORT_IQN_LEN) {
+       if (strlen(initiatorname) >= TRANSPORT_IQN_LEN) {
                printk(KERN_ERR "%s InitiatorName exceeds maximum size.\n",
                        TPG_TFO(tpg)->get_fabric_name());
                *ret = -EOVERFLOW;