Skip to content

Commit

Permalink
idr: Add new function idr_is_empty()
Browse files Browse the repository at this point in the history
Signed-off-by: Andreas Gruenbacher <[email protected]>
Signed-off-by: Philipp Reisner <[email protected]>
  • Loading branch information
andreas-gruenbacher authored and Philipp-Reisner committed Feb 17, 2014
1 parent 8e22943 commit 05f7a7d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/linux/idr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 10 additions & 0 deletions lib/idr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 05f7a7d

Please sign in to comment.