From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1a6EkK-0002eA-L3 for barebox@lists.infradead.org; Tue, 08 Dec 2015 09:39:45 +0000 From: Markus Pargmann Date: Tue, 8 Dec 2015 10:39:25 +0100 Message-Id: <1449567572-21758-3-git-send-email-mpa@pengutronix.de> In-Reply-To: <1449567572-21758-1-git-send-email-mpa@pengutronix.de> References: <1449567572-21758-1-git-send-email-mpa@pengutronix.de> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH v2 2/9] log2: Add missing __rounddown_pow_of_two() To: barebox@lists.infradead.org Signed-off-by: Markus Pargmann --- include/linux/log2.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/linux/log2.h b/include/linux/log2.h index d9913f06bd09..36519e3aa38b 100644 --- a/include/linux/log2.h +++ b/include/linux/log2.h @@ -63,6 +63,15 @@ unsigned long __roundup_pow_of_two(unsigned long n) return 1UL << fls(n - 1); } +/* + * round down to nearest power of two + */ +static inline __attribute__((const)) +unsigned long __rounddown_pow_of_two(unsigned long n) +{ + return 1UL << (fls_long(n) - 1); +} + /** * ilog2 - log of base 2 of 32-bit or a 64-bit unsigned value * @n - parameter -- 2.6.2 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox