]> git.ipfire.org Git - thirdparty/kernel/linux.git/blob - drivers/gpu/drm/nouveau/include/nvif/unpack.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[thirdparty/kernel/linux.git] / drivers / gpu / drm / nouveau / include / nvif / unpack.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __NVIF_UNPACK_H__
3 #define __NVIF_UNPACK_H__
4
5 #define nvif_unvers(r,d,s,m) ({ \
6 void **_data = (d); __u32 *_size = (s); int _ret = (r); \
7 if (_ret == -ENOSYS && *_size == sizeof(m)) { \
8 *_data = NULL; \
9 *_size = _ret = 0; \
10 } \
11 _ret; \
12 })
13
14 #define nvif_unpack(r,d,s,m,vl,vh,x) ({ \
15 void **_data = (d); __u32 *_size = (s); \
16 int _ret = (r), _vl = (vl), _vh = (vh); \
17 if (_ret == -ENOSYS && *_size >= sizeof(m) && \
18 (m).version >= _vl && (m).version <= _vh) { \
19 *_data = (__u8 *)*_data + sizeof(m); \
20 *_size = *_size - sizeof(m); \
21 if (_ret = 0, !(x)) { \
22 _ret = *_size ? -E2BIG : 0; \
23 *_data = NULL; \
24 *_size = 0; \
25 } \
26 } \
27 _ret; \
28 })
29 #endif