public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] scsi: stex: Remove use of struct timeval
@ 2015-02-25  2:11 Tina Ruchandani
  2015-02-25 10:44 ` Arnd Bergmann
  0 siblings, 1 reply; 2+ messages in thread
From: Tina Ruchandani @ 2015-02-25  2:11 UTC (permalink / raw)
  To: linux-scsi; +Cc: Arnd Bergmann, James E.J. Bottomley

Function stex_gettime uses 'struct timeval' whose tv_sec value
will overflow on 32-bit systems in year 2038 and beyond. This patch
replaces the use of struct timeval and do_gettimeofday with
ktime_get_real_seconds, which returns a 64-bit seconds value.

Signed-off-by: Tina Ruchandani <ruchandani.tina@gmail.com>
--
Changes in v2:
- Change subject line to indicate that the patch is restricted to stex driver.
---
 drivers/scsi/stex.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c
index 98a62bc..40b6290 100644
--- a/drivers/scsi/stex.c
+++ b/drivers/scsi/stex.c
@@ -25,6 +25,7 @@
 #include <linux/types.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
+#include <linux/ktime.h>
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/byteorder.h>
@@ -364,10 +365,7 @@ MODULE_VERSION(ST_DRIVER_VERSION);
 
 static void stex_gettime(__le64 *time)
 {
-	struct timeval tv;
-
-	do_gettimeofday(&tv);
-	*time = cpu_to_le64(tv.tv_sec);
+	*time = cpu_to_le64(ktime_get_real_seconds());
 }
 
 static struct status_msg *stex_get_status(struct st_hba *hba)
-- 
2.2.0.rc0.207.ga3a616c


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

* Re: [PATCH v2] scsi: stex: Remove use of struct timeval
  2015-02-25  2:11 [PATCH v2] scsi: stex: Remove use of struct timeval Tina Ruchandani
@ 2015-02-25 10:44 ` Arnd Bergmann
  0 siblings, 0 replies; 2+ messages in thread
From: Arnd Bergmann @ 2015-02-25 10:44 UTC (permalink / raw)
  To: Tina Ruchandani; +Cc: linux-scsi, James E.J. Bottomley

On Wednesday 25 February 2015 07:41:36 Tina Ruchandani wrote:
> @@ -364,10 +365,7 @@ MODULE_VERSION(ST_DRIVER_VERSION);
>  
>  static void stex_gettime(__le64 *time)
>  {
> -       struct timeval tv;
> -
> -       do_gettimeofday(&tv);
> -       *time = cpu_to_le64(tv.tv_sec);
> +       *time = cpu_to_le64(ktime_get_real_seconds());
>  }
>  
>  static struct status_msg *stex_get_status(struct st_hba *hba)
> 

The patch looks correct to me, but upon second reading, I think it
would be nicer to eliminate the function entirely and open-code
the cpu_to_le64(ktime_get_real_seconds()) in the two callers.

	Arnd

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

end of thread, other threads:[~2015-02-25 10:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-25  2:11 [PATCH v2] scsi: stex: Remove use of struct timeval Tina Ruchandani
2015-02-25 10:44 ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox