Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Tejun Heo and committed by
Linus Torvalds
2fa532c5 ec09ebc1

+4 -29
+4 -29
drivers/net/ppp/ppp_generic.c
··· 2953 2953 * by holding all_ppp_mutex 2954 2954 */ 2955 2955 2956 - static int __unit_alloc(struct idr *p, void *ptr, int n) 2957 - { 2958 - int unit, err; 2959 - 2960 - again: 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 2956 /* associate pointer with specified number */ 2977 2957 static int unit_set(struct idr *p, void *ptr, int n) 2978 2958 { 2979 2959 int unit; 2980 2960 2981 - unit = __unit_alloc(p, ptr, n); 2982 - if (unit < 0) 2983 - return unit; 2984 - else if (unit != n) { 2985 - idr_remove(p, unit); 2986 - return -EINVAL; 2987 - } 2988 - 2961 + unit = idr_alloc(p, ptr, n, n + 1, GFP_KERNEL); 2962 + if (unit == -ENOSPC) 2963 + unit = -EINVAL; 2989 2964 return unit; 2990 2965 } 2991 2966 2992 2967 /* get new free unit number and associate pointer with it */ 2993 2968 static 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 2973 /* put unit number back to a pool */