diff mbox

[14/18] libkms: use drm_mmap/drm_munmap wrappers

Message ID 1410125413-19465-15-git-send-email-emil.l.velikov@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Emil Velikov Sept. 7, 2014, 9:30 p.m. UTC
... for all by exynos.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
---
 libkms/dumb.c    | 8 +++-----
 libkms/intel.c   | 6 +++---
 libkms/nouveau.c | 6 +++---
 libkms/radeon.c  | 8 ++++----
 libkms/vmwgfx.c  | 6 +++---
 5 files changed, 16 insertions(+), 18 deletions(-)
diff mbox

Patch

diff --git a/libkms/dumb.c b/libkms/dumb.c
index 5702543..f9c16e1 100644
--- a/libkms/dumb.c
+++ b/libkms/dumb.c
@@ -36,11 +36,9 @@ 
 #include <string.h>
 #include "internal.h"
 
-#include <sys/mman.h>
 #include <sys/ioctl.h>
 #include "xf86drm.h"
-
-#include "i915_drm.h"
+#include "libdrm.h"
 
 struct dumb_bo
 {
@@ -149,7 +147,7 @@  dumb_bo_map(struct kms_bo *_bo, void **out)
 	if (ret)
 		return ret;
 
-	map = mmap(0, bo->base.size, PROT_READ | PROT_WRITE, MAP_SHARED, bo->base.kms->fd, arg.offset);
+	map = drm_mmap(0, bo->base.size, PROT_READ | PROT_WRITE, MAP_SHARED, bo->base.kms->fd, arg.offset);
 	if (map == MAP_FAILED)
 		return -errno;
 
@@ -177,7 +175,7 @@  dumb_bo_destroy(struct kms_bo *_bo)
 
 	if (bo->base.ptr) {
 		/* XXX Sanity check map_count */
-		munmap(bo->base.ptr, bo->base.size);
+		drm_munmap(bo->base.ptr, bo->base.size);
 		bo->base.ptr = NULL;
 	}
 
diff --git a/libkms/intel.c b/libkms/intel.c
index b006ea4..51a7fd2 100644
--- a/libkms/intel.c
+++ b/libkms/intel.c
@@ -36,9 +36,9 @@ 
 #include <string.h>
 #include "internal.h"
 
-#include <sys/mman.h>
 #include <sys/ioctl.h>
 #include "xf86drm.h"
+#include "libdrm.h"
 
 #include "i915_drm.h"
 
@@ -173,7 +173,7 @@  intel_bo_map(struct kms_bo *_bo, void **out)
 	if (ret)
 		return ret;
 
-	map = mmap(0, bo->base.size, PROT_READ | PROT_WRITE, MAP_SHARED, bo->base.kms->fd, arg.offset);
+	map = drm_mmap(0, bo->base.size, PROT_READ | PROT_WRITE, MAP_SHARED, bo->base.kms->fd, arg.offset);
 	if (map == MAP_FAILED)
 		return -errno;
 
@@ -201,7 +201,7 @@  intel_bo_destroy(struct kms_bo *_bo)
 
 	if (bo->base.ptr) {
 		/* XXX Sanity check map_count */
-		munmap(bo->base.ptr, bo->base.size);
+		drm_munmap(bo->base.ptr, bo->base.size);
 		bo->base.ptr = NULL;
 	}
 
diff --git a/libkms/nouveau.c b/libkms/nouveau.c
index 15c012e..228903f 100644
--- a/libkms/nouveau.c
+++ b/libkms/nouveau.c
@@ -36,9 +36,9 @@ 
 #include <string.h>
 #include "internal.h"
 
-#include <sys/mman.h>
 #include <sys/ioctl.h>
 #include "xf86drm.h"
+#include "libdrm.h"
 
 #include "nouveau_drm.h"
 
@@ -155,7 +155,7 @@  nouveau_bo_map(struct kms_bo *_bo, void **out)
 		return 0;
 	}
 
-	map = mmap(0, bo->base.size, PROT_READ | PROT_WRITE, MAP_SHARED, bo->base.kms->fd, bo->map_handle);
+	map = drm_mmap(0, bo->base.size, PROT_READ | PROT_WRITE, MAP_SHARED, bo->base.kms->fd, bo->map_handle);
 	if (map == MAP_FAILED)
 		return -errno;
 
@@ -183,7 +183,7 @@  nouveau_bo_destroy(struct kms_bo *_bo)
 
 	if (bo->base.ptr) {
 		/* XXX Sanity check map_count */
-		munmap(bo->base.ptr, bo->base.size);
+		drm_munmap(bo->base.ptr, bo->base.size);
 		bo->base.ptr = NULL;
 	}
 
diff --git a/libkms/radeon.c b/libkms/radeon.c
index 938321b..9383a0a 100644
--- a/libkms/radeon.c
+++ b/libkms/radeon.c
@@ -36,9 +36,9 @@ 
 #include <string.h>
 #include "internal.h"
 
-#include <sys/mman.h>
 #include <sys/ioctl.h>
 #include "xf86drm.h"
+#include "libdrm.h"
 
 #include "radeon_drm.h"
 
@@ -172,7 +172,7 @@  radeon_bo_map(struct kms_bo *_bo, void **out)
 	if (ret)
 		return -errno;
 
-	map = mmap(0, arg.size, PROT_READ | PROT_WRITE, MAP_SHARED,
+	map = drm_mmap(0, arg.size, PROT_READ | PROT_WRITE, MAP_SHARED,
 	           bo->base.kms->fd, arg.addr_ptr);
 	if (map == MAP_FAILED)
 		return -errno;
@@ -189,7 +189,7 @@  radeon_bo_unmap(struct kms_bo *_bo)
 {
 	struct radeon_bo *bo = (struct radeon_bo *)_bo;
 	if (--bo->map_count == 0) {
-		munmap(bo->base.ptr, bo->base.size);
+		drm_munmap(bo->base.ptr, bo->base.size);
 		bo->base.ptr = NULL;
 	}
 	return 0;
@@ -204,7 +204,7 @@  radeon_bo_destroy(struct kms_bo *_bo)
 
 	if (bo->base.ptr) {
 		/* XXX Sanity check map_count */
-		munmap(bo->base.ptr, bo->base.size);
+		drm_munmap(bo->base.ptr, bo->base.size);
 		bo->base.ptr = NULL;
 	}
 
diff --git a/libkms/vmwgfx.c b/libkms/vmwgfx.c
index 08163a1..bc04133 100644
--- a/libkms/vmwgfx.c
+++ b/libkms/vmwgfx.c
@@ -35,8 +35,8 @@ 
 #include <string.h>
 #include "internal.h"
 
-#include <sys/mman.h>
 #include "xf86drm.h"
+#include "libdrm.h"
 #include "vmwgfx_drm.h"
 
 struct vmwgfx_bo
@@ -146,7 +146,7 @@  vmwgfx_bo_map(struct kms_bo *_bo, void **out)
 		return 0;
 	}
 
-	map = mmap(NULL, bo->base.size, PROT_READ | PROT_WRITE, MAP_SHARED, bo->base.kms->fd, bo->map_handle);
+	map = drm_mmap(NULL, bo->base.size, PROT_READ | PROT_WRITE, MAP_SHARED, bo->base.kms->fd, bo->map_handle);
 	if (map == MAP_FAILED)
 		return -errno;
 
@@ -173,7 +173,7 @@  vmwgfx_bo_destroy(struct kms_bo *_bo)
 
 	if (bo->base.ptr) {
 		/* XXX Sanity check map_count */
-		munmap(bo->base.ptr, bo->base.size);
+		drm_munmap(bo->base.ptr, bo->base.size);
 		bo->base.ptr = NULL;
 	}