From: Robert Noland Date: Fri, 3 Oct 2008 17:56:50 +0000 (-0400) Subject: [FreeBSD] Do a bit of optimization on drm_order() X-Git-Tag: submit/1.0/20121108.012404~690 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4c92abfa8d0b9f2ab14e6b915bdffd47fd2e2474;p=profile%2Fivi%2Flibdrm.git [FreeBSD] Do a bit of optimization on drm_order() --- diff --git a/bsd-core/drm_bufs.c b/bsd-core/drm_bufs.c index c9b5dc4..60f57cf 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;