Skip to contentSkip to conversation

ide: Replace timeval with ktime_t

PATCH Superseded Amitoj Kaur Chawla 2 participants 5 messages Oct 22, 2015

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ide: Replace timeval with ktime_t

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.

---
 drivers/ide/pdc202xx_new.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/ide/pdc202xx_new.c +5 -5
index df73cbd..9ad014a 100644
@@ -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);
 
Signature · 1 line
1.9.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · On Thursday 22 October 2015 15:30:14 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.

Quoted 8 lines

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.

Very good,

In the subject line, I would like to see the name of the driver you are patching, like '[PATCH] ide: pdc202xx: replace timeval with ktime_t'.

Please always add [email protected] to Cc with these patches. If you want to send more of the same, you can also subscribe to the list at https://lists.linaro.org/mailman/listinfo/y2038.

As the patch looks good, please send it again with the ide maintainers on Cc.

Arnd

#2 lore raw
Quoted 14 lines · Arnd Bergmann
Quoted 4 lines · On Thursday 22 October 2015 15:30:14 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.

Quoted 8 lines

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.

Quoted 7 lines

Very good,

In the subject line, I would like to see the name of the driver you are patching, like '[PATCH] ide: pdc202xx: replace timeval with ktime_t'.

Will do.

Quoted 4 lines

Please always add [email protected] to Cc with these patches. If you want to send more of the same, you can also subscribe to the list at https://lists.linaro.org/mailman/listinfo/y2038.

I thought that ccing would be done after your review. Should I do it from the first version only in the future?

Quoted 4 lines

As the patch looks good, please send it again with the ide maintainers on Cc.

Arnd

Will do.

Signature · 1 line
Amitoj
#3 lore raw
Quoted 8 lines · On Thursday 22 October 2015 17:53:34 Amitoj Kaur Chawla wrote:
Quoted 5 lines

Please always add [email protected] to Cc with these patches. If you want to send more of the same, you can also subscribe to the list at https://lists.linaro.org/mailman/listinfo/y2038.

I thought that ccing would be done after your review. Should I do it from the first version only in the future?

The y2038 list is a bit special, I'd like you to Cc that one from the start for all y2038 patches, but only Cc the maintainers after the review.

The reason for that difference is that there are other people on the y2038 list (outside of outreachy) that are also learning here, and it is good if everyone can read and comment on everyone else's patches.

Arnd

#4 lore raw
Quoted 14 lines · Arnd Bergmann
Quoted 8 lines · On Thursday 22 October 2015 17:53:34 Amitoj Kaur Chawla wrote:
Quoted 5 lines

Please always add [email protected] to Cc with these patches. If you want to send more of the same, you can also subscribe to the list at https://lists.linaro.org/mailman/listinfo/y2038.

I thought that ccing would be done after your review. Should I do it from the first version only in the future?

The y2038 list is a bit special, I'd like you to Cc that one from the start for all y2038 patches, but only Cc the maintainers after the review.

Quoted 5 lines

The reason for that difference is that there are other people on the y2038 list (outside of outreachy) that are also learning here, and it is good if everyone can read and comment on everyone else's patches.

Arnd

Okay. Will keep in mind for future patches.

Thanks,

Signature · 1 line
Amitoj