]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
[SCSI] qla2xxx: Cleanup FC remote port registration.
authorAndrew Vasquez <andrew.vasquez@qlogic.com>
Sat, 9 Jul 2005 01:00:36 +0000 (18:00 -0700)
committerJames Bottomley <jejb@mulgrave.(none)>
Thu, 14 Jul 2005 15:15:55 +0000 (11:15 -0400)
Cleanup FC remote port registration.

Due to the inherent behaviour (an immediate scan) of adding
a 'target'-role-capable rport via fc_remote_port_add(),
split the registration into two steps -- addition as
unknown-type role, then use fc_remote_port_rolchg() with
appropriate role (based on PLOGI/PRLI bits).  This allows
for a more cleaner rport->dd_data management as can be seen
with the simplified qla2xxx_slave_alloc() function.

Signed-off-by: Andrew Vasquez <andrew.vasquez@qlogic.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
drivers/scsi/qla2xxx/qla_init.c
drivers/scsi/qla2xxx/qla_os.c

index 1a25714e85c672f78121da37461ca6410e095384..a6d2559217cded06fa9737cb9d9989190f9495e8 100644 (file)
@@ -2067,22 +2067,25 @@ qla2x00_reg_remote_port(scsi_qla_host_t *ha, fc_port_t *fcport)
        rport_ids.port_name = be64_to_cpu(*(uint64_t *)fcport->port_name);
        rport_ids.port_id = fcport->d_id.b.domain << 16 |
            fcport->d_id.b.area << 8 | fcport->d_id.b.al_pa;
+       rport_ids.roles = FC_RPORT_ROLE_UNKNOWN;
+       fcport->rport = rport = fc_remote_port_add(ha->host, 0, &rport_ids);
+       if (!rport) {
+               qla_printk(KERN_WARNING, ha,
+                   "Unable to allocate fc remote port!\n");
+               return;
+       }
+       rport->dd_data = fcport;
+
        rport_ids.roles = FC_RPORT_ROLE_UNKNOWN;
        if (fcport->port_type == FCT_INITIATOR)
                rport_ids.roles |= FC_RPORT_ROLE_FCP_INITIATOR;
        if (fcport->port_type == FCT_TARGET)
                rport_ids.roles |= FC_RPORT_ROLE_FCP_TARGET;
-
-       fcport->rport = rport = fc_remote_port_add(ha->host, 0, &rport_ids);
-       if (!rport)
-               qla_printk(KERN_WARNING, ha,
-                   "Unable to allocate fc remote port!\n");
+       fc_remote_port_rolechg(rport, rport_ids.roles);
 
        if (rport->scsi_target_id != -1 &&
            rport->scsi_target_id < ha->host->max_id)
                fcport->os_target_id = rport->scsi_target_id;
-
-       rport->dd_data = fcport;
 }
 
 /*
index d726f48728ec2ef807637c0ad4957dcd9544dc7c..9000659bfbcfcccd21ff6d4e68563f78b650e487 100644 (file)
@@ -1071,26 +1071,12 @@ qla2x00_device_reset(scsi_qla_host_t *ha, fc_port_t *reset_fcport)
 static int
 qla2xxx_slave_alloc(struct scsi_device *sdev)
 {
-       scsi_qla_host_t *ha = to_qla_host(sdev->host);
        struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
-       fc_port_t *fcport;
-       int found;
 
        if (!rport)
                return -ENXIO;
 
-       found = 0;
-       list_for_each_entry(fcport, &ha->fcports, list) {
-               if (rport->port_name ==
-                   be64_to_cpu(*(uint64_t *)fcport->port_name)) {
-                       found++;
-                       break;
-               }
-       }
-       if (!found)
-               return -ENXIO;
-
-       sdev->hostdata = fcport;
+       sdev->hostdata = rport->dd_data;
 
        return 0;
 }