Skip to contentSkip to conversation

scsi: bfa: bfa_port: Remove struct timeval

PATCH In review Amitoj Kaur Chawla 2 participants 3 messages Oct 27, 2015 – Nov 3, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: bfa: bfa_port: Remove struct timeval

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_real_seconds().

---
 drivers/scsi/bfa/bfa_port.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)
drivers/scsi/bfa/bfa_port.c +5 -12
index 8ea7697..b30718d 100644
@@ -15,6 +15,7 @@
  * General Public License for more details.
  */
 
+#include <linux/ktime.h>
 #include "bfad_drv.h"
 #include "bfa_defs_svc.h"
 #include "bfa_port.h"
@@ -95,14 +96,12 @@ bfa_port_get_stats_isr(struct bfa_port_s *port, bfa_status_t status)
 	port->stats_busy = BFA_FALSE;
 
 	if (status == BFA_STATUS_OK) {
-		struct timeval tv;
-
 		memcpy(port->stats, port->stats_dma.kva,
 		       sizeof(union bfa_port_stats_u));
 		bfa_port_stats_swap(port, port->stats);
 
-		do_gettimeofday(&tv);
-		port->stats->fc.secs_reset = tv.tv_sec - port->stats_reset_time;
+		port->stats->fc.secs_reset = ktime_get_real_seconds() -
+							port->stats_reset_time;
 	}
 
 	if (port->stats_cbfn) {
@@ -123,16 +122,13 @@ bfa_port_get_stats_isr(struct bfa_port_s *port, bfa_status_t status)
 static void
 bfa_port_clear_stats_isr(struct bfa_port_s *port, bfa_status_t status)
 {
-	struct timeval tv;
-
 	port->stats_status = status;
 	port->stats_busy   = BFA_FALSE;
 
 	/*
 	* re-initialize time stamp for stats reset
 	*/
-	do_gettimeofday(&tv);
-	port->stats_reset_time = tv.tv_sec;
+	port->stats_reset_time = ktime_get_real_seconds();
 
 	if (port->stats_cbfn) {
 		port->stats_cbfn(port->stats_cbarg, status);
@@ -470,8 +466,6 @@ void
 bfa_port_attach(struct bfa_port_s *port, struct bfa_ioc_s *ioc,
 		 void *dev, struct bfa_trc_mod_s *trcmod)
 {
-	struct timeval tv;
-
 	WARN_ON(!port);
 
 	port->dev    = dev;
@@ -493,8 +487,7 @@ bfa_port_attach(struct bfa_port_s *port, struct bfa_ioc_s *ioc,
 	/*
 	 * initialize time stamp for stats reset
 	 */
-	do_gettimeofday(&tv);
-	port->stats_reset_time = tv.tv_sec;
+	port->stats_reset_time = ktime_get_real_seconds();
 
 	bfa_trc(port, 0);
 }
Signature · 1 line
1.9.1
#1 lore raw
Quoted 7 lines · On Wednesday 28 October 2015 00:30:41 Amitoj Kaur Chawla wrote:

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_real_seconds().

This code looks like a copy of the bfa_svc.c file from your earlier patch, and the same comments apply: Make sure that stats_reset_time has an appropriate type, and convert to monotonic time.

Arnd

#2 lore raw
Quoted 4 lines · On Wednesday 04 November 2015 00:29:42 Arnd Bergmann wrote:
Quoted 3 lines · On Wednesday 28 October 2015 00:30:41 Amitoj Kaur Chawla wrote:

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

Quoted 9 lines
Quoted 4 lines

This patch replaces the use of struct timeval and do_gettimeofday() with 64 bit ktime_get_real_seconds().

This code looks like a copy of the bfa_svc.c file from your earlier patch, and the same comments apply: Make sure that stats_reset_time has an appropriate type, and convert to monotonic time.

To further clarify: when you change to using monotonic time, using a 32-bit variable to store the time is sufficient and you don't need to change the type, but you should still explain that in the patch description if you do it.

Arnd