From mboxrd@z Thu Jan 1 00:00:00 1970 From: Simon Glass Date: Mon, 22 May 2017 05:17:31 -0600 Subject: [U-Boot] [PATCH 11/12] tegra: clock: Avoid a divide-by-zero error In-Reply-To: <20170522111732.11265-1-sjg@chromium.org> References: <20170522111732.11265-1-sjg@chromium.org> Message-ID: <20170522111732.11265-12-sjg@chromium.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de The clock fix-up for tegra is still present in the code. It causes a divide-by-zero bug after relocation when chain-loading U-Boot from coreboot. Fix this by adding a check. Signed-off-by: Simon Glass Fixes: 7468676 (ARM: tegra: fix clock_get_periph_rate() for UART clocks) --- arch/arm/mach-tegra/clock.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-tegra/clock.c b/arch/arm/mach-tegra/clock.c index ce68c7d0cc..dc58b3027d 100644 --- a/arch/arm/mach-tegra/clock.c +++ b/arch/arm/mach-tegra/clock.c @@ -339,8 +339,11 @@ unsigned long clock_get_periph_rate(enum periph_id periph_id, * return value doesn't help. In summary this clock driver is * quite broken but I'm afraid I have no idea how to fix it * without completely replacing it. + * + * Be careful to avoid a divide by zero error. */ - div -= 2; + if (div >= 1) + div -= 2; break; #endif default: -- 2.13.0.303.g4ebf302169-goog