Skip to content

Commit

Permalink
Merge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/sc…
Browse files Browse the repository at this point in the history
…m/linux/kernel/git/tip/tip

Pull timer fix from Ingo Molnar:
 "ARM/MOXA SoC clocksource driver fixes"

* 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  clocksource/drivers/moxart: Plug memory and mapping leaks
  • Loading branch information
torvalds committed Dec 24, 2016
2 parents 00198da + c9435f3 commit eb3e8d9
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions drivers/clocksource/moxart_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,19 +161,22 @@ static int __init moxart_timer_init(struct device_node *node)
timer->base = of_iomap(node, 0);
if (!timer->base) {
pr_err("%s: of_iomap failed\n", node->full_name);
return -ENXIO;
ret = -ENXIO;
goto out_free;
}

irq = irq_of_parse_and_map(node, 0);
if (irq <= 0) {
pr_err("%s: irq_of_parse_and_map failed\n", node->full_name);
return -EINVAL;
ret = -EINVAL;
goto out_unmap;
}

clk = of_clk_get(node, 0);
if (IS_ERR(clk)) {
pr_err("%s: of_clk_get failed\n", node->full_name);
return PTR_ERR(clk);
ret = PTR_ERR(clk);
goto out_unmap;
}

pclk = clk_get_rate(clk);
Expand All @@ -186,7 +189,8 @@ static int __init moxart_timer_init(struct device_node *node)
timer->t1_disable_val = ASPEED_TIMER1_DISABLE;
} else {
pr_err("%s: unknown platform\n", node->full_name);
return -EINVAL;
ret = -EINVAL;
goto out_unmap;
}

timer->count_per_tick = DIV_ROUND_CLOSEST(pclk, HZ);
Expand All @@ -208,14 +212,14 @@ static int __init moxart_timer_init(struct device_node *node)
clocksource_mmio_readl_down);
if (ret) {
pr_err("%s: clocksource_mmio_init failed\n", node->full_name);
return ret;
goto out_unmap;
}

ret = request_irq(irq, moxart_timer_interrupt, IRQF_TIMER,
node->name, &timer->clkevt);
if (ret) {
pr_err("%s: setup_irq failed\n", node->full_name);
return ret;
goto out_unmap;
}

/* Clear match registers */
Expand All @@ -241,6 +245,12 @@ static int __init moxart_timer_init(struct device_node *node)
clockevents_config_and_register(&timer->clkevt, pclk, 0x4, 0xfffffffe);

return 0;

out_unmap:
iounmap(timer->base);
out_free:
kfree(timer);
return ret;
}
CLOCKSOURCE_OF_DECLARE(moxart, "moxa,moxart-timer", moxart_timer_init);
CLOCKSOURCE_OF_DECLARE(aspeed, "aspeed,ast2400-timer", moxart_timer_init);

0 comments on commit eb3e8d9

Please sign in to comment.