From: Philipp Reisner Date: Wed, 20 Jul 2011 12:59:37 +0000 (+0200) Subject: idr: idr_for_each_entry() macro X-Git-Tag: v3.4.87~126 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ee164499c5f538f1cd8e5cf31e157aff32ea0546;p=platform%2Fkernel%2Flinux-stable.git idr: idr_for_each_entry() macro commit 9749f30f1a387070e6e8351f35aeb829eacc3ab6 upstream. Inspired by the list_for_each_entry() macro Signed-off-by: Philipp Reisner Signed-off-by: Ben Hutchings Cc: Qiang Huang Cc: Li Zefan Cc: Jianguo Wu Signed-off-by: Greg Kroah-Hartman --- diff --git a/include/linux/idr.h b/include/linux/idr.h index 255491c..52a9da2 100644 --- a/include/linux/idr.h +++ b/include/linux/idr.h @@ -152,4 +152,15 @@ void ida_simple_remove(struct ida *ida, unsigned int id); void __init idr_init_cache(void); +/** + * idr_for_each_entry - iterate over an idr's elements of a given type + * @idp: idr handle + * @entry: the type * to use as cursor + * @id: id entry's key + */ +#define idr_for_each_entry(idp, entry, id) \ + for (id = 0, entry = (typeof(entry))idr_get_next((idp), &(id)); \ + entry != NULL; \ + ++id, entry = (typeof(entry))idr_get_next((idp), &(id))) + #endif /* __IDR_H__ */