lkml.org 
[lkml]   [2020]   [Oct]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/3] gpiolib: cdev: allow edge event timestamps to be configured as REALTIME
On Wed, Oct 14, 2020 at 02:27:38PM +0800, Kent Gibson wrote:
> Using CLOCK_REALTIME as the source for event timestamps is crucial for
> some specific applications, particularly those requiring timetamps
> relative to a PTP clock, so provide an option to switch the event
> timestamp source from the default CLOCK_MONOTONIC to CLOCK_REALTIME.
>
[snip]
>
> static void linereq_put_event(struct linereq *lr,
> @@ -535,6 +536,14 @@ static void linereq_put_event(struct linereq *lr,
> pr_debug_ratelimited("event FIFO is full - event dropped\n");
> }
>
> +static unsigned long line_event_timestamp(struct line *line)
> +{
> + if (test_bit(FLAG_EVENT_CLOCK_REALTIME, &line->desc->flags))
> + return ktime_get_real_ns();
> +
> + return ktime_get_ns();
> +
> +}

One minor hitch - that should be returning u64, not unsigned long,
or the time gets reduced to 32bit on 32bit platforms.

It's getting late though, so I'll send out an update tomorrow.

Cheers,
Kent.

\
 
 \ /
  Last update: 2020-10-14 18:18    [W:0.073 / U:0.276 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site