Skip to contentSkip to conversation

scsi: pmcraid: Remove usage of struct timeval

PATCH In review Tina Ruchandani 2 participants 2 messages Feb 25, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 scsi: pmcraid: Remove usage of struct timeval

struct timeval will have its tv_sec field overflow on 32-bit systems in year 2038 and beyond. This patch removes the usage of struct timeval and instead uses 64-bit ktime_t to get the current milliseconds to populate pmcraid_timestamp_data.

--
Changes in v2:
- Change subject line to indicate that change is local to pmcraid driver and doesn't cover all of scsi subsystem.
- Use u64 instead of __l64 for timestamp, as it being set to a cpu-endian value.

---
 drivers/scsi/pmcraid.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/scsi/pmcraid.c +3 -4
index 8c27b6a..60ce3c9 100644
@@ -25,6 +25,7 @@
 #include <linux/fs.h>
 #include <linux/init.h>
 #include <linux/types.h>
+#include <linux/ktime.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/ioport.h>
@@ -5569,11 +5570,9 @@ static void pmcraid_set_timestamp(struct pmcraid_cmd *cmd)
 	__be32 time_stamp_len = cpu_to_be32(PMCRAID_TIMESTAMP_LEN);
 	struct pmcraid_ioadl_desc *ioadl = ioarcb->add_data.u.ioadl;
 
-	struct timeval tv;
-	__le64 timestamp;
+	u64 timestamp;
 
-	do_gettimeofday(&tv);
-	timestamp = tv.tv_sec * 1000;
+	timestamp = ktime_to_ms(ktime_get_real());
 
 	pinstance->timestamp_data->timestamp[0] = (__u8)(timestamp);
 	pinstance->timestamp_data->timestamp[1] = (__u8)((timestamp) >> 8);
Signature · 1 line
2.2.0.rc0.207.ga3a616c
Reviewed-by on v2 1/1
#1 lore raw
Quoted 7 lines · On Wednesday 25 February 2015 07:49:21 Tina Ruchandani wrote:

struct timeval will have its tv_sec field overflow on 32-bit systems in year 2038 and beyond. This patch removes the usage of struct timeval and instead uses 64-bit ktime_t to get the current milliseconds to populate pmcraid_timestamp_data.

I notice that this patch also increases the accuracy of the timestamp from seconds to milliseconds, where the original code ignores the sub-second portion of the timeval.

Doing this will make the the function a little slower, but I have verified that it is only called for probe, reset and config-change, all of which are not timing critical.

Arnd