Skip to contentSkip to conversation

amdgpu/dc: use kernel ilog2 for log_2.

PATCH In review Dave Airlie 2 participants 2 messages Oct 3, 2017 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 amdgpu/dc: use kernel ilog2 for log_2.

From: Dave Airlie <[email protected]>

This should produce the same result.

---
 drivers/gpu/drm/amd/display/dc/basics/conversion.c | 10 ----------
 drivers/gpu/drm/amd/display/dc/basics/conversion.h |  5 ++++-
 2 files changed, 4 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/display/dc/basics/conversion.c +0 -10
index a2e22ae..23c9a0e 100644
@@ -102,13 +102,3 @@ void convert_float_matrix(
 		matrix[i] = (uint16_t)reg_value;
 	}
 }
-
-unsigned int log_2(unsigned int num)
-{
-	unsigned int result = 0;
-
-	while ((num >>= 1) != 0)
-		result++;
-
-	return result;
-}
drivers/gpu/drm/amd/display/dc/basics/conversion.h +4 -1
index 189325f..ade785c 100644
@@ -38,6 +38,9 @@ void convert_float_matrix(
 	struct fixed31_32 *flt,
 	uint32_t buffer_size);
 
-unsigned int log_2(unsigned int num);
+static inline unsigned int log_2(unsigned int num)
+{
+	return ilog2(num);
+}
 
 #endif
Signature · 6 lines
2.9.5

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 20171003031436.20269-1-airlied-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

Reviewed-by
#2 lore raw
Quoted 5 lines · Dave Airlie

From: Dave Airlie <[email protected]>

This should produce the same result.

Harry

Quoted 29 lines
---
 drivers/gpu/drm/amd/display/dc/basics/conversion.c | 10 ----------
 drivers/gpu/drm/amd/display/dc/basics/conversion.h |  5 ++++-
 2 files changed, 4 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/display/dc/basics/conversion.c +0 -10
index a2e22ae..23c9a0e 100644
@@ -102,13 +102,3 @@ void convert_float_matrix(
 		matrix[i] = (uint16_t)reg_value;
 	}
 }
-
-unsigned int log_2(unsigned int num)
-{
-	unsigned int result = 0;
-
-	while ((num >>= 1) != 0)
-		result++;
-
-	return result;
-}
drivers/gpu/drm/amd/display/dc/basics/conversion.h +0 -0
index 189325f..ade785c 100644

drivers/gpu/drm/amd/display/dc/basics/conversion.h void convert_float_matrix( · line 46

Quoted 10 lines
drivers/gpu/drm/amd/display/dc/basics/conversion.h +4 -1
@@ -38,6 +38,9 @@ void convert_float_matrix(
 	struct fixed31_32 *flt,
 	uint32_t buffer_size);
 
-unsigned int log_2(unsigned int num);
+static inline unsigned int log_2(unsigned int num)
+{
+	return ilog2(num);
+}
 
 #endif

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx