OSDN Git Service

minigbm: Fix consistency in return values
authorStéphane Marchesin <marcheu@chromium.org>
Thu, 21 Mar 2019 19:23:29 +0000 (12:23 -0700)
committerchrome-bot <chrome-bot@chromium.org>
Tue, 26 Mar 2019 11:43:19 +0000 (04:43 -0700)
minigbm functions don't use errno; however drmIoctl does. So we need
to return -errno instead of returning exactly what drmIoctl returns.

BUG=none
TEST=builds

Change-Id: I20e00141782ac1407133ee72259fe43381954d26
Reviewed-on: https://chromium-review.googlesource.com/1534878
Commit-Ready: Stéphane Marchesin <marcheu@chromium.org>
Tested-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
exynos.c
helpers.c
i915.c
mediatek.c
msm.c
rockchip.c
tegra.c
vc4.c
virtio_gpu.c

index cf95b38..b2b4040 100644 (file)
--- a/exynos.c
+++ b/exynos.c
@@ -73,6 +73,7 @@ static int exynos_bo_create(struct bo *bo, uint32_t width, uint32_t height, uint
                ret = drmIoctl(bo->drv->fd, DRM_IOCTL_EXYNOS_GEM_CREATE, &gem_create);
                if (ret) {
                        drv_log("DRM_IOCTL_EXYNOS_GEM_CREATE failed (size=%zu)\n", size);
+                       ret = -errno;
                        goto cleanup_planes;
                }
 
index 6dbc7ce..d2dab50 100644 (file)
--- a/helpers.c
+++ b/helpers.c
@@ -290,7 +290,7 @@ int drv_dumb_bo_create(struct bo *bo, uint32_t width, uint32_t height, uint32_t
        ret = drmIoctl(bo->drv->fd, DRM_IOCTL_MODE_CREATE_DUMB, &create_dumb);
        if (ret) {
                drv_log("DRM_IOCTL_MODE_CREATE_DUMB failed (%d, %d)\n", bo->drv->fd, errno);
-               return ret;
+               return -errno;
        }
 
        drv_bo_from_format(bo, create_dumb.pitch, height, format);
@@ -313,7 +313,7 @@ int drv_dumb_bo_destroy(struct bo *bo)
        ret = drmIoctl(bo->drv->fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy_dumb);
        if (ret) {
                drv_log("DRM_IOCTL_MODE_DESTROY_DUMB failed (handle=%x)\n", bo->handles[0].u32);
-               return ret;
+               return -errno;
        }
 
        return 0;
@@ -340,7 +340,7 @@ int drv_gem_bo_destroy(struct bo *bo)
                if (ret) {
                        drv_log("DRM_IOCTL_GEM_CLOSE failed (handle=%x) error %d\n",
                                bo->handles[plane].u32, ret);
-                       error = ret;
+                       error = -errno;
                }
        }
 
@@ -370,7 +370,7 @@ int drv_prime_bo_import(struct bo *bo, struct drv_import_fd_data *data)
                         */
                        bo->num_planes = plane;
                        drv_gem_bo_destroy(bo);
-                       return ret;
+                       return -errno;
                }
 
                bo->handles[plane].u32 = prime_handle.handle;
diff --git a/i915.c b/i915.c
index 922d257..fb74258 100644 (file)
--- a/i915.c
+++ b/i915.c
@@ -384,7 +384,7 @@ static int i915_bo_create_for_modifier(struct bo *bo, uint32_t width, uint32_t h
        ret = drmIoctl(bo->drv->fd, DRM_IOCTL_I915_GEM_CREATE, &gem_create);
        if (ret) {
                drv_log("DRM_IOCTL_I915_GEM_CREATE failed (size=%llu)\n", gem_create.size);
-               return ret;
+               return -errno;
        }
 
        for (plane = 0; plane < bo->num_planes; plane++)
index 59a0fac..5edb629 100644 (file)
@@ -7,6 +7,7 @@
 #ifdef DRV_MEDIATEK
 
 // clang-format off
+#include <errno.h>
 #include <fcntl.h>
 #include <poll.h>
 #include <stdio.h>
@@ -81,7 +82,7 @@ static int mediatek_bo_create(struct bo *bo, uint32_t width, uint32_t height, ui
        ret = drmIoctl(bo->drv->fd, DRM_IOCTL_MTK_GEM_CREATE, &gem_create);
        if (ret) {
                drv_log("DRM_IOCTL_MTK_GEM_CREATE failed (size=%llu)\n", gem_create.size);
-               return ret;
+               return -errno;
        }
 
        for (plane = 0; plane < bo->num_planes; plane++)
diff --git a/msm.c b/msm.c
index 085cfb0..1195a24 100644 (file)
--- a/msm.c
+++ b/msm.c
@@ -204,7 +204,7 @@ static int msm_bo_create_for_modifier(struct bo *bo, uint32_t width, uint32_t he
        ret = drmIoctl(bo->drv->fd, DRM_IOCTL_MSM_GEM_NEW, &req);
        if (ret) {
                drv_log("DRM_IOCTL_MSM_GEM_NEW failed with %s\n", strerror(errno));
-               return ret;
+               return -errno;
        }
 
        /*
index 177f9c7..e0cc118 100644 (file)
@@ -214,7 +214,7 @@ static int rockchip_bo_create_with_modifiers(struct bo *bo, uint32_t width, uint
        if (ret) {
                drv_log("DRM_IOCTL_ROCKCHIP_GEM_CREATE failed (size=%llu)\n",
                        (unsigned long long)gem_create.size);
-               return ret;
+               return -errno;
        }
 
        for (plane = 0; plane < bo->num_planes; plane++)
diff --git a/tegra.c b/tegra.c
index fb2f6a9..4b6b8d7 100644 (file)
--- a/tegra.c
+++ b/tegra.c
@@ -7,6 +7,7 @@
 #ifdef DRV_TEGRA
 
 #include <assert.h>
+#include <errno.h>
 #include <stdio.h>
 #include <string.h>
 #include <sys/mman.h>
@@ -229,7 +230,7 @@ static int tegra_bo_create(struct bo *bo, uint32_t width, uint32_t height, uint3
        ret = drmIoctl(bo->drv->fd, DRM_IOCTL_TEGRA_GEM_CREATE, &gem_create);
        if (ret) {
                drv_log("DRM_IOCTL_TEGRA_GEM_CREATE failed (size=%zu)\n", size);
-               return ret;
+               return -errno;
        }
 
        bo->handles[0].u32 = gem_create.handle;
@@ -276,7 +277,7 @@ static int tegra_bo_import(struct bo *bo, struct drv_import_fd_data *data)
        ret = drmIoctl(bo->drv->fd, DRM_IOCTL_TEGRA_GEM_GET_TILING, &gem_get_tiling);
        if (ret) {
                drv_gem_bo_destroy(bo);
-               return ret;
+               return -errno;
        }
 
        /* NOTE(djmk): we only know about one tiled format, so if our drmIoctl call tells us we are
diff --git a/vc4.c b/vc4.c
index 71e73ea..6edd967 100644 (file)
--- a/vc4.c
+++ b/vc4.c
@@ -6,6 +6,7 @@
 
 #ifdef DRV_VC4
 
+#include <errno.h>
 #include <stdio.h>
 #include <string.h>
 #include <sys/mman.h>
@@ -49,7 +50,7 @@ static int vc4_bo_create(struct bo *bo, uint32_t width, uint32_t height, uint32_
        ret = drmIoctl(bo->drv->fd, DRM_IOCTL_VC4_CREATE_BO, &bo_create);
        if (ret) {
                drv_log("DRM_IOCTL_VC4_GEM_CREATE failed (size=%zu)\n", bo->total_size);
-               return ret;
+               return -errno;
        }
 
        for (plane = 0; plane < bo->num_planes; plane++)
index 36ba8bc..e34d718 100644 (file)
@@ -111,6 +111,7 @@ static int virtio_virgl_bo_create(struct bo *bo, uint32_t width, uint32_t height
                if (ret) {
                        drv_log("DRM_IOCTL_VIRTGPU_RESOURCE_CREATE failed with %s\n",
                                strerror(errno));
+                       ret = -errno;
                        goto fail;
                }
 
@@ -251,7 +252,7 @@ static int virtio_gpu_bo_invalidate(struct bo *bo, struct mapping *mapping)
        ret = drmIoctl(bo->drv->fd, DRM_IOCTL_VIRTGPU_TRANSFER_FROM_HOST, &xfer);
        if (ret) {
                drv_log("DRM_IOCTL_VIRTGPU_TRANSFER_FROM_HOST failed with %s\n", strerror(errno));
-               return ret;
+               return -errno;
        }
 
        return 0;
@@ -280,7 +281,7 @@ static int virtio_gpu_bo_flush(struct bo *bo, struct mapping *mapping)
        ret = drmIoctl(bo->drv->fd, DRM_IOCTL_VIRTGPU_TRANSFER_TO_HOST, &xfer);
        if (ret) {
                drv_log("DRM_IOCTL_VIRTGPU_TRANSFER_TO_HOST failed with %s\n", strerror(errno));
-               return ret;
+               return -errno;
        }
 
        return 0;