Skip to contentSkip to conversation

bfa: Replace bfa_get_log_time()

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 bfa: Replace bfa_get_log_time()

struct timeval will have its tv_sec field overflow on 32-bit systems in year 2038 and beyond. This patch removes bfa_get_log_time which uses struct timeval, and instead replaces calls to it with calls to ktime_get_real_seconds() which returns 64-bit wall-clock seconds.

--
Changes in v2:
- Removed call to bfa_get_log_time entirely, instead of retaining it and making it call ktime_get_real_seconds internally.
- Made subject line more clear.

---
 drivers/scsi/bfa/bfa_svc.c | 21 +++++----------------
 1 file changed, 5 insertions(+), 16 deletions(-)
drivers/scsi/bfa/bfa_svc.c +5 -16
index 625225f..dd7cc36 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,18 +304,6 @@ plkd_validate_logrec(struct bfa_plog_rec_s *pl_rec)
 	return 0;
 }
 
-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;
-}
-
 static void
 bfa_plog_add(struct bfa_plog_s *plog, struct bfa_plog_rec_s *pl_rec)
 {
@@ -335,7 +324,7 @@ bfa_plog_add(struct bfa_plog_s *plog, struct bfa_plog_rec_s *pl_rec)
 
 	memcpy(pl_recp, pl_rec, sizeof(struct bfa_plog_rec_s));
 
-	pl_recp->tv = bfa_get_log_time();
+	pl_recp->tv = ktime_get_real_seconds();
 	BFA_PL_LOG_REC_INCR(plog->tail);
 
 	if (plog->head == plog->tail)
@@ -6278,7 +6267,7 @@ bfa_fcdiag_lb_is_running(struct bfa_s *bfa)
  *	D-port
  */
 #define bfa_dport_result_start(__dport, __mode) do {			\
-		(__dport)->result.start_time = bfa_get_log_time();	\
+		(__dport)->result.start_time = ktime_get_real_seconds();\
 		(__dport)->result.status = DPORT_TEST_ST_INPRG;		\
 		(__dport)->result.mode = (__mode);			\
 		(__dport)->result.rp_pwwn = (__dport)->rp_pwwn;		\
@@ -6717,7 +6706,7 @@ bfa_dport_scn(struct bfa_dport_s *dport, struct bfi_diag_dport_scn_s *msg)
 
 	switch (dport->i2hmsg.scn.state) {
 	case BFI_DPORT_SCN_TESTCOMP:
-		dport->result.end_time = bfa_get_log_time();
+		dport->result.end_time = ktime_get_real_seconds();
 		bfa_trc(dport->bfa, dport->result.end_time);
 
 		dport->result.status = msg->info.testcomp.status;
@@ -6764,7 +6753,7 @@ bfa_dport_scn(struct bfa_dport_s *dport, struct bfi_diag_dport_scn_s *msg)
 	case BFI_DPORT_SCN_SUBTESTSTART:
 		subtesttype = msg->info.teststart.type;
 		dport->result.subtest[subtesttype].start_time =
-			bfa_get_log_time();
+			ktime_get_real_seconds();
 		dport->result.subtest[subtesttype].status =
 			DPORT_TEST_ST_INPRG;
 
Signature · 1 line
2.2.0.rc0.207.ga3a616c
Reviewed-by on v2 1/1
#1 lore raw
Quoted 6 lines · On Wednesday 25 February 2015 07:44:39 Tina Ruchandani wrote:

struct timeval will have its tv_sec field overflow on 32-bit systems in year 2038 and beyond. This patch removes bfa_get_log_time which uses struct timeval, and instead replaces calls to it with calls to ktime_get_real_seconds() which returns 64-bit wall-clock seconds.

Quoted 7 lines

--
Changes in v2:
- Removed call to bfa_get_log_time entirely, instead of retaining it and making it call ktime_get_real_seconds internally.
- Made subject line more clear.

Nice!