lkml.org 
[lkml]   [2017]   [Sep]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 2/4] idr: Add a function idr_get()
From
Date
On Mon, 2017-09-25 at 08:56 -0400, Gargi Sharma wrote:
> idr_get(namespace, id) returns a NULL if id is not present
> in the idr tree or returns the pointer to the struct if id is
> present in the idr tree. With this function in the idr library,
> code for pid allocation can be simplified by calling this function
> instead of looking through the pidhash.

> +++ b/lib/idr.c
> @@ -135,6 +135,17 @@ void *idr_get_next_ext(struct idr *idr, unsigned
> long *nextid)
>  }
>  EXPORT_SYMBOL(idr_get_next_ext);
>  
> +void * idr_get(struct idr *idr, int *id)
> +{
> + struct radix_tree_node *node;
> + void __rcu **slot = NULL;
> +
> + __radix_tree_lookup(&idr->idr_rt, *id, &node, &slot);
> + if (!slot)
> + return NULL;
> + return node;
> +}

I should have noticed this (much) earlier, but doesn't idr_get do
essentially the same thing as idr_find?

Also, wouldn't you want to return the pid pointer from slot,
rather than a pointer to the entire radix tree node?

--
All Rights Reversed.[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2017-09-25 15:21    [W:6.250 / U:0.184 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site