From patchwork Thu Sep 27 20:27:14 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Beno=C3=AEt_Th=C3=A9baudeau?= X-Patchwork-Id: 187470 X-Patchwork-Delegate: sbabic@denx.de 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 618D32C00B4 for ; Fri, 28 Sep 2012 06:22:23 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id DD5BE28095; Thu, 27 Sep 2012 22:22:21 +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 WdHaqUM-7j5O; Thu, 27 Sep 2012 22:22:21 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 01A0D28096; Thu, 27 Sep 2012 22:22:19 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 54D9128096 for ; Thu, 27 Sep 2012 22:22:18 +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 Xdyo2ziW4Msh for ; Thu, 27 Sep 2012 22:22:17 +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 zose-mta15.web4all.fr (zose-mta15.web4all.fr [176.31.217.11]) by theia.denx.de (Postfix) with ESMTP id 99DF128095 for ; Thu, 27 Sep 2012 22:22:17 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zose-mta15.web4all.fr (Postfix) with ESMTP id 6110F3233D; Thu, 27 Sep 2012 22:25:19 +0200 (CEST) X-Virus-Scanned: amavisd-new at zose1.web4all.fr Received: from zose-mta15.web4all.fr ([127.0.0.1]) by localhost (zose-mta15.web4all.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id RES51Ip-Th2Y; Thu, 27 Sep 2012 22:25:19 +0200 (CEST) Received: from zose-store12.web4all.fr (zose-store-12.w4a.fr [178.33.204.48]) by zose-mta15.web4all.fr (Postfix) with ESMTP id 282A632106; Thu, 27 Sep 2012 22:25:19 +0200 (CEST) Date: Thu, 27 Sep 2012 22:27:14 +0200 (CEST) From: =?utf-8?Q?Beno=C3=AEt_Th=C3=A9baudeau?= To: U-Boot-Users ML Message-ID: <548551507.5372565.1348777634947.JavaMail.root@advansee.com> In-Reply-To: <354965566.5372561.1348777614543.JavaMail.root@advansee.com> MIME-Version: 1.0 X-Originating-IP: [88.188.188.98] X-Mailer: Zimbra 7.2.0_GA_2669 (ZimbraWebClient - FF3.0 (Win)/7.2.0_GA_2669) Subject: [U-Boot] [PATCH 2/7] mx25: Clean up clock calculations X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Avoid possible overflow in clock calculations, and do not waste calls to lldiv() to divide simple ulongs. Signed-off-by: Benoît Thébaudeau Cc: Stefano Babic --- .../arch/arm/cpu/arm926ejs/mx25/generic.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git u-boot-imx-e1eb75b.orig/arch/arm/cpu/arm926ejs/mx25/generic.c u-boot-imx-e1eb75b/arch/arm/cpu/arm926ejs/mx25/generic.c index 2283a89..5503522 100644 --- u-boot-imx-e1eb75b.orig/arch/arm/cpu/arm926ejs/mx25/generic.c +++ u-boot-imx-e1eb75b/arch/arm/cpu/arm926ejs/mx25/generic.c @@ -80,12 +80,12 @@ ulong imx_get_armclk(void) ulong div; if (cctl & CCM_CCTL_ARM_SRC) - fref = lldiv((fref * 3), 4); + fref = lldiv((u64) fref * 3, 4); div = ((cctl >> CCM_CCTL_ARM_DIV_SHIFT) & CCM_CCTL_ARM_DIV_MASK) + 1; - return lldiv(fref, div); + return fref / div; } ulong imx_get_ahbclk(void) @@ -98,7 +98,7 @@ ulong imx_get_ahbclk(void) div = ((cctl >> CCM_CCTL_AHB_DIV_SHIFT) & CCM_CCTL_AHB_DIV_MASK) + 1; - return lldiv(fref, div); + return fref / div; } ulong imx_get_perclk(int clk) @@ -110,7 +110,7 @@ ulong imx_get_perclk(int clk) div = readl(&ccm->pcdr[CCM_PERCLK_REG(clk)]); div = ((div >> CCM_PERCLK_SHIFT(clk)) & CCM_PERCLK_MASK) + 1; - return lldiv(fref, div); + return fref / div; } unsigned int mxc_get_clock(enum mxc_clock clk)