From 0045085c632a1cf5b4e9272304ee0e61ff9a7e6f Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Tue, 3 Oct 2017 12:46:10 +0100 Subject: 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 Cc: Joonas Lahtinen Reviewed-by: Joonas Lahtinen --- lib/ioctl_wrappers.c | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) (limited to 'lib/ioctl_wrappers.c') 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; } /** -- cgit v1.2.3