Skip to content

Commit

Permalink
ide: pdc202xx_new: Replace timeval with ktime_t
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Arnd Bergmann <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
musicakc authored and davem330 committed Nov 3, 2015
1 parent 6a13feb commit 353b39d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions drivers/ide/pdc202xx_new.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <linux/pci.h>
#include <linux/init.h>
#include <linux/ide.h>
#include <linux/ktime.h>

#include <asm/io.h>

Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);

Expand Down

0 comments on commit 353b39d

Please sign in to comment.