Skip to content

Commit e8e7288

Browse files
erwangofabiobaltieri
authored andcommitted
drivers: timer: stm32: Check return of clock functions
That will speed up debugging. Signed-off-by: Erwan Gouriou <[email protected]>
1 parent 7f2cb0f commit e8e7288

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

drivers/timer/stm32_lptim_timer.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,14 +283,19 @@ uint32_t sys_clock_cycle_get_32(void)
283283

284284
static int sys_clock_driver_init(const struct device *dev)
285285
{
286+
int err;
287+
286288
ARG_UNUSED(dev);
287289

288290
if (!device_is_ready(clk_ctrl)) {
289291
return -ENODEV;
290292
}
291293

292294
/* Enable LPTIM bus clock */
293-
clock_control_on(clk_ctrl, (clock_control_subsys_t *) &lptim_clk[0]);
295+
err = clock_control_on(clk_ctrl, (clock_control_subsys_t *) &lptim_clk[0]);
296+
if (err < 0) {
297+
return -EIO;
298+
}
294299

295300
#if defined(LL_APB1_GRP1_PERIPH_LPTIM1)
296301
LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_LPTIM1);
@@ -308,13 +313,20 @@ static int sys_clock_driver_init(const struct device *dev)
308313
}
309314

310315
/* Enable LPTIM clock source */
311-
clock_control_configure(clk_ctrl, (clock_control_subsys_t *) &lptim_clk[1],
312-
NULL);
316+
err = clock_control_configure(clk_ctrl,
317+
(clock_control_subsys_t *) &lptim_clk[1],
318+
NULL);
319+
if (err < 0) {
320+
return -EIO;
321+
}
313322

314323
/* Get LPTIM clock freq */
315-
clock_control_get_rate(clk_ctrl, (clock_control_subsys_t *) &lptim_clk[1],
324+
err = clock_control_get_rate(clk_ctrl, (clock_control_subsys_t *) &lptim_clk[1],
316325
&lptim_clock_freq);
317326

327+
if (err < 0) {
328+
return -EIO;
329+
}
318330
#if defined(CONFIG_SOC_SERIES_STM32L0X)
319331
/* Driver only supports freqs up to 32768Hz. On L0, LSI freq is 37KHz,
320332
* which will overflow the LPTIM counter.

0 commit comments

Comments
 (0)