summaryrefslogtreecommitdiff
path: root/drivers/clocksource
diff options
context:
space:
mode:
authorDong Aisheng <aisheng.dong@nxp.com>2017-09-06 21:13:25 +0800
committerLeonard Crestez <leonard.crestez@nxp.com>2018-08-24 12:41:33 +0300
commit493b06d6f4dfdf67665d579236605e8480743328 (patch)
tree07791a0bcb00678b6649c76cc0938a26da2238c3 /drivers/clocksource
parent0e3ccb3749d9931e72dc39b418252e79b83159a2 (diff)
MLK-17491-19 clocksource: imx-tpm: fix error checks
Note we shouldn't use BUG_ON here as there might be alternative timers. Cc: Shenwei Wang <shenwei.wang@nxp.com> Reviewed-by: Bai Ping <ping.bai@nxp.com> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
Diffstat (limited to 'drivers/clocksource')
-rw-r--r--drivers/clocksource/timer-imx-tpm.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/drivers/clocksource/timer-imx-tpm.c b/drivers/clocksource/timer-imx-tpm.c
index 47e69c3d593d..08d01c83e973 100644
--- a/drivers/clocksource/timer-imx-tpm.c
+++ b/drivers/clocksource/timer-imx-tpm.c
@@ -154,11 +154,20 @@ static int __init tpm_timer_init(struct device_node *np)
struct clk *ipg, *per;
uint32_t val;
int irq, ret;
+ u32 rate;
timer_base = of_iomap(np, 0);
- BUG_ON(!timer_base);
+ if (!timer_base) {
+ pr_err("tpm: failed to get base address\n");
+ return -ENXIO;
+ }
irq = irq_of_parse_and_map(np, 0);
+ if (!irq) {
+ pr_err("tpm: failed to get irq\n");
+ ret = -ENOENT;
+ goto err_iomap;
+ }
ipg = of_clk_get_by_name(np, "ipg");
per = of_clk_get_by_name(np, "per");
@@ -192,8 +201,14 @@ static int __init tpm_timer_init(struct device_node *np)
/* set the MOD register to 0xffffffff for free running counter */
__raw_writel(0xffffffff, timer_base + TPM_MOD);
- tpm_clocksource_init(clk_get_rate(per) / 8);
- tpm_clockevent_init(clk_get_rate(per) / 8, irq);
+ rate = clk_get_rate(per) >> 3;
+ ret = tpm_clocksource_init(rate);
+ if (ret)
+ goto err_per_clk_enable;
+
+ ret = tpm_clockevent_init(rate, irq);
+ if (ret)
+ goto err_per_clk_enable;
val = __raw_readl(timer_base);
@@ -204,6 +219,8 @@ err_per_clk_enable:
err_clk_get:
clk_put(per);
clk_put(ipg);
+err_iomap:
+ iounmap(timer_base);
return ret;
}