idr: Add new function idr_is_empty()
authorAndreas Gruenbacher <agruen@linbit.com>
Mon, 8 Aug 2011 21:36:56 +0000 (23:36 +0200)
committerPhilipp Reisner <philipp.reisner@linbit.com>
Mon, 17 Feb 2014 15:27:47 +0000 (16:27 +0100)
Signed-off-by: Andreas Gruenbacher <agruen@linbit.com>
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
include/linux/idr.h
lib/idr.c

index 871a213a8477eb5f1d7c6ad3318f6b796bac7106..9c95d210458bd6f7e83e6fdae98d090dd1437c22 100644 (file)
@@ -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()
index bfe4db4e165f2941654e5ba551fbc8c3fe0a467c..1ba4956bfbff70cb8d295809577ea2c7cbfcebf8 100644 (file)
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -869,6 +869,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