sys_clock.h: Make "global variable" APIs into proper functions

The existing API defined sys_clock_{hw_cycles,ticks}_per_sec as simple
"variables" to be shared, except that they were only real storage in
certain modes (the HPET driver, basically) and everywhere else they
were a build constant.

Properly, these should be an API defined by the timer driver (who
controls those rates) and consumed by the clock subsystem.  So give
them function syntax as a stepping stone to get there.

Note that this also removes the deprecated variable
_sys_clock_us_per_tick rather than give it the same treatment.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
Andy Ross 2018-09-19 10:52:07 -07:00 committed by Anas Nashif
commit 220d4f8347
14 changed files with 57 additions and 46 deletions

View file

@ -159,6 +159,7 @@
#define HPET_IOAPIC_FLAGS (IOAPIC_LEVEL | IOAPIC_LOW)
#endif
extern int z_clock_hw_cycles_per_sec;
#ifdef CONFIG_INT_LATENCY_BENCHMARK
static u32_t main_count_first_irq_value;
@ -583,7 +584,7 @@ int _sys_clock_driver_init(struct device *device)
* Get tick time (in femptoseconds).
*/
tickFempto = 1000000000000000ull / sys_clock_ticks_per_sec;
tickFempto = 1000000000000000ull / sys_clock_ticks_per_sec();
/*
* This driver shall read the COUNTER_CLK_PERIOD value from the general
@ -613,8 +614,8 @@ int _sys_clock_driver_init(struct device *device)
/* Initialize sys_clock_hw_cycles_per_tick/sec */
sys_clock_hw_cycles_per_tick = counter_load_value;
sys_clock_hw_cycles_per_sec = sys_clock_hw_cycles_per_tick *
sys_clock_ticks_per_sec;
z_clock_hw_cycles_per_sec = sys_clock_hw_cycles_per_tick *
sys_clock_ticks_per_sec();
#ifdef CONFIG_INT_LATENCY_BENCHMARK