aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-02-27 20:04:36 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-27 22:10:18 -0500
commit2fa532c5d5af8959d1b0ea369324f6d44183dba4 (patch)
treeb440e50b7e6df524838658a9ea0f812a1c67fa4d /drivers/net
parentec09ebc143818c7bb255cf2b79d97dae02a2e635 (diff)
ppp: convert to idr_alloc()
Convert to the much saner new idr interface. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/ppp/ppp_generic.c33
1 files changed, 4 insertions, 29 deletions
diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index 3db9131e9229..72ff14b811c6 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -2953,46 +2953,21 @@ static void __exit ppp_cleanup(void)
2953 * by holding all_ppp_mutex 2953 * by holding all_ppp_mutex
2954 */ 2954 */
2955 2955
2956static int __unit_alloc(struct idr *p, void *ptr, int n)
2957{
2958 int unit, err;
2959
2960again:
2961 if (!idr_pre_get(p, GFP_KERNEL)) {
2962 pr_err("PPP: No free memory for idr\n");
2963 return -ENOMEM;
2964 }
2965
2966 err = idr_get_new_above(p, ptr, n, &unit);
2967 if (err < 0) {
2968 if (err == -EAGAIN)
2969 goto again;
2970 return err;
2971 }
2972
2973 return unit;
2974}
2975
2976/* associate pointer with specified number */ 2956/* associate pointer with specified number */
2977static int unit_set(struct idr *p, void *ptr, int n) 2957static int unit_set(struct idr *p, void *ptr, int n)
2978{ 2958{
2979 int unit; 2959 int unit;
2980 2960
2981 unit = __unit_alloc(p, ptr, n); 2961 unit = idr_alloc(p, ptr, n, n + 1, GFP_KERNEL);
2982 if (unit < 0) 2962 if (unit == -ENOSPC)
2983 return unit; 2963 unit = -EINVAL;
2984 else if (unit != n) {
2985 idr_remove(p, unit);
2986 return -EINVAL;
2987 }
2988
2989 return unit; 2964 return unit;
2990} 2965}
2991 2966
2992/* get new free unit number and associate pointer with it */ 2967/* get new free unit number and associate pointer with it */
2993static int unit_get(struct idr *p, void *ptr) 2968static int unit_get(struct idr *p, void *ptr)
2994{ 2969{
2995 return __unit_alloc(p, ptr, 0); 2970 return idr_alloc(p, ptr, 0, 0, GFP_KERNEL);
2996} 2971}
2997 2972
2998/* put unit number back to a pool */ 2973/* put unit number back to a pool */