Patchwork [3.5.y.z,extended,stable] Patch "idr: idr_for_each_entry() macro" has been added to staging queue

login
register
mail settings
Submitter Luis Henriques
Date Feb. 26, 2013, 4:14 p.m.
Message ID <1361895256-28385-1-git-send-email-luis.henriques@canonical.com>
Download mbox | patch
Permalink /patch/223313/
State New
Headers show

Comments

Luis Henriques - Feb. 26, 2013, 4:14 p.m.
This is a note to let you know that I have just added a patch titled

    idr: idr_for_each_entry() macro

to the linux-3.5.y-queue branch of the 3.5.y.z extended stable tree 
which can be found at:

 http://kernel.ubuntu.com/git?p=ubuntu/linux.git;a=shortlog;h=refs/heads/linux-3.5.y-queue

If you, or anyone else, feels it should not be added to this tree, please 
reply to this email.

For more information about the 3.5.y.z tree, see
https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable

Thanks.
-Luis

------

From 75dc41570e9a9707d0257f85938b59c5431fa2a3 Mon Sep 17 00:00:00 2001
From: Philipp Reisner <philipp.reisner@linbit.com>
Date: Wed, 20 Jul 2011 14:59:37 +0200
Subject: [PATCH] idr: idr_for_each_entry() macro

commit 9749f30f1a387070e6e8351f35aeb829eacc3ab6 upstream.

Inspired by the list_for_each_entry() macro

Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 include/linux/idr.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

--
1.8.1.2

Patch

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__ */