提交 7d19d521 编写于 作者: K Kefeng Wang 提交者: Daniel Lezcano

clocksource/drivers/sp804: Cleanup clk_get_sys()

Move the clk_get_sys() part into sp804_get_clock_rate(), cleanup the same
code.
Signed-off-by: NKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: NZhen Lei <thunder.leizhen@huawei.com>
Signed-off-by: NDaniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20200918132237.3552-2-thunder.leizhen@huawei.com
上级 51b705af
...@@ -22,11 +22,18 @@ ...@@ -22,11 +22,18 @@
#include "timer-sp.h" #include "timer-sp.h"
static long __init sp804_get_clock_rate(struct clk *clk) static long __init sp804_get_clock_rate(struct clk *clk, const char *name)
{ {
long rate; long rate;
int err; int err;
if (!clk)
clk = clk_get_sys("sp804", name);
if (IS_ERR(clk)) {
pr_err("sp804: %s clock not found: %ld\n", name, PTR_ERR(clk));
return PTR_ERR(clk);
}
err = clk_prepare(clk); err = clk_prepare(clk);
if (err) { if (err) {
pr_err("sp804: clock failed to prepare: %d\n", err); pr_err("sp804: clock failed to prepare: %d\n", err);
...@@ -72,16 +79,7 @@ int __init __sp804_clocksource_and_sched_clock_init(void __iomem *base, ...@@ -72,16 +79,7 @@ int __init __sp804_clocksource_and_sched_clock_init(void __iomem *base,
{ {
long rate; long rate;
if (!clk) { rate = sp804_get_clock_rate(clk, name);
clk = clk_get_sys("sp804", name);
if (IS_ERR(clk)) {
pr_err("sp804: clock not found: %d\n",
(int)PTR_ERR(clk));
return PTR_ERR(clk);
}
}
rate = sp804_get_clock_rate(clk);
if (rate < 0) if (rate < 0)
return -EINVAL; return -EINVAL;
...@@ -173,15 +171,7 @@ int __init __sp804_clockevents_init(void __iomem *base, unsigned int irq, struct ...@@ -173,15 +171,7 @@ int __init __sp804_clockevents_init(void __iomem *base, unsigned int irq, struct
struct clock_event_device *evt = &sp804_clockevent; struct clock_event_device *evt = &sp804_clockevent;
long rate; long rate;
if (!clk) rate = sp804_get_clock_rate(clk, name);
clk = clk_get_sys("sp804", name);
if (IS_ERR(clk)) {
pr_err("sp804: %s clock not found: %d\n", name,
(int)PTR_ERR(clk));
return PTR_ERR(clk);
}
rate = sp804_get_clock_rate(clk);
if (rate < 0) if (rate < 0)
return -EINVAL; return -EINVAL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册