hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/drivers/clocksource/timer-of.c
....@@ -1,19 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (c) 2017, Linaro Ltd. All rights reserved.
34 *
45 * 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/>.
176 */
187 #include <linux/clk.h>
198 #include <linux/interrupt.h>
....@@ -30,13 +19,15 @@
3019 *
3120 * Free the irq resource
3221 */
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)
3423 {
3524 struct timer_of *to = container_of(of_irq, struct timer_of, of_irq);
3625
3726 struct clock_event_device *clkevt = &to->clkevt;
3827
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
4031 free_irq(of_irq->irq, clkevt);
4132 }
4233
....@@ -56,7 +47,7 @@
5647 *
5748 * Returns 0 on success, < 0 otherwise
5849 */
59
-static __init int timer_of_irq_init(struct device_node *np,
50
+static int timer_of_irq_init(struct device_node *np,
6051 struct of_timer_irq *of_irq)
6152 {
6253 int ret;
....@@ -66,8 +57,8 @@
6657 if (of_irq->name) {
6758 of_irq->irq = ret = of_irq_get_byname(np, of_irq->name);
6859 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);
7162 return ret;
7263 }
7364 } else {
....@@ -100,7 +91,7 @@
10091 *
10192 * Disables and releases the refcount on the clk
10293 */
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)
10495 {
10596 of_clk->rate = 0;
10697 clk_disable_unprepare(of_clk->clk);
....@@ -116,7 +107,7 @@
116107 *
117108 * Returns 0 on success, < 0 otherwise
118109 */
119
-static __init int timer_of_clk_init(struct device_node *np,
110
+static int timer_of_clk_init(struct device_node *np,
120111 struct of_timer_clk *of_clk)
121112 {
122113 int ret;
....@@ -124,8 +115,10 @@
124115 of_clk->clk = of_clk->name ? of_clk_get_by_name(np, of_clk->name) :
125116 of_clk_get(np, of_clk->index);
126117 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;
129122 }
130123
131124 ret = clk_prepare_enable(of_clk->clk);
....@@ -153,26 +146,26 @@
153146 goto out;
154147 }
155148
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)
157150 {
158151 iounmap(of_base->base);
159152 }
160153
161
-static __init int timer_of_base_init(struct device_node *np,
154
+static int timer_of_base_init(struct device_node *np,
162155 struct of_timer_base *of_base)
163156 {
164157 of_base->base = of_base->name ?
165158 of_io_request_and_map(np, of_base->index, of_base->name) :
166159 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;
170163 }
171164
172165 return 0;
173166 }
174167
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)
176169 {
177170 int ret = -EINVAL;
178171 int flags = 0;
....@@ -216,6 +209,7 @@
216209 timer_of_base_exit(&to->of_base);
217210 return ret;
218211 }
212
+EXPORT_SYMBOL_GPL(timer_of_init);
219213
220214 /**
221215 * timer_of_cleanup - release timer_of ressources
....@@ -224,7 +218,7 @@
224218 * Release the ressources that has been used in timer_of_init().
225219 * This function should be called in init error cases
226220 */
227
-void __init timer_of_cleanup(struct timer_of *to)
221
+void timer_of_cleanup(struct timer_of *to)
228222 {
229223 if (to->flags & TIMER_OF_IRQ)
230224 timer_of_irq_exit(&to->of_irq);