Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1580544

[RFC 08/13] smiapp-pll: Take existing divisor into account in minimum divisor check

From Pavel Machek <pavel@ucw.cz>
Newsgroups linux.kernel
Subject [RFC 08/13] smiapp-pll: Take existing divisor into account in minimum divisor check
Date 2017-02-14 14:50 +0100
Message-ID <taLEu-2wc-11@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

From: Sakari Ailus <sakari.ailus@iki.fi>

Required added multiplier (and divisor) calculation did not take into
account the existing divisor when checking the values against the
minimum divisor. Do just that.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
Signed-off-by: Pavel Machek <pavel@ucw.cz>
---
 drivers/media/i2c/smiapp-pll.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/smiapp-pll.c b/drivers/media/i2c/smiapp-pll.c
index 771db56..166bbaf 100644
--- a/drivers/media/i2c/smiapp-pll.c
+++ b/drivers/media/i2c/smiapp-pll.c
@@ -16,6 +16,8 @@
  * General Public License for more details.
  */
 
+#define DEBUG
+
 #include <linux/device.h>
 #include <linux/gcd.h>
 #include <linux/lcm.h>
@@ -227,7 +229,8 @@ static int __smiapp_pll_calculate(
 
 	more_mul_factor = lcm(div, pll->pre_pll_clk_div) / div;
 	dev_dbg(dev, "more_mul_factor: %u\n", more_mul_factor);
-	more_mul_factor = lcm(more_mul_factor, op_limits->min_sys_clk_div);
+	more_mul_factor = lcm(more_mul_factor,
+			      DIV_ROUND_UP(op_limits->min_sys_clk_div, div));
 	dev_dbg(dev, "more_mul_factor: min_op_sys_clk_div: %d\n",
 		more_mul_factor);
 	i = roundup(more_mul_min, more_mul_factor);
@@ -456,6 +459,10 @@ int smiapp_pll_calculate(struct device *dev,
 	i = gcd(pll->pll_op_clk_freq_hz, pll->ext_clk_freq_hz);
 	mul = div_u64(pll->pll_op_clk_freq_hz, i);
 	div = pll->ext_clk_freq_hz / i;
+	if (!mul) {
+		dev_err(dev, "forcing mul to 1\n");
+		mul = 1;
+	}
 	dev_dbg(dev, "mul %u / div %u\n", mul, div);
 
 	min_pre_pll_clk_div =
-- 
2.1.4


-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[RFC 08/13] smiapp-pll: Take existing divisor into account in  minimum divisor check Pavel Machek <pavel@ucw.cz> - 2017-02-14 14:50 +0100
  Re: [RFC 08/13] smiapp-pll: Take existing divisor into account in  minimum divisor check Sakari Ailus <sakari.ailus@iki.fi> - 2017-02-14 23:10 +0100
    Re: [RFC 08/13] smiapp-pll: Take existing divisor into account in minimum divisor check Laurent Pinchart <laurent.pinchart@ideasonboard.com> - 2017-02-14 23:20 +0100
    Re: [RFC 08/13] smiapp-pll: Take existing divisor into account in  minimum divisor check Pavel Machek <pavel@ucw.cz> - 2017-02-15 12:30 +0100
      Re: [RFC 08/13] smiapp-pll: Take existing divisor into account in  minimum divisor check Pavel Machek <pavel@ucw.cz> - 2017-02-28 15:10 +0100
        Re: [RFC 08/13] smiapp-pll: Take existing divisor into account in  minimum divisor check Sakari Ailus <sakari.ailus@iki.fi> - 2017-02-28 15:30 +0100
    Re: [RFC 08/13] smiapp-pll: Take existing divisor into account in  minimum divisor check Pali Rohár <pali.rohar@gmail.com> - 2017-02-15 12:50 +0100

csiph-web