Commit 45e7f5d2 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Jonathan Cameron

iio: use timespec64 based interfaces for iio_get_time_ns()

We have replacements for all the deprecated timespec based interfaces now,
so this can finally convert iio_get_time_ns() to consistently use the
nanosecond or timespec64 based interfaces instead, avoiding the y2038
overflow.
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 5f1d651f
...@@ -208,35 +208,27 @@ static int iio_device_set_clock(struct iio_dev *indio_dev, clockid_t clock_id) ...@@ -208,35 +208,27 @@ static int iio_device_set_clock(struct iio_dev *indio_dev, clockid_t clock_id)
*/ */
s64 iio_get_time_ns(const struct iio_dev *indio_dev) s64 iio_get_time_ns(const struct iio_dev *indio_dev)
{ {
struct timespec tp; struct timespec64 tp;
switch (iio_device_get_clock(indio_dev)) { switch (iio_device_get_clock(indio_dev)) {
case CLOCK_REALTIME: case CLOCK_REALTIME:
ktime_get_real_ts(&tp); return ktime_get_real_ns();
break;
case CLOCK_MONOTONIC: case CLOCK_MONOTONIC:
ktime_get_ts(&tp); return ktime_get_ns();
break;
case CLOCK_MONOTONIC_RAW: case CLOCK_MONOTONIC_RAW:
getrawmonotonic(&tp); return ktime_get_raw_ns();
break;
case CLOCK_REALTIME_COARSE: case CLOCK_REALTIME_COARSE:
tp = current_kernel_time(); return ktime_to_ns(ktime_get_coarse_real());
break;
case CLOCK_MONOTONIC_COARSE: case CLOCK_MONOTONIC_COARSE:
tp = get_monotonic_coarse(); ktime_get_coarse_ts64(&tp);
break; return timespec64_to_ns(&tp);
case CLOCK_BOOTTIME: case CLOCK_BOOTTIME:
get_monotonic_boottime(&tp); return ktime_get_boot_ns();
break;
case CLOCK_TAI: case CLOCK_TAI:
timekeeping_clocktai(&tp); return ktime_get_tai_ns();
break;
default: default:
BUG(); BUG();
} }
return timespec_to_ns(&tp);
} }
EXPORT_SYMBOL(iio_get_time_ns); EXPORT_SYMBOL(iio_get_time_ns);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment