From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Philipp Reisner To: Ben Hutchings Cc: stable@vger.kernel.org, akpm@linux-foundation.org, LKML Subject: Re: [ 052/153] idr: idr_for_each_entry() macro Date: Mon, 04 Mar 2013 22:05:52 +0100 Message-ID: <1607973.Qpkavuy2AM@quad> In-Reply-To: <1362373013.3768.295.camel@deadeye.wl.decadent.org.uk> References: <20130304033712.754098899@decadent.org.uk> <1362373013.3768.295.camel@deadeye.wl.decadent.org.uk> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org List-ID: Sure, here it is: ---------- From: Philipp Reisner commit 9749f30f1a387070e6e8351f35aeb829eacc3ab6 upstream. Inspired by the list_for_each_entry() macro Signed-off-by: Ben Hutchings Signed-off-by: Philipp Reisner --- include/linux/idr.h | 11 +++++++++++ 1 file changed, 11 insertions(+) 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__ */