summaryrefslogtreecommitdiff
path: root/lib/ioctl_wrappers.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2017-10-03 12:46:10 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2017-10-03 14:37:44 +0100
commit0045085c632a1cf5b4e9272304ee0e61ff9a7e6f (patch)
treeb98c60b8ea7eaeba2af79c0f642ebd497c1dd7ed /lib/ioctl_wrappers.c
parent08a2f887b26c89cfb1e1b5715a23d561b75e0dab (diff)
lib: Report the error from __gem_create()
We have two style of ioctl wrappers. The principle interface does error checking on behalf of the caller (to avoid having lots of repetitious code in each test), and for the few cases where the error is important for the test, we also expose a double underscore version. Fix up __gem_create() to follow this pattern and report the negative error code returned by the kernel. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Diffstat (limited to 'lib/ioctl_wrappers.c')
-rw-r--r--lib/ioctl_wrappers.c32
1 files changed, 13 insertions, 19 deletions
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 51b6b7b6..1b483706 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -551,22 +551,20 @@ uint32_t gem_create_stolen(int fd, uint64_t size)
return create.handle;
}
-
-uint32_t __gem_create(int fd, int size)
+int __gem_create(int fd, int size, uint32_t *handle)
{
- struct drm_i915_gem_create create;
- int ret;
-
- memset(&create, 0, sizeof(create));
- create.handle = 0;
- create.size = size;
- ret = igt_ioctl(fd, DRM_IOCTL_I915_GEM_CREATE, &create);
+ struct drm_i915_gem_create create = {
+ .size = size,
+ };
+ int err = 0;
- if (ret < 0)
- return 0;
+ if (igt_ioctl(fd, DRM_IOCTL_I915_GEM_CREATE, &create) == 0)
+ *handle = create.handle;
+ else
+ err = -errno;
errno = 0;
- return create.handle;
+ return err;
}
/**
@@ -581,15 +579,11 @@ uint32_t __gem_create(int fd, int size)
*/
uint32_t gem_create(int fd, uint64_t size)
{
- struct drm_i915_gem_create create;
+ uint32_t handle;
- memset(&create, 0, sizeof(create));
- create.handle = 0;
- create.size = size;
- do_ioctl(fd, DRM_IOCTL_I915_GEM_CREATE, &create);
- igt_assert(create.handle);
+ igt_assert_eq(__gem_create(fd, size, &handle), 0);
- return create.handle;
+ return handle;
}
/**