On Thu, Sep 12, 2024 at 06:17:26AM -0700, Yi Liu wrote:
> There is no helpers for user to check if a given ID is allocated or not,
> neither a helper to loop all the allocated IDs in an IDA and do something
> for cleanup. With the two needs, a helper to get the lowest allocated ID
> of a range and two variants based on it.
> 
> Caller can check if a given ID is allocated or not by:
> 
>       bool ida_exists(struct ida *ida, unsigned int id)
> 
> Caller can iterate all allocated IDs by:
> 
>       int id;
>       while ((id = ida_find_first(&pasid_ida)) > 0) {
>               //anything to do with the allocated ID
>               ida_free(pasid_ida, pasid);
>       }
> 
> Cc: Matthew Wilcox (Oracle) <wi...@infradead.org>
> Suggested-by: Jason Gunthorpe <j...@nvidia.com>
> Signed-off-by: Yi Liu <yi.l....@intel.com>
> ---
>  include/linux/idr.h | 11 ++++++++
>  lib/idr.c           | 67 +++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 78 insertions(+)

No test cases for the test suite?  ;-(

Reply via email to