Skip to contentSkip to conversation

block: sx8: Remove 'struct timeval'

PATCH In review Amitoj Kaur Chawla 2 participants 2 messages Nov 1, 2015 – Nov 4, 2015 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block: sx8: Remove 'struct timeval'

32 bit systems using 'struct timeval' will overflow in the year 2038, so we modify the code appropriately.

This patch replaces the use of struct timeval and do_gettimeofday() with ktime_get_real_seconds() which returns a 64 bit seconds value.

---
 drivers/block/sx8.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/block/sx8.c +2 -5
index 59c91d4..cf87d9d 100644
@@ -361,7 +361,7 @@ struct carm_msg_sync_time {
 	u16 reserved1;
 	__le32 handle;
 	u32 reserved2;
-	__le32 timestamp;
+	__le64 timestamp;
 }  __attribute__((packed));
 
 struct carm_msg_get_fw_ver {
@@ -671,16 +671,13 @@ static int carm_send_special (struct carm_host *host, carm_sspc_t func)
 static unsigned int carm_fill_sync_time(struct carm_host *host,
 					unsigned int idx, void *mem)
 {
-	struct timeval tv;
 	struct carm_msg_sync_time *st = mem;
 
-	do_gettimeofday(&tv);
-
 	memset(st, 0, sizeof(*st));
 	st->type	= CARM_MSG_MISC;
 	st->subtype	= MISC_SET_TIME;
 	st->handle	= cpu_to_le32(TAG_ENCODE(idx));
-	st->timestamp	= cpu_to_le32(tv.tv_sec);
+	st->timestamp	= cpu_to_le64(ktime_get_real_seconds());
 
 	return sizeof(struct carm_msg_sync_time);
 }
Signature · 1 line
1.9.1
#1 lore raw
Quoted 16 lines · On Sunday 01 November 2015 16:09:18 Amitoj Kaur Chawla wrote:

32 bit systems using 'struct timeval' will overflow in the year 2038, so we modify the code appropriately.

This patch replaces the use of struct timeval and do_gettimeofday() with ktime_get_real_seconds() which returns a 64 bit seconds value.

---
 drivers/block/sx8.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/block/sx8.c +0 -0
index 59c91d4..cf87d9d 100644

drivers/block/sx8.c struct carm_msg_sync_time { · line 365

Quoted 6 lines
drivers/block/sx8.c +1 -1
@@ -361,7 +361,7 @@ struct carm_msg_sync_time {
 	u16 reserved1;
 	__le32 handle;
 	u32 reserved2;
-	__le32 timestamp;
+	__le64 timestamp;
 }  __attribute__((packed));

This data structure is shared with the firmware, which means you cannot change the layout. Better truncate to 32 bit and add a comment about this breaking in 2106.

Arnd