Skip to content

Commit cedda4c

Browse files
Tinabr7htejun
authored andcommitted
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>
1 parent 5529415 commit cedda4c

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

‎drivers/ata/pata_pdc2027x.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <linux/blkdev.h>
2929
#include <linux/delay.h>
3030
#include <linux/device.h>
31+
#include <linux/ktime.h>
3132
#include <scsi/scsi.h>
3233
#include <scsi/scsi_host.h>
3334
#include <scsi/scsi_cmnd.h>
@@ -605,7 +606,7 @@ static long pdc_detect_pll_input_clock(struct ata_host *host)
605606
void __iomem *mmio_base = host->iomap[PDC_MMIO_BAR];
606607
u32 scr;
607608
long start_count, end_count;
608-
struct timeval start_time, end_time;
609+
ktime_t start_time, end_time;
609610
long pll_clock, usec_elapsed;
610611

611612
/* Start the test mode */
@@ -616,14 +617,14 @@ static long pdc_detect_pll_input_clock(struct ata_host *host)
616617

617618
/* Read current counter value */
618619
start_count = pdc_read_counter(host);
619-
do_gettimeofday(&start_time);
620+
start_time = ktime_get();
620621

621622
/* Let the counter run for 100 ms. */
622623
mdelay(100);
623624

624625
/* Read the counter values again */
625626
end_count = pdc_read_counter(host);
626-
do_gettimeofday(&end_time);
627+
end_time = ktime_get();
627628

628629
/* Stop the test mode */
629630
scr = ioread32(mmio_base + PDC_SYS_CTL);
@@ -632,8 +633,7 @@ static long pdc_detect_pll_input_clock(struct ata_host *host)
632633
ioread32(mmio_base + PDC_SYS_CTL); /* flush */
633634

634635
/* calculate the input clock in Hz */
635-
usec_elapsed = (end_time.tv_sec - start_time.tv_sec) * 1000000 +
636-
(end_time.tv_usec - start_time.tv_usec);
636+
usec_elapsed = (long) ktime_us_delta(end_time, start_time);
637637

638638
pll_clock = ((start_count - end_count) & 0x3fffffff) / 100 *
639639
(100000000 / usec_elapsed);

0 commit comments

Comments
 (0)