]> www.infradead.org Git - users/willy/xarray.git/commitdiff
bfad: Convert bfad_im_port_index to IDA
authorMatthew Wilcox <willy@infradead.org>
Sun, 10 Feb 2019 12:01:59 +0000 (07:01 -0500)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Thu, 8 Aug 2019 03:39:47 +0000 (23:39 -0400)
Also remove the unused bfad_list.

Signed-off-by: Matthew Wilcox <willy@infradead.org>
drivers/scsi/bfa/bfad.c
drivers/scsi/bfa/bfad_drv.h
drivers/scsi/bfa/bfad_im.c
drivers/scsi/bfa/bfad_im.h

index 2f9213b257a4a231854e4d3043774647951187e4..0041a99060ff99506f9b129d31fed9ba04dbeab7 100644 (file)
@@ -30,7 +30,6 @@
 
 BFA_TRC_FILE(LDRV, BFAD);
 DEFINE_MUTEX(bfad_mutex);
-LIST_HEAD(bfad_list);
 
 static int     bfad_inst;
 static int      num_sgpgs_parm;
@@ -1334,7 +1333,6 @@ bfad_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pid)
 
        mutex_lock(&bfad_mutex);
        bfad->inst_no = bfad_inst++;
-       list_add_tail(&bfad->list_entry, &bfad_list);
        mutex_unlock(&bfad_mutex);
 
        /* Initializing the state machine: State set to uninit */
@@ -1373,7 +1371,6 @@ out_drv_init_failure:
        bfad_debugfs_exit(&bfad->pport);
        mutex_lock(&bfad_mutex);
        bfad_inst--;
-       list_del(&bfad->list_entry);
        mutex_unlock(&bfad_mutex);
        bfad_pci_uninit(pdev, bfad);
 out_pci_init_failure:
@@ -1419,7 +1416,6 @@ bfad_pci_remove(struct pci_dev *pdev)
        /* Cleaning the BFAD instance */
        mutex_lock(&bfad_mutex);
        bfad_inst--;
-       list_del(&bfad->list_entry);
        mutex_unlock(&bfad_mutex);
        bfad_pci_uninit(pdev, bfad);
 
index eaee7c8bc2d28d60e0e0e6ec5dea5d7f6482e9c6..91b4189372771c3a11915029de4025e2c13a64ad 100644 (file)
@@ -22,7 +22,6 @@
 #include <linux/types.h>
 #include <linux/pci.h>
 #include <linux/dma-mapping.h>
-#include <linux/idr.h>
 #include <linux/interrupt.h>
 #include <linux/cdev.h>
 #include <linux/fs.h>
@@ -181,7 +180,6 @@ union bfad_tmp_buf {
  */
 struct bfad_s {
        bfa_sm_t        sm;     /* state machine */
-       struct list_head list_entry;
        struct bfa_s    bfa;
        struct bfa_fcs_s bfa_fcs;
        struct pci_dev *pcidev;
@@ -321,9 +319,7 @@ void bfad_rport_online_wait(struct bfad_s *bfad);
 int bfad_get_linkup_delay(struct bfad_s *bfad);
 int bfad_install_msix_handler(struct bfad_s *bfad);
 
-extern struct idr bfad_im_port_index;
 extern struct pci_device_id bfad_id_table[];
-extern struct list_head bfad_list;
 extern char    *os_name;
 extern char    *os_patch;
 extern char    *host_name;
index b2014cb96f58226b81b8c638a5ec42e532cd74eb..184f880027d207ad13d14ecb92da20a80bb9afd8 100644 (file)
@@ -13,6 +13,7 @@
  */
 
 #include <linux/export.h>
+#include <linux/idr.h>
 
 #include "bfad_drv.h"
 #include "bfad_im.h"
@@ -20,7 +21,7 @@
 
 BFA_TRC_FILE(LDRV, IM);
 
-DEFINE_IDR(bfad_im_port_index);
+static DEFINE_IDA(bfad_im_port_index);
 struct scsi_transport_template *bfad_im_scsi_transport_template;
 struct scsi_transport_template *bfad_im_scsi_vport_transport_template;
 static void bfad_im_itnim_work_handler(struct work_struct *work);
@@ -538,25 +539,22 @@ bfad_im_scsi_host_alloc(struct bfad_s *bfad, struct bfad_im_port_s *im_port,
        struct bfad_im_port_pointer *im_portp;
        int error = 1;
 
-       mutex_lock(&bfad_mutex);
-       error = idr_alloc(&bfad_im_port_index, im_port, 0, 0, GFP_KERNEL);
+       error = ida_alloc(&bfad_im_port_index, GFP_KERNEL);
        if (error < 0) {
-               mutex_unlock(&bfad_mutex);
-               printk(KERN_WARNING "idr_alloc failure\n");
+               printk(KERN_WARNING "ID alloc failure\n");
                goto out;
        }
-       im_port->idr_id = error;
-       mutex_unlock(&bfad_mutex);
+       im_port->host_id = error;
 
        im_port->shost = bfad_scsi_host_alloc(im_port, bfad);
        if (!im_port->shost) {
                error = 1;
-               goto out_free_idr;
+               goto out_free_id;
        }
 
        im_portp = shost_priv(im_port->shost);
        im_portp->p = im_port;
-       im_port->shost->unique_id = im_port->idr_id;
+       im_port->shost->unique_id = im_port->host_id;
        im_port->shost->this_id = -1;
        im_port->shost->max_id = MAX_FCP_TARGET;
        im_port->shost->max_lun = MAX_FCP_LUN;
@@ -579,10 +577,8 @@ bfad_im_scsi_host_alloc(struct bfad_s *bfad, struct bfad_im_port_s *im_port,
 out_fc_rel:
        scsi_host_put(im_port->shost);
        im_port->shost = NULL;
-out_free_idr:
-       mutex_lock(&bfad_mutex);
-       idr_remove(&bfad_im_port_index, im_port->idr_id);
-       mutex_unlock(&bfad_mutex);
+out_free_id:
+       ida_free(&bfad_im_port_index, im_port->host_id);
 out:
        return error;
 }
@@ -599,9 +595,7 @@ bfad_im_scsi_host_free(struct bfad_s *bfad, struct bfad_im_port_s *im_port)
        scsi_remove_host(im_port->shost);
        scsi_host_put(im_port->shost);
 
-       mutex_lock(&bfad_mutex);
-       idr_remove(&bfad_im_port_index, im_port->idr_id);
-       mutex_unlock(&bfad_mutex);
+       ida_free(&bfad_im_port_index, im_port->host_id);
 }
 
 static void
@@ -861,8 +855,6 @@ bfad_im_module_exit(void)
 
        if (bfad_im_scsi_vport_transport_template)
                fc_release_transport(bfad_im_scsi_vport_transport_template);
-
-       idr_destroy(&bfad_im_port_index);
 }
 
 void
index f16d4b219e440416d2533c936a10bf793b0da26c..b1cace3e4eba09b94adade35386e59aa6dfcde77 100644 (file)
@@ -51,7 +51,7 @@ struct bfad_im_port_s {
        struct bfad_s         *bfad;
        struct bfad_port_s    *port;
        struct work_struct port_delete_work;
-       int             idr_id;
+       int     host_id;
        u16        cur_scsi_id;
        u16     flags;
        struct list_head binding_list;