All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kent Gibson <warthog618@gmail.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	linux-gpio@vger.kernel.org
Subject: Re: [libgpiod v2][PATCH] API: suffix the time unit to get_timestamp functions
Date: Wed, 23 Mar 2022 00:36:53 +0800	[thread overview]
Message-ID: <20220322163653.GA179380@sol> (raw)
In-Reply-To: <20220322130636.318032-1-brgl@bgdev.pl>

On Tue, Mar 22, 2022 at 02:06:36PM +0100, Bartosz Golaszewski wrote:
> In order to make it clear what unit we're using - add the _ns suffix
> to timestamp getters for both the edge and info events.
> 

Makes sense.

A couple of minor tweaks below, but assuming those:

Signed-off-by: Kent Gibson <warthog618@gmail.com>

> Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
> ---
>  include/gpiod.h          | 4 ++--
>  lib/edge-event.c         | 2 +-
>  lib/info-event.c         | 2 +-
>  tests/tests-edge-event.c | 4 ++--
>  tests/tests-info-event.c | 6 +++---
>  tools/gpiomon.c          | 2 +-
>  6 files changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/include/gpiod.h b/include/gpiod.h
> index eaf6334..c605da8 100644
> --- a/include/gpiod.h
> +++ b/include/gpiod.h
> @@ -493,7 +493,7 @@ int gpiod_info_event_get_event_type(struct gpiod_info_event *event);
>   * @param event Line status watch event.
>   * @return Timestamp in nanoseconds, read from the monotonic clock.
>   */
> -uint64_t gpiod_info_event_get_timestamp(struct gpiod_info_event *event);
> +uint64_t gpiod_info_event_get_timestamp_ns(struct gpiod_info_event *event);
>  
>  /**
>   * @brief Get the snapshot of line-info associated with the event.
> @@ -1401,7 +1401,7 @@ int gpiod_edge_event_get_event_type(struct gpiod_edge_event *event);
>   * @note The source clock for the timestamp depends on the event_clock
>   *	 setting for the line.
>   */
> -uint64_t gpiod_edge_event_get_timestamp(struct gpiod_edge_event *event);
> +uint64_t gpiod_edge_event_get_timestamp_ns(struct gpiod_edge_event *event);
>  
>  /**
>   * @brief Get the offset of the line which triggered the event.
> diff --git a/lib/edge-event.c b/lib/edge-event.c
> index 661754e..48a0f95 100644
> --- a/lib/edge-event.c
> +++ b/lib/edge-event.c
> @@ -55,7 +55,7 @@ GPIOD_API int gpiod_edge_event_get_event_type(struct gpiod_edge_event *event)
>  }
>  
>  GPIOD_API uint64_t
> -gpiod_edge_event_get_timestamp(struct gpiod_edge_event *event)
> +gpiod_edge_event_get_timestamp_ns(struct gpiod_edge_event *event)
>  {
>  	return event->timestamp;
>  }

Shouldn't that field be timestamp_ns?

> diff --git a/lib/info-event.c b/lib/info-event.c
> index 4abed57..73a3d6d 100644
> --- a/lib/info-event.c
> +++ b/lib/info-event.c
> @@ -67,7 +67,7 @@ GPIOD_API int gpiod_info_event_get_event_type(struct gpiod_info_event *event)
>  }
>  
>  GPIOD_API uint64_t
> -gpiod_info_event_get_timestamp(struct gpiod_info_event *event)
> +gpiod_info_event_get_timestamp_ns(struct gpiod_info_event *event)
>  {
>  	return event->timestamp;
>  }

Ditto.

> diff --git a/tests/tests-edge-event.c b/tests/tests-edge-event.c
> index 28502a8..306383f 100644
> --- a/tests/tests-edge-event.c
> +++ b/tests/tests-edge-event.c
> @@ -145,7 +145,7 @@ GPIOD_TEST_CASE(read_both_events)
>  	g_assert_cmpint(gpiod_edge_event_get_event_type(event),
>  			==, GPIOD_EDGE_EVENT_RISING_EDGE);
>  	g_assert_cmpuint(gpiod_edge_event_get_line_offset(event), ==, 2);
> -	ts_rising = gpiod_edge_event_get_timestamp(event);
> +	ts_rising = gpiod_edge_event_get_timestamp_ns(event);
>  
>  	/* Second event. */
>  
> @@ -165,7 +165,7 @@ GPIOD_TEST_CASE(read_both_events)
>  	g_assert_cmpint(gpiod_edge_event_get_event_type(event),
>  			==, GPIOD_EDGE_EVENT_FALLING_EDGE);
>  	g_assert_cmpuint(gpiod_edge_event_get_line_offset(event), ==, 2);
> -	ts_falling = gpiod_edge_event_get_timestamp(event);
> +	ts_falling = gpiod_edge_event_get_timestamp_ns(event);
>  
>  	g_thread_join(thread);
>  
> diff --git a/tests/tests-info-event.c b/tests/tests-info-event.c
> index 0640d66..3f18784 100644
> --- a/tests/tests-info-event.c
> +++ b/tests/tests-info-event.c
> @@ -184,9 +184,9 @@ GPIOD_TEST_CASE(request_reconfigure_release_events)
>  
>  	g_thread_join(thread);
>  
> -	request_ts = gpiod_info_event_get_timestamp(request_event);
> -	reconfigure_ts = gpiod_info_event_get_timestamp(reconfigure_event);
> -	release_ts = gpiod_info_event_get_timestamp(release_event);
> +	request_ts = gpiod_info_event_get_timestamp_ns(request_event);
> +	reconfigure_ts = gpiod_info_event_get_timestamp_ns(reconfigure_event);
> +	release_ts = gpiod_info_event_get_timestamp_ns(release_event);
>  
>  	g_assert_cmpuint(request_ts, <, reconfigure_ts);
>  	g_assert_cmpuint(reconfigure_ts, <, release_ts);
> diff --git a/tools/gpiomon.c b/tools/gpiomon.c
> index 4769e62..f6a0dba 100644
> --- a/tools/gpiomon.c
> +++ b/tools/gpiomon.c
> @@ -299,7 +299,7 @@ int main(int argc, char **argv)
>  
>  			handle_event(gpiod_edge_event_get_line_offset(event),
>  				     gpiod_edge_event_get_event_type(event),
> -				     gpiod_edge_event_get_timestamp(event),
> +				     gpiod_edge_event_get_timestamp_ns(event),
>  				     &ctx);
>  
>  			events_done++;
> -- 
> 2.30.1
> 

      reply	other threads:[~2022-03-22 16:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-22 13:06 [libgpiod v2][PATCH] API: suffix the time unit to get_timestamp functions Bartosz Golaszewski
2022-03-22 16:36 ` Kent Gibson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220322163653.GA179380@sol \
    --to=warthog618@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=brgl@bgdev.pl \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.