From: Matthew Wilcox Date: Sun, 10 Feb 2019 12:01:59 +0000 (-0500) Subject: bfad: Convert bfad_im_port_index to IDA X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=a7b684fbb70604cadedae5ccc1d70e0e4aba8c00;p=users%2Fwilly%2Fxarray.git bfad: Convert bfad_im_port_index to IDA Also remove the unused bfad_list. Signed-off-by: Matthew Wilcox --- diff --git a/drivers/scsi/bfa/bfad.c b/drivers/scsi/bfa/bfad.c index 2f9213b257a4a..0041a99060ff9 100644 --- a/drivers/scsi/bfa/bfad.c +++ b/drivers/scsi/bfa/bfad.c @@ -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); diff --git a/drivers/scsi/bfa/bfad_drv.h b/drivers/scsi/bfa/bfad_drv.h index eaee7c8bc2d28..91b4189372771 100644 --- a/drivers/scsi/bfa/bfad_drv.h +++ b/drivers/scsi/bfa/bfad_drv.h @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include @@ -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; diff --git a/drivers/scsi/bfa/bfad_im.c b/drivers/scsi/bfa/bfad_im.c index b2014cb96f582..184f880027d20 100644 --- a/drivers/scsi/bfa/bfad_im.c +++ b/drivers/scsi/bfa/bfad_im.c @@ -13,6 +13,7 @@ */ #include +#include #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 diff --git a/drivers/scsi/bfa/bfad_im.h b/drivers/scsi/bfa/bfad_im.h index f16d4b219e440..b1cace3e4eba0 100644 --- a/drivers/scsi/bfa/bfad_im.h +++ b/drivers/scsi/bfa/bfad_im.h @@ -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;