ktime: Cleanup ktime_set() usage

ktime_set(S,N) was required for the timespec storage type and is still
useful for situations where a Seconds and Nanoseconds part of a time value
needs to be converted. For anything where the Seconds argument is 0, this
is pointless and can be replaced with a simple assignment.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
This commit is contained in:
Thomas Gleixner
2016-12-25 12:30:41 +01:00
parent 2456e85535
commit 8b0e195314
56 changed files with 84 additions and 95 deletions
+1 -2
View File
@@ -1872,8 +1872,7 @@ static void kvmppc_set_timer(struct kvm_vcpu *vcpu)
} }
dec_nsec = (vcpu->arch.dec_expires - now) * NSEC_PER_SEC dec_nsec = (vcpu->arch.dec_expires - now) * NSEC_PER_SEC
/ tb_ticks_per_sec; / tb_ticks_per_sec;
hrtimer_start(&vcpu->arch.dec_timer, ktime_set(0, dec_nsec), hrtimer_start(&vcpu->arch.dec_timer, dec_nsec, HRTIMER_MODE_REL);
HRTIMER_MODE_REL);
vcpu->arch.timer_running = 1; vcpu->arch.timer_running = 1;
} }
+2 -2
View File
@@ -180,7 +180,7 @@ static enum hrtimer_restart profile_spus(struct hrtimer *timer)
smp_wmb(); /* insure spu event buffer updates are written */ smp_wmb(); /* insure spu event buffer updates are written */
/* don't want events intermingled... */ /* don't want events intermingled... */
kt = ktime_set(0, profiling_interval); kt = profiling_interval;
if (!spu_prof_running) if (!spu_prof_running)
goto stop; goto stop;
hrtimer_forward(timer, timer->base->get_time(), kt); hrtimer_forward(timer, timer->base->get_time(), kt);
@@ -204,7 +204,7 @@ int start_spu_profiling_cycles(unsigned int cycles_reset)
ktime_t kt; ktime_t kt;
pr_debug("timer resolution: %lu\n", TICK_NSEC); pr_debug("timer resolution: %lu\n", TICK_NSEC);
kt = ktime_set(0, profiling_interval); kt = profiling_interval;
hrtimer_init(&timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); hrtimer_init(&timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
hrtimer_set_expires(&timer, kt); hrtimer_set_expires(&timer, kt);
timer.function = profile_spus; timer.function = profile_spus;
+1 -1
View File
@@ -1019,7 +1019,7 @@ int kvm_s390_handle_wait(struct kvm_vcpu *vcpu)
return 0; return 0;
__set_cpu_idle(vcpu); __set_cpu_idle(vcpu);
hrtimer_start(&vcpu->arch.ckc_timer, ktime_set (0, sltime) , HRTIMER_MODE_REL); hrtimer_start(&vcpu->arch.ckc_timer, sltime, HRTIMER_MODE_REL);
VCPU_EVENT(vcpu, 4, "enabled wait: %llu ns", sltime); VCPU_EVENT(vcpu, 4, "enabled wait: %llu ns", sltime);
no_timer: no_timer:
srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx); srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx);
+2 -2
View File
@@ -1106,7 +1106,7 @@ static u32 apic_get_tmcct(struct kvm_lapic *apic)
now = ktime_get(); now = ktime_get();
remaining = ktime_sub(apic->lapic_timer.target_expiration, now); remaining = ktime_sub(apic->lapic_timer.target_expiration, now);
if (ktime_to_ns(remaining) < 0) if (ktime_to_ns(remaining) < 0)
remaining = ktime_set(0, 0); remaining = 0;
ns = mod_64(ktime_to_ns(remaining), apic->lapic_timer.period); ns = mod_64(ktime_to_ns(remaining), apic->lapic_timer.period);
tmcct = div64_u64(ns, tmcct = div64_u64(ns,
@@ -2057,7 +2057,7 @@ void kvm_inject_apic_timer_irqs(struct kvm_vcpu *vcpu)
apic->lapic_timer.tscdeadline = 0; apic->lapic_timer.tscdeadline = 0;
if (apic_lvtt_oneshot(apic)) { if (apic_lvtt_oneshot(apic)) {
apic->lapic_timer.tscdeadline = 0; apic->lapic_timer.tscdeadline = 0;
apic->lapic_timer.target_expiration = ktime_set(0, 0); apic->lapic_timer.target_expiration = 0;
} }
atomic_set(&apic->lapic_timer.pending, 0); atomic_set(&apic->lapic_timer.pending, 0);
} }
+1 -1
View File
@@ -2569,7 +2569,7 @@ static bool blk_mq_poll_hybrid_sleep(struct request_queue *q,
* This will be replaced with the stats tracking code, using * This will be replaced with the stats tracking code, using
* 'avg_completion_time / 2' as the pre-sleep target. * 'avg_completion_time / 2' as the pre-sleep target.
*/ */
kt = ktime_set(0, nsecs); kt = nsecs;
mode = HRTIMER_MODE_REL; mode = HRTIMER_MODE_REL;
hrtimer_init_on_stack(&hs.timer, CLOCK_MONOTONIC, mode); hrtimer_init_on_stack(&hs.timer, CLOCK_MONOTONIC, mode);
+1 -1
View File
@@ -194,7 +194,7 @@ void device_pm_move_last(struct device *dev)
static ktime_t initcall_debug_start(struct device *dev) static ktime_t initcall_debug_start(struct device *dev)
{ {
ktime_t calltime = ktime_set(0, 0); ktime_t calltime = 0;
if (pm_print_times_enabled) { if (pm_print_times_enabled) {
pr_info("calling %s+ @ %i, parent: %s\n", pr_info("calling %s+ @ %i, parent: %s\n",
+1 -1
View File
@@ -1005,7 +1005,7 @@ static int print_wakeup_source_stats(struct seq_file *m,
prevent_sleep_time = ktime_add(prevent_sleep_time, prevent_sleep_time = ktime_add(prevent_sleep_time,
ktime_sub(now, ws->start_prevent_time)); ktime_sub(now, ws->start_prevent_time));
} else { } else {
active_time = ktime_set(0, 0); active_time = 0;
} }
seq_printf(m, "%-12s\t%lu\t\t%lu\t\t%lu\t\t%lu\t\t%lld\t\t%lld\t\t%lld\t\t%lld\t\t%lld\n", seq_printf(m, "%-12s\t%lu\t\t%lu\t\t%lu\t\t%lu\t\t%lld\t\t%lld\t\t%lld\t\t%lld\t\t%lld\n",
+1 -1
View File
@@ -257,7 +257,7 @@ static enum hrtimer_restart null_cmd_timer_expired(struct hrtimer *timer)
static void null_cmd_end_timer(struct nullb_cmd *cmd) static void null_cmd_end_timer(struct nullb_cmd *cmd)
{ {
ktime_t kt = ktime_set(0, completion_nsec); ktime_t kt = completion_nsec;
hrtimer_start(&cmd->timer, kt, HRTIMER_MODE_REL); hrtimer_start(&cmd->timer, kt, HRTIMER_MODE_REL);
} }
+2 -2
View File
@@ -429,8 +429,8 @@ static int dmatest_func(void *data)
int dst_cnt; int dst_cnt;
int i; int i;
ktime_t ktime, start, diff; ktime_t ktime, start, diff;
ktime_t filltime = ktime_set(0, 0); ktime_t filltime = 0;
ktime_t comparetime = ktime_set(0, 0); ktime_t comparetime = 0;
s64 runtime = 0; s64 runtime = 0;
unsigned long long total_len = 0; unsigned long long total_len = 0;
u8 align = 0; u8 align = 0;
+3 -3
View File
@@ -752,7 +752,7 @@ static enum hrtimer_restart dce_virtual_vblank_timer_handle(struct hrtimer *vbla
drm_handle_vblank(ddev, amdgpu_crtc->crtc_id); drm_handle_vblank(ddev, amdgpu_crtc->crtc_id);
dce_virtual_pageflip(adev, amdgpu_crtc->crtc_id); dce_virtual_pageflip(adev, amdgpu_crtc->crtc_id);
hrtimer_start(vblank_timer, ktime_set(0, DCE_VIRTUAL_VBLANK_PERIOD), hrtimer_start(vblank_timer, DCE_VIRTUAL_VBLANK_PERIOD,
HRTIMER_MODE_REL); HRTIMER_MODE_REL);
return HRTIMER_NORESTART; return HRTIMER_NORESTART;
@@ -772,11 +772,11 @@ static void dce_virtual_set_crtc_vblank_interrupt_state(struct amdgpu_device *ad
hrtimer_init(&adev->mode_info.crtcs[crtc]->vblank_timer, hrtimer_init(&adev->mode_info.crtcs[crtc]->vblank_timer,
CLOCK_MONOTONIC, HRTIMER_MODE_REL); CLOCK_MONOTONIC, HRTIMER_MODE_REL);
hrtimer_set_expires(&adev->mode_info.crtcs[crtc]->vblank_timer, hrtimer_set_expires(&adev->mode_info.crtcs[crtc]->vblank_timer,
ktime_set(0, DCE_VIRTUAL_VBLANK_PERIOD)); DCE_VIRTUAL_VBLANK_PERIOD);
adev->mode_info.crtcs[crtc]->vblank_timer.function = adev->mode_info.crtcs[crtc]->vblank_timer.function =
dce_virtual_vblank_timer_handle; dce_virtual_vblank_timer_handle;
hrtimer_start(&adev->mode_info.crtcs[crtc]->vblank_timer, hrtimer_start(&adev->mode_info.crtcs[crtc]->vblank_timer,
ktime_set(0, DCE_VIRTUAL_VBLANK_PERIOD), HRTIMER_MODE_REL); DCE_VIRTUAL_VBLANK_PERIOD, HRTIMER_MODE_REL);
} else if (!state && adev->mode_info.crtcs[crtc]->vsync_timer_enabled) { } else if (!state && adev->mode_info.crtcs[crtc]->vsync_timer_enabled) {
DRM_DEBUG("Disable software vsync timer\n"); DRM_DEBUG("Disable software vsync timer\n");
hrtimer_cancel(&adev->mode_info.crtcs[crtc]->vblank_timer); hrtimer_cancel(&adev->mode_info.crtcs[crtc]->vblank_timer);
+1 -1
View File
@@ -62,7 +62,7 @@ fw_domain_arm_timer(struct intel_uncore_forcewake_domain *d)
{ {
d->wake_count++; d->wake_count++;
hrtimer_start_range_ns(&d->timer, hrtimer_start_range_ns(&d->timer,
ktime_set(0, NSEC_PER_MSEC), NSEC_PER_MSEC,
NSEC_PER_MSEC, NSEC_PER_MSEC,
HRTIMER_MODE_REL); HRTIMER_MODE_REL);
} }
+1 -1
View File
@@ -330,7 +330,7 @@ nouveau_fence_wait_legacy(struct dma_fence *f, bool intr, long wait)
__set_current_state(intr ? TASK_INTERRUPTIBLE : __set_current_state(intr ? TASK_INTERRUPTIBLE :
TASK_UNINTERRUPTIBLE); TASK_UNINTERRUPTIBLE);
kt = ktime_set(0, sleep_time); kt = sleep_time;
schedule_hrtimeout(&kt, HRTIMER_MODE_REL); schedule_hrtimeout(&kt, HRTIMER_MODE_REL);
sleep_time *= 2; sleep_time *= 2;
if (sleep_time > NSEC_PER_MSEC) if (sleep_time > NSEC_PER_MSEC)
+1 -1
View File
@@ -539,7 +539,7 @@ static void tilcdc_crtc_off(struct drm_crtc *crtc, bool shutdown)
} }
drm_flip_work_commit(&tilcdc_crtc->unref_work, priv->wq); drm_flip_work_commit(&tilcdc_crtc->unref_work, priv->wq);
tilcdc_crtc->last_vblank = ktime_set(0, 0); tilcdc_crtc->last_vblank = 0;
tilcdc_crtc->enabled = false; tilcdc_crtc->enabled = false;
mutex_unlock(&tilcdc_crtc->enable_lock); mutex_unlock(&tilcdc_crtc->enable_lock);
+2 -3
View File
@@ -63,7 +63,7 @@ ssize_t iio_hrtimer_store_sampling_frequency(struct device *dev,
return -EINVAL; return -EINVAL;
info->sampling_frequency = val; info->sampling_frequency = val;
info->period = ktime_set(0, NSEC_PER_SEC / val); info->period = NSEC_PER_SEC / val;
return len; return len;
} }
@@ -141,8 +141,7 @@ static struct iio_sw_trigger *iio_trig_hrtimer_probe(const char *name)
trig_info->timer.function = iio_hrtimer_trig_handler; trig_info->timer.function = iio_hrtimer_trig_handler;
trig_info->sampling_frequency = HRTIMER_DEFAULT_SAMPLING_FREQUENCY; trig_info->sampling_frequency = HRTIMER_DEFAULT_SAMPLING_FREQUENCY;
trig_info->period = ktime_set(0, NSEC_PER_SEC / trig_info->period = NSEC_PER_SEC / trig_info->sampling_frequency;
trig_info->sampling_frequency);
ret = iio_trigger_register(trig_info->swt.trigger); ret = iio_trigger_register(trig_info->swt.trigger);
if (ret) if (ret)
+1 -1
View File
@@ -165,7 +165,7 @@ static void walkera0701_irq_handler(void *handler_data)
RESERVE + BIN1_PULSE - BIN0_PULSE) /* frame sync .. */ RESERVE + BIN1_PULSE - BIN0_PULSE) /* frame sync .. */
w->counter = 0; w->counter = 0;
hrtimer_start(&w->timer, ktime_set(0, BIN_SAMPLE), HRTIMER_MODE_REL); hrtimer_start(&w->timer, BIN_SAMPLE, HRTIMER_MODE_REL);
} }
static enum hrtimer_restart timer_handler(struct hrtimer static enum hrtimer_restart timer_handler(struct hrtimer
+1 -2
View File
@@ -87,8 +87,7 @@ exit:
if (!err && (chan->txdone_method & TXDONE_BY_POLL)) if (!err && (chan->txdone_method & TXDONE_BY_POLL))
/* kick start the timer immediately to avoid delays */ /* kick start the timer immediately to avoid delays */
hrtimer_start(&chan->mbox->poll_hrt, ktime_set(0, 0), hrtimer_start(&chan->mbox->poll_hrt, 0, HRTIMER_MODE_REL);
HRTIMER_MODE_REL);
} }
static void tx_tick(struct mbox_chan *chan, int r) static void tx_tick(struct mbox_chan *chan, int r)
+1 -1
View File
@@ -562,7 +562,7 @@ static int dvb_dmxdev_start_feed(struct dmxdev *dmxdev,
struct dmxdev_filter *filter, struct dmxdev_filter *filter,
struct dmxdev_feed *feed) struct dmxdev_feed *feed)
{ {
ktime_t timeout = ktime_set(0, 0); ktime_t timeout = 0;
struct dmx_pes_filter_params *para = &filter->params.pes; struct dmx_pes_filter_params *para = &filter->params.pes;
dmx_output_t otype; dmx_output_t otype;
int ret; int ret;
+2 -4
View File
@@ -178,8 +178,7 @@ static enum hrtimer_restart cx88_ir_work(struct hrtimer *timer)
struct cx88_IR *ir = container_of(timer, struct cx88_IR, timer); struct cx88_IR *ir = container_of(timer, struct cx88_IR, timer);
cx88_ir_handle_key(ir); cx88_ir_handle_key(ir);
missed = hrtimer_forward_now(&ir->timer, missed = hrtimer_forward_now(&ir->timer, ir->polling * 1000000);
ktime_set(0, ir->polling * 1000000));
if (missed > 1) if (missed > 1)
ir_dprintk("Missed ticks %ld\n", missed - 1); ir_dprintk("Missed ticks %ld\n", missed - 1);
@@ -199,8 +198,7 @@ static int __cx88_ir_start(void *priv)
if (ir->polling) { if (ir->polling) {
hrtimer_init(&ir->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); hrtimer_init(&ir->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
ir->timer.function = cx88_ir_work; ir->timer.function = cx88_ir_work;
hrtimer_start(&ir->timer, hrtimer_start(&ir->timer, ir->polling * 1000000,
ktime_set(0, ir->polling * 1000000),
HRTIMER_MODE_REL); HRTIMER_MODE_REL);
} }
if (ir->sampling) { if (ir->sampling) {
+1 -1
View File
@@ -463,7 +463,7 @@ static int pt3_fetch_thread(void *data)
pt3_proc_dma(adap); pt3_proc_dma(adap);
delay = ktime_set(0, PT3_FETCH_DELAY * NSEC_PER_MSEC); delay = PT3_FETCH_DELAY * NSEC_PER_MSEC;
set_current_state(TASK_UNINTERRUPTIBLE); set_current_state(TASK_UNINTERRUPTIBLE);
freezable_schedule_hrtimeout_range(&delay, freezable_schedule_hrtimeout_range(&delay,
PT3_FETCH_DELAY_DELTA * NSEC_PER_MSEC, PT3_FETCH_DELAY_DELTA * NSEC_PER_MSEC,
+2 -2
View File
@@ -390,7 +390,7 @@ static void softing_initialize_timestamp(struct softing *card)
ovf = 0x100000000ULL * 16; ovf = 0x100000000ULL * 16;
do_div(ovf, card->pdat->freq ?: 16); do_div(ovf, card->pdat->freq ?: 16);
card->ts_overflow = ktime_add_us(ktime_set(0, 0), ovf); card->ts_overflow = ktime_add_us(0, ovf);
} }
ktime_t softing_raw2ktime(struct softing *card, u32 raw) ktime_t softing_raw2ktime(struct softing *card, u32 raw)
@@ -647,7 +647,7 @@ int softing_startstop(struct net_device *dev, int up)
open_candev(netdev); open_candev(netdev);
if (dev != netdev) { if (dev != netdev) {
/* notify other busses on the restart */ /* notify other busses on the restart */
softing_netdev_rx(netdev, &msg, ktime_set(0, 0)); softing_netdev_rx(netdev, &msg, 0);
++priv->can.can_stats.restarts; ++priv->can.can_stats.restarts;
} }
netif_wake_queue(netdev); netif_wake_queue(netdev);

Some files were not shown because too many files have changed in this diff Show More