minigbm: cros_gralloc: remove constexpr functions

There's no reason to have these as functions. Also eliminate
sw_write() and sw_read(), the only reason I added them because
I was hitting the 80 column limit (we're 100 columns wide now).

BUG=chromium:616275
TEST=compiles

Change-Id: If0d406df64dc760f2c007eeecf79874c1deb3ec7
Reviewed-on: https://chromium-review.googlesource.com/457288
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
diff --git a/cros_gralloc/cros_alloc_device.cc b/cros_gralloc/cros_alloc_device.cc
index 63b455c..dbb409c 100644
--- a/cros_gralloc/cros_alloc_device.cc
+++ b/cros_gralloc/cros_alloc_device.cc
@@ -70,7 +70,7 @@
 
 	hnd->base.version = sizeof(hnd->base);
 	hnd->base.numFds = num_planes;
-	hnd->base.numInts = num_ints_handle() - num_planes;
+	hnd->base.numInts = num_ints_handle - num_planes;
 
 	for (size_t p = 0; p < num_planes; p++) {
 		hnd->fds[p] = drv_bo_get_plane_fd(bo, p);
@@ -88,7 +88,7 @@
 	hnd->format = drv_bo_get_format(bo);
 	hnd->pixel_stride = drv_bo_get_stride_in_pixels(bo);
 
-	hnd->magic = cros_gralloc_magic();
+	hnd->magic = cros_gralloc_magic;
 
 	return hnd;
 }
diff --git a/cros_gralloc/cros_gralloc_helpers.cc b/cros_gralloc/cros_gralloc_helpers.cc
index ed0a25a..366ca75 100644
--- a/cros_gralloc/cros_gralloc_helpers.cc
+++ b/cros_gralloc/cros_gralloc_helpers.cc
@@ -17,13 +17,13 @@
 
 	if (flags & GRALLOC_USAGE_CURSOR)
 		usage |= BO_USE_NONE;
-	if ((flags & sw_read()) == GRALLOC_USAGE_SW_READ_RARELY)
+	if ((flags & GRALLOC_USAGE_SW_READ_MASK) == GRALLOC_USAGE_SW_READ_RARELY)
 		usage |= BO_USE_SW_READ_RARELY;
-	if ((flags & sw_read()) == GRALLOC_USAGE_SW_READ_OFTEN)
+	if ((flags & GRALLOC_USAGE_SW_READ_MASK) == GRALLOC_USAGE_SW_READ_OFTEN)
 		usage |= BO_USE_SW_READ_OFTEN;
-	if ((flags & sw_write()) == GRALLOC_USAGE_SW_WRITE_RARELY)
+	if ((flags & GRALLOC_USAGE_SW_WRITE_MASK) == GRALLOC_USAGE_SW_WRITE_RARELY)
 		usage |= BO_USE_SW_WRITE_RARELY;
-	if ((flags & sw_write()) == GRALLOC_USAGE_SW_WRITE_OFTEN)
+	if ((flags & GRALLOC_USAGE_SW_WRITE_MASK) == GRALLOC_USAGE_SW_WRITE_OFTEN)
 		usage |= BO_USE_SW_WRITE_OFTEN;
 	if (flags & GRALLOC_USAGE_HW_TEXTURE)
 		usage |= BO_USE_TEXTURE;
@@ -147,7 +147,7 @@
 
 int32_t cros_gralloc_validate_handle(struct cros_gralloc_handle *hnd)
 {
-	if (!hnd || hnd->magic != cros_gralloc_magic())
+	if (!hnd || hnd->magic != cros_gralloc_magic)
 		return CROS_GRALLOC_ERROR_BAD_HANDLE;
 
 	return CROS_GRALLOC_ERROR_NONE;
diff --git a/cros_gralloc/cros_gralloc_helpers.h b/cros_gralloc/cros_gralloc_helpers.h
index 0d79f92..026d92a 100644
--- a/cros_gralloc/cros_gralloc_helpers.h
+++ b/cros_gralloc/cros_gralloc_helpers.h
@@ -42,30 +42,11 @@
 };
 // clang-format on
 
-constexpr uint32_t cros_gralloc_magic(void)
-{
-	return 0xABCDDCBA;
-}
+constexpr uint32_t cros_gralloc_magic = 0xABCDDCBA;
 
-constexpr uint32_t num_ints_handle()
-{
-	return ((sizeof(struct cros_gralloc_handle)) / sizeof(int));
-}
+constexpr uint32_t num_ints_handle = ((sizeof(struct cros_gralloc_handle)) / sizeof(int));
 
-constexpr uint32_t sw_access(void)
-{
-	return GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK;
-}
-
-constexpr uint32_t sw_read(void)
-{
-	return GRALLOC_USAGE_SW_READ_MASK;
-}
-
-constexpr uint32_t sw_write(void)
-{
-	return GRALLOC_USAGE_SW_WRITE_MASK;
-}
+constexpr uint32_t sw_access = GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK;
 
 uint64_t cros_gralloc_convert_flags(int flags);
 
diff --git a/cros_gralloc/cros_gralloc_module.cc b/cros_gralloc/cros_gralloc_module.cc
index c3d0e65..eef3614 100644
--- a/cros_gralloc/cros_gralloc_module.cc
+++ b/cros_gralloc/cros_gralloc_module.cc
@@ -169,7 +169,7 @@
 		return CROS_GRALLOC_ERROR_BAD_HANDLE;
 	}
 
-	if (sw_access() & usage) {
+	if (sw_access & usage) {
 		if (bo->map_data) {
 			*vaddr = bo->map_data->addr;
 		} else {
@@ -303,7 +303,7 @@
 		return CROS_GRALLOC_ERROR_BAD_HANDLE;
 	}
 
-	if (sw_access() & usage) {
+	if (sw_access & usage) {
 		void *vaddr;
 		if (bo->map_data) {
 			vaddr = bo->map_data->addr;