Replece clock_gettime(CLOCK_MONOTONIC) with clock_systime_timespec
it's better to call the kernrel api insteaad user space api in kernel Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
1699f530a5
commit
43f57240e0
14 changed files with 19 additions and 19 deletions
|
@ -127,7 +127,7 @@ static uint64_t _get_current_time64(void)
|
|||
{
|
||||
struct timespec ts;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
clock_systime_timespec(&ts);
|
||||
return (uint64_t)ts.tv_sec * NSEC_PER_SEC + (uint64_t)ts.tv_nsec;
|
||||
}
|
||||
|
||||
|
|
|
@ -548,7 +548,7 @@ int up_rtc_settime(FAR const struct timespec *ts)
|
|||
up_rtc_set_default_datetime(tp);
|
||||
#endif /* CONFIG_RTC_SAVE_DEFAULT */
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &lastupdate_mono);
|
||||
clock_systime_timespec(&lastupdate_mono);
|
||||
lastupdate_rtc = *ts;
|
||||
|
||||
/* Start rtc update */
|
||||
|
@ -660,7 +660,7 @@ int up_rtc_getrawtime(FAR struct timespec *ts)
|
|||
struct timespec now;
|
||||
struct timespec diff;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
clock_systime_timespec(&now);
|
||||
timespec_sub(&now, &lastupdate_mono, &diff);
|
||||
|
||||
if (lastupdate_rtc.tv_sec != 0 && diff.tv_sec < 1)
|
||||
|
|
|
@ -851,7 +851,7 @@ static int esp32c3_i2c_polling_waitdone(struct esp32c3_i2c_priv_s *priv)
|
|||
* forward and backwards.
|
||||
*/
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, ¤t_time);
|
||||
clock_systime_timespec(¤t_time);
|
||||
|
||||
timeout.tv_sec = current_time.tv_sec + 10;
|
||||
timeout.tv_nsec = current_time.tv_nsec + 0;
|
||||
|
@ -892,7 +892,7 @@ static int esp32c3_i2c_polling_waitdone(struct esp32c3_i2c_priv_s *priv)
|
|||
|
||||
/* Update current time */
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, ¤t_time);
|
||||
clock_systime_timespec(¤t_time);
|
||||
current_us = TIMESPEC_TO_US(current_time.tv_sec, current_time.tv_nsec);
|
||||
}
|
||||
|
||||
|
|
|
@ -784,7 +784,7 @@ static int esp32_i2c_polling_waitdone(struct esp32_i2c_priv_s *priv)
|
|||
* forward and backwards.
|
||||
*/
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, ¤t_time);
|
||||
clock_systime_timespec(¤t_time);
|
||||
|
||||
timeout.tv_sec = current_time.tv_sec + 10;
|
||||
timeout.tv_nsec = current_time.tv_nsec + 0;
|
||||
|
@ -825,7 +825,7 @@ static int esp32_i2c_polling_waitdone(struct esp32_i2c_priv_s *priv)
|
|||
|
||||
/* Update current time */
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, ¤t_time);
|
||||
clock_systime_timespec(¤t_time);
|
||||
current_us = TIMESPEC_TO_US(current_time.tv_sec, current_time.tv_nsec);
|
||||
}
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ static int stm32_cd(int irq, void *context, void *arg)
|
|||
static uint32_t prev = 0;
|
||||
struct timespec tp;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &tp);
|
||||
clock_systime_timespec(&tp);
|
||||
now = tp.tv_sec * 1000 + tp.tv_nsec / 1000000;
|
||||
|
||||
/* When inserting card, card detect plate might bounce causing this
|
||||
|
|
|
@ -643,7 +643,7 @@ static int bmp280_fetch(FAR struct sensor_lowerhalf_s *lower,
|
|||
temp = bmp280_compensate_temp(priv, temp);
|
||||
press = bmp280_compensate_press(priv, press);
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
clock_systime_timespec(&ts);
|
||||
|
||||
baro_data.timestamp = 1000000ull * ts.tv_sec + ts.tv_nsec / 1000;
|
||||
baro_data.pressure = press / 100.0f;
|
||||
|
|
|
@ -550,7 +550,7 @@ static unsigned long ds18b20_curtime(void)
|
|||
{
|
||||
struct timespec ts;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
clock_systime_timespec(&ts);
|
||||
return 1000000ull * ts.tv_sec + ts.tv_nsec / 1000;
|
||||
}
|
||||
|
||||
|
|
|
@ -188,7 +188,7 @@ static unsigned long hyt271_curtime(void)
|
|||
{
|
||||
struct timespec ts;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
clock_systime_timespec(&ts);
|
||||
return 1000000ull * ts.tv_sec + ts.tv_nsec / 1000;
|
||||
}
|
||||
|
||||
|
|
|
@ -1667,7 +1667,7 @@ static int lis2dh_reboot(FAR struct lis2dh_dev_s *dev)
|
|||
|
||||
/* Prefer monotonic for timeout calculation when enabled. */
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &start);
|
||||
clock_systime_timespec(&start);
|
||||
|
||||
/* Reboot to reset chip. */
|
||||
|
||||
|
@ -1692,7 +1692,7 @@ static int lis2dh_reboot(FAR struct lis2dh_dev_s *dev)
|
|||
break;
|
||||
}
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &curr);
|
||||
clock_systime_timespec(&curr);
|
||||
|
||||
diff_msec = (curr.tv_sec - start.tv_sec) * 1000;
|
||||
diff_msec += (curr.tv_nsec - start.tv_nsec) / (1000 * 1000);
|
||||
|
|
|
@ -158,7 +158,7 @@ static unsigned long ms5611_curtime(void)
|
|||
{
|
||||
struct timespec ts;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
clock_systime_timespec(&ts);
|
||||
return 1000000ull * ts.tv_sec + ts.tv_nsec / 1000;
|
||||
}
|
||||
|
||||
|
|
|
@ -387,7 +387,7 @@ int epoll_pwait(int epfd, FAR struct epoll_event *evs,
|
|||
expire.tv_sec = timeout / 1000;
|
||||
expire.tv_nsec = timeout % 1000 * 1000;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &curr);
|
||||
clock_systime_timespec(&curr);
|
||||
clock_timespec_add(&curr, &expire, &expire);
|
||||
}
|
||||
|
||||
|
@ -398,7 +398,7 @@ again:
|
|||
}
|
||||
else
|
||||
{
|
||||
clock_gettime(CLOCK_MONOTONIC, &curr);
|
||||
clock_systime_timespec(&curr);
|
||||
clock_timespec_subtract(&expire, &curr, &diff);
|
||||
|
||||
rc = ppoll(eph->poll, eph->occupied + 1, &diff, sigmask);
|
||||
|
|
|
@ -204,7 +204,7 @@ static inline uint64_t touch_get_time(void)
|
|||
{
|
||||
struct timespec ts;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
clock_systime_timespec(&ts);
|
||||
return 1000000ull * ts.tv_sec + ts.tv_nsec / 1000;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ static inline uint64_t lirc_get_timestamp(void)
|
|||
{
|
||||
struct timespec ts;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
clock_systime_timespec(&ts);
|
||||
return 1000000000ull * ts.tv_sec + ts.tv_nsec;
|
||||
}
|
||||
|
||||
|
|
|
@ -283,7 +283,7 @@ static inline uint64_t sensor_get_timestamp(void)
|
|||
{
|
||||
struct timespec ts;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
clock_systime_timespec(&ts);
|
||||
return 1000000ull * ts.tv_sec + ts.tv_nsec / 1000;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue