diff options
author | Ben Skeggs <bskeggs@redhat.com> | 2015-11-09 02:21:27 +0300 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2016-01-11 04:17:40 +0300 |
commit | f01c4e682c941ba70e0ebec44db754844a1b9b82 (patch) | |
tree | 4b79c3e1b8afeaaae0143565a8ad0320fa9751dc /drivers/gpu/drm/nouveau/include/nvif/unpack.h | |
parent | 13db6d6ea7190a377af31246016af66803766588 (diff) | |
download | linux-f01c4e682c941ba70e0ebec44db754844a1b9b82.tar.xz |
drm/nouveau/nvif: modify nvif_unvers/nvif_unpack macros to be more obvious
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/nouveau/include/nvif/unpack.h')
-rw-r--r-- | drivers/gpu/drm/nouveau/include/nvif/unpack.h | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/drivers/gpu/drm/nouveau/include/nvif/unpack.h b/drivers/gpu/drm/nouveau/include/nvif/unpack.h index 5933188b4a77..751bcf4930a7 100644 --- a/drivers/gpu/drm/nouveau/include/nvif/unpack.h +++ b/drivers/gpu/drm/nouveau/include/nvif/unpack.h @@ -1,24 +1,28 @@ #ifndef __NVIF_UNPACK_H__ #define __NVIF_UNPACK_H__ -#define nvif_unvers(d) ({ \ - ret = (size == sizeof(d)) ? 0 : -ENOSYS; \ - (ret == 0); \ +#define nvif_unvers(r,d,s,m) ({ \ + void **_data = (d); __u32 *_size = (s); int _ret = (r); \ + if (_ret == -ENOSYS && *_size == sizeof(m)) { \ + *_data = NULL; \ + *_size = _ret = 0; \ + } \ + _ret; \ }) -#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; \ +#define nvif_unpack(r,d,s,m,vl,vh,x) ({ \ + void **_data = (d); __u32 *_size = (s); \ + int _ret = (r), _vl = (vl), _vh = (vh); \ + if (_ret == -ENOSYS && *_size >= sizeof(m) && \ + (m).version >= _vl && (m).version <= _vh) { \ + *_data = (__u8 *)*_data + sizeof(m); \ + *_size = *_size - sizeof(m); \ + if (_ret = 0, !(x)) { \ + _ret = *_size ? -E2BIG : 0; \ + *_data = NULL; \ + *_size = 0; \ } \ } \ - (ret == 0); \ + _ret; \ }) - #endif |