diff options
Diffstat (limited to 'include/linux/idr.h')
| -rw-r--r-- | include/linux/idr.h | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/include/linux/idr.h b/include/linux/idr.h index 2640c7e99e51..871a213a8477 100644 --- a/include/linux/idr.h +++ b/include/linux/idr.h | |||
| @@ -42,6 +42,7 @@ struct idr { | |||
| 42 | struct idr_layer *id_free; | 42 | struct idr_layer *id_free; |
| 43 | int layers; /* only valid w/o concurrent changes */ | 43 | int layers; /* only valid w/o concurrent changes */ |
| 44 | int id_free_cnt; | 44 | int id_free_cnt; |
| 45 | int cur; /* current pos for cyclic allocation */ | ||
| 45 | spinlock_t lock; | 46 | spinlock_t lock; |
| 46 | }; | 47 | }; |
| 47 | 48 | ||
| @@ -75,6 +76,7 @@ struct idr { | |||
| 75 | void *idr_find_slowpath(struct idr *idp, int id); | 76 | void *idr_find_slowpath(struct idr *idp, int id); |
| 76 | void idr_preload(gfp_t gfp_mask); | 77 | void idr_preload(gfp_t gfp_mask); |
| 77 | int idr_alloc(struct idr *idp, void *ptr, int start, int end, gfp_t gfp_mask); | 78 | int idr_alloc(struct idr *idp, void *ptr, int start, int end, gfp_t gfp_mask); |
| 79 | int idr_alloc_cyclic(struct idr *idr, void *ptr, int start, int end, gfp_t gfp_mask); | ||
| 78 | int idr_for_each(struct idr *idp, | 80 | int idr_for_each(struct idr *idp, |
| 79 | int (*fn)(int id, void *p, void *data), void *data); | 81 | int (*fn)(int id, void *p, void *data), void *data); |
| 80 | void *idr_get_next(struct idr *idp, int *nextid); | 82 | void *idr_get_next(struct idr *idp, int *nextid); |
| @@ -122,11 +124,13 @@ static inline void *idr_find(struct idr *idr, int id) | |||
| 122 | * @idp: idr handle | 124 | * @idp: idr handle |
| 123 | * @entry: the type * to use as cursor | 125 | * @entry: the type * to use as cursor |
| 124 | * @id: id entry's key | 126 | * @id: id entry's key |
| 127 | * | ||
| 128 | * @entry and @id do not need to be initialized before the loop, and | ||
| 129 | * after normal terminatinon @entry is left with the value NULL. This | ||
| 130 | * is convenient for a "not found" value. | ||
| 125 | */ | 131 | */ |
| 126 | #define idr_for_each_entry(idp, entry, id) \ | 132 | #define idr_for_each_entry(idp, entry, id) \ |
| 127 | for (id = 0, entry = (typeof(entry))idr_get_next((idp), &(id)); \ | 133 | for (id = 0; ((entry) = idr_get_next(idp, &(id))) != NULL; ++id) |
| 128 | entry != NULL; \ | ||
| 129 | ++id, entry = (typeof(entry))idr_get_next((idp), &(id))) | ||
| 130 | 134 | ||
| 131 | /* | 135 | /* |
| 132 | * Don't use the following functions. These exist only to suppress | 136 | * Don't use the following functions. These exist only to suppress |
