linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] ide: pdc202xx_new: Replace timeval with ktime_t
@ 2015-10-22 12:45 Amitoj Kaur Chawla
  2015-10-22 12:47 ` [Y2038] " Arnd Bergmann
  2015-11-03 16:51 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Amitoj Kaur Chawla @ 2015-10-22 12:45 UTC (permalink / raw)
  To: outreachy-kernel; +Cc: y2038, davem, linux-ide, linux-kernel

This driver uses 'struct timeval' which we are trying to remove since
32 bit time types will break in the year 2038 by replacing it with
ktime_t.

This patch changes do_gettimeofday() to ktime_get() because
ktime_get() returns a ktime_t while do_gettimeofday() returns struct
timeval.

This patch also uses ktime_us_delta() to get the elapsed time.

Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
---
Changes in v2:
        -Modified subject of commit message

 drivers/ide/pdc202xx_new.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/ide/pdc202xx_new.c b/drivers/ide/pdc202xx_new.c
index df73cbd..9ad014a 100644
--- a/drivers/ide/pdc202xx_new.c
+++ b/drivers/ide/pdc202xx_new.c
@@ -22,6 +22,7 @@
 #include <linux/pci.h>
 #include <linux/init.h>
 #include <linux/ide.h>
+#include <linux/ktime.h>
 
 #include <asm/io.h>
 
@@ -243,13 +244,13 @@ static long read_counter(u32 dma_base)
  */
 static long detect_pll_input_clock(unsigned long dma_base)
 {
-	struct timeval start_time, end_time;
+	ktime_t start_time, end_time;
 	long start_count, end_count;
 	long pll_input, usec_elapsed;
 	u8 scr1;
 
 	start_count = read_counter(dma_base);
-	do_gettimeofday(&start_time);
+	start_time = ktime_get();
 
 	/* Start the test mode */
 	outb(0x01, dma_base + 0x01);
@@ -261,7 +262,7 @@ static long detect_pll_input_clock(unsigned long dma_base)
 	mdelay(10);
 
 	end_count = read_counter(dma_base);
-	do_gettimeofday(&end_time);
+	end_time = ktime_get();
 
 	/* Stop the test mode */
 	outb(0x01, dma_base + 0x01);
@@ -273,8 +274,7 @@ static long detect_pll_input_clock(unsigned long dma_base)
 	 * Calculate the input clock in Hz
 	 * (the clock counter is 30 bit wide and counts down)
 	 */
-	usec_elapsed = (end_time.tv_sec - start_time.tv_sec) * 1000000 +
-		(end_time.tv_usec - start_time.tv_usec);
+	usec_elapsed = ktime_us_delta(end_time, start_time);
 	pll_input = ((start_count - end_count) & 0x3fffffff) / 10 *
 		(10000000 / usec_elapsed);
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Y2038] [PATCH v2] ide: pdc202xx_new: Replace timeval with ktime_t
  2015-10-22 12:45 [PATCH v2] ide: pdc202xx_new: Replace timeval with ktime_t Amitoj Kaur Chawla
@ 2015-10-22 12:47 ` Arnd Bergmann
  2015-11-03 16:51 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Arnd Bergmann @ 2015-10-22 12:47 UTC (permalink / raw)
  To: y2038
  Cc: Amitoj Kaur Chawla, outreachy-kernel, linux-ide, davem, linux-kernel

On Thursday 22 October 2015 18:15:50 Amitoj Kaur Chawla wrote:
> This driver uses 'struct timeval' which we are trying to remove since
> 32 bit time types will break in the year 2038 by replacing it with
> ktime_t.
> 
> This patch changes do_gettimeofday() to ktime_get() because
> ktime_get() returns a ktime_t while do_gettimeofday() returns struct
> timeval.
> 
> This patch also uses ktime_us_delta() to get the elapsed time.
> 
> Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
> 

Reviewed-by: Arnd Bergmann <arnd@arndb.de>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] ide: pdc202xx_new: Replace timeval with ktime_t
  2015-10-22 12:45 [PATCH v2] ide: pdc202xx_new: Replace timeval with ktime_t Amitoj Kaur Chawla
  2015-10-22 12:47 ` [Y2038] " Arnd Bergmann
@ 2015-11-03 16:51 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2015-11-03 16:51 UTC (permalink / raw)
  To: amitoj1606; +Cc: outreachy-kernel, y2038, linux-ide, linux-kernel

From: Amitoj Kaur Chawla <amitoj1606@gmail.com>
Date: Thu, 22 Oct 2015 18:15:50 +0530

> This driver uses 'struct timeval' which we are trying to remove since
> 32 bit time types will break in the year 2038 by replacing it with
> ktime_t.
> 
> This patch changes do_gettimeofday() to ktime_get() because
> ktime_get() returns a ktime_t while do_gettimeofday() returns struct
> timeval.
> 
> This patch also uses ktime_us_delta() to get the elapsed time.
> 
> Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
> ---
> Changes in v2:
>         -Modified subject of commit message

Applied, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-11-03 16:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-22 12:45 [PATCH v2] ide: pdc202xx_new: Replace timeval with ktime_t Amitoj Kaur Chawla
2015-10-22 12:47 ` [Y2038] " Arnd Bergmann
2015-11-03 16:51 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).