diff options
author | Tejun Heo <tj@kernel.org> | 2013-02-07 12:31:33 +1100 |
---|---|---|
committer | Stephen Rothwell <sfr@canb.auug.org.au> | 2013-02-14 15:26:18 +1100 |
commit | 9bd43336be5532324e49a84af0aaef9f9e0c5566 (patch) | |
tree | 4eef4577938af432b653f62c22753827463a7393 /lib | |
parent | 08801830b834482cd3ba170f1d27c246d0620130 (diff) |
idr: refactor idr_get_new_above()
Move slot filling to idr_fill_slot() from idr_get_new_above_int() and
make idr_get_new_above() directly call it. idr_get_new_above_int() is
no longer needed and removed.
This will be used to implement a new ID allocation interface.
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/idr.c | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/lib/idr.c b/lib/idr.c index bde6eecb0e87..b13aae5bdc81 100644 --- a/lib/idr.c +++ b/lib/idr.c @@ -278,24 +278,15 @@ build_up: return(v); } -static int idr_get_new_above_int(struct idr *idp, void *ptr, int starting_id) +/* + * @id and @pa are from a successful allocation from idr_get_empty_slot(). + * Install the user pointer @ptr and mark the slot full. + */ +static void idr_fill_slot(void *ptr, int id, struct idr_layer **pa) { - struct idr_layer *pa[MAX_IDR_LEVEL]; - int id; - - id = idr_get_empty_slot(idp, starting_id, pa); - if (id >= 0) { - /* - * Successfully found an empty slot. Install the user - * pointer and mark the slot full. - */ - rcu_assign_pointer(pa[0]->ary[id & IDR_MASK], - (struct idr_layer *)ptr); - pa[0]->count++; - idr_mark_full(pa, id); - } - - return id; + rcu_assign_pointer(pa[0]->ary[id & IDR_MASK], (struct idr_layer *)ptr); + pa[0]->count++; + idr_mark_full(pa, id); } /** @@ -318,11 +309,14 @@ static int idr_get_new_above_int(struct idr *idp, void *ptr, int starting_id) */ int idr_get_new_above(struct idr *idp, void *ptr, int starting_id, int *id) { + struct idr_layer *pa[MAX_IDR_LEVEL]; int rv; - rv = idr_get_new_above_int(idp, ptr, starting_id); + rv = idr_get_empty_slot(idp, starting_id, pa); if (rv < 0) return rv == -ENOMEM ? -EAGAIN : rv; + + idr_fill_slot(ptr, rv, pa); *id = rv; return 0; } |