* [PATCH] scsi: Remove usage of struct timeval
@ 2015-02-04 3:09 Tina Ruchandani
2015-02-04 14:56 ` Arnd Bergmann
0 siblings, 1 reply; 2+ messages in thread
From: Tina Ruchandani @ 2015-02-04 3:09 UTC (permalink / raw)
To: linux-scsi; +Cc: Arnd Bergmann, James E.J. Bottomley, Anil Ravindranath
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.
Signed-off-by: Tina Ruchandani <ruchandani.tina@gmail.com>
---
drivers/scsi/pmcraid.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
index 8c27b6a..98af06f 100644
--- a/drivers/scsi/pmcraid.c
+++ b/drivers/scsi/pmcraid.c
@@ -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;
- 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);
--
2.2.0.rc0.207.ga3a616c
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] scsi: Remove usage of struct timeval
2015-02-04 3:09 [PATCH] scsi: Remove usage of struct timeval Tina Ruchandani
@ 2015-02-04 14:56 ` Arnd Bergmann
0 siblings, 0 replies; 2+ messages in thread
From: Arnd Bergmann @ 2015-02-04 14:56 UTC (permalink / raw)
To: Tina Ruchandani; +Cc: linux-scsi, James E.J. Bottomley, Anil Ravindranath
On Wednesday 04 February 2015 08:39:54 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.
>
> Signed-off-by: Tina Ruchandani <ruchandani.tina@gmail.com>
The change you did looks correct, but I see two problems:
- The subject line should mention the name of the driver you
change, as you are not doing this for the entire scsi subsystem
at once.
> @@ -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;
>
> - 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);
It looks like a preexisting bug here, but it makes sense to fix
it at the same time and describe that change in the patch
changelog:
timestamp is declared as an __le64 type but gets set to a cpu-endian
value from tv.tv_sec or ktime_to_ms, which is wrong. The code indeed
gets the endianess right by copying the bytes individually, so I think
you should just use a u64 type here.
Arnd
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-02-04 14:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-04 3:09 [PATCH] scsi: Remove usage of struct timeval Tina Ruchandani
2015-02-04 14:56 ` 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.