This driver doesn't look up the pointer that it stores, so this can just be an IDA and save some memory. Signed-off-by: Matthew Wilcox <willy@xxxxxxxxxxxxx> --- drivers/infiniband/hw/ocrdma/ocrdma_main.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_main.c b/drivers/infiniband/hw/ocrdma/ocrdma_main.c index 1f393842453a..b014eeffbcce 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_main.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_main.c @@ -62,7 +62,7 @@ MODULE_DESCRIPTION(OCRDMA_ROCE_DRV_DESC " " OCRDMA_ROCE_DRV_VERSION); MODULE_AUTHOR("Emulex Corporation"); MODULE_LICENSE("Dual BSD/GPL"); -static DEFINE_IDR(ocrdma_dev_id); +static DEFINE_IDA(ocrdma_dev_id); void ocrdma_get_guid(struct ocrdma_dev *dev, u8 *guid) { @@ -302,12 +302,12 @@ static struct ocrdma_dev *ocrdma_add(struct be_dev_info *dev_info) } dev->mbx_cmd = kzalloc(sizeof(struct ocrdma_mqe_emb_cmd), GFP_KERNEL); if (!dev->mbx_cmd) - goto idr_err; + goto ida_err; memcpy(&dev->nic_info, dev_info, sizeof(*dev_info)); - dev->id = idr_alloc(&ocrdma_dev_id, NULL, 0, 0, GFP_KERNEL); + dev->id = ida_alloc(&ocrdma_dev_id, GFP_KERNEL); if (dev->id < 0) - goto idr_err; + goto ida_err; status = ocrdma_init_hw(dev); if (status) @@ -345,8 +345,8 @@ static struct ocrdma_dev *ocrdma_add(struct be_dev_info *dev_info) ocrdma_free_resources(dev); ocrdma_cleanup_hw(dev); init_err: - idr_remove(&ocrdma_dev_id, dev->id); -idr_err: + ida_free(&ocrdma_dev_id, dev->id); +ida_err: kfree(dev->mbx_cmd); ib_dealloc_device(&dev->ibdev); pr_err("%s() leaving. ret=%d\n", __func__, status); @@ -355,8 +355,7 @@ static struct ocrdma_dev *ocrdma_add(struct be_dev_info *dev_info) static void ocrdma_remove_free(struct ocrdma_dev *dev) { - - idr_remove(&ocrdma_dev_id, dev->id); + ida_free(&ocrdma_dev_id, dev->id); kfree(dev->mbx_cmd); ib_dealloc_device(&dev->ibdev); } @@ -461,7 +460,6 @@ static void __exit ocrdma_exit_module(void) { be_roce_unregister_driver(&ocrdma_drv); ocrdma_rem_debugfs(); - idr_destroy(&ocrdma_dev_id); } module_init(ocrdma_init_module); -- 2.20.1