提交 8182503d 编写于 作者: S Shraddha Barke 提交者: Jens Axboe

block: sx8.c: Replace timeval with ktime_t

32-bit systems using 'struct timeval' will break in the year 2038,
in order to avoid that replace the code with more appropriate types.
This patch replaces timeval with 64 bit ktime_t which is y2038 safe.
Since st->timestamp is only interested in seconds, directly using
time64_t here. Function ktime_get_seconds is used since it uses
monotonic instead of real time and thus will not cause overflow.
Signed-off-by: NShraddha Barke <shraddha.6596@gmail.com>
Signed-off-by: NJens Axboe <axboe@fb.com>
上级 8011e249
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/time.h> #include <linux/ktime.h>
#include <linux/hdreg.h> #include <linux/hdreg.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/completion.h> #include <linux/completion.h>
...@@ -671,16 +671,15 @@ static int carm_send_special (struct carm_host *host, carm_sspc_t func) ...@@ -671,16 +671,15 @@ static int carm_send_special (struct carm_host *host, carm_sspc_t func)
static unsigned int carm_fill_sync_time(struct carm_host *host, static unsigned int carm_fill_sync_time(struct carm_host *host,
unsigned int idx, void *mem) unsigned int idx, void *mem)
{ {
struct timeval tv;
struct carm_msg_sync_time *st = mem; struct carm_msg_sync_time *st = mem;
do_gettimeofday(&tv); time64_t tv = ktime_get_seconds();
memset(st, 0, sizeof(*st)); memset(st, 0, sizeof(*st));
st->type = CARM_MSG_MISC; st->type = CARM_MSG_MISC;
st->subtype = MISC_SET_TIME; st->subtype = MISC_SET_TIME;
st->handle = cpu_to_le32(TAG_ENCODE(idx)); st->handle = cpu_to_le32(TAG_ENCODE(idx));
st->timestamp = cpu_to_le32(tv.tv_sec); st->timestamp = cpu_to_le32(tv);
return sizeof(struct carm_msg_sync_time); return sizeof(struct carm_msg_sync_time);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册