diff options
author | Tejun Heo <tj@kernel.org> | 2013-02-27 20:04:25 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-27 22:10:17 -0500 |
commit | 80f22b4430cd5c108a4676803439ecb0c5cfeca1 (patch) | |
tree | b0b712b22aa03ea3bab37acc82e41e81550c7caa /drivers/infiniband | |
parent | cffcd59f15db02b341e50da653860afa0ba11a83 (diff) |
IB/qib: convert to idr_alloc()
Convert to the much saner new idr interface.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Mike Marciniszyn <infinipath@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/hw/qib/qib_init.c | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/drivers/infiniband/hw/qib/qib_init.c b/drivers/infiniband/hw/qib/qib_init.c index ddf066d9abb6..50e33aa0b4e3 100644 --- a/drivers/infiniband/hw/qib/qib_init.c +++ b/drivers/infiniband/hw/qib/qib_init.c | |||
@@ -1060,22 +1060,23 @@ struct qib_devdata *qib_alloc_devdata(struct pci_dev *pdev, size_t extra) | |||
1060 | struct qib_devdata *dd; | 1060 | struct qib_devdata *dd; |
1061 | int ret; | 1061 | int ret; |
1062 | 1062 | ||
1063 | if (!idr_pre_get(&qib_unit_table, GFP_KERNEL)) { | ||
1064 | dd = ERR_PTR(-ENOMEM); | ||
1065 | goto bail; | ||
1066 | } | ||
1067 | |||
1068 | dd = (struct qib_devdata *) ib_alloc_device(sizeof(*dd) + extra); | 1063 | dd = (struct qib_devdata *) ib_alloc_device(sizeof(*dd) + extra); |
1069 | if (!dd) { | 1064 | if (!dd) { |
1070 | dd = ERR_PTR(-ENOMEM); | 1065 | dd = ERR_PTR(-ENOMEM); |
1071 | goto bail; | 1066 | goto bail; |
1072 | } | 1067 | } |
1073 | 1068 | ||
1069 | idr_preload(GFP_KERNEL); | ||
1074 | spin_lock_irqsave(&qib_devs_lock, flags); | 1070 | spin_lock_irqsave(&qib_devs_lock, flags); |
1075 | ret = idr_get_new(&qib_unit_table, dd, &dd->unit); | 1071 | |
1076 | if (ret >= 0) | 1072 | ret = idr_alloc(&qib_unit_table, dd, 0, 0, GFP_NOWAIT); |
1073 | if (ret >= 0) { | ||
1074 | dd->unit = ret; | ||
1077 | list_add(&dd->list, &qib_dev_list); | 1075 | list_add(&dd->list, &qib_dev_list); |
1076 | } | ||
1077 | |||
1078 | spin_unlock_irqrestore(&qib_devs_lock, flags); | 1078 | spin_unlock_irqrestore(&qib_devs_lock, flags); |
1079 | idr_preload_end(); | ||
1079 | 1080 | ||
1080 | if (ret < 0) { | 1081 | if (ret < 0) { |
1081 | qib_early_err(&pdev->dev, | 1082 | qib_early_err(&pdev->dev, |
@@ -1180,11 +1181,6 @@ static int __init qlogic_ib_init(void) | |||
1180 | * the PCI subsystem. | 1181 | * the PCI subsystem. |
1181 | */ | 1182 | */ |
1182 | idr_init(&qib_unit_table); | 1183 | idr_init(&qib_unit_table); |
1183 | if (!idr_pre_get(&qib_unit_table, GFP_KERNEL)) { | ||
1184 | pr_err("idr_pre_get() failed\n"); | ||
1185 | ret = -ENOMEM; | ||
1186 | goto bail_cq_wq; | ||
1187 | } | ||
1188 | 1184 | ||
1189 | ret = pci_register_driver(&qib_driver); | 1185 | ret = pci_register_driver(&qib_driver); |
1190 | if (ret < 0) { | 1186 | if (ret < 0) { |
@@ -1199,7 +1195,6 @@ static int __init qlogic_ib_init(void) | |||
1199 | 1195 | ||
1200 | bail_unit: | 1196 | bail_unit: |
1201 | idr_destroy(&qib_unit_table); | 1197 | idr_destroy(&qib_unit_table); |
1202 | bail_cq_wq: | ||
1203 | destroy_workqueue(qib_cq_wq); | 1198 | destroy_workqueue(qib_cq_wq); |
1204 | bail_dev: | 1199 | bail_dev: |
1205 | qib_dev_cleanup(); | 1200 | qib_dev_cleanup(); |