armv7-a timer:fix timer overflow.
Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
parent
8eddf00212
commit
5aeab4a36c
@ -143,7 +143,9 @@ static inline void arm_timer_set_cval(uint64_t cval)
|
|||||||
|
|
||||||
static inline uint64_t nsec_from_count(uint64_t count, uint32_t freq)
|
static inline uint64_t nsec_from_count(uint64_t count, uint32_t freq)
|
||||||
{
|
{
|
||||||
return (uint64_t)count * NSEC_PER_SEC / freq;
|
uint64_t sec = count / freq;
|
||||||
|
uint64_t nsec = (count % freq) * NSEC_PER_SEC / freq;
|
||||||
|
return sec * NSEC_PER_SEC + nsec;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint64_t nsec_to_count(uint32_t nsec, uint32_t freq)
|
static inline uint64_t nsec_to_count(uint32_t nsec, uint32_t freq)
|
||||||
|
Loading…
Reference in New Issue
Block a user