diff options
| author | Andreas Gruenbacher <agruen@linbit.com> | 2011-08-08 23:36:56 +0200 |
|---|---|---|
| committer | Mister Oyster <oysterized@gmail.com> | 2017-04-11 10:59:24 +0200 |
| commit | 04ac44b79464f1261164ca822b1e83eeaced215b (patch) | |
| tree | 359553d86aed8796203b9c09421bda2b42253660 | |
| parent | c6419f03c9d6f1e2732b96a463b217c0b5ee1248 (diff) | |
idr: Add new function idr_is_empty()
Signed-off-by: Andreas Gruenbacher <agruen@linbit.com>
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
| -rw-r--r-- | include/linux/idr.h | 1 | ||||
| -rw-r--r-- | lib/idr.c | 10 |
2 files changed, 11 insertions, 0 deletions
diff --git a/include/linux/idr.h b/include/linux/idr.h index 871a213a8..9c95d2104 100644 --- a/include/linux/idr.h +++ b/include/linux/idr.h @@ -85,6 +85,7 @@ void idr_remove(struct idr *idp, int id); void idr_free(struct idr *idp, int id); void idr_destroy(struct idr *idp); void idr_init(struct idr *idp); +bool idr_is_empty(struct idr *idp); /** * idr_preload_end - end preload section started with idr_preload() @@ -867,6 +867,16 @@ void idr_init(struct idr *idp) } EXPORT_SYMBOL(idr_init); +static int idr_has_entry(int id, void *p, void *data) +{ + return 1; +} + +bool idr_is_empty(struct idr *idp) +{ + return !idr_for_each(idp, idr_has_entry, NULL); +} +EXPORT_SYMBOL(idr_is_empty); /** * DOC: IDA description |
