Skip to content

Commit 05f7a7d

Browse files
idr: Add new function idr_is_empty()
Signed-off-by: Andreas Gruenbacher <agruen@linbit.com> Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
1 parent 8e22943 commit 05f7a7d

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

‎include/linux/idr.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ void idr_remove(struct idr *idp, int id);
8585
void idr_free(struct idr *idp, int id);
8686
void idr_destroy(struct idr *idp);
8787
void idr_init(struct idr *idp);
88+
bool idr_is_empty(struct idr *idp);
8889

8990
/**
9091
* idr_preload_end - end preload section started with idr_preload()

‎lib/idr.c‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,16 @@ void idr_init(struct idr *idp)
869869
}
870870
EXPORT_SYMBOL(idr_init);
871871

872+
static int idr_has_entry(int id, void *p, void *data)
873+
{
874+
return 1;
875+
}
876+
877+
bool idr_is_empty(struct idr *idp)
878+
{
879+
return !idr_for_each(idp, idr_has_entry, NULL);
880+
}
881+
EXPORT_SYMBOL(idr_is_empty);
872882

873883
/**
874884
* DOC: IDA description

0 commit comments

Comments
 (0)