diff options
author | Stephen Warren <swarren@nvidia.com> | 2016-01-06 10:33:03 -0700 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2016-01-20 19:06:23 -0700 |
commit | 0a7edce0ef26d9a8c11e9c097e0ed12cf334e27d (patch) | |
tree | 12aa4e174c947f098a7c508b5137d2cfb1904018 /drivers/timer/timer-uclass.c | |
parent | cf2045283284a3226889b66541c456eb7ca869e9 (diff) | |
download | u-boot-imx-0a7edce0ef26d9a8c11e9c097e0ed12cf334e27d.zip u-boot-imx-0a7edce0ef26d9a8c11e9c097e0ed12cf334e27d.tar.gz u-boot-imx-0a7edce0ef26d9a8c11e9c097e0ed12cf334e27d.tar.bz2 |
dm: timer: refuse timers with zero clock_rate
If a timer has a zero clock_rate, get_tbclk() will return zero for it,
which will cause tick_to_time() to perform a division-by-zero, which will
crash U-Boot.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/timer/timer-uclass.c')
-rw-r--r-- | drivers/timer/timer-uclass.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c index b1f4868..83d1a35 100644 --- a/drivers/timer/timer-uclass.c +++ b/drivers/timer/timer-uclass.c @@ -49,6 +49,16 @@ static int timer_pre_probe(struct udevice *dev) return 0; } +static int timer_post_probe(struct udevice *dev) +{ + struct timer_dev_priv *uc_priv = dev_get_uclass_priv(dev); + + if (!uc_priv->clock_rate) + return -EINVAL; + + return 0; +} + u64 timer_conv_64(u32 count) { /* increment tbh if tbl has rolled over */ @@ -105,5 +115,6 @@ UCLASS_DRIVER(timer) = { .name = "timer", .pre_probe = timer_pre_probe, .flags = DM_UC_FLAG_SEQ_ALIAS, + .post_probe = timer_post_probe, .per_device_auto_alloc_size = sizeof(struct timer_dev_priv), }; |