drm/radeon: Use hweight32
authorAkinobu Mita <akinobu.mita@gmail.com>
Fri, 9 Nov 2012 12:10:41 +0000 (12:10 +0000)
committerDave Airlie <airlied@redhat.com>
Tue, 20 Nov 2012 06:06:18 +0000 (16:06 +1000)
Use hweight32 instead of counting for each bit

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: David Airlie <airlied@linux.ie>
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/radeon/r600.c
drivers/gpu/drm/radeon/r600_cp.c

index cda280d157da95725b414f54ebcc5cce9f78b7fc..169ecc9628ea9780885b977248ed05f017418d63 100644 (file)
@@ -1424,13 +1424,7 @@ u32 r6xx_remap_render_backend(struct radeon_device *rdev,
 
 int r600_count_pipe_bits(uint32_t val)
 {
-       int i, ret = 0;
-
-       for (i = 0; i < 32; i++) {
-               ret += val & 1;
-               val >>= 1;
-       }
-       return ret;
+       return hweight32(val);
 }
 
 static void r600_gpu_init(struct radeon_device *rdev)
index 2514123d2d00a9f759cc3b7ce034cee1d268396a..be85f75aedda35c8d401f4f2046d76c07bbb6fe0 100644 (file)
@@ -721,12 +721,7 @@ static u32 r600_get_tile_pipe_to_backend_map(u32 num_tile_pipes,
 
 static int r600_count_pipe_bits(uint32_t val)
 {
-       int i, ret = 0;
-       for (i = 0; i < 32; i++) {
-               ret += val & 1;
-               val >>= 1;
-       }
-       return ret;
+       return hweight32(val);
 }
 
 static void r600_gfx_init(struct drm_device *dev,