Skip to content

Commit e69aae7

Browse files
Zhen Leidlezcano
authored andcommitted
clocksource/drivers/sp804: Prepare for support non-standard register offset
Add two local variables: timer1_base and timer2_base in sp804_of_init(), to avoid repeatedly calculate the base address of timer2, and make it easier to recognize timer1. Hope to make the next patch looks more clear. No functional change. Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20200918132237.3552-6-thunder.leizhen@huawei.com
1 parent 2f71078 commit e69aae7

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

drivers/clocksource/timer-sp804.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ static int __init sp804_of_init(struct device_node *np)
188188
{
189189
static bool initialized = false;
190190
void __iomem *base;
191+
void __iomem *timer1_base;
192+
void __iomem *timer2_base;
191193
int irq, ret = -EINVAL;
192194
u32 irq_num = 0;
193195
struct clk *clk1, *clk2;
@@ -197,9 +199,12 @@ static int __init sp804_of_init(struct device_node *np)
197199
if (!base)
198200
return -ENXIO;
199201

202+
timer1_base = base;
203+
timer2_base = base + TIMER_2_BASE;
204+
200205
/* Ensure timers are disabled */
201-
writel(0, base + TIMER_CTRL);
202-
writel(0, base + TIMER_2_BASE + TIMER_CTRL);
206+
writel(0, timer1_base + TIMER_CTRL);
207+
writel(0, timer2_base + TIMER_CTRL);
203208

204209
if (initialized || !of_device_is_available(np)) {
205210
ret = -EINVAL;
@@ -228,21 +233,21 @@ static int __init sp804_of_init(struct device_node *np)
228233
of_property_read_u32(np, "arm,sp804-has-irq", &irq_num);
229234
if (irq_num == 2) {
230235

231-
ret = sp804_clockevents_init(base + TIMER_2_BASE, irq, clk2, name);
236+
ret = sp804_clockevents_init(timer2_base, irq, clk2, name);
232237
if (ret)
233238
goto err;
234239

235-
ret = sp804_clocksource_and_sched_clock_init(base,
240+
ret = sp804_clocksource_and_sched_clock_init(timer1_base,
236241
name, clk1, 1);
237242
if (ret)
238243
goto err;
239244
} else {
240245

241-
ret = sp804_clockevents_init(base, irq, clk1, name);
246+
ret = sp804_clockevents_init(timer1_base, irq, clk1, name);
242247
if (ret)
243248
goto err;
244249

245-
ret = sp804_clocksource_and_sched_clock_init(base + TIMER_2_BASE,
250+
ret = sp804_clocksource_and_sched_clock_init(timer2_base,
246251
name, clk2, 1);
247252
if (ret)
248253
goto err;

0 commit comments

Comments
 (0)