]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
[SCSI] libfc: changes to libfc_host_alloc to consolidate initialization with allocation
authorChris Leech <christopher.leech@intel.com>
Tue, 3 Nov 2009 19:46:08 +0000 (11:46 -0800)
committerJames Bottomley <James.Bottomley@suse.de>
Fri, 4 Dec 2009 18:00:56 +0000 (12:00 -0600)
I'd like to keep basic initialization together with allocation, which means
this can't just be a tail-call to scsi_host_alloc.

This is needed to create a generic libfc host allocation routine for NPIV
VN_Ports, which will share the exchange ID space (through sharing exchange
manager structures) with the parent lport.  In order to clone the exchange
manager list when the lport is allocated, the list head must be initialized
earlier.

Also, update fnic to use the libfc_host_alloc so that later changes do not break
it. (contribution by Joe Eykholt)

Signed-off-by: Chris Leech <christopher.leech@intel.com>
Signed-off-by: Joe Eykholt <jeykholt@cisco.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
drivers/scsi/fcoe/fcoe.c
drivers/scsi/fnic/fnic_main.c
drivers/scsi/libfc/fc_lport.c
include/scsi/libfc.h

index 4efbc17a7d7fd9274e218bd27804601d4d4eae09..8ca488de492db2557c50699127423f4bb4072e65 100644 (file)
@@ -515,8 +515,6 @@ static int fcoe_shost_config(struct fc_lport *lp, struct Scsi_Host *shost,
        int rc = 0;
 
        /* lport scsi host config */
-       lp->host = shost;
-
        lp->host->max_lun = FCOE_MAX_LUN;
        lp->host->max_id = FCOE_MAX_FCP_TARGET;
        lp->host->max_channel = 0;
@@ -734,14 +732,14 @@ static struct fc_lport *fcoe_if_create(struct fcoe_interface *fcoe,
 
        FCOE_NETDEV_DBG(netdev, "Create Interface\n");
 
-       shost = libfc_host_alloc(&fcoe_shost_template,
+       lport = libfc_host_alloc(&fcoe_shost_template,
                                 sizeof(struct fcoe_port));
-       if (!shost) {
+       if (!lport) {
                FCOE_NETDEV_DBG(netdev, "Could not allocate host structure\n");
                rc = -ENOMEM;
                goto out;
        }
-       lport = shost_priv(shost);
+       shost = lport->host;
        port = lport_priv(lport);
        port->lport = lport;
        port->fcoe = fcoe;
index fc61f17025cee503f83d36a1ef60304b5b0bada7..018cc427504ad70709217061b56ed5b00f55b8f1 100644 (file)
@@ -424,15 +424,13 @@ static int __devinit fnic_probe(struct pci_dev *pdev,
         * Allocate SCSI Host and set up association between host,
         * local port, and fnic
         */
-       host = scsi_host_alloc(&fnic_host_template,
-                              sizeof(struct fc_lport) + sizeof(struct fnic));
-       if (!host) {
-               printk(KERN_ERR PFX "Unable to alloc SCSI host\n");
+       lp = libfc_host_alloc(&fnic_host_template, sizeof(struct fnic));
+       if (!lp) {
+               printk(KERN_ERR PFX "Unable to alloc libfc local port\n");
                err = -ENOMEM;
                goto err_out;
        }
-       lp = shost_priv(host);
-       lp->host = host;
+       host = lp->host;
        fnic = lport_priv(lp);
        fnic->lport = lp;
 
index f7f20a46e494750d66839c09c6ca03cc839537a2..41650d3362892e3843f3b08627e274de53dd9d0a 100644 (file)
@@ -1505,7 +1505,6 @@ int fc_lport_init(struct fc_lport *lport)
        if (lport->link_supported_speeds & FC_PORTSPEED_10GBIT)
                fc_host_supported_speeds(lport->host) |= FC_PORTSPEED_10GBIT;
 
-       INIT_LIST_HEAD(&lport->ema_list);
        return 0;
 }
 EXPORT_SYMBOL(fc_lport_init);
index 690f8296e63380c25f2f79a4f2f4cc2e2856c02e..ed3057b4e78d027b87f0b78ab6fe1ed4636e1506 100644 (file)
@@ -739,12 +739,21 @@ static inline void *lport_priv(const struct fc_lport *lp)
  * @sht: ptr to the scsi host templ
  * @priv_size: size of private data after fc_lport
  *
- * Returns: ptr to Scsi_Host
+ * Returns: libfc lport
  */
-static inline struct Scsi_Host *
+static inline struct fc_lport *
 libfc_host_alloc(struct scsi_host_template *sht, int priv_size)
 {
-       return scsi_host_alloc(sht, sizeof(struct fc_lport) + priv_size);
+       struct fc_lport *lport;
+       struct Scsi_Host *shost;
+
+       shost = scsi_host_alloc(sht, sizeof(*lport) + priv_size);
+       if (!shost)
+               return NULL;
+       lport = shost_priv(shost);
+       lport->host = shost;
+       INIT_LIST_HEAD(&lport->ema_list);
+       return lport;
 }
 
 /*