From patchwork Tue Jun 28 15:39:40 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 102408 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 181E0B6F5D for ; Wed, 29 Jun 2011 01:40:39 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 18F202810A; Tue, 28 Jun 2011 17:40:25 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nk0E0jpkP+oE; Tue, 28 Jun 2011 17:40:24 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A66EC28125; Tue, 28 Jun 2011 17:40:12 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 14DB528112 for ; Tue, 28 Jun 2011 17:40:08 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id S3gt0MDacazX for ; Tue, 28 Jun 2011 17:40:07 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-yx0-f172.google.com (mail-yx0-f172.google.com [209.85.213.172]) by theia.denx.de (Postfix) with ESMTPS id A0B9B28100 for ; Tue, 28 Jun 2011 17:40:02 +0200 (CEST) Received: by yxp4 with SMTP id 4so142019yxp.3 for ; Tue, 28 Jun 2011 08:40:01 -0700 (PDT) Received: by 10.91.160.13 with SMTP id m13mr8206259ago.168.1309275601534; Tue, 28 Jun 2011 08:40:01 -0700 (PDT) Received: from rob-laptop.i.smooth-stone.com ([173.226.190.126]) by mx.google.com with ESMTPS id x32sm244413anx.6.2011.06.28.08.40.00 (version=SSLv3 cipher=OTHER); Tue, 28 Jun 2011 08:40:00 -0700 (PDT) From: Rob Herring To: u-boot@lists.denx.de Date: Tue, 28 Jun 2011 10:39:40 -0500 Message-Id: <1309275583-11763-4-git-send-email-robherring2@gmail.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1309275583-11763-1-git-send-email-robherring2@gmail.com> References: <1309275583-11763-1-git-send-email-robherring2@gmail.com> Cc: Albert ARIBAUD , Rob Herring Subject: [U-Boot] [PATCH 3/6] arm: add __ilog2 function X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de From: Rob Herring Add __ilog2 function for ARM. Needed for ahci.c Signed-off-by: Rob Herring Cc: Albert ARIBAUD --- arch/arm/include/asm/bitops.h | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/arch/arm/include/asm/bitops.h b/arch/arm/include/asm/bitops.h index 270f163..0420182 100644 --- a/arch/arm/include/asm/bitops.h +++ b/arch/arm/include/asm/bitops.h @@ -106,6 +106,15 @@ static inline int test_bit(int nr, const void * addr) return ((unsigned char *) addr)[nr >> 3] & (1U << (nr & 7)); } +extern __inline__ int __ilog2(unsigned int x) +{ + int ret; + + asm("clz\t%0, %1" : "=r" (ret) : "r" (x)); + ret = 31 - ret; + return ret; +} + /* * ffz = Find First Zero in word. Undefined if no zero exists, * so code should check against ~0UL first..