From patchwork Tue Jun 21 21:33:20 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 101376 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 77DCAB6F8A for ; Wed, 22 Jun 2011 07:34:14 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 90847280DE; Tue, 21 Jun 2011 23:34:11 +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 k0IDfB8i3LTZ; Tue, 21 Jun 2011 23:34:11 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 628CF280C7; Tue, 21 Jun 2011 23:33:59 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8D81828083 for ; Tue, 21 Jun 2011 23:33:56 +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 0vbDS6FIOfPV for ; Tue, 21 Jun 2011 23:33:55 +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-iw0-f172.google.com (mail-iw0-f172.google.com [209.85.214.172]) by theia.denx.de (Postfix) with ESMTPS id 6C946280B6 for ; Tue, 21 Jun 2011 23:33:55 +0200 (CEST) Received: by iwn39 with SMTP id 39so178910iwn.3 for ; Tue, 21 Jun 2011 14:33:54 -0700 (PDT) Received: by 10.42.1.12 with SMTP id 12mr1479137ice.366.1308692034015; Tue, 21 Jun 2011 14:33:54 -0700 (PDT) Received: from rob-laptop.i.smooth-stone.com ([173.226.190.126]) by mx.google.com with ESMTPS id q15sm3999290ibb.48.2011.06.21.14.33.52 (version=SSLv3 cipher=OTHER); Tue, 21 Jun 2011 14:33:53 -0700 (PDT) From: Rob Herring To: u-boot@lists.denx.de Date: Tue, 21 Jun 2011 16:33:20 -0500 Message-Id: <1308692003-2488-3-git-send-email-robherring2@gmail.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1308692003-2488-1-git-send-email-robherring2@gmail.com> References: <1308692003-2488-1-git-send-email-robherring2@gmail.com> Cc: Albert ARIBAUD , Rob Herring Subject: [U-Boot] [PATCH 2/5] 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..