* [PATCH] iio: Convert to use timespec64 variables to get a time stamp
@ 2018-06-04 9:07 Baolin Wang
2018-06-04 9:17 ` Arnd Bergmann
0 siblings, 1 reply; 3+ messages in thread
From: Baolin Wang @ 2018-06-04 9:07 UTC (permalink / raw)
To: jic23
Cc: baolin.wang, knaack.h, lars, pmeerw, arnd, broonie, linux-iio,
linux-kernel
The struct timespec is not y2038 safe on 32bit machines, thus this patch
converts to use timespec64 variables and related APIs to get a time stamp
for events etc.
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
---
drivers/iio/industrialio-core.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index 19bdf3d..8d2b93b 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -207,35 +207,35 @@ 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)
{
- struct timespec tp;
+ struct timespec64 tp;
switch (iio_device_get_clock(indio_dev)) {
case CLOCK_REALTIME:
- ktime_get_real_ts(&tp);
+ ktime_get_real_ts64(&tp);
break;
case CLOCK_MONOTONIC:
- ktime_get_ts(&tp);
+ ktime_get_ts64(&tp);
break;
case CLOCK_MONOTONIC_RAW:
- getrawmonotonic(&tp);
+ getrawmonotonic64(&tp);
break;
case CLOCK_REALTIME_COARSE:
- tp = current_kernel_time();
+ tp = current_kernel_time64();
break;
case CLOCK_MONOTONIC_COARSE:
- tp = get_monotonic_coarse();
+ tp = get_monotonic_coarse64();
break;
case CLOCK_BOOTTIME:
- get_monotonic_boottime(&tp);
+ get_monotonic_boottime64(&tp);
break;
case CLOCK_TAI:
- timekeeping_clocktai(&tp);
+ timekeeping_clocktai64(&tp);
break;
default:
BUG();
}
- return timespec_to_ns(&tp);
+ return timespec64_to_ns(&tp);
}
EXPORT_SYMBOL(iio_get_time_ns);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] iio: Convert to use timespec64 variables to get a time stamp
2018-06-04 9:07 [PATCH] iio: Convert to use timespec64 variables to get a time stamp Baolin Wang
@ 2018-06-04 9:17 ` Arnd Bergmann
2018-06-04 9:42 ` Baolin Wang
0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2018-06-04 9:17 UTC (permalink / raw)
To: Baolin Wang
Cc: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
Peter Meerwald-Stadler, Mark Brown, linux-iio,
Linux Kernel Mailing List, Thomas Gleixner
On Mon, Jun 4, 2018 at 11:07 AM, Baolin Wang <baolin.wang@linaro.org> wrote:
> The struct timespec is not y2038 safe on 32bit machines, thus this patch
> converts to use timespec64 variables and related APIs to get a time stamp
> for events etc.
>
> Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Hi Baolin,
I was waiting with this for the new header file cleanup to land. Thomas
merged that one recently, so now we should be able to do this more nicely:
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index 19bdf3d2962a..fcbe92c34a3d 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -207,35 +207,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)
{
- struct timespec tp;
+ struct timespec64 tp;
switch (iio_device_get_clock(indio_dev)) {
case CLOCK_REALTIME:
- ktime_get_real_ts(&tp);
- break;
+ return ktime_get_real_ns();
case CLOCK_MONOTONIC:
- ktime_get_ts(&tp);
- break;
+ return ktime_get_ns();
case CLOCK_MONOTONIC_RAW:
- getrawmonotonic(&tp);
- break;
+ return ktime_get_raw_ns();
case CLOCK_REALTIME_COARSE:
- tp = current_kernel_time();
- break;
+ return ktime_to_ns(ktime_get_coarse_real());
case CLOCK_MONOTONIC_COARSE:
- tp = get_monotonic_coarse();
- break;
+ ktime_get_coarse_ts64(&tp);
+ return timespec64_to_ns(&tp);
case CLOCK_BOOTTIME:
- get_monotonic_boottime(&tp);
- break;
+ return ktime_get_boot_ns();
case CLOCK_TAI:
- timekeeping_clocktai(&tp);
- break;
+ return ktime_get_tai_ns();
default:
BUG();
}
-
- return timespec_to_ns(&tp);
}
EXPORT_SYMBOL(iio_get_time_ns);
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] iio: Convert to use timespec64 variables to get a time stamp
2018-06-04 9:17 ` Arnd Bergmann
@ 2018-06-04 9:42 ` Baolin Wang
0 siblings, 0 replies; 3+ messages in thread
From: Baolin Wang @ 2018-06-04 9:42 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
Peter Meerwald-Stadler, Mark Brown, linux-iio,
Linux Kernel Mailing List, Thomas Gleixner
Hi Arnd,
On 4 June 2018 at 17:17, Arnd Bergmann <arnd@arndb.de> wrote:
> On Mon, Jun 4, 2018 at 11:07 AM, Baolin Wang <baolin.wang@linaro.org> wrote:
>> The struct timespec is not y2038 safe on 32bit machines, thus this patch
>> converts to use timespec64 variables and related APIs to get a time stamp
>> for events etc.
>>
>> Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
>
> Hi Baolin,
>
> I was waiting with this for the new header file cleanup to land. Thomas
> merged that one recently, so now we should be able to do this more nicely:
Thanks to point this out. Yes, let's use your nice patch.
>
> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
> index 19bdf3d2962a..fcbe92c34a3d 100644
> --- a/drivers/iio/industrialio-core.c
> +++ b/drivers/iio/industrialio-core.c
> @@ -207,35 +207,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)
> {
> - struct timespec tp;
> + struct timespec64 tp;
>
> switch (iio_device_get_clock(indio_dev)) {
> case CLOCK_REALTIME:
> - ktime_get_real_ts(&tp);
> - break;
> + return ktime_get_real_ns();
> case CLOCK_MONOTONIC:
> - ktime_get_ts(&tp);
> - break;
> + return ktime_get_ns();
> case CLOCK_MONOTONIC_RAW:
> - getrawmonotonic(&tp);
> - break;
> + return ktime_get_raw_ns();
> case CLOCK_REALTIME_COARSE:
> - tp = current_kernel_time();
> - break;
> + return ktime_to_ns(ktime_get_coarse_real());
> case CLOCK_MONOTONIC_COARSE:
> - tp = get_monotonic_coarse();
> - break;
> + ktime_get_coarse_ts64(&tp);
> + return timespec64_to_ns(&tp);
> case CLOCK_BOOTTIME:
> - get_monotonic_boottime(&tp);
> - break;
> + return ktime_get_boot_ns();
> case CLOCK_TAI:
> - timekeeping_clocktai(&tp);
> - break;
> + return ktime_get_tai_ns();
> default:
> BUG();
> }
> -
> - return timespec_to_ns(&tp);
> }
> EXPORT_SYMBOL(iio_get_time_ns);
--
Baolin.wang
Best Regards
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-06-04 9:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-04 9:07 [PATCH] iio: Convert to use timespec64 variables to get a time stamp Baolin Wang
2018-06-04 9:17 ` Arnd Bergmann
2018-06-04 9:42 ` Baolin Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).