aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clocksource/mips-gic-timer.c
diff options
context:
space:
mode:
authorDaniel Lezcano <daniel.lezcano@linaro.org>2016-06-06 11:57:25 -0400
committerDaniel Lezcano <daniel.lezcano@linaro.org>2016-06-28 04:19:24 -0400
commitd8152bf85d2c057fc39c3e20a4d623f524d9f09c (patch)
treea64dddacd92cc44e0afa6a36e5fc6031d8e66bde /drivers/clocksource/mips-gic-timer.c
parentca46acb981072f084d63d2a94430a5c3190aa32a (diff)
clocksource/drivers/mips-gic-timer: Convert init function to return error
The init functions do not return any error. They behave as the following: - panic, thus leading to a kernel crash while another timer may work and make the system boot up correctly or - print an error and let the caller unaware if the state of the system Change that by converting the init functions to return an error conforming to the CLOCKSOURCE_OF_RET prototype. Proper error handling (rollback, errno value) will be changed later case by case, thus this change just return back an error or success in the init function. Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Diffstat (limited to 'drivers/clocksource/mips-gic-timer.c')
-rw-r--r--drivers/clocksource/mips-gic-timer.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/drivers/clocksource/mips-gic-timer.c b/drivers/clocksource/mips-gic-timer.c
index 89d3e4d7900c..b164b8712f39 100644
--- a/drivers/clocksource/mips-gic-timer.c
+++ b/drivers/clocksource/mips-gic-timer.c
@@ -146,7 +146,7 @@ static struct clocksource gic_clocksource = {
146 .archdata = { .vdso_clock_mode = VDSO_CLOCK_GIC }, 146 .archdata = { .vdso_clock_mode = VDSO_CLOCK_GIC },
147}; 147};
148 148
149static void __init __gic_clocksource_init(void) 149static int __init __gic_clocksource_init(void)
150{ 150{
151 int ret; 151 int ret;
152 152
@@ -159,6 +159,8 @@ static void __init __gic_clocksource_init(void)
159 ret = clocksource_register_hz(&gic_clocksource, gic_frequency); 159 ret = clocksource_register_hz(&gic_clocksource, gic_frequency);
160 if (ret < 0) 160 if (ret < 0)
161 pr_warn("GIC: Unable to register clocksource\n"); 161 pr_warn("GIC: Unable to register clocksource\n");
162
163 return ret;
162} 164}
163 165
164void __init gic_clocksource_init(unsigned int frequency) 166void __init gic_clocksource_init(unsigned int frequency)
@@ -179,31 +181,35 @@ static void __init gic_clocksource_of_init(struct device_node *node)
179 struct clk *clk; 181 struct clk *clk;
180 int ret; 182 int ret;
181 183
182 if (WARN_ON(!gic_present || !node->parent || 184 if (!gic_present || !node->parent ||
183 !of_device_is_compatible(node->parent, "mti,gic"))) 185 !of_device_is_compatible(node->parent, "mti,gic")) {
184 return; 186 pr_warn("No DT definition for the mips gic driver");
187 return -ENXIO;
188 }
185 189
186 clk = of_clk_get(node, 0); 190 clk = of_clk_get(node, 0);
187 if (!IS_ERR(clk)) { 191 if (!IS_ERR(clk)) {
188 if (clk_prepare_enable(clk) < 0) { 192 if (clk_prepare_enable(clk) < 0) {
189 pr_err("GIC failed to enable clock\n"); 193 pr_err("GIC failed to enable clock\n");
190 clk_put(clk); 194 clk_put(clk);
191 return; 195 return PTR_ERR(clk);
192 } 196 }
193 197
194 gic_frequency = clk_get_rate(clk); 198 gic_frequency = clk_get_rate(clk);
195 } else if (of_property_read_u32(node, "clock-frequency", 199 } else if (of_property_read_u32(node, "clock-frequency",
196 &gic_frequency)) { 200 &gic_frequency)) {
197 pr_err("GIC frequency not specified.\n"); 201 pr_err("GIC frequency not specified.\n");
198 return; 202 return -EINVAL;;
199 } 203 }
200 gic_timer_irq = irq_of_parse_and_map(node, 0); 204 gic_timer_irq = irq_of_parse_and_map(node, 0);
201 if (!gic_timer_irq) { 205 if (!gic_timer_irq) {
202 pr_err("GIC timer IRQ not specified.\n"); 206 pr_err("GIC timer IRQ not specified.\n");
203 return; 207 return -EINVAL;;
204 } 208 }
205 209
206 __gic_clocksource_init(); 210 ret = __gic_clocksource_init();
211 if (ret)
212 return ret;
207 213
208 ret = gic_clockevent_init(); 214 ret = gic_clockevent_init();
209 if (!ret && !IS_ERR(clk)) { 215 if (!ret && !IS_ERR(clk)) {
@@ -213,6 +219,8 @@ static void __init gic_clocksource_of_init(struct device_node *node)
213 219
214 /* And finally start the counter */ 220 /* And finally start the counter */
215 gic_start_count(); 221 gic_start_count();
222
223 return 0;
216} 224}
217CLOCKSOURCE_OF_DECLARE(mips_gic_timer, "mti,gic-timer", 225CLOCKSOURCE_OF_DECLARE_RET(mips_gic_timer, "mti,gic-timer",
218 gic_clocksource_of_init); 226 gic_clocksource_of_init);