32 bit systems using 'struct timeval' will break in the year 2038, so
we modify the code appropriately.

This patch replaces the use of struct timeval and do_gettimeofday()
with 64 bit ktime_get_seconds() since we only need to find elapsed
seconds.

stats_reset_time variable has been converted from a u32 to u64 type to
store the 64 bit value returned by ktime_get_seconds().

Signed-off-by: Amitoj Kaur Chawla <[email protected]>
---
 drivers/scsi/bfa/bfa_svc.c | 9 +++------
 drivers/scsi/bfa/bfa_svc.h | 2 +-
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/bfa/bfa_svc.c b/drivers/scsi/bfa/bfa_svc.c
index b3668e9..de18153 100644
--- a/drivers/scsi/bfa/bfa_svc.c
+++ b/drivers/scsi/bfa/bfa_svc.c
@@ -3081,7 +3081,6 @@ bfa_fcport_attach(struct bfa_s *bfa, void *bfad, struct 
bfa_iocfc_cfg_s *cfg,
        struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
        struct bfa_port_cfg_s *port_cfg = &fcport->cfg;
        struct bfa_fcport_ln_s *ln = &fcport->ln;
-       struct timeval tv;
 
        fcport->bfa = bfa;
        ln->fcport = fcport;
@@ -3094,8 +3093,7 @@ bfa_fcport_attach(struct bfa_s *bfa, void *bfad, struct 
bfa_iocfc_cfg_s *cfg,
        /*
         * initialize time stamp for stats reset
         */
-       do_gettimeofday(&tv);
-       fcport->stats_reset_time = tv.tv_sec;
+       fcport->stats_reset_time = ktime_get_seconds();
        fcport->stats_dma_ready = BFA_FALSE;
 
        /*
@@ -3347,9 +3345,8 @@ __bfa_cb_fcport_stats_get(void *cbarg, bfa_boolean_t 
complete)
        union bfa_fcport_stats_u *ret;
 
        if (complete) {
-               struct timeval tv;
+               u64 timestamp = ktime_get_seconds();
                if (fcport->stats_status == BFA_STATUS_OK)
-                       do_gettimeofday(&tv);
 
                list_for_each_safe(qe, qen, &fcport->stats_pending_q) {
                        bfa_q_deq(&fcport->stats_pending_q, &qe);
@@ -3364,7 +3361,7 @@ __bfa_cb_fcport_stats_get(void *cbarg, bfa_boolean_t 
complete)
                                        bfa_fcport_fcoe_stats_swap(&ret->fcoe,
                                                        &fcport->stats->fcoe);
                                        ret->fcoe.secs_reset =
-                                       tv.tv_sec - fcport->stats_reset_time;
+                                       timestamp - fcport->stats_reset_time;
                                }
                        }
                        bfa_cb_queue_status(fcport->bfa, &cb->hcb_qe,
diff --git a/drivers/scsi/bfa/bfa_svc.h b/drivers/scsi/bfa/bfa_svc.h
index ef07365..0c25ee3 100644
--- a/drivers/scsi/bfa/bfa_svc.h
+++ b/drivers/scsi/bfa/bfa_svc.h
@@ -504,7 +504,7 @@ struct bfa_fcport_s {
        struct list_head        stats_pending_q;
        struct list_head        statsclr_pending_q;
        bfa_boolean_t           stats_qfull;
-       u32             stats_reset_time; /*  stats reset time stamp */
+       u64             stats_reset_time; /*  stats reset time stamp */
        bfa_boolean_t           diag_busy; /*  diag busy status */
        bfa_boolean_t           beacon; /*  port beacon status */
        bfa_boolean_t           link_e2e_beacon; /*  link beacon status */
-- 
1.9.1

_______________________________________________
Y2038 mailing list
[email protected]
https://lists.linaro.org/mailman/listinfo/y2038

Reply via email to