summaryrefslogtreecommitdiff
path: root/nvif/unpack.h
blob: 5933188b4a77f8a01a5b206dc3dc14c2a75f1321 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#ifndef __NVIF_UNPACK_H__
#define __NVIF_UNPACK_H__

#define nvif_unvers(d) ({                                                      \
	ret = (size == sizeof(d)) ? 0 : -ENOSYS;                               \
	(ret == 0);                                                            \
})

#define nvif_unpack(d,vl,vh,m) ({                                              \
	if ((vl) == 0 || ret == -ENOSYS) {                                     \
		int _size = sizeof(d);                                         \
		if (_size <= size && (d).version >= (vl) &&                    \
				     (d).version <= (vh)) {                    \
			data = (u8 *)data + _size;                             \
			size = size - _size;                                   \
			ret = ((m) || !size) ? 0 : -E2BIG;                     \
		} else {                                                       \
			ret = -ENOSYS;                                         \
		}                                                              \
	}                                                                      \
	(ret == 0);                                                            \
})

#endif