aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pps
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-02-27 20:04:38 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-27 22:10:18 -0500
commit19dd2da3b4f643b65964a7f340000e27b5556f93 (patch)
tree740c5937f0adedea94428473710f1508fcf21621 /drivers/pps
parent05e2cefab4acb5ae9b54266935eeec32cc5269ea (diff)
pps: convert to idr_alloc()
Convert to the much saner new idr interface. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Rodolfo Giometti <giometti@enneenne.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/pps')
-rw-r--r--drivers/pps/kapi.c2
-rw-r--r--drivers/pps/pps.c36
2 files changed, 15 insertions, 23 deletions
diff --git a/drivers/pps/kapi.c b/drivers/pps/kapi.c
index f197e8ea185c..cdad4d95b20e 100644
--- a/drivers/pps/kapi.c
+++ b/drivers/pps/kapi.c
@@ -102,7 +102,7 @@ struct pps_device *pps_register_source(struct pps_source_info *info,
102 goto pps_register_source_exit; 102 goto pps_register_source_exit;
103 } 103 }
104 104
105 /* These initializations must be done before calling idr_get_new() 105 /* These initializations must be done before calling idr_alloc()
106 * in order to avoid reces into pps_event(). 106 * in order to avoid reces into pps_event().
107 */ 107 */
108 pps->params.api_version = PPS_API_VERS; 108 pps->params.api_version = PPS_API_VERS;
diff --git a/drivers/pps/pps.c b/drivers/pps/pps.c
index 6437703eb10f..7173e3ad475d 100644
--- a/drivers/pps/pps.c
+++ b/drivers/pps/pps.c
@@ -295,29 +295,21 @@ int pps_register_cdev(struct pps_device *pps)
295 dev_t devt; 295 dev_t devt;
296 296
297 mutex_lock(&pps_idr_lock); 297 mutex_lock(&pps_idr_lock);
298 /* Get new ID for the new PPS source */ 298 /*
299 if (idr_pre_get(&pps_idr, GFP_KERNEL) == 0) { 299 * Get new ID for the new PPS source. After idr_alloc() calling
300 mutex_unlock(&pps_idr_lock); 300 * the new source will be freely available into the kernel.
301 return -ENOMEM;
302 }
303
304 /* Now really allocate the PPS source.
305 * After idr_get_new() calling the new source will be freely available
306 * into the kernel.
307 */ 301 */
308 err = idr_get_new(&pps_idr, pps, &pps->id); 302 err = idr_alloc(&pps_idr, pps, 0, PPS_MAX_SOURCES, GFP_KERNEL);
309 mutex_unlock(&pps_idr_lock); 303 if (err < 0) {
310 304 if (err == -ENOSPC) {
311 if (err < 0) 305 pr_err("%s: too many PPS sources in the system\n",
312 return err; 306 pps->info.name);
313 307 err = -EBUSY;
314 pps->id &= MAX_IDR_MASK; 308 }
315 if (pps->id >= PPS_MAX_SOURCES) { 309 goto out_unlock;
316 pr_err("%s: too many PPS sources in the system\n",
317 pps->info.name);
318 err = -EBUSY;
319 goto free_idr;
320 } 310 }
311 pps->id = err;
312 mutex_unlock(&pps_idr_lock);
321 313
322 devt = MKDEV(MAJOR(pps_devt), pps->id); 314 devt = MKDEV(MAJOR(pps_devt), pps->id);
323 315
@@ -351,8 +343,8 @@ del_cdev:
351free_idr: 343free_idr:
352 mutex_lock(&pps_idr_lock); 344 mutex_lock(&pps_idr_lock);
353 idr_remove(&pps_idr, pps->id); 345 idr_remove(&pps_idr, pps->id);
346out_unlock:
354 mutex_unlock(&pps_idr_lock); 347 mutex_unlock(&pps_idr_lock);
355
356 return err; 348 return err;
357} 349}
358 350