From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Philipp Reisner To: linux-kernel@vger.kernel.org, Jens Axboe Date: Thu, 25 Aug 2011 17:07:23 +0200 Message-Id: <1314284934-17999-28-git-send-email-philipp.reisner@linbit.com> In-Reply-To: <1314284934-17999-1-git-send-email-philipp.reisner@linbit.com> References: <1314284934-17999-1-git-send-email-philipp.reisner@linbit.com> Cc: drbd-dev@lists.linbit.com Subject: [Drbd-dev] [PATCH 027/118] idr: idr_for_each_entry() macro List-Id: Coordination of development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Inspired by the list_for_each_entry() macro --- include/linux/idr.h | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) 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__ */ -- 1.7.4.1