Re: [PATCH 1/3] gpiolib: cdev: allow edge event timestamps to be configured as REALTIME

From: Kent Gibson
Date: Wed Oct 14 2020 - 12:17:35 EST


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.