.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (c) 2017, Linaro Ltd. All rights reserved. |
---|
3 | 4 | * |
---|
4 | 5 | * Author: Daniel Lezcano <daniel.lezcano@linaro.org> |
---|
5 | | - * |
---|
6 | | - * This program is free software; you can redistribute it and/or modify it |
---|
7 | | - * under the terms and conditions of the GNU General Public License, |
---|
8 | | - * version 2, as published by the Free Software Foundation. |
---|
9 | | - * |
---|
10 | | - * This program is distributed in the hope it will be useful, but WITHOUT |
---|
11 | | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
12 | | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
---|
13 | | - * more details. |
---|
14 | | - * |
---|
15 | | - * You should have received a copy of the GNU General Public License |
---|
16 | | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
17 | 6 | */ |
---|
18 | 7 | #include <linux/clk.h> |
---|
19 | 8 | #include <linux/interrupt.h> |
---|
.. | .. |
---|
30 | 19 | * |
---|
31 | 20 | * Free the irq resource |
---|
32 | 21 | */ |
---|
33 | | -static __init void timer_of_irq_exit(struct of_timer_irq *of_irq) |
---|
| 22 | +static void timer_of_irq_exit(struct of_timer_irq *of_irq) |
---|
34 | 23 | { |
---|
35 | 24 | struct timer_of *to = container_of(of_irq, struct timer_of, of_irq); |
---|
36 | 25 | |
---|
37 | 26 | struct clock_event_device *clkevt = &to->clkevt; |
---|
38 | 27 | |
---|
39 | | - of_irq->percpu ? free_percpu_irq(of_irq->irq, clkevt) : |
---|
| 28 | + if (of_irq->percpu) |
---|
| 29 | + free_percpu_irq(of_irq->irq, clkevt); |
---|
| 30 | + else |
---|
40 | 31 | free_irq(of_irq->irq, clkevt); |
---|
41 | 32 | } |
---|
42 | 33 | |
---|
.. | .. |
---|
56 | 47 | * |
---|
57 | 48 | * Returns 0 on success, < 0 otherwise |
---|
58 | 49 | */ |
---|
59 | | -static __init int timer_of_irq_init(struct device_node *np, |
---|
| 50 | +static int timer_of_irq_init(struct device_node *np, |
---|
60 | 51 | struct of_timer_irq *of_irq) |
---|
61 | 52 | { |
---|
62 | 53 | int ret; |
---|
.. | .. |
---|
66 | 57 | if (of_irq->name) { |
---|
67 | 58 | of_irq->irq = ret = of_irq_get_byname(np, of_irq->name); |
---|
68 | 59 | if (ret < 0) { |
---|
69 | | - pr_err("Failed to get interrupt %s for %s\n", |
---|
70 | | - of_irq->name, np->full_name); |
---|
| 60 | + pr_err("Failed to get interrupt %s for %pOF\n", |
---|
| 61 | + of_irq->name, np); |
---|
71 | 62 | return ret; |
---|
72 | 63 | } |
---|
73 | 64 | } else { |
---|
.. | .. |
---|
100 | 91 | * |
---|
101 | 92 | * Disables and releases the refcount on the clk |
---|
102 | 93 | */ |
---|
103 | | -static __init void timer_of_clk_exit(struct of_timer_clk *of_clk) |
---|
| 94 | +static void timer_of_clk_exit(struct of_timer_clk *of_clk) |
---|
104 | 95 | { |
---|
105 | 96 | of_clk->rate = 0; |
---|
106 | 97 | clk_disable_unprepare(of_clk->clk); |
---|
.. | .. |
---|
116 | 107 | * |
---|
117 | 108 | * Returns 0 on success, < 0 otherwise |
---|
118 | 109 | */ |
---|
119 | | -static __init int timer_of_clk_init(struct device_node *np, |
---|
| 110 | +static int timer_of_clk_init(struct device_node *np, |
---|
120 | 111 | struct of_timer_clk *of_clk) |
---|
121 | 112 | { |
---|
122 | 113 | int ret; |
---|
.. | .. |
---|
124 | 115 | of_clk->clk = of_clk->name ? of_clk_get_by_name(np, of_clk->name) : |
---|
125 | 116 | of_clk_get(np, of_clk->index); |
---|
126 | 117 | if (IS_ERR(of_clk->clk)) { |
---|
127 | | - pr_err("Failed to get clock for %pOF\n", np); |
---|
128 | | - return PTR_ERR(of_clk->clk); |
---|
| 118 | + ret = PTR_ERR(of_clk->clk); |
---|
| 119 | + if (ret != -EPROBE_DEFER) |
---|
| 120 | + pr_err("Failed to get clock for %pOF\n", np); |
---|
| 121 | + goto out; |
---|
129 | 122 | } |
---|
130 | 123 | |
---|
131 | 124 | ret = clk_prepare_enable(of_clk->clk); |
---|
.. | .. |
---|
153 | 146 | goto out; |
---|
154 | 147 | } |
---|
155 | 148 | |
---|
156 | | -static __init void timer_of_base_exit(struct of_timer_base *of_base) |
---|
| 149 | +static void timer_of_base_exit(struct of_timer_base *of_base) |
---|
157 | 150 | { |
---|
158 | 151 | iounmap(of_base->base); |
---|
159 | 152 | } |
---|
160 | 153 | |
---|
161 | | -static __init int timer_of_base_init(struct device_node *np, |
---|
| 154 | +static int timer_of_base_init(struct device_node *np, |
---|
162 | 155 | struct of_timer_base *of_base) |
---|
163 | 156 | { |
---|
164 | 157 | of_base->base = of_base->name ? |
---|
165 | 158 | of_io_request_and_map(np, of_base->index, of_base->name) : |
---|
166 | 159 | of_iomap(np, of_base->index); |
---|
167 | | - if (IS_ERR(of_base->base)) { |
---|
168 | | - pr_err("Failed to iomap (%s)\n", of_base->name); |
---|
169 | | - return PTR_ERR(of_base->base); |
---|
| 160 | + if (IS_ERR_OR_NULL(of_base->base)) { |
---|
| 161 | + pr_err("Failed to iomap (%s:%s)\n", np->name, of_base->name); |
---|
| 162 | + return of_base->base ? PTR_ERR(of_base->base) : -ENOMEM; |
---|
170 | 163 | } |
---|
171 | 164 | |
---|
172 | 165 | return 0; |
---|
173 | 166 | } |
---|
174 | 167 | |
---|
175 | | -int __init timer_of_init(struct device_node *np, struct timer_of *to) |
---|
| 168 | +int timer_of_init(struct device_node *np, struct timer_of *to) |
---|
176 | 169 | { |
---|
177 | 170 | int ret = -EINVAL; |
---|
178 | 171 | int flags = 0; |
---|
.. | .. |
---|
216 | 209 | timer_of_base_exit(&to->of_base); |
---|
217 | 210 | return ret; |
---|
218 | 211 | } |
---|
| 212 | +EXPORT_SYMBOL_GPL(timer_of_init); |
---|
219 | 213 | |
---|
220 | 214 | /** |
---|
221 | 215 | * timer_of_cleanup - release timer_of ressources |
---|
.. | .. |
---|
224 | 218 | * Release the ressources that has been used in timer_of_init(). |
---|
225 | 219 | * This function should be called in init error cases |
---|
226 | 220 | */ |
---|
227 | | -void __init timer_of_cleanup(struct timer_of *to) |
---|
| 221 | +void timer_of_cleanup(struct timer_of *to) |
---|
228 | 222 | { |
---|
229 | 223 | if (to->flags & TIMER_OF_IRQ) |
---|
230 | 224 | timer_of_irq_exit(&to->of_irq); |
---|