Skip to contentSkip to conversation

is_power_of_2-drm/drm_bufs.c

PATCH New vignesh babu 1 participant 1 message Jun 7, 2007

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

PATCH 1/1 is_power_of_2-drm/drm_bufs.c

Replacing (n & (n-1)) in the context of power of 2 checks with is_power_of_2

---

drivers/char/drm/drm_bufs.c +2 -1
index c113458..f6c35a3 100644
@@ -34,6 +34,7 @@
  */
 
 #include <linux/vmalloc.h>
+#include <linux/log2.h>
 #include "drmP.h"
 
 unsigned long drm_get_resource_start(drm_device_t *dev, unsigned int resource)
@@ -1653,7 +1654,7 @@ int drm_order(unsigned long size)
 
 	for (order = 0, tmp = size >> 1; tmp; tmp >>= 1, order++) ;
 
-	if (size & (size - 1))
+	if (!is_power_of_2(size))
 		++order;
 
 	return order;
Signature · 8 lines
Vignesh Babu BM 
_____________________________________________________________ 
"Why is it that every time I'm with you, makes me believe in magic?"

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors