All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 11/12] tegra: clock: Avoid a divide-by-zero error
Date: Mon, 22 May 2017 05:17:31 -0600	[thread overview]
Message-ID: <20170522111732.11265-12-sjg@chromium.org> (raw)
In-Reply-To: <20170522111732.11265-1-sjg@chromium.org>

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 <sjg@chromium.org>
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

  parent reply	other threads:[~2017-05-22 11:17 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-22 11:17 [U-Boot] [PATCH 00/12] tegra: nyan-big: Support chainloading and add documentation Simon Glass
2017-05-22 11:17 ` [U-Boot] [PATCH 01/12] arm: arm720t: Support CONFIG_SKIP_LOWLEVEL_INIT_ONLY Simon Glass
2017-05-23  1:15   ` Tom Rini
2017-05-22 11:17 ` [U-Boot] [PATCH 02/12] tegra: Init clocks even when SPL did not run Simon Glass
2017-05-22 11:17 ` [U-Boot] [PATCH 03/12] tegra: dts: Add cros-ec SPI settings Simon Glass
2017-05-22 11:17 ` [U-Boot] [PATCH 04/12] arm: Rename HCTR to HTCR Simon Glass
2017-05-23  1:15   ` Tom Rini
2017-05-22 11:17 ` [U-Boot] [PATCH 05/12] arm: Don't try to support CONFIG_ARMV7_LPAE on ARMv4T Simon Glass
2017-05-23  1:15   ` Tom Rini
2017-06-09  3:00     ` Simon Glass
2017-06-09 11:16       ` Tom Rini
2017-05-22 11:17 ` [U-Boot] [PATCH 06/12] arm: Disable LPAE if not enabled Simon Glass
2017-05-23  1:15   ` Tom Rini
2017-05-22 11:17 ` [U-Boot] [PATCH 07/12] tegra: spi: Wait a little after setting the clocks Simon Glass
2017-05-22 11:17 ` [U-Boot] [PATCH 08/12] tegra: nyan-big: Enable the dhrystone benchmark Simon Glass
2017-05-22 11:17 ` [U-Boot] [PATCH 09/12] tegra: video: Don't power up the SOR twice Simon Glass
2017-06-07 12:52   ` Anatolij Gustschin
2017-05-22 11:17 ` [U-Boot] [PATCH 10/12] tegra: Enable CP15 init Simon Glass
2017-05-22 11:17 ` Simon Glass [this message]
2017-05-22 11:17 ` [U-Boot] [PATCH 12/12] README: Add instructions for chain-loading U-Boot Simon Glass
2017-05-29 13:29   ` Peter Robinson
2017-06-01  3:11     ` Simon Glass
2017-05-31 18:28 ` [U-Boot] [PATCH 00/12] tegra: nyan-big: Support chainloading and add documentation Matthew Gorski
2017-05-31 18:40   ` Matthew Gorski
2017-05-31 19:19     ` Simon Glass
2017-06-01 13:52   ` Matthew Gorski
2017-06-07 11:58     ` Simon Glass
2017-06-07 15:32       ` Tom Warren
2017-06-07 15:41         ` Stephen Warren
2017-06-09 12:27           ` Simon Glass
2017-06-27 20:09             ` Thomas Hoff
2017-07-07  3:58               ` Simon Glass
2017-07-07  7:27                 ` Thomas Hoff
2017-07-08 16:09                   ` Simon Glass
2017-07-09 13:59                     ` Tom Warren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170522111732.11265-12-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.