diff options
author | Tejun Heo <tj@kernel.org> | 2013-02-27 20:04:22 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-27 22:10:17 -0500 |
commit | 5c213f86417b264b38b279def3363811c2be54f0 (patch) | |
tree | 4aceb8856bbb6cb97509230a8b91299bd8d2d48f /drivers/infiniband/hw | |
parent | cbbbce1de2763cdf923b0e85c1a13877a6b61025 (diff) |
IB/ipath: convert to idr_alloc()
Convert to the much saner new idr interface.
[yongjun_wei@trendmicro.com.cn: use GFP_NOWAIT under spin lock]
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Cc: Mike Marciniszyn <mike.marciniszyn@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/hw')
-rw-r--r-- | drivers/infiniband/hw/ipath/ipath_driver.c | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/drivers/infiniband/hw/ipath/ipath_driver.c b/drivers/infiniband/hw/ipath/ipath_driver.c index 7b371f545ece..bd0caedafe99 100644 --- a/drivers/infiniband/hw/ipath/ipath_driver.c +++ b/drivers/infiniband/hw/ipath/ipath_driver.c | |||
@@ -194,11 +194,6 @@ static struct ipath_devdata *ipath_alloc_devdata(struct pci_dev *pdev) | |||
194 | struct ipath_devdata *dd; | 194 | struct ipath_devdata *dd; |
195 | int ret; | 195 | int ret; |
196 | 196 | ||
197 | if (!idr_pre_get(&unit_table, GFP_KERNEL)) { | ||
198 | dd = ERR_PTR(-ENOMEM); | ||
199 | goto bail; | ||
200 | } | ||
201 | |||
202 | dd = vzalloc(sizeof(*dd)); | 197 | dd = vzalloc(sizeof(*dd)); |
203 | if (!dd) { | 198 | if (!dd) { |
204 | dd = ERR_PTR(-ENOMEM); | 199 | dd = ERR_PTR(-ENOMEM); |
@@ -206,9 +201,10 @@ static struct ipath_devdata *ipath_alloc_devdata(struct pci_dev *pdev) | |||
206 | } | 201 | } |
207 | dd->ipath_unit = -1; | 202 | dd->ipath_unit = -1; |
208 | 203 | ||
204 | idr_preload(GFP_KERNEL); | ||
209 | spin_lock_irqsave(&ipath_devs_lock, flags); | 205 | spin_lock_irqsave(&ipath_devs_lock, flags); |
210 | 206 | ||
211 | ret = idr_get_new(&unit_table, dd, &dd->ipath_unit); | 207 | ret = idr_alloc(&unit_table, dd, 0, 0, GFP_NOWAIT); |
212 | if (ret < 0) { | 208 | if (ret < 0) { |
213 | printk(KERN_ERR IPATH_DRV_NAME | 209 | printk(KERN_ERR IPATH_DRV_NAME |
214 | ": Could not allocate unit ID: error %d\n", -ret); | 210 | ": Could not allocate unit ID: error %d\n", -ret); |
@@ -216,6 +212,7 @@ static struct ipath_devdata *ipath_alloc_devdata(struct pci_dev *pdev) | |||
216 | dd = ERR_PTR(ret); | 212 | dd = ERR_PTR(ret); |
217 | goto bail_unlock; | 213 | goto bail_unlock; |
218 | } | 214 | } |
215 | dd->ipath_unit = ret; | ||
219 | 216 | ||
220 | dd->pcidev = pdev; | 217 | dd->pcidev = pdev; |
221 | pci_set_drvdata(pdev, dd); | 218 | pci_set_drvdata(pdev, dd); |
@@ -224,7 +221,7 @@ static struct ipath_devdata *ipath_alloc_devdata(struct pci_dev *pdev) | |||
224 | 221 | ||
225 | bail_unlock: | 222 | bail_unlock: |
226 | spin_unlock_irqrestore(&ipath_devs_lock, flags); | 223 | spin_unlock_irqrestore(&ipath_devs_lock, flags); |
227 | 224 | idr_preload_end(); | |
228 | bail: | 225 | bail: |
229 | return dd; | 226 | return dd; |
230 | } | 227 | } |
@@ -2503,11 +2500,6 @@ static int __init infinipath_init(void) | |||
2503 | * the PCI subsystem. | 2500 | * the PCI subsystem. |
2504 | */ | 2501 | */ |
2505 | idr_init(&unit_table); | 2502 | idr_init(&unit_table); |
2506 | if (!idr_pre_get(&unit_table, GFP_KERNEL)) { | ||
2507 | printk(KERN_ERR IPATH_DRV_NAME ": idr_pre_get() failed\n"); | ||
2508 | ret = -ENOMEM; | ||
2509 | goto bail; | ||
2510 | } | ||
2511 | 2503 | ||
2512 | ret = pci_register_driver(&ipath_driver); | 2504 | ret = pci_register_driver(&ipath_driver); |
2513 | if (ret < 0) { | 2505 | if (ret < 0) { |