Commit 2afe8be8 authored by Thomas Gleixner's avatar Thomas Gleixner Committed by Takashi Iwai

ALSA: intel8x0: Use ktime and ktime_get()

do_posix_clock_monotonic_gettime() is a leftover from the initial
posix timer implementation which maps to ktime_get_ts() and returns
the monotonic time in a timespec.

Use ktime based ktime_get() and use the ktime_delta_us() function to
calculate the delta instead of open coding the timespec math.
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 26204e04
...@@ -2779,7 +2779,7 @@ static void intel8x0_measure_ac97_clock(struct intel8x0 *chip) ...@@ -2779,7 +2779,7 @@ static void intel8x0_measure_ac97_clock(struct intel8x0 *chip)
unsigned long port; unsigned long port;
unsigned long pos, pos1, t; unsigned long pos, pos1, t;
int civ, timeout = 1000, attempt = 1; int civ, timeout = 1000, attempt = 1;
struct timespec start_time, stop_time; ktime_t start_time, stop_time;
if (chip->ac97_bus->clock != 48000) if (chip->ac97_bus->clock != 48000)
return; /* specified in module option */ return; /* specified in module option */
...@@ -2813,7 +2813,7 @@ static void intel8x0_measure_ac97_clock(struct intel8x0 *chip) ...@@ -2813,7 +2813,7 @@ static void intel8x0_measure_ac97_clock(struct intel8x0 *chip)
iputbyte(chip, port + ICH_REG_OFF_CR, ICH_IOCE); iputbyte(chip, port + ICH_REG_OFF_CR, ICH_IOCE);
iputdword(chip, ICHREG(ALI_DMACR), 1 << ichdev->ali_slot); iputdword(chip, ICHREG(ALI_DMACR), 1 << ichdev->ali_slot);
} }
do_posix_clock_monotonic_gettime(&start_time); start_time = ktime_get();
spin_unlock_irq(&chip->reg_lock); spin_unlock_irq(&chip->reg_lock);
msleep(50); msleep(50);
spin_lock_irq(&chip->reg_lock); spin_lock_irq(&chip->reg_lock);
...@@ -2837,7 +2837,7 @@ static void intel8x0_measure_ac97_clock(struct intel8x0 *chip) ...@@ -2837,7 +2837,7 @@ static void intel8x0_measure_ac97_clock(struct intel8x0 *chip)
pos += ichdev->position; pos += ichdev->position;
} }
chip->in_measurement = 0; chip->in_measurement = 0;
do_posix_clock_monotonic_gettime(&stop_time); stop_time = ktime_get();
/* stop */ /* stop */
if (chip->device_type == DEVICE_ALI) { if (chip->device_type == DEVICE_ALI) {
iputdword(chip, ICHREG(ALI_DMACR), 1 << (ichdev->ali_slot + 16)); iputdword(chip, ICHREG(ALI_DMACR), 1 << (ichdev->ali_slot + 16));
...@@ -2865,9 +2865,7 @@ static void intel8x0_measure_ac97_clock(struct intel8x0 *chip) ...@@ -2865,9 +2865,7 @@ static void intel8x0_measure_ac97_clock(struct intel8x0 *chip)
} }
pos /= 4; pos /= 4;
t = stop_time.tv_sec - start_time.tv_sec; t = ktime_us_delta(stop_time, start_time);
t *= 1000000;
t += (stop_time.tv_nsec - start_time.tv_nsec) / 1000;
dev_info(chip->card->dev, dev_info(chip->card->dev,
"%s: measured %lu usecs (%lu samples)\n", __func__, t, pos); "%s: measured %lu usecs (%lu samples)\n", __func__, t, pos);
if (t == 0) { if (t == 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment