lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 21 Nov 2014 19:34:01 +0100
From:	Alban Bedel <albeu@...e.fr>
To:	linux-kernel@...r.kernel.org
Cc:	devicetree@...r.kernel.org, Alban Bedel <albeu@...e.fr>,
	Mike Turquette <mturquette@...aro.org>
Subject: [PATCH 2/4] clk: fractional-divider: add support for m/(n+1) dividers

Many divider hardware use a (n+1) scheme to prevent a zero divider.

Signed-off-by: Alban Bedel <albeu@...e.fr>
---
 drivers/clk/clk-fractional-divider.c | 4 ++++
 include/linux/clk-provider.h         | 1 +
 2 files changed, 5 insertions(+)

diff --git a/drivers/clk/clk-fractional-divider.c b/drivers/clk/clk-fractional-divider.c
index b562281..bcee7f7d3 100644
--- a/drivers/clk/clk-fractional-divider.c
+++ b/drivers/clk/clk-fractional-divider.c
@@ -35,6 +35,8 @@ static unsigned long clk_fd_recalc_rate(struct clk_hw *hw,
 
 	m = (val & fd->mmask) >> fd->mshift;
 	n = (val & fd->nmask) >> fd->nshift;
+	if (fd->flags & CLK_FRACTIONAL_DIVIDER_DIVISOR_PLUS_ONE)
+		n += 1;
 
 	ret = (u64)parent_rate * m;
 	do_div(ret, n);
@@ -74,6 +76,8 @@ static int clk_fd_set_rate(struct clk_hw *hw, unsigned long rate,
 	div = gcd(parent_rate, rate);
 	m = rate / div;
 	n = parent_rate / div;
+	if (fd->flags & CLK_FRACTIONAL_DIVIDER_DIVISOR_PLUS_ONE)
+		n -= 1;
 
 	if (fd->lock)
 		spin_lock_irqsave(fd->lock, flags);
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index 29ea77a..00013b1 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -463,6 +463,7 @@ struct clk_fractional_divider {
 };
 
 #define CLK_FRACTIONAL_DIVIDER_READ_ONLY		BIT(0)
+#define CLK_FRACTIONAL_DIVIDER_DIVISOR_PLUS_ONE		BIT(1)
 
 extern const struct clk_ops clk_fractional_divider_ops;
 extern const struct clk_ops clk_fractional_divider_ro_ops;
-- 
2.0.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ