Skip to contentSkip to conversation

bfa: Remove use of struct timeval

PATCH Superseded Tina Ruchandani 2 participants 2 messages Feb 4, 2015

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bfa: Remove use 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 ktime_get_real_seconds() which returns 64-bit wall-clock seconds.

---
 drivers/scsi/bfa/bfa_svc.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/scsi/bfa/bfa_svc.c +3 -9
index 625225f..5554461 100644
@@ -14,6 +14,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * General Public License for more details.
  */
+#include <linux/ktime.h>
 
 #include "bfad_drv.h"
 #include "bfad_im.h"
@@ -303,16 +304,9 @@ plkd_validate_logrec(struct bfa_plog_rec_s *pl_rec)
 	return 0;
 }
 
-static u64
-bfa_get_log_time(void)
+static u64 bfa_get_log_time(void)
 {
-	u64 system_time = 0;
-	struct timeval tv;
-	do_gettimeofday(&tv);
-
-	/* We are interested in seconds only. */
-	system_time = tv.tv_sec;
-	return system_time;
+	return ktime_get_real_seconds();
 }
 
 static void
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#1 lore raw
Quoted 7 lines · On Wednesday 04 February 2015 08:42:03 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 ktime_get_real_seconds() which returns 64-bit wall-clock seconds.

The patch is correct, but you can do it better by removing the bfa_get_log_time() function completely and changing the four callers to call ktime_get_real_seconds() directly.

The subject line could be improved too: you don't remember all uses of timeval in this patch, but only one of them. When you do the first change, a good subject line would be:

[SCSI] bfa: replace bfa_get_log_time with ktime_get_real_seconds

Arnd