diff options
-rw-r--r-- | drivers/clocksource/vf_pit_timer.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/drivers/clocksource/vf_pit_timer.c b/drivers/clocksource/vf_pit_timer.c index a0e6c68536a1..ca4dff4d5684 100644 --- a/drivers/clocksource/vf_pit_timer.c +++ b/drivers/clocksource/vf_pit_timer.c | |||
@@ -156,15 +156,18 @@ static int __init pit_clockevent_init(unsigned long rate, int irq) | |||
156 | return 0; | 156 | return 0; |
157 | } | 157 | } |
158 | 158 | ||
159 | static void __init pit_timer_init(struct device_node *np) | 159 | static int __init pit_timer_init(struct device_node *np) |
160 | { | 160 | { |
161 | struct clk *pit_clk; | 161 | struct clk *pit_clk; |
162 | void __iomem *timer_base; | 162 | void __iomem *timer_base; |
163 | unsigned long clk_rate; | 163 | unsigned long clk_rate; |
164 | int irq; | 164 | int irq, ret; |
165 | 165 | ||
166 | timer_base = of_iomap(np, 0); | 166 | timer_base = of_iomap(np, 0); |
167 | BUG_ON(!timer_base); | 167 | if (!timer_base) { |
168 | pr_err("Failed to iomap"); | ||
169 | return -ENXIO; | ||
170 | } | ||
168 | 171 | ||
169 | /* | 172 | /* |
170 | * PIT0 and PIT1 can be chained to build a 64-bit timer, | 173 | * PIT0 and PIT1 can be chained to build a 64-bit timer, |
@@ -175,12 +178,16 @@ static void __init pit_timer_init(struct device_node *np) | |||
175 | clkevt_base = timer_base + PITn_OFFSET(3); | 178 | clkevt_base = timer_base + PITn_OFFSET(3); |
176 | 179 | ||
177 | irq = irq_of_parse_and_map(np, 0); | 180 | irq = irq_of_parse_and_map(np, 0); |
178 | BUG_ON(irq <= 0); | 181 | if (irq <= 0) |
182 | return -EINVAL; | ||
179 | 183 | ||
180 | pit_clk = of_clk_get(np, 0); | 184 | pit_clk = of_clk_get(np, 0); |
181 | BUG_ON(IS_ERR(pit_clk)); | 185 | if (IS_ERR(pit_clk)) |
186 | return PTR_ERR(pit_clk); | ||
182 | 187 | ||
183 | BUG_ON(clk_prepare_enable(pit_clk)); | 188 | ret = clk_prepare_enable(pit_clk); |
189 | if (ret) | ||
190 | return ret; | ||
184 | 191 | ||
185 | clk_rate = clk_get_rate(pit_clk); | 192 | clk_rate = clk_get_rate(pit_clk); |
186 | cycle_per_jiffy = clk_rate / (HZ); | 193 | cycle_per_jiffy = clk_rate / (HZ); |
@@ -188,8 +195,10 @@ static void __init pit_timer_init(struct device_node *np) | |||
188 | /* enable the pit module */ | 195 | /* enable the pit module */ |
189 | __raw_writel(~PITMCR_MDIS, timer_base + PITMCR); | 196 | __raw_writel(~PITMCR_MDIS, timer_base + PITMCR); |
190 | 197 | ||
191 | BUG_ON(pit_clocksource_init(clk_rate)); | 198 | ret = pit_clocksource_init(clk_rate); |
199 | if (ret) | ||
200 | return ret; | ||
192 | 201 | ||
193 | pit_clockevent_init(clk_rate, irq); | 202 | return pit_clockevent_init(clk_rate, irq); |
194 | } | 203 | } |
195 | CLOCKSOURCE_OF_DECLARE(vf610, "fsl,vf610-pit", pit_timer_init); | 204 | CLOCKSOURCE_OF_DECLARE_RET(vf610, "fsl,vf610-pit", pit_timer_init); |