diff options
author | Tina Ruchandani <ruchandani.tina@gmail.com> | 2015-01-27 05:19:48 -0500 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2015-01-27 11:06:19 -0500 |
commit | cedda4c3b1ded2cc4951aeca38fdf862b9b79fb6 (patch) | |
tree | 2f02198d245329c9901f9d58484bdb67da95db01 /drivers/ata | |
parent | 552941503b9500a99be06cc9f60348099435b160 (diff) |
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>
Diffstat (limited to 'drivers/ata')
-rw-r--r-- | drivers/ata/pata_pdc2027x.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/ata/pata_pdc2027x.c b/drivers/ata/pata_pdc2027x.c index 4d06a5cda987..dca8251b1aea 100644 --- a/drivers/ata/pata_pdc2027x.c +++ b/drivers/ata/pata_pdc2027x.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/blkdev.h> | 28 | #include <linux/blkdev.h> |
29 | #include <linux/delay.h> | 29 | #include <linux/delay.h> |
30 | #include <linux/device.h> | 30 | #include <linux/device.h> |
31 | #include <linux/ktime.h> | ||
31 | #include <scsi/scsi.h> | 32 | #include <scsi/scsi.h> |
32 | #include <scsi/scsi_host.h> | 33 | #include <scsi/scsi_host.h> |
33 | #include <scsi/scsi_cmnd.h> | 34 | #include <scsi/scsi_cmnd.h> |
@@ -605,7 +606,7 @@ static long pdc_detect_pll_input_clock(struct ata_host *host) | |||
605 | void __iomem *mmio_base = host->iomap[PDC_MMIO_BAR]; | 606 | void __iomem *mmio_base = host->iomap[PDC_MMIO_BAR]; |
606 | u32 scr; | 607 | u32 scr; |
607 | long start_count, end_count; | 608 | long start_count, end_count; |
608 | struct timeval start_time, end_time; | 609 | ktime_t start_time, end_time; |
609 | long pll_clock, usec_elapsed; | 610 | long pll_clock, usec_elapsed; |
610 | 611 | ||
611 | /* Start the test mode */ | 612 | /* Start the test mode */ |
@@ -616,14 +617,14 @@ static long pdc_detect_pll_input_clock(struct ata_host *host) | |||
616 | 617 | ||
617 | /* Read current counter value */ | 618 | /* Read current counter value */ |
618 | start_count = pdc_read_counter(host); | 619 | start_count = pdc_read_counter(host); |
619 | do_gettimeofday(&start_time); | 620 | start_time = ktime_get(); |
620 | 621 | ||
621 | /* Let the counter run for 100 ms. */ | 622 | /* Let the counter run for 100 ms. */ |
622 | mdelay(100); | 623 | mdelay(100); |
623 | 624 | ||
624 | /* Read the counter values again */ | 625 | /* Read the counter values again */ |
625 | end_count = pdc_read_counter(host); | 626 | end_count = pdc_read_counter(host); |
626 | do_gettimeofday(&end_time); | 627 | end_time = ktime_get(); |
627 | 628 | ||
628 | /* Stop the test mode */ | 629 | /* Stop the test mode */ |
629 | scr = ioread32(mmio_base + PDC_SYS_CTL); | 630 | scr = ioread32(mmio_base + PDC_SYS_CTL); |
@@ -632,8 +633,7 @@ static long pdc_detect_pll_input_clock(struct ata_host *host) | |||
632 | ioread32(mmio_base + PDC_SYS_CTL); /* flush */ | 633 | ioread32(mmio_base + PDC_SYS_CTL); /* flush */ |
633 | 634 | ||
634 | /* calculate the input clock in Hz */ | 635 | /* calculate the input clock in Hz */ |
635 | usec_elapsed = (end_time.tv_sec - start_time.tv_sec) * 1000000 + | 636 | usec_elapsed = (long) ktime_us_delta(end_time, start_time); |
636 | (end_time.tv_usec - start_time.tv_usec); | ||
637 | 637 | ||
638 | pll_clock = ((start_count - end_count) & 0x3fffffff) / 100 * | 638 | pll_clock = ((start_count - end_count) & 0x3fffffff) / 100 * |
639 | (100000000 / usec_elapsed); | 639 | (100000000 / usec_elapsed); |