Skip to contentSkip to conversation

hrtimers: Switch to new hrtimer interface functions (4/5)

PATCH Superseded Nam Cao 11 participants 55 messages Oct 28, 2024 – Nov 2, 2024

Subsystems (60)
DRM drivers Media (V4L/DVB) SCSI USB +56 more subsystems

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Nam Cao

author
#0 lore raw

cover hrtimers: Switch to new hrtimer interface functions (4/5)

This is the forth part of a 5-part series (split for convenience). All 5 parts are:

Part 1: https://lore.kernel.org/lkml/[email protected]
Part 2: https://lore.kernel.org/lkml/[email protected]
Part 3: https://lore.kernel.org/lkml/[email protected]
Part 4: https://lore.kernel.org/lkml/[email protected]
Part 5: https://lore.kernel.org/lkml/[email protected]

To use hrtimer, hrtimer_init() (or one of its variant) must be called, and also the timer's callfack function must be setup separately.

That can cause misuse of hrtimer. For example, because:
- The callback function is not setup
- The callback function is setup while it is not safe to do so

To prevent misuse of hrtimer, this series:
- Introduce new functions hrtimer_setup*(). These new functions are similar to hrtimer_init*(), except that they also sanity-check and initialize the callback function.
- Introduce hrtimer_update_function() which checks that it is safe to change the callback function. The 'function' field of hrtimer is then made private.
- Convert all users to use the new functions.
- Some minor cleanups on the way.

Most conversion patches were created using Coccinelle with the sematic patch below; except for tricky cases that Coccinelle cannot handle, or for some cases where a Coccinelle's bug regarding 100 column limit is triggered. Any patches not mentioning Coccinelle were done manually.

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 Greg Kroah-Hartman <[email protected]>
Cc "Martin K. Petersen" <[email protected]>
Cc Alexandre Belloni <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Sebastian Reichel <[email protected]>
Cc Will Deacon <[email protected]>
Cc Jon Mason <[email protected]>
Cc Jaehoon Chung <[email protected]>
Cc Hans Verkuil <[email protected]>
Cc Jassi Brar <[email protected]>
Cc Pavel Machek <[email protected]>
Cc Dmitry Torokhov <[email protected]>
Cc Jonathan Cameron <[email protected]>
Cc Andi Shyti <[email protected]>
Cc Alexander Shishkin <[email protected]>
Cc Alex Deucher <[email protected]>
Cc Jani Nikula <[email protected]>
Cc Rob Clark <[email protected]>
Cc Lucas De Marchi <[email protected]>
Cc Zack Rusin <[email protected]>
Cc "Michael S. Tsirkin" <[email protected]>
Cc Jason Gunthorpe <[email protected]>
Cc "Uwe Kleine-König" <[email protected]>
Cc Takashi Iwai <[email protected]>

Nam Cao (44):
USB: chipidea: Switch to use hrtimer_setup()
usb: dwc2: Switch to use hrtimer_setup()
usb: fotg210-hcd: Switch to use hrtimer_setup()
usb: gadget: Switch to use hrtimer_setup()
usb: ehci: Switch to use hrtimer_setup()
usb: musb: cppi41: Switch to use hrtimer_setup()
usb: typec: tcpm: Switch to use hrtimer_setup()
serial: 8250: Switch to use hrtimer_setup()
serial: imx: Switch to use hrtimer_setup()
serial: sh-sci: Switch to use hrtimer_setup()
serial: xilinx_uartps: Switch to use hrtimer_setup()
scsi: Switch to use hrtimer_setup()
rtc: class: Switch to use hrtimer_setup()
pps: generators: pps_gen_parport: Switch to use hrtimer_setup()
powercap: Switch to use hrtimer_setup()
power: supply: ab8500_chargalg: Switch to use hrtimer_setup()
power: reset: ltc2952-poweroff: Switch to use hrtimer_setup()
drivers: perf: Switch to use hrtimer_setup()
ntb: ntb_pingpong: Switch to use hrtimer_setup()
mmc: dw_mmc: Switch to use hrtimer_setup()
misc: vcpu_stall_detector: Switch to use hrtimer_setup()
media: Switch to use hrtimer_setup()
mailbox: Switch to use hrtimer_setup()
leds: trigger: pattern: Switch to use hrtimer_setup()
Input: Switch to use hrtimer_setup()
iio: Switch to use hrtimer_setup()
i2c: Switch to use hrtimer_setup()
stm class: heartbeat: Switch to use hrtimer_setup() drm/amdgpu: Switch to use hrtimer_setup() drm/i915/huc: Switch to use hrtimer_setup() drm/i915/gvt: Switch to use hrtimer_setup() drm/i915/perf: Switch to use hrtimer_setup() drm/i915/pmu: Switch to use hrtimer_setup() drm/i915/uncore: Switch to use hrtimer_setup() drm/i915/request: Switch to use hrtimer_setup() drm/msm: Switch to use hrtimer_setup()
drm/vkms: Switch to use hrtimer_setup()
drm/xe/oa: Switch to use hrtimer_setup()
drm/vmwgfx: Switch to use hrtimer_setup()
virtio: mem: Switch to use hrtimer_setup()
RDMA: Switch to use hrtimer_setup()
pwm: gpio: Switch to use hrtimer_setup()
ASoC: fsl: imx-pcm-fiq: Switch to use hrtimer_setup()
ALSA: Switch to use hrtimer_setup()

 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c         |  4 ++--
 drivers/gpu/drm/i915/gt/uc/intel_huc.c           |  4 ++--
 drivers/gpu/drm/i915/gvt/display.c               |  3 +--
 drivers/gpu/drm/i915/gvt/sched_policy.c          |  3 +--
 drivers/gpu/drm/i915/i915_perf.c                 |  5 ++---
 drivers/gpu/drm/i915/i915_pmu.c                  |  3 +--
 drivers/gpu/drm/i915/i915_request.c              |  3 +--
 drivers/gpu/drm/i915/intel_uncore.c              |  3 +--
 drivers/gpu/drm/msm/msm_fence.c                  |  3 +--
 drivers/gpu/drm/msm/msm_io_utils.c               |  3 +--
 drivers/gpu/drm/vkms/vkms_crtc.c                 |  4 ++--
 drivers/gpu/drm/vmwgfx/vmwgfx_vkms.c             |  4 ++--
 drivers/gpu/drm/xe/xe_oa.c                       |  4 ++--
 drivers/hwtracing/stm/heartbeat.c                |  6 ++----
 drivers/i2c/busses/i2c-imx.c                     |  4 ++--
 drivers/iio/adc/ti-tsc2046.c                     |  4 +---
 drivers/iio/trigger/iio-trig-hrtimer.c           |  4 ++--
 drivers/infiniband/hw/hfi1/init.c                |  5 ++---
 drivers/infiniband/sw/rdmavt/qp.c                |  5 ++---
 drivers/input/joystick/walkera0701.c             |  3 +--
 drivers/input/keyboard/gpio_keys.c               | 10 ++++------
 drivers/leds/trigger/ledtrig-pattern.c           |  4 ++--
 drivers/mailbox/mailbox.c                        |  4 +---
 drivers/media/cec/core/cec-pin.c                 |  3 +--
 drivers/media/pci/cx88/cx88-input.c              |  3 +--
 .../media/platform/chips-media/wave5/wave5-vpu.c |  4 ++--
 drivers/media/rc/pwm-ir-tx.c                     |  3 +--
 drivers/misc/vcpu_stall_detector.c               |  3 +--
 drivers/mmc/host/dw_mmc.c                        |  3 +--
 drivers/ntb/test/ntb_pingpong.c                  |  3 +--
 drivers/perf/arm-ccn.c                           |  5 ++---
 drivers/perf/marvell_cn10k_ddr_pmu.c             |  4 ++--
 drivers/perf/thunderx2_pmu.c                     |  5 ++---
 drivers/power/reset/ltc2952-poweroff.c           |  8 ++++----
 drivers/power/supply/ab8500_chargalg.c           |  9 ++++-----
 drivers/powercap/idle_inject.c                   |  3 +--
 drivers/powercap/intel_rapl_common.c             |  3 +--
 drivers/pps/generators/pps_gen_parport.c         |  3 +--
 drivers/pwm/pwm-gpio.c                           |  5 ++---
 drivers/rtc/class.c                              |  3 +--
 drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c         |  4 +---
 drivers/scsi/lpfc/lpfc_init.c                    |  7 +++----
 drivers/scsi/scsi_debug.c                        |  4 ++--
 drivers/tty/serial/8250/8250_bcm7271.c           |  3 +--
 drivers/tty/serial/8250/8250_port.c              | 10 ++++------
 drivers/tty/serial/imx.c                         |  8 ++++----
 drivers/tty/serial/sh-sci.c                      |  3 +--
 drivers/tty/serial/xilinx_uartps.c               |  4 ++--
 drivers/usb/chipidea/otg_fsm.c                   |  3 +--
 drivers/usb/dwc2/hcd_queue.c                     |  3 +--
 drivers/usb/fotg210/fotg210-hcd.c                |  3 +--
 drivers/usb/gadget/function/f_ncm.c              |  3 +--
 drivers/usb/gadget/udc/dummy_hcd.c               |  6 ++----
 drivers/usb/host/ehci-hcd.c                      |  3 +--
 drivers/usb/musb/musb_cppi41.c                   |  4 ++--
 drivers/usb/typec/tcpm/tcpm.c                    | 16 ++++++++--------
 drivers/virtio/virtio_mem.c                      |  4 ++--
 sound/core/hrtimer.c                             |  3 +--
 sound/drivers/dummy.c                            |  3 +--
 sound/drivers/pcsp/pcsp.c                        |  3 +--
 sound/sh/sh_dac_audio.c                          |  3 +--
 sound/soc/fsl/imx-pcm-fiq.c                      |  3 +--
 62 files changed, 108 insertions(+), 160 deletions(-)
Signature · 1 line
2.39.5
author
#1 lore raw

PATCH 1/44 USB: chipidea: Switch to use hrtimer_setup()

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: Greg Kroah-Hartman <[email protected]>

---
 drivers/usb/chipidea/otg_fsm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/chipidea/otg_fsm.c +1 -2
index c17516c29b63..a093544482d5 100644
@@ -424,8 +424,7 @@ static enum hrtimer_restart ci_otg_hrtimer_func(struct hrtimer *t)
 /* Initialize timers */
 static int ci_otg_init_timers(struct ci_hdrc *ci)
 {
-	hrtimer_init(&ci->otg_fsm_hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
-	ci->otg_fsm_hrtimer.function = ci_otg_hrtimer_func;
+	hrtimer_setup(&ci->otg_fsm_hrtimer, ci_otg_hrtimer_func, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
 
 	return 0;
 }
Signature · 1 line
2.39.5
author
#2 lore raw

PATCH 2/44 usb: dwc2: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: Greg Kroah-Hartman <[email protected]>

---
 drivers/usb/dwc2/hcd_queue.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/dwc2/hcd_queue.c +1 -2
index 238c6fd50e75..2a542a99ec44 100644
@@ -1459,8 +1459,7 @@ static void dwc2_qh_init(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh,
 	/* Initialize QH */
 	qh->hsotg = hsotg;
 	timer_setup(&qh->unreserve_timer, dwc2_unreserve_timer_fn, 0);
-	hrtimer_init(&qh->wait_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	qh->wait_timer.function = &dwc2_wait_timer_fn;
+	hrtimer_setup(&qh->wait_timer, &dwc2_wait_timer_fn, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 	qh->ep_type = ep_type;
 	qh->ep_is_in = ep_is_in;
 
Signature · 1 line
2.39.5
author
#3 lore raw

PATCH 3/44 usb: fotg210-hcd: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: Greg Kroah-Hartman <[email protected]>

---
 drivers/usb/fotg210/fotg210-hcd.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/fotg210/fotg210-hcd.c +1 -2
index 8c5aaf860635..36d4d5ab7a89 100644
@@ -4901,8 +4901,7 @@ static int hcd_fotg210_init(struct usb_hcd *hcd)
 	 */
 	fotg210->need_io_watchdog = 1;
 
-	hrtimer_init(&fotg210->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
-	fotg210->hrtimer.function = fotg210_hrtimer_func;
+	hrtimer_setup(&fotg210->hrtimer, fotg210_hrtimer_func, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
 	fotg210->next_hrtimer_event = FOTG210_HRTIMER_NO_EVENT;
 
 	hcc_params = fotg210_readl(fotg210, &fotg210->caps->hcc_params);
Signature · 1 line
2.39.5
author
#4 lore raw

PATCH 4/44 usb: gadget: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: Greg Kroah-Hartman <[email protected]>

---
 drivers/usb/gadget/function/f_ncm.c | 3 +--
 drivers/usb/gadget/udc/dummy_hcd.c  | 6 ++----
 2 files changed, 3 insertions(+), 6 deletions(-)
drivers/usb/gadget/function/f_ncm.c +1 -2
index 8e761249d672..dcdb6246e542 100644
@@ -1558,8 +1558,7 @@ static int ncm_bind(struct usb_configuration *c, struct usb_function *f)
 	ncm->port.open = ncm_open;
 	ncm->port.close = ncm_close;
 
-	hrtimer_init(&ncm->task_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_SOFT);
-	ncm->task_timer.function = ncm_tx_timeout;
+	hrtimer_setup(&ncm->task_timer, ncm_tx_timeout, CLOCK_MONOTONIC, HRTIMER_MODE_REL_SOFT);
 
 	DBG(cdev, "CDC Network: IN/%s OUT/%s NOTIFY/%s\n",
 			ncm->port.in_ep->name, ncm->port.out_ep->name,
drivers/usb/gadget/udc/dummy_hcd.c +2 -4
index ff7bee78bcc4..bae07e87f37f 100644
@@ -2469,8 +2469,7 @@ static DEVICE_ATTR_RO(urbs);
 
 static int dummy_start_ss(struct dummy_hcd *dum_hcd)
 {
-	hrtimer_init(&dum_hcd->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_SOFT);
-	dum_hcd->timer.function = dummy_timer;
+	hrtimer_setup(&dum_hcd->timer, dummy_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_SOFT);
 	dum_hcd->rh_state = DUMMY_RH_RUNNING;
 	dum_hcd->stream_en_ep = 0;
 	INIT_LIST_HEAD(&dum_hcd->urbp_list);
@@ -2499,8 +2498,7 @@ static int dummy_start(struct usb_hcd *hcd)
 		return dummy_start_ss(dum_hcd);
 
 	spin_lock_init(&dum_hcd->dum->lock);
-	hrtimer_init(&dum_hcd->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_SOFT);
-	dum_hcd->timer.function = dummy_timer;
+	hrtimer_setup(&dum_hcd->timer, dummy_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_SOFT);
 	dum_hcd->rh_state = DUMMY_RH_RUNNING;
 
 	INIT_LIST_HEAD(&dum_hcd->urbp_list);
Signature · 1 line
2.39.5
author
#5 lore raw

PATCH 5/44 usb: ehci: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: Greg Kroah-Hartman <[email protected]>

---
 drivers/usb/host/ehci-hcd.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/host/ehci-hcd.c +1 -2
index 802bfafb1012..127699aa482a 100644
@@ -466,8 +466,7 @@ static int ehci_init(struct usb_hcd *hcd)
 	 */
 	ehci->need_io_watchdog = 1;
 
-	hrtimer_init(&ehci->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
-	ehci->hrtimer.function = ehci_hrtimer_func;
+	hrtimer_setup(&ehci->hrtimer, ehci_hrtimer_func, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
 	ehci->next_hrtimer_event = EHCI_HRTIMER_NO_EVENT;
 
 	hcc_params = ehci_readl(ehci, &ehci->caps->hcc_params);
Signature · 1 line
2.39.5
author
#6 lore raw

PATCH 6/44 usb: musb: cppi41: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: Greg Kroah-Hartman <[email protected]>

---
 drivers/usb/musb/musb_cppi41.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/musb/musb_cppi41.c +2 -2
index 9589243e8951..4cde3abb7006 100644
@@ -760,8 +760,8 @@ cppi41_dma_controller_create(struct musb *musb, void __iomem *base)
 	if (!controller)
 		goto kzalloc_fail;
 
-	hrtimer_init(&controller->early_tx, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	controller->early_tx.function = cppi41_recheck_tx_req;
+	hrtimer_setup(&controller->early_tx, cppi41_recheck_tx_req, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 	INIT_LIST_HEAD(&controller->early_tx_list);
 
 	controller->controller.channel_alloc = cppi41_dma_channel_allocate;
Signature · 1 line
2.39.5
author
#7 lore raw

PATCH 7/44 usb: typec: tcpm: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: Greg Kroah-Hartman <[email protected]>

---
 drivers/usb/typec/tcpm/tcpm.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/usb/typec/tcpm/tcpm.c +8 -8
index fc619478200f..48ae73033972 100644
@@ -7587,14 +7587,14 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
 	kthread_init_work(&port->event_work, tcpm_pd_event_handler);
 	kthread_init_work(&port->enable_frs, tcpm_enable_frs_work);
 	kthread_init_work(&port->send_discover_work, tcpm_send_discover_work);
-	hrtimer_init(&port->state_machine_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	port->state_machine_timer.function = state_machine_timer_handler;
-	hrtimer_init(&port->vdm_state_machine_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	port->vdm_state_machine_timer.function = vdm_state_machine_timer_handler;
-	hrtimer_init(&port->enable_frs_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	port->enable_frs_timer.function = enable_frs_timer_handler;
-	hrtimer_init(&port->send_discover_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	port->send_discover_timer.function = send_discover_timer_handler;
+	hrtimer_setup(&port->state_machine_timer, state_machine_timer_handler, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
+	hrtimer_setup(&port->vdm_state_machine_timer, vdm_state_machine_timer_handler,
+		      CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+	hrtimer_setup(&port->enable_frs_timer, enable_frs_timer_handler, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
+	hrtimer_setup(&port->send_discover_timer, send_discover_timer_handler, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 
 	spin_lock_init(&port->pd_event_lock);
 
Signature · 1 line
2.39.5
author
#8 lore raw

PATCH 8/44 serial: 8250: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: Greg Kroah-Hartman <[email protected]>

---
 drivers/tty/serial/8250/8250_bcm7271.c |  3 +--
 drivers/tty/serial/8250/8250_port.c    | 10 ++++------
 2 files changed, 5 insertions(+), 8 deletions(-)
drivers/tty/serial/8250/8250_bcm7271.c +1 -2
index 2569ca69223f..766bbdb36d19 100644
@@ -1056,8 +1056,7 @@ static int brcmuart_probe(struct platform_device *pdev)
 	}
 
 	/* setup HR timer */
-	hrtimer_init(&priv->hrt, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
-	priv->hrt.function = brcmuart_hrtimer_func;
+	hrtimer_setup(&priv->hrt, brcmuart_hrtimer_func, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
 
 	up.port.shutdown = brcmuart_shutdown;
 	up.port.startup = brcmuart_startup;
drivers/tty/serial/8250/8250_port.c +4 -6
index 3509af7dc52b..36820eed535a 100644
@@ -546,12 +546,10 @@ static int serial8250_em485_init(struct uart_8250_port *p)
 	if (!p->em485)
 		return -ENOMEM;
 
-	hrtimer_init(&p->em485->stop_tx_timer, CLOCK_MONOTONIC,
-		     HRTIMER_MODE_REL);
-	hrtimer_init(&p->em485->start_tx_timer, CLOCK_MONOTONIC,
-		     HRTIMER_MODE_REL);
-	p->em485->stop_tx_timer.function = &serial8250_em485_handle_stop_tx;
-	p->em485->start_tx_timer.function = &serial8250_em485_handle_start_tx;
+	hrtimer_setup(&p->em485->stop_tx_timer, &serial8250_em485_handle_stop_tx, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
+	hrtimer_setup(&p->em485->start_tx_timer, &serial8250_em485_handle_start_tx, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 	p->em485->port = p;
 	p->em485->active_timer = NULL;
 	p->em485->tx_stopped = true;
Signature · 1 line
2.39.5
author
#9 lore raw

PATCH 9/44 serial: imx: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: Greg Kroah-Hartman <[email protected]>

---
 drivers/tty/serial/imx.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/tty/serial/imx.c +4 -4
index 67d4a72eda77..753325b6d125 100644
@@ -2475,10 +2475,10 @@ static int imx_uart_probe(struct platform_device *pdev)
 		imx_uart_writel(sport, ucr3, UCR3);
 	}
 
-	hrtimer_init(&sport->trigger_start_tx, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	hrtimer_init(&sport->trigger_stop_tx, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	sport->trigger_start_tx.function = imx_trigger_start_tx;
-	sport->trigger_stop_tx.function = imx_trigger_stop_tx;
+	hrtimer_setup(&sport->trigger_start_tx, imx_trigger_start_tx, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
+	hrtimer_setup(&sport->trigger_stop_tx, imx_trigger_stop_tx, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 
 	/*
 	 * Allocate the IRQ(s) i.MX1 has three interrupts whereas later
Signature · 1 line
2.39.5
author
#10 lore raw

PATCH 10/44 serial: sh-sci: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: Greg Kroah-Hartman <[email protected]>

---
 drivers/tty/serial/sh-sci.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/tty/serial/sh-sci.c +1 -2
index b80e9a528e17..42e9722c2c82 100644
@@ -1695,8 +1695,7 @@ static void sci_request_dma(struct uart_port *port)
 			dma += s->buf_len_rx;
 		}
 
-		hrtimer_init(&s->rx_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-		s->rx_timer.function = sci_dma_rx_timer_fn;
+		hrtimer_setup(&s->rx_timer, sci_dma_rx_timer_fn, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 
 		s->chan_rx_saved = s->chan_rx = chan;
 
Signature · 1 line
2.39.5
author
#11 lore raw

PATCH 11/44 serial: xilinx_uartps: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: Greg Kroah-Hartman <[email protected]>

---
 drivers/tty/serial/xilinx_uartps.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/serial/xilinx_uartps.c +2 -2
index 777392914819..4e9a63590c82 100644
@@ -1628,8 +1628,8 @@ static int cdns_rs485_config(struct uart_port *port, struct ktermios *termios,
 		writel(val, port->membase + CDNS_UART_MODEMCR);
 
 		/* Timer setup */
-		hrtimer_init(&cdns_uart->tx_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-		cdns_uart->tx_timer.function = &cdns_rs485_tx_callback;
+		hrtimer_setup(&cdns_uart->tx_timer, &cdns_rs485_tx_callback, CLOCK_MONOTONIC,
+			      HRTIMER_MODE_REL);
 
 		/* Disable transmitter and make Rx setup*/
 		cdns_uart_stop_tx(port);
Signature · 1 line
2.39.5
author
#12 lore raw

PATCH 12/44 scsi: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: "Martin K. Petersen" <[email protected]>

---
 drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c | 4 +---
 drivers/scsi/lpfc/lpfc_init.c            | 7 +++----
 drivers/scsi/scsi_debug.c                | 4 ++--
 3 files changed, 6 insertions(+), 9 deletions(-)
drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c +1 -3
index 16d085d56e9d..9e42230e42b8 100644
@@ -2922,9 +2922,7 @@ static long ibmvscsis_alloctimer(struct scsi_info *vscsi)
 	struct timer_cb *p_timer;
 
 	p_timer = &vscsi->rsp_q_timer;
-	hrtimer_init(&p_timer->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-
-	p_timer->timer.function = ibmvscsis_service_wait_q;
+	hrtimer_setup(&p_timer->timer, ibmvscsis_service_wait_q, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 	p_timer->started = false;
 	p_timer->timer_pops = 0;
 
drivers/scsi/lpfc/lpfc_init.c +3 -4
index 0dd451009b07..5dc9f47af1f2 100644
@@ -7969,11 +7969,10 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba)
 	timer_setup(&phba->fcf.redisc_wait, lpfc_sli4_fcf_redisc_wait_tmo, 0);
 
 	/* CMF congestion timer */
-	hrtimer_init(&phba->cmf_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	phba->cmf_timer.function = lpfc_cmf_timer;
+	hrtimer_setup(&phba->cmf_timer, lpfc_cmf_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 	/* CMF 1 minute stats collection timer */
-	hrtimer_init(&phba->cmf_stats_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	phba->cmf_stats_timer.function = lpfc_cmf_stats_timer;
+	hrtimer_setup(&phba->cmf_stats_timer, lpfc_cmf_stats_timer, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 
 	/*
 	 * Control structure for handling external multi-buffer mailbox
drivers/scsi/scsi_debug.c +2 -2
index d95f417e24c0..6ddd2f83003d 100644
@@ -6385,8 +6385,8 @@ static struct sdebug_queued_cmd *sdebug_alloc_queued_cmd(struct scsi_cmnd *scmd)
 
 	sd_dp = &sqcp->sd_dp;
 
-	hrtimer_init(&sd_dp->hrt, CLOCK_MONOTONIC, HRTIMER_MODE_REL_PINNED);
-	sd_dp->hrt.function = sdebug_q_cmd_hrt_complete;
+	hrtimer_setup(&sd_dp->hrt, sdebug_q_cmd_hrt_complete, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL_PINNED);
 	INIT_WORK(&sd_dp->ew.work, sdebug_q_cmd_wq_complete);
 
 	sqcp->scmd = scmd;
Signature · 1 line
2.39.5
author
#13 lore raw

PATCH 13/44 rtc: class: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: Alexandre Belloni <[email protected]>

---
 drivers/rtc/class.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/rtc/class.c +1 -2
index e31fa0ad127e..b88cd4fb295b 100644
@@ -240,8 +240,7 @@ static struct rtc_device *rtc_allocate_device(void)
 	/* Init uie timer */
 	rtc_timer_init(&rtc->uie_rtctimer, rtc_uie_update_irq, rtc);
 	/* Init pie timer */
-	hrtimer_init(&rtc->pie_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	rtc->pie_timer.function = rtc_pie_update_irq;
+	hrtimer_setup(&rtc->pie_timer, rtc_pie_update_irq, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 	rtc->pie_enabled = 0;
 
 	set_bit(RTC_FEATURE_ALARM, rtc->features);
Signature · 1 line
2.39.5
author
#14 lore raw

PATCH 14/44 pps: generators: pps_gen_parport: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: Greg Kroah-Hartman <[email protected]>

---
 drivers/pps/generators/pps_gen_parport.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/pps/generators/pps_gen_parport.c +1 -2
index d46eed159495..f5eeb4dd01ad 100644
@@ -208,8 +208,7 @@ static void parport_attach(struct parport *port)
 
 	calibrate_port(&device);
 
-	hrtimer_init(&device.timer, CLOCK_REALTIME, HRTIMER_MODE_ABS);
-	device.timer.function = hrtimer_event;
+	hrtimer_setup(&device.timer, hrtimer_event, CLOCK_REALTIME, HRTIMER_MODE_ABS);
 	hrtimer_start(&device.timer, next_intr_time(&device), HRTIMER_MODE_ABS);
 
 	return;
Signature · 1 line
2.39.5
author
#15 lore raw

PATCH 15/44 powercap: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: "Rafael J. Wysocki" <[email protected]>

---
 drivers/powercap/idle_inject.c       | 3 +--
 drivers/powercap/intel_rapl_common.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/powercap/idle_inject.c +1 -2
index bafc59904ed3..29f9f452d445 100644
@@ -339,8 +339,7 @@ struct idle_inject_device *idle_inject_register_full(struct cpumask *cpumask,
 		return NULL;
 
 	cpumask_copy(to_cpumask(ii_dev->cpumask), cpumask);
-	hrtimer_init(&ii_dev->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	ii_dev->timer.function = idle_inject_timer_fn;
+	hrtimer_setup(&ii_dev->timer, idle_inject_timer_fn, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 	ii_dev->latency_us = UINT_MAX;
 	ii_dev->update = update;
 
drivers/powercap/intel_rapl_common.c +1 -2
index 5e793b80fd6b..e675d4240d9f 100644
@@ -2063,8 +2063,7 @@ int rapl_package_add_pmu(struct rapl_package *rp)
 	raw_spin_lock_init(&data->lock);
 	INIT_LIST_HEAD(&data->active_list);
 	data->timer_interval = ms_to_ktime(rapl_pmu.timer_ms);
-	hrtimer_init(&data->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	data->hrtimer.function = rapl_hrtimer_handle;
+	hrtimer_setup(&data->hrtimer, rapl_hrtimer_handle, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 
 	return rapl_pmu_update(rp);
 }
Signature · 1 line
2.39.5
maintainer Acked-by on v1 15/44
#16 lore raw

Re: [PATCH 15/44] powercap: Switch to use hrtimer_setup()

Quoted 5 lines · Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Quoted 7 lines

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: "Rafael J. Wysocki" <[email protected]>

Fine by me.

Quoted 36 lines
---
 drivers/powercap/idle_inject.c       | 3 +--
 drivers/powercap/intel_rapl_common.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/powercap/idle_inject.c +1 -2
index bafc59904ed3..29f9f452d445 100644
@@ -339,8 +339,7 @@ struct idle_inject_device *idle_inject_register_full(struct cpumask *cpumask,
                return NULL;
 
        cpumask_copy(to_cpumask(ii_dev->cpumask), cpumask);
-       hrtimer_init(&ii_dev->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-       ii_dev->timer.function = idle_inject_timer_fn;
+       hrtimer_setup(&ii_dev->timer, idle_inject_timer_fn, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
        ii_dev->latency_us = UINT_MAX;
        ii_dev->update = update;
 
drivers/powercap/intel_rapl_common.c +1 -3
index 5e793b80fd6b..e675d4240d9f 100644
@@ -2063,8 +2063,7 @@ int rapl_package_add_pmu(struct rapl_package *rp)
        raw_spin_lock_init(&data->lock);
        INIT_LIST_HEAD(&data->active_list);
        data->timer_interval = ms_to_ktime(rapl_pmu.timer_ms);
-       hrtimer_init(&data->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-       data->hrtimer.function = rapl_hrtimer_handle;
+       hrtimer_setup(&data->hrtimer, rapl_hrtimer_handle, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 
        return rapl_pmu_update(rp);
 }
--

2.39.5

author
#17 lore raw

PATCH 16/44 power: supply: ab8500_chargalg: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: Linus Walleij <[email protected]>

---
 drivers/power/supply/ab8500_chargalg.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/power/supply/ab8500_chargalg.c +4 -5
index 854491ad3ecd..56afd5d1f8c3 100644
@@ -1788,13 +1788,12 @@ static int ab8500_chargalg_probe(struct platform_device *pdev)
 	psy_cfg.drv_data = di;
 
 	/* Initilialize safety timer */
-	hrtimer_init(&di->safety_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	di->safety_timer.function = ab8500_chargalg_safety_timer_expired;
+	hrtimer_setup(&di->safety_timer, ab8500_chargalg_safety_timer_expired, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 
 	/* Initilialize maintenance timer */
-	hrtimer_init(&di->maintenance_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	di->maintenance_timer.function =
-		ab8500_chargalg_maintenance_timer_expired;
+	hrtimer_setup(&di->maintenance_timer, ab8500_chargalg_maintenance_timer_expired,
+		      CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 
 	/* Init work for chargalg */
 	INIT_DEFERRABLE_WORK(&di->chargalg_periodic_work,
Signature · 1 line
2.39.5
Reviewed-by on v1 16/44
#18 lore raw

Re: [PATCH 16/44] power: supply: ab8500_chargalg: Switch to use hrtimer_setup()

Quoted 9 lines · Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

Yours,
Linus Walleij

author
#19 lore raw

PATCH 17/44 power: reset: ltc2952-poweroff: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: Sebastian Reichel <[email protected]>

---
 drivers/power/reset/ltc2952-poweroff.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/power/reset/ltc2952-poweroff.c +4 -4
index fa25fbd53934..f87ce4686d4f 100644
@@ -162,11 +162,11 @@ static void ltc2952_poweroff_default(struct ltc2952_poweroff *data)
 	data->wde_interval = 300L * NSEC_PER_MSEC;
 	data->trigger_delay = ktime_set(2, 500L * NSEC_PER_MSEC);
 
-	hrtimer_init(&data->timer_trigger, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	data->timer_trigger.function = ltc2952_poweroff_timer_trigger;
+	hrtimer_setup(&data->timer_trigger, ltc2952_poweroff_timer_trigger, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 
-	hrtimer_init(&data->timer_wde, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	data->timer_wde.function = ltc2952_poweroff_timer_wde;
+	hrtimer_setup(&data->timer_wde, ltc2952_poweroff_timer_wde, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 }
 
 static int ltc2952_poweroff_init(struct platform_device *pdev)
Signature · 1 line
2.39.5
author
#20 lore raw

PATCH 18/44 drivers: perf: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: Will Deacon <[email protected]>

---
 drivers/perf/arm-ccn.c               | 5 ++---
 drivers/perf/marvell_cn10k_ddr_pmu.c | 4 ++--
 drivers/perf/thunderx2_pmu.c         | 5 ++---
 3 files changed, 6 insertions(+), 8 deletions(-)
drivers/perf/arm-ccn.c +2 -3
index 5c66b9278862..716c14da5564 100644
@@ -1273,9 +1273,8 @@ static int arm_ccn_pmu_init(struct arm_ccn *ccn)
 	/* No overflow interrupt? Have to use a timer instead. */
 	if (!ccn->irq) {
 		dev_info(ccn->dev, "No access to interrupts, using timer.\n");
-		hrtimer_init(&ccn->dt.hrtimer, CLOCK_MONOTONIC,
-				HRTIMER_MODE_REL);
-		ccn->dt.hrtimer.function = arm_ccn_pmu_timer_handler;
+		hrtimer_setup(&ccn->dt.hrtimer, arm_ccn_pmu_timer_handler, CLOCK_MONOTONIC,
+			      HRTIMER_MODE_REL);
 	}
 
 	/* Pick one CPU which we will use to collect data from CCN... */
drivers/perf/marvell_cn10k_ddr_pmu.c +2 -2
index 94f1ebcd2a27..12ee0971b6ee 100644
@@ -677,8 +677,8 @@ static int cn10k_ddr_perf_probe(struct platform_device *pdev)
 	if (!name)
 		return -ENOMEM;
 
-	hrtimer_init(&ddr_pmu->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	ddr_pmu->hrtimer.function = cn10k_ddr_pmu_timer_handler;
+	hrtimer_setup(&ddr_pmu->hrtimer, cn10k_ddr_pmu_timer_handler, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 
 	cpuhp_state_add_instance_nocalls(
 				CPUHP_AP_PERF_ARM_MARVELL_CN10K_DDR_ONLINE,
drivers/perf/thunderx2_pmu.c +2 -3
index faf763d2c95c..769a088c8747 100644
@@ -752,9 +752,8 @@ static int tx2_uncore_pmu_add_dev(struct tx2_uncore_pmu *tx2_pmu)
 	tx2_pmu->cpu = cpu;
 
 	if (tx2_pmu->hrtimer_callback) {
-		hrtimer_init(&tx2_pmu->hrtimer,
-				CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-		tx2_pmu->hrtimer.function = tx2_pmu->hrtimer_callback;
+		hrtimer_setup(&tx2_pmu->hrtimer, tx2_pmu->hrtimer_callback, CLOCK_MONOTONIC,
+			      HRTIMER_MODE_REL);
 	}
 
 	ret = tx2_uncore_pmu_register(tx2_pmu);
Signature · 1 line
2.39.5
author
#21 lore raw

PATCH 19/44 ntb: ntb_pingpong: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: Jon Mason <[email protected]>

---
 drivers/ntb/test/ntb_pingpong.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/ntb/test/ntb_pingpong.c +1 -2
index 8aeca7914050..1c1c74f4ff2d 100644
@@ -284,8 +284,7 @@ static struct pp_ctx *pp_create_data(struct ntb_dev *ntb)
 	pp->ntb = ntb;
 	atomic_set(&pp->count, 0);
 	spin_lock_init(&pp->lock);
-	hrtimer_init(&pp->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	pp->timer.function = pp_timer_func;
+	hrtimer_setup(&pp->timer, pp_timer_func, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 
 	return pp;
 }
Signature · 1 line
2.39.5
author
#22 lore raw

PATCH 20/44 mmc: dw_mmc: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: Jaehoon Chung <[email protected]>

---
 drivers/mmc/host/dw_mmc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/mmc/host/dw_mmc.c +1 -2
index 41e451235f63..3a15af97e4e1 100644
@@ -1875,8 +1875,7 @@ static void dw_mci_init_fault(struct dw_mci *host)
 {
 	host->fail_data_crc = (struct fault_attr) FAULT_ATTR_INITIALIZER;
 
-	hrtimer_init(&host->fault_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	host->fault_timer.function = dw_mci_fault_timer;
+	hrtimer_setup(&host->fault_timer, dw_mci_fault_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 }
 #else
 static void dw_mci_init_fault(struct dw_mci *host)
Signature · 1 line
2.39.5
author
#23 lore raw

PATCH 21/44 misc: vcpu_stall_detector: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: Greg Kroah-Hartman <[email protected]>

---
 drivers/misc/vcpu_stall_detector.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/misc/vcpu_stall_detector.c +1 -2
index 41b8c2119e20..dea5f8290895 100644
@@ -111,8 +111,7 @@ static int start_stall_detector_cpu(unsigned int cpu)
 	ping_timeout_ms = vcpu_stall_config.stall_timeout_sec *
 			  MSEC_PER_SEC / 2;
 
-	hrtimer_init(vcpu_hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	vcpu_hrtimer->function = vcpu_stall_detect_timer_fn;
+	hrtimer_setup(vcpu_hrtimer, vcpu_stall_detect_timer_fn, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 	vcpu_stall_detector->is_initialized = true;
 
 	hrtimer_start(vcpu_hrtimer, ms_to_ktime(ping_timeout_ms),
Signature · 1 line
2.39.5
author
#24 lore raw

PATCH 22/44 media: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: Hans Verkuil <[email protected]>

---
 drivers/media/cec/core/cec-pin.c                     | 3 +--
 drivers/media/pci/cx88/cx88-input.c                  | 3 +--
 drivers/media/platform/chips-media/wave5/wave5-vpu.c | 4 ++--
 drivers/media/rc/pwm-ir-tx.c                         | 3 +--
 4 files changed, 5 insertions(+), 8 deletions(-)
drivers/media/cec/core/cec-pin.c +1 -2
index 330d5d5d86ab..fe1cf365a25c 100644
@@ -1345,9 +1345,8 @@ struct cec_adapter *cec_pin_allocate_adapter(const struct cec_pin_ops *pin_ops,
 	if (pin == NULL)
 		return ERR_PTR(-ENOMEM);
 	pin->ops = pin_ops;
-	hrtimer_init(&pin->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 	atomic_set(&pin->work_pin_num_events, 0);
-	pin->timer.function = cec_pin_timer;
+	hrtimer_setup(&pin->timer, cec_pin_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 	init_waitqueue_head(&pin->kthread_waitq);
 	pin->tx_custom_low_usecs = CEC_TIM_CUSTOM_DEFAULT;
 	pin->tx_custom_high_usecs = CEC_TIM_CUSTOM_DEFAULT;
drivers/media/pci/cx88/cx88-input.c +1 -2
index a04a1d33fadb..b9f2c14d62b4 100644
@@ -190,8 +190,7 @@ static int __cx88_ir_start(void *priv)
 	ir = core->ir;
 
 	if (ir->polling) {
-		hrtimer_init(&ir->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-		ir->timer.function = cx88_ir_work;
+		hrtimer_setup(&ir->timer, cx88_ir_work, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 		hrtimer_start(&ir->timer,
 			      ktime_set(0, ir->polling * 1000000),
 			      HRTIMER_MODE_REL);
drivers/media/platform/chips-media/wave5/wave5-vpu.c +2 -2
index 7273254ecb03..d7795d7f8a35 100644
@@ -229,8 +229,8 @@ static int wave5_vpu_probe(struct platform_device *pdev)
 	dev->irq = platform_get_irq(pdev, 0);
 	if (dev->irq < 0) {
 		dev_err(&pdev->dev, "failed to get irq resource, falling back to polling\n");
-		hrtimer_init(&dev->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_PINNED);
-		dev->hrtimer.function = &wave5_vpu_timer_callback;
+		hrtimer_setup(&dev->hrtimer, &wave5_vpu_timer_callback, CLOCK_MONOTONIC,
+			      HRTIMER_MODE_REL_PINNED);
 		dev->worker = kthread_create_worker(0, "vpu_irq_thread");
 		if (IS_ERR(dev->worker)) {
 			dev_err(&pdev->dev, "failed to create vpu irq worker\n");
drivers/media/rc/pwm-ir-tx.c +1 -2
index fe368aebbc13..84533fdd61aa 100644
@@ -172,8 +172,7 @@ static int pwm_ir_probe(struct platform_device *pdev)
 		rcdev->tx_ir = pwm_ir_tx_sleep;
 	} else {
 		init_completion(&pwm_ir->tx_done);
-		hrtimer_init(&pwm_ir->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-		pwm_ir->timer.function = pwm_ir_timer;
+		hrtimer_setup(&pwm_ir->timer, pwm_ir_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 		rcdev->tx_ir = pwm_ir_tx_atomic;
 	}
 
Signature · 1 line
2.39.5
Acked-by on v1 22/44
#25 lore raw

Re: [PATCH 22/44] media: Switch to use hrtimer_setup()

Quoted 9 lines · Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

Regards,

Hans

Quoted 67 lines

---
Cc: Hans Verkuil <[email protected]>

---
 drivers/media/cec/core/cec-pin.c                     | 3 +--
 drivers/media/pci/cx88/cx88-input.c                  | 3 +--
 drivers/media/platform/chips-media/wave5/wave5-vpu.c | 4 ++--
 drivers/media/rc/pwm-ir-tx.c                         | 3 +--
 4 files changed, 5 insertions(+), 8 deletions(-)
drivers/media/cec/core/cec-pin.c +1 -2
index 330d5d5d86ab..fe1cf365a25c 100644
@@ -1345,9 +1345,8 @@ struct cec_adapter *cec_pin_allocate_adapter(const struct cec_pin_ops *pin_ops,
 	if (pin == NULL)
 		return ERR_PTR(-ENOMEM);
 	pin->ops = pin_ops;
-	hrtimer_init(&pin->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 	atomic_set(&pin->work_pin_num_events, 0);
-	pin->timer.function = cec_pin_timer;
+	hrtimer_setup(&pin->timer, cec_pin_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 	init_waitqueue_head(&pin->kthread_waitq);
 	pin->tx_custom_low_usecs = CEC_TIM_CUSTOM_DEFAULT;
 	pin->tx_custom_high_usecs = CEC_TIM_CUSTOM_DEFAULT;
drivers/media/pci/cx88/cx88-input.c +1 -2
index a04a1d33fadb..b9f2c14d62b4 100644
@@ -190,8 +190,7 @@ static int __cx88_ir_start(void *priv)
 	ir = core->ir;
 
 	if (ir->polling) {
-		hrtimer_init(&ir->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-		ir->timer.function = cx88_ir_work;
+		hrtimer_setup(&ir->timer, cx88_ir_work, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 		hrtimer_start(&ir->timer,
 			      ktime_set(0, ir->polling * 1000000),
 			      HRTIMER_MODE_REL);
drivers/media/platform/chips-media/wave5/wave5-vpu.c +2 -2
index 7273254ecb03..d7795d7f8a35 100644
@@ -229,8 +229,8 @@ static int wave5_vpu_probe(struct platform_device *pdev)
 	dev->irq = platform_get_irq(pdev, 0);
 	if (dev->irq < 0) {
 		dev_err(&pdev->dev, "failed to get irq resource, falling back to polling\n");
-		hrtimer_init(&dev->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_PINNED);
-		dev->hrtimer.function = &wave5_vpu_timer_callback;
+		hrtimer_setup(&dev->hrtimer, &wave5_vpu_timer_callback, CLOCK_MONOTONIC,
+			      HRTIMER_MODE_REL_PINNED);
 		dev->worker = kthread_create_worker(0, "vpu_irq_thread");
 		if (IS_ERR(dev->worker)) {
 			dev_err(&pdev->dev, "failed to create vpu irq worker\n");
drivers/media/rc/pwm-ir-tx.c +1 -2
index fe368aebbc13..84533fdd61aa 100644
@@ -172,8 +172,7 @@ static int pwm_ir_probe(struct platform_device *pdev)
 		rcdev->tx_ir = pwm_ir_tx_sleep;
 	} else {
 		init_completion(&pwm_ir->tx_done);
-		hrtimer_init(&pwm_ir->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-		pwm_ir->timer.function = pwm_ir_timer;
+		hrtimer_setup(&pwm_ir->timer, pwm_ir_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 		rcdev->tx_ir = pwm_ir_tx_atomic;
 	}
 
author
#26 lore raw

PATCH 23/44 mailbox: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: Jassi Brar <[email protected]>

---
 drivers/mailbox/mailbox.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/mailbox/mailbox.c +1 -3
index d3d26a2c9895..118beaf447aa 100644
@@ -534,9 +534,7 @@ int mbox_controller_register(struct mbox_controller *mbox)
 			return -EINVAL;
 		}
 
-		hrtimer_init(&mbox->poll_hrt, CLOCK_MONOTONIC,
-			     HRTIMER_MODE_REL);
-		mbox->poll_hrt.function = txdone_hrtimer;
+		hrtimer_setup(&mbox->poll_hrt, txdone_hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 		spin_lock_init(&mbox->poll_hrt_lock);
 	}
 
Signature · 1 line
2.39.5
author
#27 lore raw

PATCH 24/44 leds: trigger: pattern: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: Pavel Machek <[email protected]>

---
 drivers/leds/trigger/ledtrig-pattern.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/leds/trigger/ledtrig-pattern.c +2 -2
index aad48c2540fc..a594bd5e2233 100644
@@ -483,8 +483,8 @@ static int pattern_trig_activate(struct led_classdev *led_cdev)
 	data->led_cdev = led_cdev;
 	led_set_trigger_data(led_cdev, data);
 	timer_setup(&data->timer, pattern_trig_timer_function, 0);
-	hrtimer_init(&data->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	data->hrtimer.function = pattern_trig_hrtimer_function;
+	hrtimer_setup(&data->hrtimer, pattern_trig_hrtimer_function, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 	led_cdev->activated = true;
 
 	if (led_cdev->flags & LED_INIT_DEFAULT_TRIGGER) {
Signature · 1 line
2.39.5
author
#28 lore raw

PATCH 25/44 Input: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: Dmitry Torokhov <[email protected]>

---
 drivers/input/joystick/walkera0701.c |  3 +--
 drivers/input/keyboard/gpio_keys.c   | 10 ++++------
 2 files changed, 5 insertions(+), 8 deletions(-)
drivers/input/joystick/walkera0701.c +1 -2
index 59eea813f258..15370fb82317 100644
@@ -232,8 +232,7 @@ static void walkera0701_attach(struct parport *pp)
 		goto err_unregister_device;
 	}
 
-	hrtimer_init(&w->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	w->timer.function = timer_handler;
+	hrtimer_setup(&w->timer, timer_handler, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 
 	w->input_dev = input_allocate_device();
 	if (!w->input_dev) {
drivers/input/keyboard/gpio_keys.c +4 -6
index 380fe8dab3b0..224cfd0062a1 100644
@@ -592,9 +592,8 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
 
 		INIT_DELAYED_WORK(&bdata->work, gpio_keys_gpio_work_func);
 
-		hrtimer_init(&bdata->debounce_timer,
-			     CLOCK_REALTIME, HRTIMER_MODE_REL);
-		bdata->debounce_timer.function = gpio_keys_debounce_timer;
+		hrtimer_setup(&bdata->debounce_timer, gpio_keys_debounce_timer, CLOCK_REALTIME,
+			      HRTIMER_MODE_REL);
 
 		isr = gpio_keys_gpio_isr;
 		irqflags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING;
@@ -630,9 +629,8 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
 		}
 
 		bdata->release_delay = button->debounce_interval;
-		hrtimer_init(&bdata->release_timer,
-			     CLOCK_REALTIME, HRTIMER_MODE_REL_HARD);
-		bdata->release_timer.function = gpio_keys_irq_timer;
+		hrtimer_setup(&bdata->release_timer, gpio_keys_irq_timer, CLOCK_REALTIME,
+			      HRTIMER_MODE_REL_HARD);
 
 		isr = gpio_keys_irq_isr;
 		irqflags = 0;
Signature · 1 line
2.39.5
author
#29 lore raw

PATCH 26/44 iio: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: Jonathan Cameron <[email protected]>

---
 drivers/iio/adc/ti-tsc2046.c           | 4 +---
 drivers/iio/trigger/iio-trig-hrtimer.c | 4 ++--
 2 files changed, 3 insertions(+), 5 deletions(-)
drivers/iio/adc/ti-tsc2046.c +1 -3
index 311d97001249..87c86d752293 100644
@@ -812,9 +812,7 @@ static int tsc2046_adc_probe(struct spi_device *spi)
 
 	spin_lock_init(&priv->state_lock);
 	priv->state = TSC2046_STATE_SHUTDOWN;
-	hrtimer_init(&priv->trig_timer, CLOCK_MONOTONIC,
-		     HRTIMER_MODE_REL_SOFT);
-	priv->trig_timer.function = tsc2046_adc_timer;
+	hrtimer_setup(&priv->trig_timer, tsc2046_adc_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_SOFT);
 
 	ret = devm_iio_trigger_register(dev, trig);
 	if (ret) {
drivers/iio/trigger/iio-trig-hrtimer.c +2 -2
index 716c795d08fb..82c72baccb62 100644
@@ -145,8 +145,8 @@ static struct iio_sw_trigger *iio_trig_hrtimer_probe(const char *name)
 	trig_info->swt.trigger->ops = &iio_hrtimer_trigger_ops;
 	trig_info->swt.trigger->dev.groups = iio_hrtimer_attr_groups;
 
-	hrtimer_init(&trig_info->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
-	trig_info->timer.function = iio_hrtimer_trig_handler;
+	hrtimer_setup(&trig_info->timer, iio_hrtimer_trig_handler, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL_HARD);
 
 	trig_info->sampling_frequency[0] = HRTIMER_DEFAULT_SAMPLING_FREQUENCY;
 	trig_info->period = NSEC_PER_SEC / trig_info->sampling_frequency[0];
Signature · 1 line
2.39.5
maintainer Acked-by on v1 26/44
#30 lore raw

Re: [PATCH 26/44] iio: Switch to use hrtimer_setup()

Quoted 9 lines · On Mon, 28 Oct 2024 08:35:02 +0100 Nam Cao <[email protected]> wrote:

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

Seems sensible to me.

https://lore.kernel.org/lkml/2159c09badceec667d800005ac98824105ba8dc6.1729864615.git.namcao@linutronix.de/
Has definition of hrtimer_setup()

+CC linux-iio as an FYI.

Jonathan

Quoted 37 lines

---
Cc: Jonathan Cameron <[email protected]>

---
 drivers/iio/adc/ti-tsc2046.c           | 4 +---
 drivers/iio/trigger/iio-trig-hrtimer.c | 4 ++--
 2 files changed, 3 insertions(+), 5 deletions(-)
drivers/iio/adc/ti-tsc2046.c +1 -3
index 311d97001249..87c86d752293 100644
@@ -812,9 +812,7 @@ static int tsc2046_adc_probe(struct spi_device *spi)
 
 	spin_lock_init(&priv->state_lock);
 	priv->state = TSC2046_STATE_SHUTDOWN;
-	hrtimer_init(&priv->trig_timer, CLOCK_MONOTONIC,
-		     HRTIMER_MODE_REL_SOFT);
-	priv->trig_timer.function = tsc2046_adc_timer;
+	hrtimer_setup(&priv->trig_timer, tsc2046_adc_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_SOFT);
 
 	ret = devm_iio_trigger_register(dev, trig);
 	if (ret) {
drivers/iio/trigger/iio-trig-hrtimer.c +2 -2
index 716c795d08fb..82c72baccb62 100644
@@ -145,8 +145,8 @@ static struct iio_sw_trigger *iio_trig_hrtimer_probe(const char *name)
 	trig_info->swt.trigger->ops = &iio_hrtimer_trigger_ops;
 	trig_info->swt.trigger->dev.groups = iio_hrtimer_attr_groups;
 
-	hrtimer_init(&trig_info->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
-	trig_info->timer.function = iio_hrtimer_trig_handler;
+	hrtimer_setup(&trig_info->timer, iio_hrtimer_trig_handler, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL_HARD);
 
 	trig_info->sampling_frequency[0] = HRTIMER_DEFAULT_SAMPLING_FREQUENCY;
 	trig_info->period = NSEC_PER_SEC / trig_info->sampling_frequency[0];
author
#31 lore raw

PATCH 27/44 i2c: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: Andi Shyti <[email protected]>

---
 drivers/i2c/busses/i2c-imx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-imx.c +2 -2
index 98539313cbc9..47f3ea4dc79d 100644
@@ -1417,8 +1417,8 @@ static int i2c_imx_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	spin_lock_init(&i2c_imx->slave_lock);
-	hrtimer_init(&i2c_imx->slave_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
-	i2c_imx->slave_timer.function = i2c_imx_slave_timeout;
+	hrtimer_setup(&i2c_imx->slave_timer, i2c_imx_slave_timeout, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_ABS);
 
 	match = device_get_match_data(&pdev->dev);
 	if (match)
Signature · 1 line
2.39.5
author
#32 lore raw

PATCH 28/44 stm class: heartbeat: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: Alexander Shishkin <[email protected]>

---
 drivers/hwtracing/stm/heartbeat.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/hwtracing/stm/heartbeat.c +2 -4
index e9496fe97baa..495eb1dc8ac5 100644
@@ -81,10 +81,8 @@ static int stm_heartbeat_init(void)
 		stm_heartbeat[i].data.type	= STM_USER;
 		stm_heartbeat[i].data.link	= stm_heartbeat_link;
 		stm_heartbeat[i].data.unlink	= stm_heartbeat_unlink;
-		hrtimer_init(&stm_heartbeat[i].hrtimer, CLOCK_MONOTONIC,
-			     HRTIMER_MODE_ABS);
-		stm_heartbeat[i].hrtimer.function =
-			stm_heartbeat_hrtimer_handler;
+		hrtimer_setup(&stm_heartbeat[i].hrtimer, stm_heartbeat_hrtimer_handler,
+			      CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
 
 		ret = stm_source_register_device(NULL, &stm_heartbeat[i].data);
 		if (ret)
Signature · 1 line
2.39.5
author
#33 lore raw

PATCH 29/44 drm/amdgpu: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: Alex Deucher <[email protected]>

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c +2 -2
index d4c2afafbb73..9f78dd176057 100644
@@ -188,8 +188,8 @@ static int amdgpu_vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
 	amdgpu_crtc->connector = NULL;
 	amdgpu_crtc->vsync_timer_enabled = AMDGPU_IRQ_STATE_DISABLE;
 
-	hrtimer_init(&amdgpu_crtc->vblank_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	amdgpu_crtc->vblank_timer.function = &amdgpu_vkms_vblank_simulate;
+	hrtimer_setup(&amdgpu_crtc->vblank_timer, &amdgpu_vkms_vblank_simulate, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 
 	return ret;
 }
Signature · 1 line
2.39.5
author
#34 lore raw

PATCH 30/44 drm/i915/huc: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: Jani Nikula <[email protected]>

---
 drivers/gpu/drm/i915/gt/uc/intel_huc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/gt/uc/intel_huc.c +2 -2
index 2d9152eb7282..1c1582aef8b9 100644
@@ -231,8 +231,8 @@ static void delayed_huc_load_init(struct intel_huc *huc)
 			   sw_fence_dummy_notify);
 	i915_sw_fence_commit(&huc->delayed_load.fence);
 
-	hrtimer_init(&huc->delayed_load.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	huc->delayed_load.timer.function = huc_delayed_load_timer_callback;
+	hrtimer_setup(&huc->delayed_load.timer, huc_delayed_load_timer_callback, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 }
 
 static void delayed_huc_load_fini(struct intel_huc *huc)
Signature · 1 line
2.39.5
author
#35 lore raw

PATCH 31/44 drm/i915/gvt: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: Jani Nikula <[email protected]>

---
 drivers/gpu/drm/i915/gvt/display.c      | 3 +--
 drivers/gpu/drm/i915/gvt/sched_policy.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/gvt/display.c +1 -2
index c66d6d3177c8..0e80251d2666 100644
@@ -575,8 +575,7 @@ static int setup_virtual_dp_monitor(struct intel_vgpu *vgpu, int port_num,
 	vgpu->display.port_num = port_num;
 
 	/* Init hrtimer based on default refresh rate */
-	hrtimer_init(&vblank_timer->timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
-	vblank_timer->timer.function = vblank_timer_fn;
+	hrtimer_setup(&vblank_timer->timer, vblank_timer_fn, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
 	vblank_timer->vrefresh_k = port->vrefresh_k;
 	vblank_timer->period = DIV64_U64_ROUND_CLOSEST(NSEC_PER_SEC * MSEC_PER_SEC, vblank_timer->vrefresh_k);
 
drivers/gpu/drm/i915/gvt/sched_policy.c +1 -2
index c077fb4674f0..9f97f743aa71 100644
@@ -286,8 +286,7 @@ static int tbs_sched_init(struct intel_gvt *gvt)
 		return -ENOMEM;
 
 	INIT_LIST_HEAD(&data->lru_runq_head);
-	hrtimer_init(&data->timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
-	data->timer.function = tbs_timer_fn;
+	hrtimer_setup(&data->timer, tbs_timer_fn, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
 	data->period = GVT_DEFAULT_TIME_SLICE;
 	data->gvt = gvt;
 
Signature · 1 line
2.39.5
author
#36 lore raw

PATCH 32/44 drm/i915/perf: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: Jani Nikula <[email protected]>

---
 drivers/gpu/drm/i915/i915_perf.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_perf.c +2 -3
index 2406cda75b7b..e82a47ceed68 100644
@@ -3359,9 +3359,8 @@ static int i915_oa_stream_init(struct i915_perf_stream *stream,
 		"opening stream oa config uuid=%s\n",
 		  stream->oa_config->uuid);
 
-	hrtimer_init(&stream->poll_check_timer,
-		     CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	stream->poll_check_timer.function = oa_poll_check_timer_cb;
+	hrtimer_setup(&stream->poll_check_timer, oa_poll_check_timer_cb, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 	init_waitqueue_head(&stream->poll_wq);
 	spin_lock_init(&stream->oa_buffer.ptr_lock);
 	mutex_init(&stream->lock);
Signature · 1 line
2.39.5
author
#37 lore raw

PATCH 33/44 drm/i915/pmu: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: Jani Nikula <[email protected]>

---
 drivers/gpu/drm/i915/i915_pmu.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_pmu.c +1 -2
index 21eb0c5b320d..5f5210a8f58b 100644
@@ -1261,8 +1261,7 @@ void i915_pmu_register(struct drm_i915_private *i915)
 	}
 
 	spin_lock_init(&pmu->lock);
-	hrtimer_init(&pmu->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	pmu->timer.function = i915_sample;
+	hrtimer_setup(&pmu->timer, i915_sample, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 	pmu->cpuhp.cpu = -1;
 	init_rc6(pmu);
 
Signature · 1 line
2.39.5
author
#38 lore raw

PATCH 34/44 drm/i915/uncore: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: Jani Nikula <[email protected]>

---
 drivers/gpu/drm/i915/intel_uncore.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_uncore.c +1 -2
index 6aa179a3e92a..f68e76c5c883 100644
@@ -2098,8 +2098,7 @@ static int __fw_domain_init(struct intel_uncore *uncore,
 
 	d->mask = BIT(domain_id);
 
-	hrtimer_init(&d->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	d->timer.function = intel_uncore_fw_release_timer;
+	hrtimer_setup(&d->timer, intel_uncore_fw_release_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 
 	uncore->fw_domains |= BIT(domain_id);
 
Signature · 1 line
2.39.5
author
#39 lore raw

PATCH 35/44 drm/i915/request: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: Jani Nikula <[email protected]>

---
 drivers/gpu/drm/i915/i915_request.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_request.c +1 -2
index 8f62cfa23fb7..ea0b8e7e4828 100644
@@ -293,8 +293,7 @@ static void __rq_init_watchdog(struct i915_request *rq)
 {
 	struct i915_request_watchdog *wdg = &rq->watchdog;
 
-	hrtimer_init(&wdg->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	wdg->timer.function = __rq_watchdog_expired;
+	hrtimer_setup(&wdg->timer, __rq_watchdog_expired, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 }
 
 static void __rq_arm_watchdog(struct i915_request *rq)
Signature · 1 line
2.39.5
author
#40 lore raw

PATCH 36/44 drm/msm: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: Rob Clark <[email protected]>

---
 drivers/gpu/drm/msm/msm_fence.c    | 3 +--
 drivers/gpu/drm/msm/msm_io_utils.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/msm/msm_fence.c +1 -2
index 1a5d4f1c8b42..d41e5a6bbee0 100644
@@ -65,8 +65,7 @@ msm_fence_context_alloc(struct drm_device *dev, volatile uint32_t *fenceptr,
 	fctx->completed_fence = fctx->last_fence;
 	*fctx->fenceptr = fctx->last_fence;
 
-	hrtimer_init(&fctx->deadline_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
-	fctx->deadline_timer.function = deadline_timer;
+	hrtimer_setup(&fctx->deadline_timer, deadline_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
 
 	kthread_init_work(&fctx->deadline_work, deadline_work);
 
drivers/gpu/drm/msm/msm_io_utils.c +1 -2
index afedd61c3e28..a6efe1eac271 100644
@@ -135,8 +135,7 @@ void msm_hrtimer_work_init(struct msm_hrtimer_work *work,
 			   clockid_t clock_id,
 			   enum hrtimer_mode mode)
 {
-	hrtimer_init(&work->timer, clock_id, mode);
-	work->timer.function = msm_hrtimer_worktimer;
+	hrtimer_setup(&work->timer, msm_hrtimer_worktimer, clock_id, mode);
 	work->worker = worker;
 	kthread_init_work(&work->work, fn);
 }
Signature · 1 line
2.39.5
author
#41 lore raw

PATCH 37/44 drm/vkms: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: Rodrigo Siqueira <[email protected]>

---
 drivers/gpu/drm/vkms/vkms_crtc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/vkms/vkms_crtc.c +2 -2
index 40b4d084e3ce..5fb597bfdcaf 100644
@@ -66,8 +66,8 @@ static int vkms_enable_vblank(struct drm_crtc *crtc)
 
 	drm_calc_timestamping_constants(crtc, &crtc->mode);
 
-	hrtimer_init(&out->vblank_hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	out->vblank_hrtimer.function = &vkms_vblank_simulate;
+	hrtimer_setup(&out->vblank_hrtimer, &vkms_vblank_simulate, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 	out->period_ns = ktime_set(0, vblank->framedur_ns);
 	hrtimer_start(&out->vblank_hrtimer, out->period_ns, HRTIMER_MODE_REL);
 
Signature · 1 line
2.39.5
author
#42 lore raw

PATCH 38/44 drm/xe/oa: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: Lucas De Marchi <[email protected]>

---
 drivers/gpu/drm/xe/xe_oa.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/xe/xe_oa.c +2 -2
index eae38a49ee8e..600eaaee8a72 100644
@@ -1437,8 +1437,8 @@ static int xe_oa_stream_init(struct xe_oa_stream *stream,
 
 	WRITE_ONCE(u->exclusive_stream, stream);
 
-	hrtimer_init(&stream->poll_check_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	stream->poll_check_timer.function = xe_oa_poll_check_timer_cb;
+	hrtimer_setup(&stream->poll_check_timer, xe_oa_poll_check_timer_cb, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 	init_waitqueue_head(&stream->poll_wq);
 
 	spin_lock_init(&stream->oa_buffer.ptr_lock);
Signature · 1 line
2.39.5
Acked-by on v1 38/44
#43 lore raw

Re: [PATCH 38/44] drm/xe/oa: Switch to use hrtimer_setup()

Quoted 9 lines · Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

Lucas De Marchi

Quoted 24 lines

---
Cc: Lucas De Marchi <[email protected]>
---
drivers/gpu/drm/xe/xe_oa.c | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/xe/xe_oa.c +2 -2
index eae38a49ee8e..600eaaee8a72 100644
@@ -1437,8 +1437,8 @@ static int xe_oa_stream_init(struct xe_oa_stream *stream,
 
 	WRITE_ONCE(u->exclusive_stream, stream);
 
-	hrtimer_init(&stream->poll_check_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	stream->poll_check_timer.function = xe_oa_poll_check_timer_cb;
+	hrtimer_setup(&stream->poll_check_timer, xe_oa_poll_check_timer_cb, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 	init_waitqueue_head(&stream->poll_wq);
 
 	spin_lock_init(&stream->oa_buffer.ptr_lock);
Signature · 1 line
2.39.5
author
#44 lore raw

PATCH 39/44 drm/vmwgfx: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

---
Cc: Zack Rusin <[email protected]>

---
 drivers/gpu/drm/vmwgfx/vmwgfx_vkms.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_vkms.c +2 -2
index 8651b788e98b..aec774fa4d7b 100644
@@ -290,8 +290,8 @@ vmw_vkms_enable_vblank(struct drm_crtc *crtc)
 
 	drm_calc_timestamping_constants(crtc, &crtc->mode);
 
-	hrtimer_init(&du->vkms.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	du->vkms.timer.function = &vmw_vkms_vblank_simulate;
+	hrtimer_setup(&du->vkms.timer, &vmw_vkms_vblank_simulate, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 	du->vkms.period_ns = ktime_set(0, vblank->framedur_ns);
 	hrtimer_start(&du->vkms.timer, du->vkms.period_ns, HRTIMER_MODE_REL);
 
Signature · 1 line
2.39.5
author
#45 lore raw

PATCH 40/44 virtio: mem: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

---
Cc: "Michael S. Tsirkin" <[email protected]>

---
 drivers/virtio/virtio_mem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/virtio/virtio_mem.c +2 -2
index b0b871441578..a74ff1418282 100644
@@ -2855,8 +2855,8 @@ static int virtio_mem_probe(struct virtio_device *vdev)
 	mutex_init(&vm->hotplug_mutex);
 	INIT_LIST_HEAD(&vm->next);
 	spin_lock_init(&vm->removal_lock);
-	hrtimer_init(&vm->retry_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	vm->retry_timer.function = virtio_mem_timer_expired;
+	hrtimer_setup(&vm->retry_timer, virtio_mem_timer_expired, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 	vm->retry_timer_ms = VIRTIO_MEM_RETRY_TIMER_MIN_MS;
 	vm->in_kdump = is_kdump_kernel();
 
Signature · 1 line
2.39.5
author
#46 lore raw

PATCH 41/44 RDMA: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

---
Cc: Jason Gunthorpe <[email protected]>

---
 drivers/infiniband/hw/hfi1/init.c | 5 ++---
 drivers/infiniband/sw/rdmavt/qp.c | 5 ++---
 2 files changed, 4 insertions(+), 6 deletions(-)
drivers/infiniband/hw/hfi1/init.c +2 -3
index cbac4a442d9e..d6fbd9c2b8b4 100644
@@ -635,12 +635,11 @@ void hfi1_init_pportdata(struct pci_dev *pdev, struct hfi1_pportdata *ppd,
 	spin_lock_init(&ppd->cca_timer_lock);
 
 	for (i = 0; i < OPA_MAX_SLS; i++) {
-		hrtimer_init(&ppd->cca_timer[i].hrtimer, CLOCK_MONOTONIC,
-			     HRTIMER_MODE_REL);
 		ppd->cca_timer[i].ppd = ppd;
 		ppd->cca_timer[i].sl = i;
 		ppd->cca_timer[i].ccti = 0;
-		ppd->cca_timer[i].hrtimer.function = cca_timer_fn;
+		hrtimer_setup(&ppd->cca_timer[i].hrtimer, cca_timer_fn, CLOCK_MONOTONIC,
+			      HRTIMER_MODE_REL);
 	}
 
 	ppd->cc_max_table_entries = IB_CC_TABLE_CAP_DEFAULT;
drivers/infiniband/sw/rdmavt/qp.c +2 -3
index e6203e26cc06..614009fb9632 100644
@@ -1107,9 +1107,8 @@ int rvt_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *init_attr,
 		}
 		/* initialize timers needed for rc qp */
 		timer_setup(&qp->s_timer, rvt_rc_timeout, 0);
-		hrtimer_init(&qp->s_rnr_timer, CLOCK_MONOTONIC,
-			     HRTIMER_MODE_REL);
-		qp->s_rnr_timer.function = rvt_rc_rnr_retry;
+		hrtimer_setup(&qp->s_rnr_timer, rvt_rc_rnr_retry, CLOCK_MONOTONIC,
+			      HRTIMER_MODE_REL);
 
 		/*
 		 * Driver needs to set up it's private QP structure and do any
Signature · 1 line
2.39.5
author
#47 lore raw

PATCH 42/44 pwm: gpio: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

---
Cc: "Uwe Kleine-König" <[email protected]>

---
 drivers/pwm/pwm-gpio.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/pwm/pwm-gpio.c +2 -3
index 9f8884ac7504..5f4edeb394a9 100644
@@ -207,13 +207,12 @@ static int pwm_gpio_probe(struct platform_device *pdev)
 	chip->ops = &pwm_gpio_ops;
 	chip->atomic = true;
 
-	hrtimer_init(&gpwm->gpio_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+	hrtimer_setup(&gpwm->gpio_timer, pwm_gpio_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+
 	ret = devm_add_action_or_reset(dev, pwm_gpio_disable_hrtimer, gpwm);
 	if (ret)
 		return ret;
 
-	gpwm->gpio_timer.function = pwm_gpio_timer;
-
 	ret = pwmchip_add(chip);
 	if (ret < 0)
 		return dev_err_probe(dev, ret, "could not add pwmchip\n");
Signature · 1 line
2.39.5
author
#48 lore raw

PATCH 43/44 ASoC: fsl: imx-pcm-fiq: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: Takashi Iwai <[email protected]>

---
 sound/soc/fsl/imx-pcm-fiq.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
sound/soc/fsl/imx-pcm-fiq.c +1 -2
index 3391430e4253..83de3ae33691 100644
@@ -185,8 +185,7 @@ static int snd_imx_open(struct snd_soc_component *component,
 
 	atomic_set(&iprtd->playing, 0);
 	atomic_set(&iprtd->capturing, 0);
-	hrtimer_init(&iprtd->hrt, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	iprtd->hrt.function = snd_hrtimer_callback;
+	hrtimer_setup(&iprtd->hrt, snd_hrtimer_callback, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 
 	ret = snd_pcm_hw_constraint_integer(substream->runtime,
 			SNDRV_PCM_HW_PARAM_PERIODS);
Signature · 1 line
2.39.5
author
#49 lore raw

PATCH 44/44 ALSA: Switch to use hrtimer_setup()

In reply to Nam Cao

There is a newly introduced hrtimer_setup() which will replace hrtimer_init(). This new function is similar to the old one, except that it also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

---
Cc: Takashi Iwai <[email protected]>

---
 sound/core/hrtimer.c      | 3 +--
 sound/drivers/dummy.c     | 3 +--
 sound/drivers/pcsp/pcsp.c | 3 +--
 sound/sh/sh_dac_audio.c   | 3 +--
 4 files changed, 4 insertions(+), 8 deletions(-)
sound/core/hrtimer.c +1 -2
index 147c1fea4708..e9c60dce59fb 100644
@@ -66,9 +66,8 @@ static int snd_hrtimer_open(struct snd_timer *t)
 	stime = kzalloc(sizeof(*stime), GFP_KERNEL);
 	if (!stime)
 		return -ENOMEM;
-	hrtimer_init(&stime->hrt, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 	stime->timer = t;
-	stime->hrt.function = snd_hrtimer_callback;
+	hrtimer_setup(&stime->hrt, snd_hrtimer_callback, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 	t->private_data = stime;
 	return 0;
 }
sound/drivers/dummy.c +1 -2
index 8f5df9b3aaaa..c1a3efb633c5 100644
@@ -457,8 +457,7 @@ static int dummy_hrtimer_create(struct snd_pcm_substream *substream)
 	if (!dpcm)
 		return -ENOMEM;
 	substream->runtime->private_data = dpcm;
-	hrtimer_init(&dpcm->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_SOFT);
-	dpcm->timer.function = dummy_hrtimer_callback;
+	hrtimer_setup(&dpcm->timer, dummy_hrtimer_callback, CLOCK_MONOTONIC, HRTIMER_MODE_REL_SOFT);
 	dpcm->substream = substream;
 	atomic_set(&dpcm->running, 0);
 	return 0;
sound/drivers/pcsp/pcsp.c +1 -2
index 78c9b1c7590f..e8482c2290c3 100644
@@ -103,8 +103,7 @@ static int snd_card_pcsp_probe(int devnum, struct device *dev)
 	if (devnum != 0)
 		return -EINVAL;
 
-	hrtimer_init(&pcsp_chip.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	pcsp_chip.timer.function = pcsp_do_timer;
+	hrtimer_setup(&pcsp_chip.timer, pcsp_do_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 
 	err = snd_devm_card_new(dev, index, id, THIS_MODULE, 0, &card);
 	if (err < 0)
sound/sh/sh_dac_audio.c +1 -2
index e7b6ce7bd086..4fb88c3a4902 100644
@@ -313,8 +313,7 @@ static int snd_sh_dac_create(struct snd_card *card,
 
 	chip->card = card;
 
-	hrtimer_init(&chip->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	chip->hrtimer.function = sh_dac_audio_timer;
+	hrtimer_setup(&chip->hrtimer, sh_dac_audio_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 
 	dac_audio_reset(chip);
 	chip->rate = 8000;
Signature · 1 line
2.39.5
#50 lore raw
In reply to Nam Cao
Quoted 8 lines · Nam Cao

This is the forth part of a 5-part series (split for convenience). All 5 parts are:

Part 1: https://lore.kernel.org/lkml/[email protected]
Part 2: https://lore.kernel.org/lkml/[email protected]
Part 3: https://lore.kernel.org/lkml/[email protected]
Part 4: https://lore.kernel.org/lkml/[email protected]
Part 5: https://lore.kernel.org/lkml/[email protected]

Which one do I need to click on to see the actual hrtimer_setup*() implementations? Why is it even a separate series? Please, don't make people click on things.

Quoted 2 lines

To use hrtimer, hrtimer_init() (or one of its variant) must be called, and also the timer's callfack function must be setup separately.

"callback", right?

Quoted 3 lines

That can cause misuse of hrtimer. For example, because:
- The callback function is not setup
- The callback function is setup while it is not safe to do so

These are not examples, these are hypotheticals. Do either of these things actually happen in the codebase?

Quoted 4 lines

To prevent misuse of hrtimer, this series:
- Introduce new functions hrtimer_setup*(). These new functions are similar to hrtimer_init*(), except that they also sanity-check and initialize the callback function.

No, it doesn't. This series only converts some drivers. I'd like to see the sanity-checking in question, since it's the big selling point. But IMO, "switching to a cleaner hrtimer API" or some words to that effect is a better justification than sanity checking.

I'm not objecting to the idea, it's just carried out weirdly.

Quoted 3 lines

- Introduce hrtimer_update_function() which checks that it is safe to change the callback function. The 'function' field of hrtimer is then made private.

Also not in this series.

Quoted 2 lines

- Convert all users to use the new functions.
- Some minor cleanups on the way.

Thanks,
--
Alex

#51 lore raw
Quoted 11 lines · Alexander Shishkin
Quoted 8 lines · Nam Cao

This is the forth part of a 5-part series (split for convenience). All 5 parts are:

Part 1: https://lore.kernel.org/lkml/[email protected]
Part 2: https://lore.kernel.org/lkml/[email protected]
Part 3: https://lore.kernel.org/lkml/[email protected]
Part 4: https://lore.kernel.org/lkml/[email protected]
Part 5: https://lore.kernel.org/lkml/[email protected]

Quoted 3 lines

Which one do I need to click on to see the actual hrtimer_setup*() implementations? Why is it even a separate series? Please, don't make people click on things.

Obviously part 1. The splitup was dont to avoid 500+ people which is generally frowned upon.

Quoted 6 lines
Quoted 3 lines

That can cause misuse of hrtimer. For example, because:
- The callback function is not setup
- The callback function is setup while it is not safe to do so

These are not examples, these are hypotheticals. Do either of these things actually happen in the codebase?

Right now not, but we had this in the past.

Quoted 6 lines
Quoted 4 lines

To prevent misuse of hrtimer, this series:
- Introduce new functions hrtimer_setup*(). These new functions are similar to hrtimer_init*(), except that they also sanity-check and initialize the callback function.

I'm not objecting to the idea, it's just carried out weirdly.

Right. There should have been a sectioning to explain what which part of the series does. My bad.

Thanks,

tglx

maintainer Acked-by on the v1 series
#52 lore raw
In reply to Nam Cao
Quoted 6 lines · Nam Cao

drm/i915/huc: Switch to use hrtimer_setup()
drm/i915/gvt: Switch to use hrtimer_setup()
drm/i915/perf: Switch to use hrtimer_setup()
drm/i915/pmu: Switch to use hrtimer_setup()
drm/i915/uncore: Switch to use hrtimer_setup()
drm/i915/request: Switch to use hrtimer_setup()

for merging the above via whichever tree you find convenient.

Signature · 1 line
Jani Nikula, Intel
maintainer Acked-by on the v1 series
#53 lore raw
In reply to Nam Cao
Quoted 114 lines · Nam Cao

This is the forth part of a 5-part series (split for convenience). All 5 parts are:

Part 1: https://lore.kernel.org/lkml/[email protected]
Part 2: https://lore.kernel.org/lkml/[email protected]
Part 3: https://lore.kernel.org/lkml/[email protected]
Part 4: https://lore.kernel.org/lkml/[email protected]
Part 5: https://lore.kernel.org/lkml/[email protected]

To use hrtimer, hrtimer_init() (or one of its variant) must be called, and also the timer's callfack function must be setup separately.

That can cause misuse of hrtimer. For example, because:
- The callback function is not setup
- The callback function is setup while it is not safe to do so

To prevent misuse of hrtimer, this series:
- Introduce new functions hrtimer_setup*(). These new functions are similar to hrtimer_init*(), except that they also sanity-check and initialize the callback function.
- Introduce hrtimer_update_function() which checks that it is safe to change the callback function. The 'function' field of hrtimer is then made private.
- Convert all users to use the new functions.
- Some minor cleanups on the way.

Most conversion patches were created using Coccinelle with the sematic patch below; except for tricky cases that Coccinelle cannot handle, or for some cases where a Coccinelle's bug regarding 100 column limit is triggered. Any patches not mentioning Coccinelle were done manually.

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 Greg Kroah-Hartman <[email protected]>
Cc "Martin K. Petersen" <[email protected]>
Cc Alexandre Belloni <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Sebastian Reichel <[email protected]>
Cc Will Deacon <[email protected]>
Cc Jon Mason <[email protected]>
Cc Jaehoon Chung <[email protected]>
Cc Hans Verkuil <[email protected]>
Cc Jassi Brar <[email protected]>
Cc Pavel Machek <[email protected]>
Cc Dmitry Torokhov <[email protected]>
Cc Jonathan Cameron <[email protected]>
Cc Andi Shyti <[email protected]>
Cc Alexander Shishkin <[email protected]>
Cc Alex Deucher <[email protected]>
Cc Jani Nikula <[email protected]>
Cc Rob Clark <[email protected]>
Cc Lucas De Marchi <[email protected]>
Cc Zack Rusin <[email protected]>
Cc "Michael S. Tsirkin" <[email protected]>
Cc Jason Gunthorpe <[email protected]>
Cc "Uwe Kleine-König" <[email protected]>
Cc Takashi Iwai <[email protected]>

Nam Cao (44):
USB: chipidea: Switch to use hrtimer_setup()
usb: dwc2: Switch to use hrtimer_setup()
usb: fotg210-hcd: Switch to use hrtimer_setup()
usb: gadget: Switch to use hrtimer_setup()
usb: ehci: Switch to use hrtimer_setup()
usb: musb: cppi41: Switch to use hrtimer_setup()
usb: typec: tcpm: Switch to use hrtimer_setup()
serial: 8250: Switch to use hrtimer_setup()
serial: imx: Switch to use hrtimer_setup()
serial: sh-sci: Switch to use hrtimer_setup()
serial: xilinx_uartps: Switch to use hrtimer_setup()
scsi: Switch to use hrtimer_setup()
rtc: class: Switch to use hrtimer_setup()
pps: generators: pps_gen_parport: Switch to use hrtimer_setup()
powercap: Switch to use hrtimer_setup()
power: supply: ab8500_chargalg: Switch to use hrtimer_setup()
power: reset: ltc2952-poweroff: Switch to use hrtimer_setup()
drivers: perf: Switch to use hrtimer_setup()
ntb: ntb_pingpong: Switch to use hrtimer_setup()
mmc: dw_mmc: Switch to use hrtimer_setup()
misc: vcpu_stall_detector: Switch to use hrtimer_setup()
media: Switch to use hrtimer_setup()
mailbox: Switch to use hrtimer_setup()
leds: trigger: pattern: Switch to use hrtimer_setup()
Input: Switch to use hrtimer_setup()
iio: Switch to use hrtimer_setup()
i2c: Switch to use hrtimer_setup()
stm class: heartbeat: Switch to use hrtimer_setup() drm/amdgpu: Switch to use hrtimer_setup() drm/i915/huc: Switch to use hrtimer_setup() drm/i915/gvt: Switch to use hrtimer_setup()

Quoted 8 lines

drm/i915/perf: Switch to use hrtimer_setup()
drm/i915/pmu: Switch to use hrtimer_setup()
drm/i915/uncore: Switch to use hrtimer_setup()
drm/i915/request: Switch to use hrtimer_setup()
drm/msm: Switch to use hrtimer_setup()
drm/vkms: Switch to use hrtimer_setup()
drm/xe/oa: Switch to use hrtimer_setup()
drm/vmwgfx: Switch to use hrtimer_setup()

FWIW, even if there's no current errors in those paths, that's a nice change. I remember looking at the hrtimer initialization code the first time and thinking that setting the function member of the struct after initialization must be a bug or some hack... Now it will instinctively make sense to anyone reading it for the first time.

z

maintainer Acked-by on the v1 series
#54 lore raw
In reply to Nam Cao

[Public]

Quoted 26 lines

-----Original Message-----
From: Nam Cao <[email protected]>
Sent: Monday, October 28, 2024 3:35 AM
To: Anna-Maria Behnsen <[email protected]>; Frederic Weisbecker <[email protected]>; Thomas Gleixner <[email protected]>; Andreas Hindborg <[email protected]>; Alice Ryhl <[email protected]>; Miguel Ojeda <[email protected]>; Kees Cook <[email protected]>; [email protected]
Cc: Nam Cao <[email protected]>; Greg Kroah-Hartman <[email protected]>; Martin K. Petersen <[email protected]>; Alexandre Belloni <[email protected]>; Rafael J. Wysocki <[email protected]>; Linus Walleij <[email protected]>; Sebastian Reichel <[email protected]>; Will Deacon <[email protected]>; Jon Mason <[email protected]>; Jaehoon Chung <[email protected]>; Hans Verkuil <[email protected]>; Jassi Brar <[email protected]>; Pavel Machek <[email protected]>; Dmitry Torokhov <[email protected]>; Jonathan Cameron <[email protected]>; Andi Shyti <[email protected]>; Alexander Shishkin <[email protected]>; Deucher, Alexander <[email protected]>; Jani Nikula <[email protected]>; Rob Clark <[email protected]>; Lucas De Marchi <[email protected]>; Zack Rusin <[email protected]>; Michael S. Tsirkin <[email protected]>; Jason Gunthorpe <[email protected]>; Uwe Kleine-König <[email protected]>; Takashi Iwai <[email protected]>
Subject: [PATCH 00/44] hrtimers: Switch to new hrtimer interface functions (4/5)

Quoted 1 line

drm/amdgpu: Switch to use hrtimer_setup()

Feel free to take it via whatever tree makes sense.

Alex