core: kill nsec_to_timespec()
authorBartosz Golaszewski <bartekgola@gmail.com>
Sat, 24 Jun 2017 10:43:00 +0000 (12:43 +0200)
committerBartosz Golaszewski <bartekgola@gmail.com>
Thu, 6 Jul 2017 09:11:36 +0000 (11:11 +0200)
This function is tiny and only used in one place.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
src/lib/core.c

index 3c9ed217039061c857074d734718ac26bf52211a..c1230289e9c776bb562497e6a5ee4e6bbb7f56b7 100644 (file)
@@ -74,12 +74,6 @@ static bool is_unsigned_int(const char *str)
        return *str == '\0';
 }
 
-static void nsec_to_timespec(uint64_t nsec, struct timespec *ts)
-{
-       ts->tv_sec = nsec / 1000000000ULL;
-       ts->tv_nsec = (nsec % 1000000000ULL);
-}
-
 int gpiod_simple_get_value_multiple(const char *consumer, const char *device,
                                    const unsigned int *offsets, int *values,
                                    unsigned int num_lines, bool active_low)
@@ -881,7 +875,9 @@ int gpiod_line_event_read_fd(int fd, struct gpiod_line_event *event)
        event->event_type = evdata.id == GPIOEVENT_EVENT_RISING_EDGE
                                                ? GPIOD_EVENT_RISING_EDGE
                                                : GPIOD_EVENT_FALLING_EDGE;
-       nsec_to_timespec(evdata.timestamp, &event->ts);
+
+       event->ts.tv_sec = evdata.timestamp / 1000000000ULL;
+       event->ts.tv_nsec = evdata.timestamp % 1000000000ULL;
 
        return 0;
 }