Skip to content

Commit

Permalink
clocksource/drivers/sp804: Cleanup clk_get_sys()
Browse files Browse the repository at this point in the history
Move the clk_get_sys() part into sp804_get_clock_rate(), cleanup the same
code.

Signed-off-by: Kefeng Wang <[email protected]>
Signed-off-by: Zhen Lei <[email protected]>
Signed-off-by: Daniel Lezcano <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
  • Loading branch information
Kefeng Wang authored and dlezcano committed Sep 24, 2020
1 parent 51b705a commit 7d19d52
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions drivers/clocksource/timer-sp804.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,18 @@

#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;
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);
if (err) {
pr_err("sp804: clock failed to prepare: %d\n", err);
Expand Down Expand Up @@ -72,16 +79,7 @@ int __init __sp804_clocksource_and_sched_clock_init(void __iomem *base,
{
long rate;

if (!clk) {
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);
rate = sp804_get_clock_rate(clk, name);
if (rate < 0)
return -EINVAL;

Expand Down Expand Up @@ -173,15 +171,7 @@ int __init __sp804_clockevents_init(void __iomem *base, unsigned int irq, struct
struct clock_event_device *evt = &sp804_clockevent;
long rate;

if (!clk)
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);
rate = sp804_get_clock_rate(clk, name);
if (rate < 0)
return -EINVAL;

Expand Down

0 comments on commit 7d19d52

Please sign in to comment.