Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: rockchip: validity should be checked prior to cpu clock rate change

If validity is not checked prior to clock rate change, clk_set_rate(
cpu_clk, unsupported_rate) will return success, but the real clock rate
change operation is prohibited in post clock change event. Alough post
clock change event will report error due to unsupported clock rate is
set, but this error message is ignored by clock framework.

Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
Tested-by: Rocky Hao <rocky.hao@rock-chips.com>
Signed-off-by: Heiko Stuebner <heiko@sntech.de>

authored by

Elaine Zhang and committed by
Heiko Stuebner
a554bb5f bf92384b

+9
+9
drivers/clk/rockchip/clk-cpu.c
··· 124 124 struct clk_notifier_data *ndata) 125 125 { 126 126 const struct rockchip_cpuclk_reg_data *reg_data = cpuclk->reg_data; 127 + const struct rockchip_cpuclk_rate_table *rate; 127 128 unsigned long alt_prate, alt_div; 128 129 unsigned long flags; 130 + 131 + /* check validity of the new rate */ 132 + rate = rockchip_get_cpuclk_settings(cpuclk, ndata->new_rate); 133 + if (!rate) { 134 + pr_err("%s: Invalid rate : %lu for cpuclk\n", 135 + __func__, ndata->new_rate); 136 + return -EINVAL; 137 + } 129 138 130 139 alt_prate = clk_get_rate(cpuclk->alt_parent); 131 140