xref: /wlan-driver/qca-wifi-host-cmn/qdf/inc/qdf_idr.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2018 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 /**
21  * DOC: qdf_idr(ID Allocation)
22  * QCA driver framework (QDF) ID allocation APIs
23  */
24 
25 #if !defined(__QDF_IDR_H)
26 #define __QDF_IDR_H
27 
28 /* Include Files */
29 #include <qdf_types.h>
30 #include <qdf_status.h>
31 #include <i_qdf_idr.h>
32 
33 /**
34  * typedef qdf_idr - platform idr object
35  */
36 typedef __qdf_idr qdf_idr;
37 
38 /**
39  * qdf_idr_create() - idr initialization function
40  * @idp: pointer to qdf idr
41  *
42  * Return: QDF status
43  */
44 QDF_STATUS qdf_idr_create(qdf_idr *idp);
45 
46 /**
47  * qdf_idr_destroy() - idr deinitialization function
48  * @idp: pointer to qdf idr
49  *
50  * Return: QDF status
51  */
52 QDF_STATUS qdf_idr_destroy(qdf_idr *idp);
53 
54 /**
55  * qdf_idr_alloc() - Allocates an unused ID
56  * @idp: pointer to qdf idr
57  * @ptr: pointer to be associated with the new ID
58  * @id:  pointer to return new ID
59  *
60  * Return: QDF status
61  */
62 QDF_STATUS qdf_idr_alloc(qdf_idr *idp, void *ptr, int32_t *id);
63 
64 /**
65  * qdf_idr_remove() - Removes this ID from the IDR.
66  * @idp: pointer to qdf idr
67  * @id:  ID to be remove
68  *
69  * Return: QDF status
70  */
71 QDF_STATUS qdf_idr_remove(qdf_idr *idp, int32_t id);
72 
73 /**
74  * qdf_idr_find() - find the user pointer from the IDR by id.
75  * @idp: pointer to qdf idr
76  * @id:  ID to be remove
77  * @ptr: pointer to return user pointer for given ID
78  *
79  * Return: QDF status
80  */
81 QDF_STATUS qdf_idr_find(qdf_idr *idp, int32_t id, void **ptr);
82 
83 #endif /* __QDF_IDR_H */
84