Commit 525b164f authored by Vaibhav Gupta's avatar Vaibhav Gupta

kernel: timer: 'struct timespec' (32 bit) and related interfaces are deprecated

In linux-v5.6 release:

'struct timespec' got unsupported for in-kernel use at
	commit c766d1472c70d25ad475cf56042af1652e792b23 ("y2038: hide
	timeval/timespec/itimerval/itimerspec types")

And accordingly, the 32 bit interfaces were also removed at
	commit 412c53a680a97cb1ae2c0ab60230e193bee86387 ("y2038: remove
	unused time32 interfaces")

Thus, use 'struct timespec64' and related interfaces for 5.10.65 kernel.
Signed-off-by: 's avatarVaibhav Gupta <vaibhav.gupta@cern.ch>
parent 14b36222
......@@ -401,10 +401,17 @@ extern int fd_dump_mcp(struct fd_dev *fd);
/* Functions exported by time.c */
extern int fd_time_init(struct fd_dev *fd);
extern void fd_time_exit(struct fd_dev *fd);
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0)
extern int fd_time_set(struct fd_dev *fd, struct fd_time *t,
struct timespec *ts);
extern int fd_time_get(struct fd_dev *fd, struct fd_time *t,
struct timespec *ts);
#else
extern int fd_time_set(struct fd_dev *fd, struct fd_time *t,
struct timespec64 *ts);
extern int fd_time_get(struct fd_dev *fd, struct fd_time *t,
struct timespec64 *ts);
#endif
/* Functions exported by fd-zio.c */
extern int fd_zio_register(void);
......
......@@ -18,11 +18,18 @@
#include "hw/fd_main_regs.h"
/* If fd_time is not null, use it. if ts is not null, use it, else current */
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0)
int fd_time_set(struct fd_dev *fd, struct fd_time *t, struct timespec *ts)
{
struct timespec localts;
#else
int fd_time_set(struct fd_dev *fd, struct fd_time *t, struct timespec64 *ts)
{
struct timespec64 localts;
#endif
uint32_t tcr, gcr;
unsigned long flags;
struct timespec localts;
spin_lock_irqsave(&fd->lock, flags);
......@@ -36,7 +43,11 @@ int fd_time_set(struct fd_dev *fd, struct fd_time *t, struct timespec *ts)
if (!ts) {
/* no caller-provided time: use Linux timer */
ts = &localts;
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0)
getnstimeofday(ts);
#else
ktime_get_ts64(ts);
#endif
}
fd_writel(fd, GET_HI32(ts->tv_sec), FD_REG_TM_SECH);
fd_writel(fd, (int32_t)ts->tv_sec, FD_REG_TM_SECL);
......@@ -52,7 +63,11 @@ int fd_time_set(struct fd_dev *fd, struct fd_time *t, struct timespec *ts)
}
/* If fd_time is not null, use it. Otherwise use ts */
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0)
int fd_time_get(struct fd_dev *fd, struct fd_time *t, struct timespec *ts)
#else
int fd_time_get(struct fd_dev *fd, struct fd_time *t, struct timespec64 *ts)
#endif
{
uint32_t tcr, h, l, c;
unsigned long flags;
......@@ -78,7 +93,11 @@ int fd_time_get(struct fd_dev *fd, struct fd_time *t, struct timespec *ts)
int fd_time_init(struct fd_dev *fd)
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0)
struct timespec ts = {0,0};
#else
struct timespec64 ts = {0,0};
#endif
/* Set the time to zero, so internal stuff resyncs */
return fd_time_set(fd, NULL, &ts);
......
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