projects
/
firefly-linux-kernel-4.4.55.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
6618bf1
)
idr: idr_for_each_entry() macro
author
Philipp Reisner
<philipp.reisner@linbit.com>
Wed, 20 Jul 2011 12:59:37 +0000
(14:59 +0200)
committer
Philipp Reisner
<philipp.reisner@linbit.com>
Mon, 29 Aug 2011 09:27:01 +0000
(11:27 +0200)
Inspired by the list_for_each_entry() macro
include/linux/idr.h
patch
|
blob
|
history
diff --git
a/include/linux/idr.h
b/include/linux/idr.h
index 255491cf522e1d08ea6d0066fc7872f32817c82c..52a9da295296ce072a5326b70441e8eda9b8eff9 100644
(file)
--- 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__ */