mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 18:41:58 +09:00
clk: rockchip: avoid division by zero
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com> Change-Id: Ie28c61d3907d80c3d12087dea59a9567e183012d
This commit is contained in:
@@ -186,6 +186,14 @@ static void rockchip_fractional_approximation(struct clk_hw *hw,
|
||||
unsigned long p_rate, p_parent_rate;
|
||||
struct clk_hw *p_parent;
|
||||
|
||||
if (rate == 0) {
|
||||
pr_warn("%s p_rate(%ld), rate(%ld), maybe invalid frequency setting!\n",
|
||||
clk_hw_get_name(hw), *parent_rate, rate);
|
||||
*m = 0;
|
||||
*n = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
p_rate = clk_hw_get_rate(clk_hw_get_parent(hw));
|
||||
if ((rate * 20 > p_rate) && (p_rate % rate != 0)) {
|
||||
p_parent = clk_hw_get_parent(clk_hw_get_parent(hw));
|
||||
@@ -196,6 +204,14 @@ static void rockchip_fractional_approximation(struct clk_hw *hw,
|
||||
*parent_rate = p_parent_rate;
|
||||
}
|
||||
|
||||
if (*parent_rate == 0) {
|
||||
pr_warn("%s p_rate(%ld), rate(%ld), maybe invalid frequency setting!\n",
|
||||
clk_hw_get_name(hw), *parent_rate, rate);
|
||||
*m = 0;
|
||||
*n = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
if (*parent_rate < rate * 20) {
|
||||
/*
|
||||
* Fractional frequency divider to do
|
||||
|
||||
Reference in New Issue
Block a user