All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mpt2sas: Remove usage of 'struct timeval'
@ 2015-02-04  5:58 Tina Ruchandani
  2015-02-04 14:49 ` Arnd Bergmann
  0 siblings, 1 reply; 2+ messages in thread
From: Tina Ruchandani @ 2015-02-04  5:58 UTC (permalink / raw)
  To: linux-scsi
  Cc: Arnd Bergmann, James E.J. Bottomley, Abhijit Mahajan,
	Praveen Krishnamoorthy, Nagalakshmi Nandigama

'struct timeval' will have its tv_sec value overflow on 32-bit systems
in year 2038 and beyond. This patch replaces the use of struct timeval
for computing mpi_request.TimeStamp, and instead uses ktime_t which provides
64-bit seconds value. The timestamp computed remains unaffected (milliseconds
since Unix epoch).

Signed-off-by: Tina Ruchandani <ruchandani.tina@gmail.com>
---
 drivers/scsi/mpt2sas/mpt2sas_base.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c b/drivers/scsi/mpt2sas/mpt2sas_base.c
index 58e4521..6d80477 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_base.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_base.c
@@ -57,6 +57,7 @@
 #include <linux/sort.h>
 #include <linux/io.h>
 #include <linux/time.h>
+#include <linux/ktime.h>
 #include <linux/kthread.h>
 #include <linux/aer.h>
 
@@ -3616,7 +3617,7 @@ _base_send_ioc_init(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
 	Mpi2IOCInitRequest_t mpi_request;
 	Mpi2IOCInitReply_t mpi_reply;
 	int i, r = 0;
-	struct timeval current_time;
+	ktime_t current_time;
 	u16 ioc_status;
 	u32 reply_post_free_array_sz = 0;
 	Mpi2IOCInitRDPQArrayEntry *reply_post_free_array = NULL;
@@ -3678,9 +3679,8 @@ _base_send_ioc_init(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
 	/* This time stamp specifies number of milliseconds
 	 * since epoch ~ midnight January 1, 1970.
 	 */
-	do_gettimeofday(&current_time);
-	mpi_request.TimeStamp = cpu_to_le64((u64)current_time.tv_sec * 1000 +
-	    (current_time.tv_usec / 1000));
+	current_time = ktime_get_real();
+	mpi_request.TimeStamp = cpu_to_le64(ktime_to_ms(current_time));
 
 	if (ioc->logging_level & MPT_DEBUG_INIT) {
 		__le32 *mfp;
-- 
2.2.0.rc0.207.ga3a616c


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mpt2sas: Remove usage of 'struct timeval'
  2015-02-04  5:58 [PATCH] mpt2sas: Remove usage of 'struct timeval' Tina Ruchandani
@ 2015-02-04 14:49 ` Arnd Bergmann
  0 siblings, 0 replies; 2+ messages in thread
From: Arnd Bergmann @ 2015-02-04 14:49 UTC (permalink / raw)
  To: Tina Ruchandani
  Cc: linux-scsi, James E.J. Bottomley, Abhijit Mahajan,
	Praveen Krishnamoorthy, Nagalakshmi Nandigama

On Wednesday 04 February 2015 11:28:35 Tina Ruchandani wrote:
> 'struct timeval' will have its tv_sec value overflow on 32-bit systems
> in year 2038 and beyond. This patch replaces the use of struct timeval
> for computing mpi_request.TimeStamp, and instead uses ktime_t which provides
> 64-bit seconds value. The timestamp computed remains unaffected (milliseconds
> since Unix epoch).
> 
> Signed-off-by: Tina Ruchandani <ruchandani.tina@gmail.com>
> 

Looks good to me,

Acked-by: Arnd Bergmann <arnd@arndb.de>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-02-04 14:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-04  5:58 [PATCH] mpt2sas: Remove usage of 'struct timeval' Tina Ruchandani
2015-02-04 14:49 ` Arnd Bergmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.