Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samueldr/9ec964726e9e8ef59614e4c242185f49 to your computer and use it in GitHub Desktop.
Save samueldr/9ec964726e9e8ef59614e4c242185f49 to your computer and use it in GitHub Desktop.
From d4a4d674ce7a7e54dc7625e5d5e1dbb08d5f6c36 Mon Sep 17 00:00:00 2001
From: Samuel Dionne-Riel <samuel@dionne-riel.com>
Date: Thu, 9 Sep 2021 21:20:36 -0400
Subject: [PATCH] [WIP] sun4i_dotclock: Prevent divide by zero searching for
clock
---
drivers/gpu/drm/sun4i/sun4i_dotclock.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/gpu/drm/sun4i/sun4i_dotclock.c b/drivers/gpu/drm/sun4i/sun4i_dotclock.c
index 417ade3d2565d..8e347fd4cf765 100644
--- a/drivers/gpu/drm/sun4i/sun4i_dotclock.c
+++ b/drivers/gpu/drm/sun4i/sun4i_dotclock.c
@@ -80,6 +80,9 @@ static long sun4i_dclk_round_rate(struct clk_hw *hw, unsigned long rate,
u64 ideal = (u64)rate * i;
unsigned long rounded;
+ if (WARN_ONCE(ideal == 0, "sun4i_dclk_round_rate, ideal rate search encountered zero ideal rate."))
+ continue;
+
/*
* ideal has overflowed the max value that can be stored in an
* unsigned long, and every clk operation we might do on a
--
2.32.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment