Commit 659849cd authored by Bryan O'Donoghue's avatar Bryan O'Donoghue Committed by Greg Kroah-Hartman

staging: greybus/timesync: avoid divide by zero on X86 Qemu

A system configured without CONFIG_CPUFREQ will return 0 for cpufreq_get().
greybus-timesync can subsequently then do a divide-by-zero as result. This
patch fixes by checking for a zero return value from cpufreq_get() and
setting to a default value of 19.2MHz.
Reported-by: default avatarRui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: default avatarBryan O'Donoghue <pure.logic@nexus-software.ie>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3d7f3588
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
#include "greybus.h" #include "greybus.h"
#include "arche_platform.h" #include "arche_platform.h"
#define DEFAULT_FRAMETIME_CLOCK_HZ 19200000
static u32 gb_timesync_clock_frequency; static u32 gb_timesync_clock_frequency;
int (*arche_platform_change_state_cb)(enum arche_platform_state state, int (*arche_platform_change_state_cb)(enum arche_platform_state state,
struct gb_timesync_svc *pdata); struct gb_timesync_svc *pdata);
...@@ -32,8 +34,11 @@ u64 gb_timesync_platform_get_counter(void) ...@@ -32,8 +34,11 @@ u64 gb_timesync_platform_get_counter(void)
u32 gb_timesync_platform_get_clock_rate(void) u32 gb_timesync_platform_get_clock_rate(void)
{ {
if (unlikely(!gb_timesync_clock_frequency)) if (unlikely(!gb_timesync_clock_frequency)) {
return cpufreq_get(0); gb_timesync_clock_frequency = cpufreq_get(0);
if (!gb_timesync_clock_frequency)
gb_timesync_clock_frequency = DEFAULT_FRAMETIME_CLOCK_HZ;
}
return gb_timesync_clock_frequency; return gb_timesync_clock_frequency;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment