xref: /linux/drivers/gpu/drm/nouveau/include/nvkm/core/os.h (revision 3a39d672e7f48b8d6b91a09afa4b55352773b4b5)
1 /* SPDX-License-Identifier: MIT */
2 #ifndef __NVKM_OS_H__
3 #define __NVKM_OS_H__
4 #include <nvif/os.h>
5 
6 struct nvkm_blob {
7 	void *data;
8 	u32 size;
9 };
10 
11 static inline void
nvkm_blob_dtor(struct nvkm_blob * blob)12 nvkm_blob_dtor(struct nvkm_blob *blob)
13 {
14 	kfree(blob->data);
15 	blob->data = NULL;
16 	blob->size = 0;
17 }
18 
19 #define nvkm_list_find_next(p,h,m,c) ({                                                      \
20 	typeof(p) _p = NULL;                                                                 \
21 	list_for_each_entry_continue(p, (h), m) {                                            \
22 		if (c) {                                                                     \
23 			_p = p;                                                              \
24 			break;                                                               \
25 		}                                                                            \
26 	}                                                                                    \
27 	_p;                                                                                  \
28 })
29 #define nvkm_list_find(p,h,m,c)                                                              \
30 	(p = container_of((h), typeof(*p), m), nvkm_list_find_next(p, (h), m, (c)))
31 #define nvkm_list_foreach(p,h,m,c)                                                           \
32 	for (p = nvkm_list_find(p, (h), m, (c)); p; p = nvkm_list_find_next(p, (h), m, (c)))
33 #endif
34