From: Elaine Zhang Date: Tue, 8 Nov 2016 09:10:14 +0000 (+0800) Subject: UPSTREAM: clk: rockchip: validity should be checked prior to cpu clock rate change X-Git-Tag: firefly_0821_release~1060 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=f90dde6dd43e23699f73ca82018da8c8d9c83a50;p=firefly-linux-kernel-4.4.55.git UPSTREAM: 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 Tested-by: Rocky Hao Signed-off-by: Heiko Stuebner (am from mmind/linux-rockchip.git branch v4.10-clk/next commit a554bb5fb01804a38fde3782831c9567d997939e) Change-Id: I521700f86fe1d9bf2d1bef4ebe0350cd6f558c0a Signed-off-by: Jianqun Xu --- diff --git a/drivers/clk/rockchip/clk-cpu.c b/drivers/clk/rockchip/clk-cpu.c index 4b366a3691a4..cd2b1d87f4a4 100644 --- a/drivers/clk/rockchip/clk-cpu.c +++ b/drivers/clk/rockchip/clk-cpu.c @@ -124,9 +124,18 @@ static int rockchip_cpuclk_pre_rate_change(struct rockchip_cpuclk *cpuclk, struct clk_notifier_data *ndata) { const struct rockchip_cpuclk_reg_data *reg_data = cpuclk->reg_data; + const struct rockchip_cpuclk_rate_table *rate; unsigned long alt_prate, alt_div; unsigned long flags; + /* check validity of the new rate */ + rate = rockchip_get_cpuclk_settings(cpuclk, ndata->new_rate); + if (!rate) { + pr_err("%s: Invalid rate : %lu for cpuclk\n", + __func__, ndata->new_rate); + return -EINVAL; + } + alt_prate = clk_get_rate(cpuclk->alt_parent); spin_lock_irqsave(cpuclk->lock, flags);