summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Noland <rnoland@2hip.net>2008-10-03 13:56:50 -0400
committerRobert Noland <rnoland@2hip.net>2008-10-03 13:56:50 -0400
commit4c92abfa8d0b9f2ab14e6b915bdffd47fd2e2474 (patch)
tree3e4e02e5c3a507ec9b249e9a68334e8c72c4cb7c
parent81952c7dd18d8fc4617fe4cb761fdf830de5244f (diff)
[FreeBSD] Do a bit of optimization on drm_order()
-rw-r--r--bsd-core/drm_bufs.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/bsd-core/drm_bufs.c b/bsd-core/drm_bufs.c
index c9b5dc4e..60f57cfd 100644
--- a/bsd-core/drm_bufs.c
+++ b/bsd-core/drm_bufs.c
@@ -1099,11 +1099,12 @@ int drm_mapbufs(struct drm_device *dev, void *data, struct drm_file *file_priv)
int drm_order(unsigned long size)
{
int order;
- unsigned long tmp;
- for (order = 0, tmp = size; tmp >>= 1; ++order);
+ if (size == 0)
+ return 0;
- if (size & ~(1 << order))
+ order = ffsl(size) - 1;
+ if (size & ~(1ul << order))
++order;
return order;