From patchwork Tue Nov 20 14:33:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 200354 X-Patchwork-Delegate: wd@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 5F52D2C00A4 for ; Wed, 21 Nov 2012 01:45:37 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7979A4A03C; Tue, 20 Nov 2012 15:45:25 +0100 (CET) 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 xGkKIoD4GIfz; Tue, 20 Nov 2012 15:45:25 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7F99F4A032; Tue, 20 Nov 2012 15:45:15 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8480F4A036 for ; Tue, 20 Nov 2012 15:34:10 +0100 (CET) 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 s36I2BsITxeo for ; Tue, 20 Nov 2012 15:34:09 +0100 (CET) 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-we0-f172.google.com (mail-we0-f172.google.com [74.125.82.172]) by theia.denx.de (Postfix) with ESMTPS id CEF244A032 for ; Tue, 20 Nov 2012 15:34:08 +0100 (CET) Received: by mail-we0-f172.google.com with SMTP id r3so455189wey.3 for ; Tue, 20 Nov 2012 06:34:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=/UUEcn8KZQj1qcULiRoCZG+Cg5dByZ8rjOHYtZIHXxI=; b=SROXrgB49203MZ7ug17zvhhogeHhUYRD+pdfoqGn2fwHB7jT4C65aVxdBbNGgZ01gL whOWvlXTSenjey8h3LmeRCDOnaGjoIBb0qibCFm9C85sPpCAerepNegAr7HWgmR8GZIX qUyGJq/CcJygQ0RbRoKJwR6Tufqhkc0W+man8EfgiGgntpN9scuJxxHg3956Pf0w07uV NxFCnD2QVb7YAPJtuvC7zz3XqG9X1urN/ZCxdJylj5/qj1WfWUpqMkdyFItrSioqLTfS 2mmN9+qatjtYQlfd5CZzNUWVzm7QMokFW/VIvzYm1sI5usn90/OGPMl+84uqevNjP7n1 gxUA== Received: by 10.180.76.203 with SMTP id m11mr14835663wiw.6.1353422047858; Tue, 20 Nov 2012 06:34:07 -0800 (PST) Received: from localhost.localdomain (cpc1-aztw13-0-0-cust473.18-1.cable.virginmedia.com. [77.102.241.218]) by mx.google.com with ESMTPS id bn7sm20254052wib.8.2012.11.20.06.34.05 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 20 Nov 2012 06:34:06 -0800 (PST) From: Lee Jones To: u-boot@lists.denx.de Date: Tue, 20 Nov 2012 14:33:47 +0000 Message-Id: <1353422034-28107-2-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1353422034-28107-1-git-send-email-lee.jones@linaro.org> References: <1353422034-28107-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQlbfMI3Y34p9UAUkWiiDNt7Gu/pqsp9Ouss1VesSgG8vqFoy4gg1hPCJt9gM6QxXKDW0J8d X-Mailman-Approved-At: Tue, 20 Nov 2012 15:45:12 +0100 Cc: Lee Jones Subject: [U-Boot] [PATCH 1/8] u8500: Correct unnecessary mathematical roll-over 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: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de If we attempt to take a 32bit timer value and multiply it by a significant number, the core will not be able to handle it. This gives the illusion that the timer is rolling over, when in fact this is not the case. If we ensure the division in this instance is carried out before the multiplication, the issue vanishes. Signed-off-by: Lee Jones --- arch/arm/cpu/armv7/u8500/timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/cpu/armv7/u8500/timer.c b/arch/arm/cpu/armv7/u8500/timer.c index 79aad99..40326d8 100644 --- a/arch/arm/cpu/armv7/u8500/timer.c +++ b/arch/arm/cpu/armv7/u8500/timer.c @@ -70,7 +70,7 @@ struct u8500_mtu { * The MTU is clocked at 133 MHz by default. (V1 and later) */ #define TIMER_CLOCK (133 * 1000 * 1000 / 16) -#define COUNT_TO_USEC(x) ((x) * 16 / 133) +#define COUNT_TO_USEC(x) ((x) / 133 * 16) #define USEC_TO_COUNT(x) ((x) * 133 / 16) #define TICKS_PER_HZ (TIMER_CLOCK / CONFIG_SYS_HZ) #define TICKS_TO_HZ(x) ((x) / TICKS_PER_HZ)