[SCSI] lpfc: Restore HEX safe bahavior of the sysfs xxx_store functions.
[linux-2.6-block.git] / drivers / scsi / lpfc / lpfc_hbadisc.c
index 0a8269d6b130c0a4982f50eee6e8509985dca176..6c846ad373bcd0e4c08cad7e5f6025c15982961d 100644 (file)
@@ -1017,13 +1017,10 @@ lpfc_register_remote_port(struct lpfc_hba * phba,
        struct fc_rport *rport;
        struct lpfc_rport_data *rdata;
        struct fc_rport_identifiers rport_ids;
-       uint64_t wwn;
 
        /* Remote port has reappeared. Re-register w/ FC transport */
-       memcpy(&wwn, &ndlp->nlp_nodename, sizeof(uint64_t));
-       rport_ids.node_name = be64_to_cpu(wwn);
-       memcpy(&wwn, &ndlp->nlp_portname, sizeof(uint64_t));
-       rport_ids.port_name = be64_to_cpu(wwn);
+       rport_ids.node_name = wwn_to_u64(ndlp->nlp_nodename.u.wwn);
+       rport_ids.port_name = wwn_to_u64(ndlp->nlp_portname.u.wwn);
        rport_ids.port_id = ndlp->nlp_DID;
        rport_ids.roles = FC_RPORT_ROLE_UNKNOWN;
        if (ndlp->nlp_type & NLP_FCP_TARGET)
@@ -1031,6 +1028,7 @@ lpfc_register_remote_port(struct lpfc_hba * phba,
        if (ndlp->nlp_type & NLP_FCP_INITIATOR)
                rport_ids.roles |= FC_RPORT_ROLE_FCP_INITIATOR;
 
+       scsi_block_requests(phba->host);
        ndlp->rport = rport = fc_remote_port_add(phba->host, 0, &rport_ids);
        if (!rport) {
                dev_printk(KERN_WARNING, &phba->pcidev->dev,
@@ -1047,6 +1045,23 @@ lpfc_register_remote_port(struct lpfc_hba * phba,
        }
        rdata = rport->dd_data;
        rdata->pnode = ndlp;
+       scsi_unblock_requests(phba->host);
+
+       return;
+}
+
+static void
+lpfc_unregister_remote_port(struct lpfc_hba * phba,
+                           struct lpfc_nodelist * ndlp)
+{
+       struct fc_rport *rport = ndlp->rport;
+       struct lpfc_rport_data *rdata = rport->dd_data;
+
+       ndlp->rport = NULL;
+       rdata->pnode = NULL;
+       scsi_block_requests(phba->host);
+       fc_remote_port_delete(rport);
+       scsi_unblock_requests(phba->host);
 
        return;
 }
@@ -1263,7 +1278,7 @@ lpfc_nlp_list(struct lpfc_hba * phba, struct lpfc_nodelist * nlp, int list)
                 * may have removed the remote port.
                 */
                if ((rport_del != none) && nlp->rport)
-                       fc_remote_port_block(nlp->rport);
+                       lpfc_unregister_remote_port(phba, nlp);
 
                if (rport_add != none) {
                        /*
@@ -1273,8 +1288,6 @@ lpfc_nlp_list(struct lpfc_hba * phba, struct lpfc_nodelist * nlp, int list)
                         */
                        if (!nlp->rport)
                                lpfc_register_remote_port(phba, nlp);
-                       else
-                               fc_remote_port_unblock(nlp->rport);
 
                        /*
                         * if we added to Mapped list, but the remote port
@@ -1493,7 +1506,6 @@ lpfc_freenode(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp)
        LPFC_MBOXQ_t       *mb;
        LPFC_MBOXQ_t       *nextmb;
        struct lpfc_dmabuf *mp;
-       struct fc_rport *rport;
 
        /* Cleanup node for NPort <nlp_DID> */
        lpfc_printf_log(phba, KERN_INFO, LOG_NODE,
@@ -1510,10 +1522,7 @@ lpfc_freenode(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp)
         * and flush cache's w/o generating flush errors.
         */
        if ((ndlp->rport) && !(phba->fc_flag & FC_UNLOADING)) {
-               rport = ndlp->rport;
-               ndlp->rport = NULL;
-               fc_remote_port_unblock(rport);
-               fc_remote_port_delete(rport);
+               lpfc_unregister_remote_port(phba, ndlp);
                ndlp->nlp_sid = NLP_NO_SID;
        }