summaryrefslogtreecommitdiffstats
path: root/include/linux/xarray.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/xarray.h')
-rw-r--r--include/linux/xarray.h36
1 files changed, 23 insertions, 13 deletions
diff --git a/include/linux/xarray.h b/include/linux/xarray.h
index 687c150071a5..588733abd19d 100644
--- a/include/linux/xarray.h
+++ b/include/linux/xarray.h
@@ -131,6 +131,12 @@ static inline unsigned int xa_pointer_tag(void *entry)
131 * xa_mk_internal() - Create an internal entry. 131 * xa_mk_internal() - Create an internal entry.
132 * @v: Value to turn into an internal entry. 132 * @v: Value to turn into an internal entry.
133 * 133 *
134 * Internal entries are used for a number of purposes. Entries 0-255 are
135 * used for sibling entries (only 0-62 are used by the current code). 256
136 * is used for the retry entry. 257 is used for the reserved / zero entry.
137 * Negative internal entries are used to represent errnos. Node pointers
138 * are also tagged as internal entries in some situations.
139 *
134 * Context: Any context. 140 * Context: Any context.
135 * Return: An XArray internal entry corresponding to this value. 141 * Return: An XArray internal entry corresponding to this value.
136 */ 142 */
@@ -163,6 +169,22 @@ static inline bool xa_is_internal(const void *entry)
163 return ((unsigned long)entry & 3) == 2; 169 return ((unsigned long)entry & 3) == 2;
164} 170}
165 171
172#define XA_ZERO_ENTRY xa_mk_internal(257)
173
174/**
175 * xa_is_zero() - Is the entry a zero entry?
176 * @entry: Entry retrieved from the XArray
177 *
178 * The normal API will return NULL as the contents of a slot containing
179 * a zero entry. You can only see zero entries by using the advanced API.
180 *
181 * Return: %true if the entry is a zero entry.
182 */
183static inline bool xa_is_zero(const void *entry)
184{
185 return unlikely(entry == XA_ZERO_ENTRY);
186}
187
166/** 188/**
167 * xa_is_err() - Report whether an XArray operation returned an error 189 * xa_is_err() - Report whether an XArray operation returned an error
168 * @entry: Result from calling an XArray function 190 * @entry: Result from calling an XArray function
@@ -1050,7 +1072,7 @@ int xa_reserve_irq(struct xarray *xa, unsigned long index, gfp_t gfp)
1050 */ 1072 */
1051static inline void xa_release(struct xarray *xa, unsigned long index) 1073static inline void xa_release(struct xarray *xa, unsigned long index)
1052{ 1074{
1053 xa_cmpxchg(xa, index, NULL, NULL, 0); 1075 xa_cmpxchg(xa, index, XA_ZERO_ENTRY, NULL, 0);
1054} 1076}
1055 1077
1056/* Everything below here is the Advanced API. Proceed with caution. */ 1078/* Everything below here is the Advanced API. Proceed with caution. */
@@ -1210,18 +1232,6 @@ static inline bool xa_is_sibling(const void *entry)
1210} 1232}
1211 1233
1212#define XA_RETRY_ENTRY xa_mk_internal(256) 1234#define XA_RETRY_ENTRY xa_mk_internal(256)
1213#define XA_ZERO_ENTRY xa_mk_internal(257)
1214
1215/**
1216 * xa_is_zero() - Is the entry a zero entry?
1217 * @entry: Entry retrieved from the XArray
1218 *
1219 * Return: %true if the entry is a zero entry.
1220 */
1221static inline bool xa_is_zero(const void *entry)
1222{
1223 return unlikely(entry == XA_ZERO_ENTRY);
1224}
1225 1235
1226/** 1236/**
1227 * xa_is_retry() - Is the entry a retry entry? 1237 * xa_is_retry() - Is the entry a retry entry?