Skip to contentSkip to conversation

hrtimers: Consolidate hrtimer initialization - Part 2

PATCH In review Nam Cao 6 participants 39 messages Feb 5, 2025 – Feb 13, 2025

Subsystems (50)
lore
Share & tools
lore

Nam Cao

author
#0 lore raw

v2 cover hrtimers: Consolidate hrtimer initialization - Part 2

hrtimers is initialized with hrtimer_init(), and after that the timer's callback function is setup separately. This separate initialization is error prone and awkward to use.

hrtimer_setup() combines the initialization and is simpler to use.

Switch to use the new setup function. Most conversions were done with Coccinelle, see the sematic patch below.

This series is intended to be applied to the tip tree.

v1 -> v2 https://lore.kernel.org/lkml/[email protected]
- rebase onto v6.14.rc1
---
virtual patch
@@ expression timer, clock, mode, func; @@
- hrtimer_init(timer, clock, mode);
...
- timer->function = func;
+ hrtimer_setup(timer, func, clock, mode);

@@ expression timer, clock, mode, func; @@
- hrtimer_init(&timer, clock, mode);
...
- timer.function = func;
+ hrtimer_setup(&timer, func, clock, mode);

@@ expression timer, clock, mode, func; @@
- hrtimer_init_on_stack(&timer, clock, mode);
...
- timer.function = func;
+ hrtimer_setup_on_stack(&timer, func, clock, mode);

@@ expression timer, clock, mode; @@
- hrtimer_init_sleeper_on_stack(timer, clock, mode);
+ hrtimer_setup_sleeper_on_stack(timer, clock, mode);

---
Cc: Thomas Bogendoerfer <[email protected]>
Cc: Michael Ellerman <[email protected]>
Cc: Christian Borntraeger <[email protected]>
Cc: Sean Christopherson <[email protected]>
Cc: Marc Zyngier <[email protected]>
Cc: Huacai Chen <[email protected]>
Cc: Anup Patel <[email protected]>
Cc: Sascha Hauer <[email protected]>
Cc: Russell King <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: "Paul E. McKenney" <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Jens Axboe <[email protected]>
Cc: Oleg Nesterov <[email protected]>
Cc: Christian Brauner <[email protected]>
Cc: John Stultz <[email protected]>
Cc: Alexei Starovoitov <[email protected]>
Cc: Richard Weinberger <[email protected]>
Cc: Wim Van Sebroeck <[email protected]>
Cc: Steven Rostedt <[email protected]>
Cc: Damien Le Moal <[email protected]>
Cc: "Rafael J. Wysocki" <[email protected]>
Cc: Heiko Stuebner <[email protected]>
Cc: Herbert Xu <[email protected]>
---

 arch/arm/mach-imx/mmdc.c                       |  5 ++---
 arch/arm/mm/cache-l2x0-pmu.c                   |  3 +--
 arch/arm64/kvm/arch_timer.c                    |  7 +++----
 arch/loongarch/kvm/vcpu.c                      |  4 ++--
 arch/mips/kvm/mips.c                           |  5 ++---
 arch/powerpc/kernel/watchdog.c                 |  3 +--
 arch/powerpc/kvm/powerpc.c                     |  4 ++--
 arch/riscv/kvm/vcpu_timer.c                    |  7 ++++---
 arch/s390/kvm/interrupt.c                      |  3 +--
 arch/s390/kvm/kvm-s390.c                       |  4 ++--
 arch/x86/events/intel/uncore.c                 |  3 +--
 arch/x86/events/rapl.c                         |  3 +--
 arch/x86/kvm/hyperv.c                          |  3 +--
 arch/x86/kvm/i8254.c                           |  3 +--
 arch/x86/kvm/lapic.c                           |  5 ++---
 arch/x86/kvm/vmx/nested.c                      |  5 ++---
 arch/x86/kvm/xen.c                             |  4 ++--
 block/bfq-iosched.c                            |  5 ++---
 block/blk-iocost.c                             |  3 +--
 drivers/ata/pata_octeon_cf.c                   |  5 ++---
 drivers/base/power/runtime.c                   |  4 ++--
 drivers/block/null_blk/main.c                  |  7 +++----
 drivers/char/hw_random/timeriomem-rng.c        |  3 +--
 drivers/devfreq/event/rockchip-dfi.c           |  3 +--
 drivers/s390/crypto/ap_bus.c                   |  3 +--
 drivers/watchdog/softdog.c                     |  8 +++-----
 drivers/watchdog/watchdog_dev.c                |  4 ++--
 drivers/watchdog/watchdog_hrtimer_pretimeout.c |  4 ++--
 fs/timerfd.c                                   |  5 ++---
 fs/ubifs/io.c                                  |  3 +--
 io_uring/timeout.c                             | 13 ++++++-------
 kernel/bpf/helpers.c                           |  3 +--
 kernel/events/core.c                           |  7 +++----
 kernel/fork.c                                  |  3 +--
 kernel/sched/core.c                            |  3 +--
 kernel/sched/deadline.c                        |  6 ++----
 kernel/sched/fair.c                            |  8 ++++----
 kernel/sched/rt.c                              |  5 ++---
 kernel/time/ntp.c                              |  3 +--
 kernel/time/posix-timers.c                     |  7 +++----
 kernel/time/sched_clock.c                      |  3 +--
 kernel/time/tick-broadcast-hrtimer.c           |  3 +--
 kernel/time/tick-sched.c                       |  6 ++----
 kernel/trace/trace_osnoise.c                   |  6 ++----
 kernel/watchdog.c                              |  3 +--
 lib/test_objpool.c                             |  3 +--
 mm/slab_common.c                               |  4 ++--
 47 files changed, 87 insertions(+), 127 deletions(-)
Signature · 1 line
2.39.5
author
#1 lore raw

PATCH v2 1/31 KVM: MIPS: Switch to use hrtimer_setup()

hrtimer_setup() takes the callback function pointer as argument and initializes the timer completely.

Replace hrtimer_init() and the open coded initialization of hrtimer::function with the new setup mechanism.

Patch was created by using Coccinelle.

Cc Thomas Bogendoerfer <[email protected]>
---
 arch/mips/kvm/mips.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
arch/mips/kvm/mips.c +2 -3
index 60b43ea85c12..cef3c423a41a 100644
@@ -288,9 +288,8 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu)
 	if (err)
 		return err;
 
-	hrtimer_init(&vcpu->arch.comparecount_timer, CLOCK_MONOTONIC,
-		     HRTIMER_MODE_REL);
-	vcpu->arch.comparecount_timer.function = kvm_mips_comparecount_wakeup;
+	hrtimer_setup(&vcpu->arch.comparecount_timer, kvm_mips_comparecount_wakeup, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 
 	/*
 	 * Allocate space for host mode exception handlers that handle
Signature · 1 line
2.39.5
author
#2 lore raw

PATCH v2 2/31 KVM: PPC: Switch to use hrtimer_setup()

In reply to Nam Cao

hrtimer_setup() takes the callback function pointer as argument and initializes the timer completely.

Replace hrtimer_init() and the open coded initialization of hrtimer::function with the new setup mechanism.

Patch was created by using Coccinelle.

Cc Michael Ellerman <[email protected]>
---
 arch/powerpc/kvm/powerpc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/kvm/powerpc.c +2 -2
index ce1d91eed231..61f2b7e007fa 100644
@@ -766,8 +766,8 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu)
 {
 	int err;
 
-	hrtimer_init(&vcpu->arch.dec_timer, CLOCK_REALTIME, HRTIMER_MODE_ABS);
-	vcpu->arch.dec_timer.function = kvmppc_decrementer_wakeup;
+	hrtimer_setup(&vcpu->arch.dec_timer, kvmppc_decrementer_wakeup, CLOCK_REALTIME,
+		      HRTIMER_MODE_ABS);
 
 #ifdef CONFIG_KVM_EXIT_TIMING
 	mutex_init(&vcpu->arch.exit_timing_lock);
Signature · 1 line
2.39.5
author
#3 lore raw

PATCH v2 3/31 KVM: s390: Switch to use hrtimer_setup()

In reply to Nam Cao

hrtimer_setup() takes the callback function pointer as argument and initializes the timer completely.

Replace hrtimer_init() and the open coded initialization of hrtimer::function with the new setup mechanism.

Patch was created by using Coccinelle.

Cc Christian Borntraeger <[email protected]>
---
 arch/s390/kvm/interrupt.c | 3 +--
 arch/s390/kvm/kvm-s390.c  | 4 ++--
 2 files changed, 3 insertions(+), 4 deletions(-)
arch/s390/kvm/interrupt.c +1 -2
index d4f031e086fc..11a33fa21dfd 100644
@@ -3171,8 +3171,7 @@ void kvm_s390_gisa_init(struct kvm *kvm)
 	gi->alert.mask = 0;
 	spin_lock_init(&gi->alert.ref_lock);
 	gi->expires = 50 * 1000; /* 50 usec */
-	hrtimer_init(&gi->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	gi->timer.function = gisa_vcpu_kicker;
+	hrtimer_setup(&gi->timer, gisa_vcpu_kicker, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 	memset(gi->origin, 0, sizeof(struct kvm_s390_gisa));
 	gi->origin->next_alert = (u32)virt_to_phys(gi->origin);
 	VM_EVENT(kvm, 3, "gisa 0x%pK initialized", gi->origin);
arch/s390/kvm/kvm-s390.c +2 -2
index d8080c27d45b..a0ef902c7a3d 100644
@@ -3930,8 +3930,8 @@ static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu)
 		if (rc)
 			return rc;
 	}
-	hrtimer_init(&vcpu->arch.ckc_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	vcpu->arch.ckc_timer.function = kvm_s390_idle_wakeup;
+	hrtimer_setup(&vcpu->arch.ckc_timer, kvm_s390_idle_wakeup, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 
 	vcpu->arch.sie_block->hpid = HPID_KVM;
 
Signature · 1 line
2.39.5
maintainer Acked-by on v2 3/31
#4 lore raw

Re: [PATCH v2 03/31] KVM: s390: Switch to use hrtimer_setup()

Am 05.02.25 um 11:38 schrieb Nam Cao:

Quoted 10 lines

hrtimer_setup() takes the callback function pointer as argument and initializes the timer completely.

Replace hrtimer_init() and the open coded initialization of hrtimer::function with the new setup mechanism.

Patch was created by using Coccinelle.

Cc Christian Borntraeger <[email protected]>
Quoted 34 lines
---
  arch/s390/kvm/interrupt.c | 3 +--
  arch/s390/kvm/kvm-s390.c  | 4 ++--
  2 files changed, 3 insertions(+), 4 deletions(-)
arch/s390/kvm/interrupt.c +1 -2
index d4f031e086fc..11a33fa21dfd 100644
@@ -3171,8 +3171,7 @@ void kvm_s390_gisa_init(struct kvm *kvm)
  	gi->alert.mask = 0;
  	spin_lock_init(&gi->alert.ref_lock);
  	gi->expires = 50 * 1000; /* 50 usec */
-	hrtimer_init(&gi->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	gi->timer.function = gisa_vcpu_kicker;
+	hrtimer_setup(&gi->timer, gisa_vcpu_kicker, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
  	memset(gi->origin, 0, sizeof(struct kvm_s390_gisa));
  	gi->origin->next_alert = (u32)virt_to_phys(gi->origin);
  	VM_EVENT(kvm, 3, "gisa 0x%pK initialized", gi->origin);
arch/s390/kvm/kvm-s390.c +2 -2
index d8080c27d45b..a0ef902c7a3d 100644
@@ -3930,8 +3930,8 @@ static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu)
  		if (rc)
  			return rc;
  	}
-	hrtimer_init(&vcpu->arch.ckc_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	vcpu->arch.ckc_timer.function = kvm_s390_idle_wakeup;
+	hrtimer_setup(&vcpu->arch.ckc_timer, kvm_s390_idle_wakeup, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 
  	vcpu->arch.sie_block->hpid = HPID_KVM;
 
author
#5 lore raw

PATCH v2 4/31 KVM: x86: Switch to use hrtimer_setup()

In reply to Nam Cao

hrtimer_setup() takes the callback function pointer as argument and initializes the timer completely.

Replace hrtimer_init() and the open coded initialization of hrtimer::function with the new setup mechanism.

Patch was created by using Coccinelle.

Cc Sean Christopherson <[email protected]>
---
 arch/x86/kvm/hyperv.c     | 3 +--
 arch/x86/kvm/i8254.c      | 3 +--
 arch/x86/kvm/lapic.c      | 5 ++---
 arch/x86/kvm/vmx/nested.c | 5 ++---
 arch/x86/kvm/xen.c        | 4 ++--
 5 files changed, 8 insertions(+), 12 deletions(-)
arch/x86/kvm/hyperv.c +1 -2
index 6a6dd5a84f22..eb9bca66bad0 100644
@@ -952,8 +952,7 @@ static void stimer_init(struct kvm_vcpu_hv_stimer *stimer, int timer_index)
 {
 	memset(stimer, 0, sizeof(*stimer));
 	stimer->index = timer_index;
-	hrtimer_init(&stimer->timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
-	stimer->timer.function = stimer_timer_callback;
+	hrtimer_setup(&stimer->timer, stimer_timer_callback, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
 	stimer_prepare_msg(stimer);
 }
 
arch/x86/kvm/i8254.c +1 -2
index d7ab8780ab9e..739aa6c0d0c3 100644
@@ -690,8 +690,7 @@ struct kvm_pit *kvm_create_pit(struct kvm *kvm, u32 flags)
 	pit->kvm = kvm;
 
 	pit_state = &pit->pit_state;
-	hrtimer_init(&pit_state->timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
-	pit_state->timer.function = pit_timer_fn;
+	hrtimer_setup(&pit_state->timer, pit_timer_fn, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
 
 	pit_state->irq_ack_notifier.gsi = 0;
 	pit_state->irq_ack_notifier.irq_acked = kvm_pit_ack_irq;
arch/x86/kvm/lapic.c +2 -3
index a009c94c26c2..eb56cd989574 100644
@@ -2921,9 +2921,8 @@ int kvm_create_lapic(struct kvm_vcpu *vcpu)
 
 	apic->nr_lvt_entries = kvm_apic_calc_nr_lvt_entries(vcpu);
 
-	hrtimer_init(&apic->lapic_timer.timer, CLOCK_MONOTONIC,
-		     HRTIMER_MODE_ABS_HARD);
-	apic->lapic_timer.timer.function = apic_timer_fn;
+	hrtimer_setup(&apic->lapic_timer.timer, apic_timer_fn, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_ABS_HARD);
 	if (lapic_timer_advance)
 		apic->lapic_timer.timer_advance_ns = LAPIC_TIMER_ADVANCE_NS_INIT;
 
arch/x86/kvm/vmx/nested.c +2 -3
index 8a7af02d466e..ca18c3eec76d 100644
@@ -5316,9 +5316,8 @@ static int enter_vmx_operation(struct kvm_vcpu *vcpu)
 	if (enable_shadow_vmcs && !alloc_shadow_vmcs(vcpu))
 		goto out_shadow_vmcs;
 
-	hrtimer_init(&vmx->nested.preemption_timer, CLOCK_MONOTONIC,
-		     HRTIMER_MODE_ABS_PINNED);
-	vmx->nested.preemption_timer.function = vmx_preemption_timer_fn;
+	hrtimer_setup(&vmx->nested.preemption_timer, vmx_preemption_timer_fn, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_ABS_PINNED);
 
 	vmx->nested.vpid02 = allocate_vpid();
 
arch/x86/kvm/xen.c +2 -2
index a909b817b9c0..1ac738dcf7a2 100644
@@ -2225,8 +2225,8 @@ void kvm_xen_init_vcpu(struct kvm_vcpu *vcpu)
 	vcpu->arch.xen.poll_evtchn = 0;
 
 	timer_setup(&vcpu->arch.xen.poll_timer, cancel_evtchn_poll, 0);
-	hrtimer_init(&vcpu->arch.xen.timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_HARD);
-	vcpu->arch.xen.timer.function = xen_timer_callback;
+	hrtimer_setup(&vcpu->arch.xen.timer, xen_timer_callback, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_ABS_HARD);
 
 	kvm_gpc_init(&vcpu->arch.xen.runstate_cache, vcpu->kvm);
 	kvm_gpc_init(&vcpu->arch.xen.runstate2_cache, vcpu->kvm);
Signature · 1 line
2.39.5
maintainer Acked-by on v2 4/31
#6 lore raw

Re: [PATCH v2 04/31] KVM: x86: Switch to use hrtimer_setup()

Quoted 11 lines · Nam Cao

hrtimer_setup() takes the callback function pointer as argument and initializes the timer completely.

Replace hrtimer_init() and the open coded initialization of hrtimer::function with the new setup mechanism.

Patch was created by using Coccinelle.

Cc Sean Christopherson <[email protected]>

---

author
#7 lore raw

PATCH v2 5/31 KVM: arm64: Switch to use hrtimer_setup()

In reply to Nam Cao

hrtimer_setup() takes the callback function pointer as argument and initializes the timer completely.

Replace hrtimer_init() and the open coded initialization of hrtimer::function with the new setup mechanism.

---
 arch/arm64/kvm/arch_timer.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
arch/arm64/kvm/arch_timer.c +3 -4
index d3d243366536..8b1fe7c47d65 100644
@@ -1099,8 +1099,7 @@ static void timer_context_init(struct kvm_vcpu *vcpu, int timerid)
 	else
 		ctxt->offset.vm_offset = &kvm->arch.timer_data.poffset;
 
-	hrtimer_init(&ctxt->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_HARD);
-	ctxt->hrtimer.function = kvm_hrtimer_expire;
+	hrtimer_setup(&ctxt->hrtimer, kvm_hrtimer_expire, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_HARD);
 
 	switch (timerid) {
 	case TIMER_PTIMER:
@@ -1127,8 +1126,8 @@ void kvm_timer_vcpu_init(struct kvm_vcpu *vcpu)
 		timer_set_offset(vcpu_ptimer(vcpu), 0);
 	}
 
-	hrtimer_init(&timer->bg_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_HARD);
-	timer->bg_timer.function = kvm_bg_timer_expire;
+	hrtimer_setup(&timer->bg_timer, kvm_bg_timer_expire, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_ABS_HARD);
 }
 
 void kvm_timer_init_vm(struct kvm *kvm)
Signature · 1 line
2.39.5
author
#8 lore raw

PATCH v2 6/31 LoongArch: KVM: Switch to use hrtimer_setup()

In reply to Nam Cao

hrtimer_setup() takes the callback function pointer as argument and initializes the timer completely.

Replace hrtimer_init() and the open coded initialization of hrtimer::function with the new setup mechanism.

Patch was created by using Coccinelle.

Cc Huacai Chen <[email protected]>
---
 arch/loongarch/kvm/vcpu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/loongarch/kvm/vcpu.c +2 -2
index fb72095c8077..e721127c614e 100644
@@ -1459,8 +1459,8 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu)
 	vcpu->arch.vpid = 0;
 	vcpu->arch.flush_gpa = INVALID_GPA;
 
-	hrtimer_init(&vcpu->arch.swtimer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED_HARD);
-	vcpu->arch.swtimer.function = kvm_swtimer_wakeup;
+	hrtimer_setup(&vcpu->arch.swtimer, kvm_swtimer_wakeup, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_ABS_PINNED_HARD);
 
 	vcpu->arch.handle_exit = kvm_handle_exit;
 	vcpu->arch.guest_eentry = (unsigned long)kvm_loongarch_ops->exc_entry;
Signature · 1 line
2.39.5
author
#9 lore raw

PATCH v2 7/31 riscv: kvm: Switch to use hrtimer_setup()

In reply to Nam Cao

hrtimer_setup() takes the callback function pointer as argument and initializes the timer completely.

Replace hrtimer_init() and the open coded initialization of hrtimer::function with the new setup mechanism.

Patch was created by using Coccinelle.

---
 arch/riscv/kvm/vcpu_timer.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
arch/riscv/kvm/vcpu_timer.c +4 -3
index 96e7a4e463f7..ff672fa71fcc 100644
@@ -248,18 +248,19 @@ int kvm_riscv_vcpu_timer_init(struct kvm_vcpu *vcpu)
 	if (t->init_done)
 		return -EINVAL;
 
-	hrtimer_init(&t->hrt, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 	t->init_done = true;
 	t->next_set = false;
 
 	/* Enable sstc for every vcpu if available in hardware */
 	if (riscv_isa_extension_available(NULL, SSTC)) {
 		t->sstc_enabled = true;
-		t->hrt.function = kvm_riscv_vcpu_vstimer_expired;
+		hrtimer_setup(&t->hrt, kvm_riscv_vcpu_vstimer_expired, CLOCK_MONOTONIC,
+			      HRTIMER_MODE_REL);
 		t->timer_next_event = kvm_riscv_vcpu_update_vstimecmp;
 	} else {
 		t->sstc_enabled = false;
-		t->hrt.function = kvm_riscv_vcpu_hrtimer_expired;
+		hrtimer_setup(&t->hrt, kvm_riscv_vcpu_hrtimer_expired, CLOCK_MONOTONIC,
+			      HRTIMER_MODE_REL);
 		t->timer_next_event = kvm_riscv_vcpu_update_hrtimer;
 	}
 
Signature · 1 line
2.39.5
author
#10 lore raw

PATCH v2 8/31 ARM: imx: Switch to use hrtimer_setup()

In reply to Nam Cao

hrtimer_setup() takes the callback function pointer as argument and initializes the timer completely.

Replace hrtimer_init() and the open coded initialization of hrtimer::function with the new setup mechanism.

Cc Sascha Hauer <[email protected]>
---
 arch/arm/mach-imx/mmdc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
arch/arm/mach-imx/mmdc.c +2 -3
index e898f7c2733e..94e4f4a2f73f 100644
@@ -509,9 +509,8 @@ static int imx_mmdc_perf_init(struct platform_device *pdev, void __iomem *mmdc_b
 	pmu_mmdc->mmdc_ipg_clk = mmdc_ipg_clk;
 	pmu_mmdc->devtype_data = device_get_match_data(&pdev->dev);
 
-	hrtimer_init(&pmu_mmdc->hrtimer, CLOCK_MONOTONIC,
-			HRTIMER_MODE_REL);
-	pmu_mmdc->hrtimer.function = mmdc_pmu_timer_handler;
+	hrtimer_setup(&pmu_mmdc->hrtimer, mmdc_pmu_timer_handler, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 
 	cpumask_set_cpu(raw_smp_processor_id(), &pmu_mmdc->cpu);
 
Signature · 1 line
2.39.5
author
#11 lore raw

PATCH v2 9/31 ARM: 8611/1: l2x0: Switch to use hrtimer_setup()

In reply to Nam Cao

hrtimer_setup() takes the callback function pointer as argument and initializes the timer completely.

Replace hrtimer_init() and the open coded initialization of hrtimer::function with the new setup mechanism.

Patch was created by using Coccinelle.

Cc Russell King <[email protected]>
---
 arch/arm/mm/cache-l2x0-pmu.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm/mm/cache-l2x0-pmu.c +1 -2
index 993fefdc167a..93ef0502b7ff 100644
@@ -539,8 +539,7 @@ static __init int l2x0_pmu_init(void)
 	 * at higher frequencies.
 	 */
 	l2x0_pmu_poll_period = ms_to_ktime(1000);
-	hrtimer_init(&l2x0_pmu_hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	l2x0_pmu_hrtimer.function = l2x0_pmu_poll;
+	hrtimer_setup(&l2x0_pmu_hrtimer, l2x0_pmu_poll, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 
 	cpumask_set_cpu(0, &pmu_cpu);
 	ret = cpuhp_setup_state_nocalls(CPUHP_AP_PERF_ARM_L2X0_ONLINE,
Signature · 1 line
2.39.5
author
#12 lore raw

PATCH v2 10/31 powerpc/watchdog: Switch to use hrtimer_setup()

In reply to Nam Cao

hrtimer_setup() takes the callback function pointer as argument and initializes the timer completely.

Replace hrtimer_init() and the open coded initialization of hrtimer::function with the new setup mechanism.

Patch was created by using Coccinelle.

Cc Michael Ellerman <[email protected]>
---
 arch/powerpc/kernel/watchdog.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/powerpc/kernel/watchdog.c +1 -2
index 8c464a5d8246..2429cb1c7baa 100644
@@ -495,8 +495,7 @@ static void start_watchdog(void *arg)
 
 	*this_cpu_ptr(&wd_timer_tb) = get_tb();
 
-	hrtimer_init(hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	hrtimer->function = watchdog_timer_fn;
+	hrtimer_setup(hrtimer, watchdog_timer_fn, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 	hrtimer_start(hrtimer, ms_to_ktime(wd_timer_period_ms),
 		      HRTIMER_MODE_REL_PINNED);
 }
Signature · 1 line
2.39.5
author
#13 lore raw

PATCH v2 11/31 perf/x86: Switch to use hrtimer_setup()

In reply to Nam Cao

hrtimer_setup() takes the callback function pointer as argument and initializes the timer completely.

Replace hrtimer_init() and the open coded initialization of hrtimer::function with the new setup mechanism.

Patch was created by using Coccinelle.

Cc Peter Zijlstra <[email protected]>
---
 arch/x86/events/intel/uncore.c | 3 +--
 arch/x86/events/rapl.c         | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
arch/x86/events/intel/uncore.c +1 -2
index 60b3078b7502..a34e50fc4a8f 100644
@@ -347,8 +347,7 @@ void uncore_pmu_cancel_hrtimer(struct intel_uncore_box *box)
 
 static void uncore_pmu_init_hrtimer(struct intel_uncore_box *box)
 {
-	hrtimer_init(&box->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	box->hrtimer.function = uncore_pmu_hrtimer;
+	hrtimer_setup(&box->hrtimer, uncore_pmu_hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 }
 
 static struct intel_uncore_box *uncore_alloc_box(struct intel_uncore_type *type,
arch/x86/events/rapl.c +1 -2
index d3bb3865c1b1..2b6cc2860836 100644
@@ -274,8 +274,7 @@ static void rapl_hrtimer_init(struct rapl_pmu *rapl_pmu)
 {
 	struct hrtimer *hr = &rapl_pmu->hrtimer;
 
-	hrtimer_init(hr, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	hr->function = rapl_hrtimer_handle;
+	hrtimer_setup(hr, rapl_hrtimer_handle, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 }
 
 static void __rapl_pmu_event_start(struct rapl_pmu *rapl_pmu,
Signature · 1 line
2.39.5
author
#14 lore raw

PATCH v2 12/31 s390/ap_bus: Switch to use hrtimer_setup()

In reply to Nam Cao

hrtimer_setup() takes the callback function pointer as argument and initializes the timer completely.

Replace hrtimer_init() and the open coded initialization of hrtimer::function with the new setup mechanism.

Patch was created by using Coccinelle.

Cc Christian Borntraeger <[email protected]>
---
 drivers/s390/crypto/ap_bus.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/s390/crypto/ap_bus.c +1 -2
index 26e1ea1940ec..62feb2c639d5 100644
@@ -2326,8 +2326,7 @@ static inline int __init ap_async_init(void)
 	 */
 	if (MACHINE_IS_VM)
 		poll_high_timeout = 1500000;
-	hrtimer_init(&ap_poll_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
-	ap_poll_timer.function = ap_poll_timeout;
+	hrtimer_setup(&ap_poll_timer, ap_poll_timeout, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
 
 	queue_work(system_long_wq, &ap_scan_bus_work);
 
Signature · 1 line
2.39.5
author
#15 lore raw

PATCH v2 13/31 sched: Switch to use hrtimer_setup()

In reply to Nam Cao

hrtimer_setup() takes the callback function pointer as argument and initializes the timer completely.

Replace hrtimer_init() and the open coded initialization of hrtimer::function with the new setup mechanism.

Cc Peter Zijlstra <[email protected]>
---
 kernel/sched/core.c     | 3 +--
 kernel/sched/deadline.c | 6 ++----
 kernel/sched/fair.c     | 8 ++++----
 kernel/sched/rt.c       | 5 ++---
 4 files changed, 9 insertions(+), 13 deletions(-)
kernel/sched/core.c +1 -2
index 165c90ba64ea..357ff79cc760 100644
@@ -916,8 +916,7 @@ static void hrtick_rq_init(struct rq *rq)
 #ifdef CONFIG_SMP
 	INIT_CSD(&rq->hrtick_csd, __hrtick_start, rq);
 #endif
-	hrtimer_init(&rq->hrtick_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
-	rq->hrtick_timer.function = hrtick;
+	hrtimer_setup(&rq->hrtick_timer, hrtick, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
 }
 #else	/* CONFIG_SCHED_HRTICK */
 static inline void hrtick_clear(struct rq *rq)
kernel/sched/deadline.c +2 -4
index 38e4537790af..2d0f571f95e9 100644
@@ -1382,8 +1382,7 @@ static void init_dl_task_timer(struct sched_dl_entity *dl_se)
 {
 	struct hrtimer *timer = &dl_se->dl_timer;
 
-	hrtimer_init(timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
-	timer->function = dl_task_timer;
+	hrtimer_setup(timer, dl_task_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
 }
 
 /*
@@ -1839,8 +1838,7 @@ static void init_dl_inactive_task_timer(struct sched_dl_entity *dl_se)
 {
 	struct hrtimer *timer = &dl_se->inactive_timer;
 
-	hrtimer_init(timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
-	timer->function = inactive_task_timer;
+	hrtimer_setup(timer, inactive_task_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
 }
 
 #define __node_2_dle(node) \
kernel/sched/fair.c +4 -4
index 1c0ef435a7aa..88923f1873f6 100644
@@ -6539,14 +6539,14 @@ void init_cfs_bandwidth(struct cfs_bandwidth *cfs_b, struct cfs_bandwidth *paren
 	cfs_b->hierarchical_quota = parent ? parent->hierarchical_quota : RUNTIME_INF;
 
 	INIT_LIST_HEAD(&cfs_b->throttled_cfs_rq);
-	hrtimer_init(&cfs_b->period_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED);
-	cfs_b->period_timer.function = sched_cfs_period_timer;
+	hrtimer_setup(&cfs_b->period_timer, sched_cfs_period_timer, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_ABS_PINNED);
 
 	/* Add a random offset so that timers interleave */
 	hrtimer_set_expires(&cfs_b->period_timer,
 			    get_random_u32_below(cfs_b->period));
-	hrtimer_init(&cfs_b->slack_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	cfs_b->slack_timer.function = sched_cfs_slack_timer;
+	hrtimer_setup(&cfs_b->slack_timer, sched_cfs_slack_timer, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 	cfs_b->slack_started = false;
 }
 
kernel/sched/rt.c +2 -3
index 4b8e33c615b1..7a9ed4d93397 100644
@@ -127,9 +127,8 @@ void init_rt_bandwidth(struct rt_bandwidth *rt_b, u64 period, u64 runtime)
 
 	raw_spin_lock_init(&rt_b->rt_runtime_lock);
 
-	hrtimer_init(&rt_b->rt_period_timer, CLOCK_MONOTONIC,
-		     HRTIMER_MODE_REL_HARD);
-	rt_b->rt_period_timer.function = sched_rt_period_timer;
+	hrtimer_setup(&rt_b->rt_period_timer, sched_rt_period_timer, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL_HARD);
 }
 
 static inline void do_start_rt_bandwidth(struct rt_bandwidth *rt_b)
Signature · 1 line
2.39.5
author
#16 lore raw

PATCH v2 14/31 mm/slab: Switch to use hrtimer_setup()

In reply to Nam Cao

hrtimer_setup() takes the callback function pointer as argument and initializes the timer completely.

Replace hrtimer_init() and the open coded initialization of hrtimer::function with the new setup mechanism.

Patch was created by using Coccinelle.

---
 mm/slab_common.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mm/slab_common.c +2 -2
index 4030907b6b7d..59578dafbf37 100644
@@ -1887,8 +1887,8 @@ run_page_cache_worker(struct kfree_rcu_cpu *krcp)
 				&krcp->page_cache_work,
 					msecs_to_jiffies(rcu_delay_page_cache_fill_msec));
 		} else {
-			hrtimer_init(&krcp->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-			krcp->hrtimer.function = schedule_page_work_fn;
+			hrtimer_setup(&krcp->hrtimer, schedule_page_work_fn, CLOCK_MONOTONIC,
+				      HRTIMER_MODE_REL);
 			hrtimer_start(&krcp->hrtimer, 0, HRTIMER_MODE_REL);
 		}
 	}
Signature · 1 line
2.39.5
author
#17 lore raw

PATCH v2 15/31 lib: test_objpool: Switch to use hrtimer_setup()

In reply to Nam Cao

hrtimer_setup() takes the callback function pointer as argument and initializes the timer completely.

Replace hrtimer_init() and the open coded initialization of hrtimer::function with the new setup mechanism.

Patch was created by using Coccinelle.

Cc Andrew Morton <[email protected]>
---
 lib/test_objpool.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
lib/test_objpool.c +1 -2
index 896c0131c9a8..8f688187fa87 100644
@@ -190,8 +190,7 @@ static int ot_init_hrtimer(struct ot_item *item, unsigned long hrtimer)
 		return -ENOENT;
 
 	item->hrtcycle = ktime_set(0, hrtimer * 1000000UL);
-	hrtimer_init(hrt, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	hrt->function = ot_hrtimer_handler;
+	hrtimer_setup(hrt, ot_hrtimer_handler, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 	return 0;
 }
 
Signature · 1 line
2.39.5
author
#18 lore raw

PATCH v2 16/31 io_uring/timeout: Switch to use hrtimer_setup()

In reply to Nam Cao

hrtimer_setup() takes the callback function pointer as argument and initializes the timer completely.

Replace hrtimer_init() and the open coded initialization of hrtimer::function with the new setup mechanism.

---
 io_uring/timeout.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
io_uring/timeout.c +6 -7
index 48fc8cf70784..c5fb817b1e28 100644
@@ -407,8 +407,7 @@ static int io_linked_timeout_update(struct io_ring_ctx *ctx, __u64 user_data,
 	io = req->async_data;
 	if (hrtimer_try_to_cancel(&io->timer) == -1)
 		return -EALREADY;
-	hrtimer_init(&io->timer, io_timeout_get_clock(io), mode);
-	io->timer.function = io_link_timeout_fn;
+	hrtimer_setup(&io->timer, io_link_timeout_fn, io_timeout_get_clock(io), mode);
 	hrtimer_start(&io->timer, timespec64_to_ktime(*ts), mode);
 	return 0;
 }
@@ -430,8 +429,7 @@ static int io_timeout_update(struct io_ring_ctx *ctx, __u64 user_data,
 	data->ts = *ts;
 
 	list_add_tail(&timeout->list, &ctx->timeout_list);
-	hrtimer_init(&data->timer, io_timeout_get_clock(data), mode);
-	data->timer.function = io_timeout_fn;
+	hrtimer_setup(&data->timer, io_timeout_fn, io_timeout_get_clock(data), mode);
 	hrtimer_start(&data->timer, timespec64_to_ktime(data->ts), mode);
 	return 0;
 }
@@ -557,7 +555,6 @@ static int __io_timeout_prep(struct io_kiocb *req,
 		return -EINVAL;
 
 	data->mode = io_translate_timeout_mode(flags);
-	hrtimer_init(&data->timer, io_timeout_get_clock(data), data->mode);
 
 	if (is_timeout_link) {
 		struct io_submit_link *link = &req->ctx->submit_state.link;
@@ -568,6 +565,10 @@ static int __io_timeout_prep(struct io_kiocb *req,
 			return -EINVAL;
 		timeout->head = link->last;
 		link->last->flags |= REQ_F_ARM_LTIMEOUT;
+		hrtimer_setup(&data->timer, io_link_timeout_fn, io_timeout_get_clock(data),
+			      data->mode);
+	} else {
+		hrtimer_setup(&data->timer, io_timeout_fn, io_timeout_get_clock(data), data->mode);
 	}
 	return 0;
 }
@@ -627,7 +628,6 @@ int io_timeout(struct io_kiocb *req, unsigned int issue_flags)
 	}
 add:
 	list_add(&timeout->list, entry);
-	data->timer.function = io_timeout_fn;
 	hrtimer_start(&data->timer, timespec64_to_ktime(data->ts), data->mode);
 	raw_spin_unlock_irq(&ctx->timeout_lock);
 	return IOU_ISSUE_SKIP_COMPLETE;
@@ -646,7 +646,6 @@ void io_queue_linked_timeout(struct io_kiocb *req)
 	if (timeout->head) {
 		struct io_timeout_data *data = req->async_data;
 
-		data->timer.function = io_link_timeout_fn;
 		hrtimer_start(&data->timer, timespec64_to_ktime(data->ts),
 				data->mode);
 		list_add_tail(&timeout->list, &ctx->ltimeout_list);
Signature · 1 line
2.39.5
author
#19 lore raw

PATCH v2 17/31 fork: Switch to use hrtimer_setup()

In reply to Nam Cao

hrtimer_setup() takes the callback function pointer as argument and initializes the timer completely.

Replace hrtimer_init() and the open coded initialization of hrtimer::function with the new setup mechanism.

Patch was created by using Coccinelle.

Cc Oleg Nesterov <[email protected]>
---
 kernel/fork.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/fork.c +1 -2
index 735405a9c5f3..e27fe5d5a15c 100644
@@ -1891,8 +1891,7 @@ static int copy_signal(unsigned long clone_flags, struct task_struct *tsk)
 #ifdef CONFIG_POSIX_TIMERS
 	INIT_HLIST_HEAD(&sig->posix_timers);
 	INIT_HLIST_HEAD(&sig->ignored_posix_timers);
-	hrtimer_init(&sig->real_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	sig->real_timer.function = it_real_fn;
+	hrtimer_setup(&sig->real_timer, it_real_fn, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 #endif
 
 	task_lock(current->group_leader);
Signature · 1 line
2.39.5
author
#20 lore raw

PATCH v2 18/31 perf: Switch to use hrtimer_setup()

In reply to Nam Cao

hrtimer_setup() takes the callback function pointer as argument and initializes the timer completely.

Replace hrtimer_init() and the open coded initialization of hrtimer::function with the new setup mechanism.

Patch was created by using Coccinelle.

Cc Peter Zijlstra <[email protected]>
---
 kernel/events/core.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
kernel/events/core.c +3 -4
index 0f8c55990783..59059e348844 100644
@@ -1147,8 +1147,8 @@ static void __perf_mux_hrtimer_init(struct perf_cpu_pmu_context *cpc, int cpu)
 	cpc->hrtimer_interval = ns_to_ktime(NSEC_PER_MSEC * interval);
 
 	raw_spin_lock_init(&cpc->hrtimer_lock);
-	hrtimer_init(timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED_HARD);
-	timer->function = perf_mux_hrtimer_handler;
+	hrtimer_setup(timer, perf_mux_hrtimer_handler, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_ABS_PINNED_HARD);
 }
 
 static int perf_mux_hrtimer_restart(struct perf_cpu_pmu_context *cpc)
@@ -11366,8 +11366,7 @@ static void perf_swevent_init_hrtimer(struct perf_event *event)
 	if (!is_sampling_event(event))
 		return;
 
-	hrtimer_init(&hwc->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
-	hwc->hrtimer.function = perf_swevent_hrtimer;
+	hrtimer_setup(&hwc->hrtimer, perf_swevent_hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
 
 	/*
 	 * Since hrtimers have a fixed rate, we can do a static freq->period
Signature · 1 line
2.39.5
author
#21 lore raw

PATCH v2 19/31 timerfd: Switch to use hrtimer_setup()

In reply to Nam Cao

hrtimer_setup() takes the callback function pointer as argument and initializes the timer completely.

Replace hrtimer_init() and the open coded initialization of hrtimer::function with the new setup mechanism.

Cc Christian Brauner <[email protected]>
---
 fs/timerfd.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
fs/timerfd.c +2 -3
index 9f7eb451a60f..cee007e0d978 100644
@@ -205,9 +205,8 @@ static int timerfd_setup(struct timerfd_ctx *ctx, int flags,
 			   ALARM_REALTIME : ALARM_BOOTTIME,
 			   timerfd_alarmproc);
 	} else {
-		hrtimer_init(&ctx->t.tmr, clockid, htmode);
+		hrtimer_setup(&ctx->t.tmr, timerfd_tmrproc, clockid, htmode);
 		hrtimer_set_expires(&ctx->t.tmr, texp);
-		ctx->t.tmr.function = timerfd_tmrproc;
 	}
 
 	if (texp != 0) {
@@ -429,7 +428,7 @@ SYSCALL_DEFINE2(timerfd_create, int, clockid, int, flags)
 			   ALARM_REALTIME : ALARM_BOOTTIME,
 			   timerfd_alarmproc);
 	else
-		hrtimer_init(&ctx->t.tmr, clockid, HRTIMER_MODE_ABS);
+		hrtimer_setup(&ctx->t.tmr, timerfd_tmrproc, clockid, HRTIMER_MODE_ABS);
 
 	ctx->moffs = ktime_mono_to_real(0);
 
Signature · 1 line
2.39.5
author
#22 lore raw

PATCH v2 20/31 time: Switch to hrtimer_setup()

In reply to Nam Cao

hrtimer_setup() takes the callback function pointer as argument and initializes the timer completely.

Replace hrtimer_init() and the open coded initialization of hrtimer::function with the new setup mechanism.

Cc John Stultz <[email protected]>
---
 kernel/time/ntp.c                    | 3 +--
 kernel/time/posix-timers.c           | 7 +++----
 kernel/time/sched_clock.c            | 3 +--
 kernel/time/tick-broadcast-hrtimer.c | 3 +--
 kernel/time/tick-sched.c             | 6 ++----
 5 files changed, 8 insertions(+), 14 deletions(-)
kernel/time/ntp.c +1 -2
index 163e7a2033b6..b837d3d9d325 100644
@@ -678,8 +678,7 @@ void ntp_notify_cmos_timer(bool offset_set)
 
 static void __init ntp_init_cmos_sync(void)
 {
-	hrtimer_init(&sync_hrtimer, CLOCK_REALTIME, HRTIMER_MODE_ABS);
-	sync_hrtimer.function = sync_timer_callback;
+	hrtimer_setup(&sync_hrtimer, sync_timer_callback, CLOCK_REALTIME, HRTIMER_MODE_ABS);
 }
 #else /* CONFIG_GENERIC_CMOS_UPDATE) || defined(CONFIG_RTC_SYSTOHC) */
 static inline void __init ntp_init_cmos_sync(void) { }
kernel/time/posix-timers.c +3 -4
index 1b675aee99a9..58351f537a04 100644
@@ -381,7 +381,7 @@ static void posix_timer_unhash_and_free(struct k_itimer *tmr)
 
 static int common_timer_create(struct k_itimer *new_timer)
 {
-	hrtimer_init(&new_timer->it.real.timer, new_timer->it_clock, 0);
+	hrtimer_setup(&new_timer->it.real.timer, posix_timer_fn, new_timer->it_clock, 0);
 	return 0;
 }
 
@@ -747,7 +747,7 @@ static void common_hrtimer_arm(struct k_itimer *timr, ktime_t expires,
 	/*
 	 * Posix magic: Relative CLOCK_REALTIME timers are not affected by
 	 * clock modifications, so they become CLOCK_MONOTONIC based under the
-	 * hood. See hrtimer_init(). Update timr->kclock, so the generic
+	 * hood. See hrtimer_setup(). Update timr->kclock, so the generic
 	 * functions which use timr->kclock->clock_get_*() work.
 	 *
 	 * Note: it_clock stays unmodified, because the next timer_set() might
@@ -756,8 +756,7 @@ static void common_hrtimer_arm(struct k_itimer *timr, ktime_t expires,
 	if (timr->it_clock == CLOCK_REALTIME)
 		timr->kclock = absolute ? &clock_realtime : &clock_monotonic;
 
-	hrtimer_init(&timr->it.real.timer, timr->it_clock, mode);
-	timr->it.real.timer.function = posix_timer_fn;
+	hrtimer_setup(&timr->it.real.timer, posix_timer_fn, timr->it_clock, mode);
 
 	if (!absolute)
 		expires = ktime_add_safe(expires, timer->base->get_time());
kernel/time/sched_clock.c +1 -2
index fcca4e72f1ef..cc15fe293719 100644
@@ -263,8 +263,7 @@ void __init generic_sched_clock_init(void)
 	 * Start the timer to keep sched_clock() properly updated and
 	 * sets the initial epoch.
 	 */
-	hrtimer_init(&sched_clock_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
-	sched_clock_timer.function = sched_clock_poll;
+	hrtimer_setup(&sched_clock_timer, sched_clock_poll, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
 	hrtimer_start(&sched_clock_timer, cd.wrap_kt, HRTIMER_MODE_REL_HARD);
 }
 
kernel/time/tick-broadcast-hrtimer.c +1 -2
index e28f9210f8a1..a88b72b0f35e 100644
@@ -100,7 +100,6 @@ static enum hrtimer_restart bc_handler(struct hrtimer *t)
 
 void tick_setup_hrtimer_broadcast(void)
 {
-	hrtimer_init(&bctimer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_HARD);
-	bctimer.function = bc_handler;
+	hrtimer_setup(&bctimer, bc_handler, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_HARD);
 	clockevents_register_device(&ce_broadcast_hrtimer);
 }
kernel/time/tick-sched.c +2 -4
index fa058510af9c..c527b421c865 100644
@@ -1573,12 +1573,10 @@ void tick_setup_sched_timer(bool hrtimer)
 	struct tick_sched *ts = this_cpu_ptr(&tick_cpu_sched);
 
 	/* Emulate tick processing via per-CPU hrtimers: */
-	hrtimer_init(&ts->sched_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_HARD);
+	hrtimer_setup(&ts->sched_timer, tick_nohz_handler, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_HARD);
 
-	if (IS_ENABLED(CONFIG_HIGH_RES_TIMERS) && hrtimer) {
+	if (IS_ENABLED(CONFIG_HIGH_RES_TIMERS) && hrtimer)
 		tick_sched_flag_set(ts, TS_FLAG_HIGHRES);
-		ts->sched_timer.function = tick_nohz_handler;
-	}
 
 	/* Get the next period (per-CPU) */
 	hrtimer_set_expires(&ts->sched_timer, tick_init_jiffy_update());
Signature · 1 line
2.39.5
author
#23 lore raw

PATCH v2 21/31 bpf: Switch to use hrtimer_setup()

In reply to Nam Cao

hrtimer_setup() takes the callback function pointer as argument and initializes the timer completely.

Replace hrtimer_init() and the open coded initialization of hrtimer::function with the new setup mechanism.

Patch was created by using Coccinelle.

Cc Alexei Starovoitov <[email protected]>
---
 kernel/bpf/helpers.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/bpf/helpers.c +1 -2
index f27ce162427a..672abe111282 100644
@@ -1284,8 +1284,7 @@ static int __bpf_async_init(struct bpf_async_kern *async, struct bpf_map *map, u
 
 		atomic_set(&t->cancelling, 0);
 		INIT_WORK(&t->cb.delete_work, bpf_timer_delete_work);
-		hrtimer_init(&t->timer, clockid, HRTIMER_MODE_REL_SOFT);
-		t->timer.function = bpf_timer_cb;
+		hrtimer_setup(&t->timer, bpf_timer_cb, clockid, HRTIMER_MODE_REL_SOFT);
 		cb->value = (void *)async - map->record->timer_off;
 		break;
 	case BPF_ASYNC_TYPE_WQ:
Signature · 1 line
2.39.5
author
#24 lore raw

PATCH v2 22/31 ubifs: Switch to use hrtimer_setup()

In reply to Nam Cao

hrtimer_setup() takes the callback function pointer as argument and initializes the timer completely.

Replace hrtimer_init() and the open coded initialization of hrtimer::function with the new setup mechanism.

Patch was created by using Coccinelle.

Cc Richard Weinberger <[email protected]>
---
 fs/ubifs/io.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/ubifs/io.c +1 -2
index 01d8eb170382..a79f229df475 100644
@@ -1179,8 +1179,7 @@ int ubifs_wbuf_init(struct ubifs_info *c, struct ubifs_wbuf *wbuf)
 	wbuf->c = c;
 	wbuf->next_ino = 0;
 
-	hrtimer_init(&wbuf->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	wbuf->timer.function = wbuf_timer_callback_nolock;
+	hrtimer_setup(&wbuf->timer, wbuf_timer_callback_nolock, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 	return 0;
 }
 
Signature · 1 line
2.39.5
maintainer Acked-by on v2 22/31
#25 lore raw

Re: [PATCH v2 22/31] ubifs: Switch to use hrtimer_setup()

----- Ursprüngliche Mail -----

Quoted 26 lines

Von: "Nam Cao" <[email protected]>
An: "Anna-Maria Behnsen" <[email protected]>, "frederic" <[email protected]>, "tglx" <[email protected]>, "linux-kernel" <[email protected]>
CC: "Nam Cao" <[email protected]>, "richard" <[email protected]>
Gesendet: Mittwoch, 5. Februar 2025 11:39:06
Betreff: [PATCH v2 22/31] ubifs: Switch to use hrtimer_setup()

hrtimer_setup() takes the callback function pointer as argument and initializes the timer completely.

Replace hrtimer_init() and the open coded initialization of hrtimer::function with the new setup mechanism.

Patch was created by using Coccinelle.

Cc Richard Weinberger <[email protected]>

---
fs/ubifs/io.c | 3 +--

1 file changed, 1 insertion(+), 2 deletions(-)
fs/ubifs/io.c +0 -0
index 01d8eb170382..a79f229df475 100644

fs/ubifs/io.c int ubifs_wbuf_init(struct ubifs_info *c, struct · line 1185

Quoted 9 lines
fs/ubifs/io.c +1 -2
@@ -1179,8 +1179,7 @@ int ubifs_wbuf_init(struct ubifs_info *c, struct
 ubifs_wbuf *wbuf)
 	wbuf->c = c;
 	wbuf->next_ino = 0;
 
-	hrtimer_init(&wbuf->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	wbuf->timer.function = wbuf_timer_callback_nolock;
+	hrtimer_setup(&wbuf->timer, wbuf_timer_callback_nolock, CLOCK_MONOTONIC,
 HRTIMER_MODE_REL);
 	return 0;

Thanks,
//richard

author
#26 lore raw

PATCH v2 23/31 watchdog: Switch to use hrtimer_setup()

In reply to Nam Cao

hrtimer_setup() takes the callback function pointer as argument and initializes the timer completely.

Replace hrtimer_init() and the open coded initialization of hrtimer::function with the new setup mechanism.

Patch was created by using Coccinelle.

---
 drivers/watchdog/softdog.c                     | 8 +++-----
 drivers/watchdog/watchdog_dev.c                | 4 ++--
 drivers/watchdog/watchdog_hrtimer_pretimeout.c | 4 ++--
 kernel/watchdog.c                              | 3 +--
 4 files changed, 8 insertions(+), 11 deletions(-)
drivers/watchdog/softdog.c +3 -5
index 7a1096265f18..0820e35ad2e3 100644
@@ -187,14 +187,12 @@ static int __init softdog_init(void)
 	watchdog_set_nowayout(&softdog_dev, nowayout);
 	watchdog_stop_on_reboot(&softdog_dev);
 
-	hrtimer_init(&softdog_ticktock, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	softdog_ticktock.function = softdog_fire;
+	hrtimer_setup(&softdog_ticktock, softdog_fire, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 
 	if (IS_ENABLED(CONFIG_SOFT_WATCHDOG_PRETIMEOUT)) {
 		softdog_info.options |= WDIOF_PRETIMEOUT;
-		hrtimer_init(&softdog_preticktock, CLOCK_MONOTONIC,
-			     HRTIMER_MODE_REL);
-		softdog_preticktock.function = softdog_pretimeout;
+		hrtimer_setup(&softdog_preticktock, softdog_pretimeout, CLOCK_MONOTONIC,
+			      HRTIMER_MODE_REL);
 	}
 
 	if (soft_active_on_boot)
drivers/watchdog/watchdog_dev.c +2 -2
index 19698d87dc57..8369fd94fc1a 100644
@@ -1051,8 +1051,8 @@ static int watchdog_cdev_register(struct watchdog_device *wdd)
 	}
 
 	kthread_init_work(&wd_data->work, watchdog_ping_work);
-	hrtimer_init(&wd_data->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
-	wd_data->timer.function = watchdog_timer_expired;
+	hrtimer_setup(&wd_data->timer, watchdog_timer_expired, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL_HARD);
 	watchdog_hrtimer_pretimeout_init(wdd);
 
 	if (wdd->id == 0) {
drivers/watchdog/watchdog_hrtimer_pretimeout.c +2 -2
index 940b53718a91..fbc7eecd8b20 100644
@@ -23,8 +23,8 @@ void watchdog_hrtimer_pretimeout_init(struct watchdog_device *wdd)
 {
 	struct watchdog_core_data *wd_data = wdd->wd_data;
 
-	hrtimer_init(&wd_data->pretimeout_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	wd_data->pretimeout_timer.function = watchdog_hrtimer_pretimeout;
+	hrtimer_setup(&wd_data->pretimeout_timer, watchdog_hrtimer_pretimeout, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 }
 
 void watchdog_hrtimer_pretimeout_start(struct watchdog_device *wdd)
kernel/watchdog.c +1 -2
index b2da7de39d06..6a98dbc931ac 100644
@@ -797,8 +797,7 @@ static void watchdog_enable(unsigned int cpu)
 	 * Start the timer first to prevent the hardlockup watchdog triggering
 	 * before the timer has a chance to fire.
 	 */
-	hrtimer_init(hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
-	hrtimer->function = watchdog_timer_fn;
+	hrtimer_setup(hrtimer, watchdog_timer_fn, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
 	hrtimer_start(hrtimer, ns_to_ktime(sample_period),
 		      HRTIMER_MODE_REL_PINNED_HARD);
 
Signature · 1 line
2.39.5
maintainer
#27 lore raw

Re: [PATCH v2 23/31] watchdog: Switch to use hrtimer_setup()

Quoted 6 lines · Nam Cao

hrtimer_setup() takes the callback function pointer as argument and initializes the timer completely.

Replace hrtimer_init() and the open coded initialization of hrtimer::function with the new setup mechanism.

Quoted 6 lines

Patch was created by using Coccinelle.

---

Change log missing. I am also personally not a friend of changing multiple drivers in a single patch for changes like this. That makes it all but impossible to revert one of the driver changes if it was wrong without reverting everything.

Guenter

Quoted 76 lines
 drivers/watchdog/softdog.c                     | 8 +++-----
 drivers/watchdog/watchdog_dev.c                | 4 ++--
 drivers/watchdog/watchdog_hrtimer_pretimeout.c | 4 ++--
 kernel/watchdog.c                              | 3 +--
 4 files changed, 8 insertions(+), 11 deletions(-)
drivers/watchdog/softdog.c +3 -5
index 7a1096265f18..0820e35ad2e3 100644
@@ -187,14 +187,12 @@ static int __init softdog_init(void)
 	watchdog_set_nowayout(&softdog_dev, nowayout);
 	watchdog_stop_on_reboot(&softdog_dev);
 
-	hrtimer_init(&softdog_ticktock, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	softdog_ticktock.function = softdog_fire;
+	hrtimer_setup(&softdog_ticktock, softdog_fire, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 
 	if (IS_ENABLED(CONFIG_SOFT_WATCHDOG_PRETIMEOUT)) {
 		softdog_info.options |= WDIOF_PRETIMEOUT;
-		hrtimer_init(&softdog_preticktock, CLOCK_MONOTONIC,
-			     HRTIMER_MODE_REL);
-		softdog_preticktock.function = softdog_pretimeout;
+		hrtimer_setup(&softdog_preticktock, softdog_pretimeout, CLOCK_MONOTONIC,
+			      HRTIMER_MODE_REL);
 	}
 
 	if (soft_active_on_boot)
drivers/watchdog/watchdog_dev.c +2 -2
index 19698d87dc57..8369fd94fc1a 100644
@@ -1051,8 +1051,8 @@ static int watchdog_cdev_register(struct watchdog_device *wdd)
 	}
 
 	kthread_init_work(&wd_data->work, watchdog_ping_work);
-	hrtimer_init(&wd_data->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
-	wd_data->timer.function = watchdog_timer_expired;
+	hrtimer_setup(&wd_data->timer, watchdog_timer_expired, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL_HARD);
 	watchdog_hrtimer_pretimeout_init(wdd);
 
 	if (wdd->id == 0) {
drivers/watchdog/watchdog_hrtimer_pretimeout.c +2 -2
index 940b53718a91..fbc7eecd8b20 100644
@@ -23,8 +23,8 @@ void watchdog_hrtimer_pretimeout_init(struct watchdog_device *wdd)
 {
 	struct watchdog_core_data *wd_data = wdd->wd_data;
 
-	hrtimer_init(&wd_data->pretimeout_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	wd_data->pretimeout_timer.function = watchdog_hrtimer_pretimeout;
+	hrtimer_setup(&wd_data->pretimeout_timer, watchdog_hrtimer_pretimeout, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 }
 
 void watchdog_hrtimer_pretimeout_start(struct watchdog_device *wdd)
kernel/watchdog.c +1 -2
index b2da7de39d06..6a98dbc931ac 100644
@@ -797,8 +797,7 @@ static void watchdog_enable(unsigned int cpu)
 	 * Start the timer first to prevent the hardlockup watchdog triggering
 	 * before the timer has a chance to fire.
 	 */
-	hrtimer_init(hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
-	hrtimer->function = watchdog_timer_fn;
+	hrtimer_setup(hrtimer, watchdog_timer_fn, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
 	hrtimer_start(hrtimer, ns_to_ktime(sample_period),
 		      HRTIMER_MODE_REL_PINNED_HARD);
 
Signature · 1 line
2.39.5
#28 lore raw

Re: [PATCH v2 23/31] watchdog: Switch to use hrtimer_setup()

Quoted 7 lines · Guenter Roeck
Quoted 6 lines · Nam Cao

hrtimer_setup() takes the callback function pointer as argument and initializes the timer completely.

Replace hrtimer_init() and the open coded initialization of hrtimer::function with the new setup mechanism.

Quoted 8 lines
Quoted 6 lines

Patch was created by using Coccinelle.

---

Change log missing.

I read the above as a change log, but _I_ might be missing something.

Quoted 4 lines

I am also personally not a friend of changing
multiple drivers in a single patch for changes like this. That makes it all but impossible to revert one of the driver changes if it was wrong without reverting everything.

Come on. This is a purely mechanical change which is fully equivalent, so splitting it up further is just increasing patch count for no value.

Thanks,

tglx

maintainer
#29 lore raw

Re: [PATCH v2 23/31] watchdog: Switch to use hrtimer_setup()

Quoted 10 lines · Thomas Gleixner
Quoted 9 lines · Guenter Roeck
Quoted 8 lines · Nam Cao

hrtimer_setup() takes the callback function pointer as argument and initializes the timer completely.

Replace hrtimer_init() and the open coded initialization of hrtimer::function with the new setup mechanism.

Patch was created by using Coccinelle.

Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

---

Change log missing.

I read the above as a change log, but _I_ might be missing something.

I have no idea what changed since v1 or why. If you can see that in the patch description, good for you.

Guenter

author
#30 lore raw

Re: [PATCH v2 23/31] watchdog: Switch to use hrtimer_setup()

Hi Guenter,

Quoted 2 lines · Guenter Roeck

I have no idea what changed since v1 or why. If you can see that in the patch description, good for you.

The change log is in the cover letter [1]. I just noticed that I forgot to Cc the cover letter to the watchdog mailing list, sorry about that!

This v2 is sent due to conflict with 6.14-rc1. Most patches (including this one) are the same.

Best regards,
Nam

[1] https://lore.kernel.org/lkml/[email protected]/

author
#31 lore raw

PATCH v2 24/31 tracing/osnoise: Switch to use hrtimer_setup()

In reply to Nam Cao

hrtimer_setup() takes the callback function pointer as argument and initializes the timer completely.

Replace hrtimer_init() and the open coded initialization of hrtimer::function with the new setup mechanism.

Patch was created by using Coccinelle.

---
 kernel/trace/trace_osnoise.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
kernel/trace/trace_osnoise.c +2 -4
index f3a2722ee4c0..15999532956a 100644
@@ -1901,8 +1901,7 @@ static int timerlat_main(void *data)
 	tlat->count = 0;
 	tlat->tracing_thread = false;
 
-	hrtimer_init(&tlat->timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED_HARD);
-	tlat->timer.function = timerlat_irq;
+	hrtimer_setup(&tlat->timer, timerlat_irq, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED_HARD);
 	tlat->kthread = current;
 	osn_var->pid = current->pid;
 	/*
@@ -2456,8 +2455,7 @@ static int timerlat_fd_open(struct inode *inode, struct file *file)
 	tlat = this_cpu_tmr_var();
 	tlat->count = 0;
 
-	hrtimer_init(&tlat->timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED_HARD);
-	tlat->timer.function = timerlat_irq;
+	hrtimer_setup(&tlat->timer, timerlat_irq, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED_HARD);
 
 	migrate_enable();
 	return 0;
Signature · 1 line
2.39.5
author
#32 lore raw

PATCH v2 25/31 block, bfq: Switch to use hrtimer_setup()

In reply to Nam Cao

hrtimer_setup() takes the callback function pointer as argument and initializes the timer completely.

Replace hrtimer_init() and the open coded initialization of hrtimer::function with the new setup mechanism.

Patch was created by using Coccinelle.

---
 block/bfq-iosched.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
block/bfq-iosched.c +2 -3
index 167542201603..abd80dc13562 100644
@@ -7315,9 +7315,8 @@ static int bfq_init_queue(struct request_queue *q, struct elevator_type *e)
 
 	INIT_LIST_HEAD(&bfqd->dispatch);
 
-	hrtimer_init(&bfqd->idle_slice_timer, CLOCK_MONOTONIC,
-		     HRTIMER_MODE_REL);
-	bfqd->idle_slice_timer.function = bfq_idle_slice_timer;
+	hrtimer_setup(&bfqd->idle_slice_timer, bfq_idle_slice_timer, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 
 	bfqd->queue_weights_tree = RB_ROOT_CACHED;
 #ifdef CONFIG_BFQ_GROUP_IOSCHED
Signature · 1 line
2.39.5
author
#33 lore raw

PATCH v2 26/31 ata: pata_octeon_cf: Switch to use hrtimer_setup()

In reply to Nam Cao

hrtimer_setup() takes the callback function pointer as argument and initializes the timer completely.

Replace hrtimer_init() and the open coded initialization of hrtimer::function with the new setup mechanism.

Patch was created by using Coccinelle.

---
 drivers/ata/pata_octeon_cf.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/ata/pata_octeon_cf.c +2 -3
index dce24806a052..2d32125c16fd 100644
@@ -935,9 +935,8 @@ static int octeon_cf_probe(struct platform_device *pdev)
 		ap->mwdma_mask	= enable_dma ? ATA_MWDMA4 : 0;
 
 		/* True IDE mode needs a timer to poll for not-busy.  */
-		hrtimer_init(&cf_port->delayed_finish, CLOCK_MONOTONIC,
-			     HRTIMER_MODE_REL);
-		cf_port->delayed_finish.function = octeon_cf_delayed_finish;
+		hrtimer_setup(&cf_port->delayed_finish, octeon_cf_delayed_finish, CLOCK_MONOTONIC,
+			      HRTIMER_MODE_REL);
 	} else {
 		/* 16 bit but not True IDE */
 		base = cs0 + 0x800;
Signature · 1 line
2.39.5
author
#34 lore raw

PATCH v2 27/31 blk_iocost: Switch to use hrtimer_setup()

In reply to Nam Cao

hrtimer_setup() takes the callback function pointer as argument and initializes the timer completely.

Replace hrtimer_init() and the open coded initialization of hrtimer::function with the new setup mechanism.

Patch was created by using Coccinelle.

---
 block/blk-iocost.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
block/blk-iocost.c +1 -2
index 65a1d4427ccf..ed11438eb4be 100644
@@ -3004,8 +3004,7 @@ static void ioc_pd_init(struct blkg_policy_data *pd)
 	iocg->hweight_inuse = WEIGHT_ONE;
 
 	init_waitqueue_head(&iocg->waitq);
-	hrtimer_init(&iocg->waitq_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
-	iocg->waitq_timer.function = iocg_waitq_timer_fn;
+	hrtimer_setup(&iocg->waitq_timer, iocg_waitq_timer_fn, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
 
 	iocg->level = blkg->blkcg->css.cgroup->level;
 
Signature · 1 line
2.39.5
author
#35 lore raw

PATCH v2 28/31 PM: runtime: Switch to use hrtimer_setup()

In reply to Nam Cao

hrtimer_setup() takes the callback function pointer as argument and initializes the timer completely.

Replace hrtimer_init() and the open coded initialization of hrtimer::function with the new setup mechanism.

Patch was created by using Coccinelle.

---
 drivers/base/power/runtime.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/base/power/runtime.c +2 -2
index 2ee45841486b..425c43b2d478 100644
@@ -1764,8 +1764,8 @@ void pm_runtime_init(struct device *dev)
 	INIT_WORK(&dev->power.work, pm_runtime_work);
 
 	dev->power.timer_expires = 0;
-	hrtimer_init(&dev->power.suspend_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
-	dev->power.suspend_timer.function = pm_suspend_timer_fn;
+	hrtimer_setup(&dev->power.suspend_timer, pm_suspend_timer_fn, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_ABS);
 
 	init_waitqueue_head(&dev->power.wait_queue);
 }
Signature · 1 line
2.39.5
author
#36 lore raw

PATCH v2 29/31 PM / devfreq: rockchip-dfi: Switch to use hrtimer_setup()

In reply to Nam Cao

hrtimer_setup() takes the callback function pointer as argument and initializes the timer completely.

Replace hrtimer_init() and the open coded initialization of hrtimer::function with the new setup mechanism.

Patch was created by using Coccinelle.

---
 drivers/devfreq/event/rockchip-dfi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/devfreq/event/rockchip-dfi.c +1 -2
index e2a1e4463b6f..0470d7c175f4 100644
@@ -642,8 +642,7 @@ static int rockchip_ddr_perf_init(struct rockchip_dfi *dfi)
 	if (ret)
 		return ret;
 
-	hrtimer_init(&dfi->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	dfi->timer.function = rockchip_dfi_timer;
+	hrtimer_setup(&dfi->timer, rockchip_dfi_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 
 	switch (dfi->ddr_type) {
 	case ROCKCHIP_DDRTYPE_LPDDR2:
Signature · 1 line
2.39.5
author
#37 lore raw

PATCH v2 30/31 null_blk: Switch to use hrtimer_setup()

In reply to Nam Cao

hrtimer_setup() takes the callback function pointer as argument and initializes the timer completely.

Replace hrtimer_init() and the open coded initialization of hrtimer::function with the new setup mechanism.

Patch was created by using Coccinelle.

---
 drivers/block/null_blk/main.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/block/null_blk/main.c +3 -4
index d94ef37480bd..16457330c1bc 100644
@@ -1426,8 +1426,7 @@ static void nullb_setup_bwtimer(struct nullb *nullb)
 {
 	ktime_t timer_interval = ktime_set(0, TIMER_INTERVAL);
 
-	hrtimer_init(&nullb->bw_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	nullb->bw_timer.function = nullb_bwtimer_fn;
+	hrtimer_setup(&nullb->bw_timer, nullb_bwtimer_fn, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 	atomic_long_set(&nullb->cur_bytes, mb_per_tick(nullb->dev->mbps));
 	hrtimer_start(&nullb->bw_timer, timer_interval, HRTIMER_MODE_REL);
 }
@@ -1604,8 +1603,8 @@ static blk_status_t null_queue_rq(struct blk_mq_hw_ctx *hctx,
 	might_sleep_if(hctx->flags & BLK_MQ_F_BLOCKING);
 
 	if (!is_poll && nq->dev->irqmode == NULL_IRQ_TIMER) {
-		hrtimer_init(&cmd->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-		cmd->timer.function = null_cmd_timer_expired;
+		hrtimer_setup(&cmd->timer, null_cmd_timer_expired, CLOCK_MONOTONIC,
+			      HRTIMER_MODE_REL);
 	}
 	cmd->error = BLK_STS_OK;
 	cmd->nq = nq;
Signature · 1 line
2.39.5
author
#38 lore raw

PATCH v2 31/31 hwrng: timeriomem: Switch to use hrtimer_setup()

In reply to Nam Cao

hrtimer_setup() takes the callback function pointer as argument and initializes the timer completely.

Replace hrtimer_init() and the open coded initialization of hrtimer::function with the new setup mechanism.

Patch was created by using Coccinelle.

---
 drivers/char/hw_random/timeriomem-rng.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/char/hw_random/timeriomem-rng.c +1 -2
index 7174bfccc7b3..b95f6d0f17ed 100644
@@ -152,8 +152,7 @@ static int timeriomem_rng_probe(struct platform_device *pdev)
 
 	priv->period = ns_to_ktime(period * NSEC_PER_USEC);
 	init_completion(&priv->completion);
-	hrtimer_init(&priv->timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
-	priv->timer.function = timeriomem_rng_trigger;
+	hrtimer_setup(&priv->timer, timeriomem_rng_trigger, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
 
 	priv->rng_ops.name = dev_name(&pdev->dev);
 	priv->rng_ops.read = timeriomem_rng_read;
Signature · 1 line
2.39.5