[PATCH 6/7] kernel: cobalt: migrate to ktime_t

Jan Kiszka jan.kiszka at siemens.com
Tue Mar 5 19:16:09 CET 2019


On 05.03.19 15:45, roman.stratiienko--- via Xenomai wrote:
> From: Roman Stratiienko <roman.stratiienko at globallogic.com>
> 
> Signed-off-by: Roman Stratiienko <roman.stratiienko at globallogic.com>
> ---
>   kernel/cobalt/clock.c                 | 4 +---
>   kernel/drivers/analogy/rtdm_helpers.c | 5 +----
>   2 files changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/kernel/cobalt/clock.c b/kernel/cobalt/clock.c
> index 272db3241..f8291b006 100644
> --- a/kernel/cobalt/clock.c
> +++ b/kernel/cobalt/clock.c
> @@ -350,9 +350,7 @@ EXPORT_SYMBOL_GPL(xnclock_adjust);
>   
>   xnticks_t xnclock_get_host_time(void)
>   {
> -	struct timeval tv;
> -	do_gettimeofday(&tv);
> -	return tv.tv_sec * 1000000000ULL + tv.tv_usec * 1000;
> +	return ktime_to_ns(ktime_get_real());
>   }
>   EXPORT_SYMBOL_GPL(xnclock_get_host_time);
>   
> diff --git a/kernel/drivers/analogy/rtdm_helpers.c b/kernel/drivers/analogy/rtdm_helpers.c
> index 8330d0676..675594152 100644
> --- a/kernel/drivers/analogy/rtdm_helpers.c
> +++ b/kernel/drivers/analogy/rtdm_helpers.c
> @@ -32,11 +32,8 @@ static nanosecs_abs_t a4l_clkofs;
>   void a4l_init_time(void)
>   {
>   	nanosecs_abs_t t1, t2;
> -	struct timeval tv;
>   	t1 = rtdm_clock_read();
> -	do_gettimeofday(&tv);
> -	t2 = 1000000000 * ((nanosecs_abs_t)tv.tv_sec) +
> -		1000000 * ((nanosecs_abs_t)tv.tv_usec);

Hmm.... I think this even fixes a bug: Should have been "1000 * ...".

> +	t2 = ktime_to_ns(ktime_get_real());
>   	a4l_clkofs = t2 - t1;
>   }
>   
> 

For the record: This pattern is supported since 3.17. So we are fine.

Jan

-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux



More information about the Xenomai mailing list