Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / drivers / gpu / drm / nouveau / include / nvif / unpack.h
blob7f0d9f6cc1e7ef4613b66b9219058571a02e1c1d
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __NVIF_UNPACK_H__
3 #define __NVIF_UNPACK_H__
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; \
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; \
29 #endif