clocksource/drivers/sun5i: Fail gracefully when clock rate is unavailable
authorChen-Yu Tsai <wens@csie.org>
Thu, 10 Jan 2019 06:22:07 +0000 (14:22 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 27 Jan 2020 13:50:27 +0000 (14:50 +0100)
commit8bdfc04f016633638c46ae99349a4ecd3c0f51bf
tree53aa5bd7468d702ecfc80740e5a023a765a0857f
parentb34abf24f2027f2df1f1c3d994aac9098060ea9a
clocksource/drivers/sun5i: Fail gracefully when clock rate is unavailable

[ Upstream commit e7e7e0d7beafebd11b0c065cd5fbc1e5759c5aab ]

If the clock tree is not fully populated when the timer-sun5i init code
is called, attempts to get the clock rate for the timer would fail and
return 0.

Make the init code for both clock events and clocksource check the
returned clock rate and fail gracefully if the result is 0, instead of
causing a divide by 0 exception later on.

Fixes: 4a59058f0b09 ("clocksource/drivers/sun5i: Refactor the current code")
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/clocksource/timer-sun5i.c