Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

pata_pdc2027x: Use 64-bit timekeeping

Function pdc_detect_pll_input_clock uses 'struct timeval'
to measure start and end times, used to compute the pll_clock value.
'struct timeval' on 32-bit systems will have its tv_sec field
overflow in year 2038 and beyond. This patch uses 'ktime_t'
(which uses 64 bits for seconds) for start and end times instead.

Suggested-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Tina Ruchandani <ruchandani.tina@gmail.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Tejun Heo <tj@kernel.org>

authored by

Tina Ruchandani and committed by
Tejun Heo
cedda4c3 55294150

+5 -5
+5 -5
drivers/ata/pata_pdc2027x.c
··· 28 28 #include <linux/blkdev.h> 29 29 #include <linux/delay.h> 30 30 #include <linux/device.h> 31 + #include <linux/ktime.h> 31 32 #include <scsi/scsi.h> 32 33 #include <scsi/scsi_host.h> 33 34 #include <scsi/scsi_cmnd.h> ··· 606 605 void __iomem *mmio_base = host->iomap[PDC_MMIO_BAR]; 607 606 u32 scr; 608 607 long start_count, end_count; 609 - struct timeval start_time, end_time; 608 + ktime_t start_time, end_time; 610 609 long pll_clock, usec_elapsed; 611 610 612 611 /* Start the test mode */ ··· 617 616 618 617 /* Read current counter value */ 619 618 start_count = pdc_read_counter(host); 620 - do_gettimeofday(&start_time); 619 + start_time = ktime_get(); 621 620 622 621 /* Let the counter run for 100 ms. */ 623 622 mdelay(100); 624 623 625 624 /* Read the counter values again */ 626 625 end_count = pdc_read_counter(host); 627 - do_gettimeofday(&end_time); 626 + end_time = ktime_get(); 628 627 629 628 /* Stop the test mode */ 630 629 scr = ioread32(mmio_base + PDC_SYS_CTL); ··· 633 632 ioread32(mmio_base + PDC_SYS_CTL); /* flush */ 634 633 635 634 /* calculate the input clock in Hz */ 636 - usec_elapsed = (end_time.tv_sec - start_time.tv_sec) * 1000000 + 637 - (end_time.tv_usec - start_time.tv_usec); 635 + usec_elapsed = (long) ktime_us_delta(end_time, start_time); 638 636 639 637 pll_clock = ((start_count - end_count) & 0x3fffffff) / 100 * 640 638 (100000000 / usec_elapsed);