public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/24] hrtimers: Switch to new hrtimer interface functions (3/5)
@ 2024-10-28  7:34 Nam Cao
  2024-10-28  7:34 ` [PATCH 01/24] netdev: Switch to use hrtimer_setup() Nam Cao
                   ` (23 more replies)
  0 siblings, 24 replies; 28+ messages in thread
From: Nam Cao @ 2024-10-28  7:34 UTC (permalink / raw)
  To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
	Andreas Hindborg, Alice Ryhl, Miguel Ojeda, Kees Cook,
	linux-kernel
  Cc: Nam Cao, Jakub Kicinski, Paolo Abeni, Marc Kleine-Budde,
	Oliver Neukum, Kalle Valo

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

Part 1: https://lore.kernel.org/lkml/cover.1729864615.git.namcao@linutronix.de
Part 2: https://lore.kernel.org/lkml/cover.1729864823.git.namcao@linutronix.de
Part 3: https://lore.kernel.org/lkml/cover.1729865232.git.namcao@linutronix.de
Part 4: https://lore.kernel.org/lkml/cover.1729865485.git.namcao@linutronix.de
Part 5: https://lore.kernel.org/lkml/cover.1729865740.git.namcao@linutronix.de

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);

Signed-off-by: Nam Cao <namcao@linutronix.de>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: Oliver Neukum <oliver@neukum.org>
Cc: Kalle Valo <kvalo@kernel.org>

Nam Cao (24):
  netdev: Switch to use hrtimer_setup()
  net/sched: Switch to use hrtimer_setup()
  mac802154: Switch to use hrtimer_setup()
  tcp: Switch to use hrtimer_setup()
  can: m_can: Switch to use hrtimer_setup()
  can: mcp251xfd: Switch to use hrtimer_setup()
  can: Switch to use hrtimer_setup()
  net: ethernet: ti: Switch to use hrtimer_setup()
  net: ethernet: cortina: Switch to use hrtimer_setup()
  net: ethernet: ec_bhf: Switch to use hrtimer_setup()
  net: ethernet: hisilicon: Switch to use hrtimer_setup()
  net: sparx5: Switch to use hrtimer_setup()
  net: ieee802154: at86rf230: Switch to use hrtimer_setup()
  net: mvpp2: Switch to use hrtimer_setup()
  net: qualcomm: rmnet: Switch to use hrtimer_setup()
  net: stmmac: Switch to use hrtimer_setup()
  net: fec: Switch to use hrtimer_setup()
  net: wwan: iosm: Switch to use hrtimer_setup()
  net/cdc_ncm: Switch to use hrtimer_setup()
  wifi: Switch to use hrtimer_setup()
  wifi: rt2x00: Switch to use hrtimer_setup()
  igc: Switch to use hrtimer_setup()
  octeontx2-pf: Switch to use hrtimer_setup()
  xfrm: Switch to use hrtimer_setup()

 drivers/net/can/m_can/m_can.c                 |  9 ++++---
 .../net/can/spi/mcp251xfd/mcp251xfd-ring.c    |  8 +++----
 drivers/net/ethernet/cortina/gemini.c         |  5 ++--
 drivers/net/ethernet/ec_bhf.c                 |  3 +--
 drivers/net/ethernet/freescale/fec_ptp.c      |  4 ++--
 drivers/net/ethernet/hisilicon/hip04_eth.c    |  4 +---
 drivers/net/ethernet/intel/igc/igc_main.c     |  4 ++--
 .../net/ethernet/marvell/mvpp2/mvpp2_main.c   |  5 ++--
 .../net/ethernet/marvell/octeontx2/af/ptp.c   |  3 +--
 .../ethernet/microchip/sparx5/sparx5_packet.c |  4 ++--
 .../ethernet/qualcomm/rmnet/rmnet_map_data.c  |  4 ++--
 .../net/ethernet/stmicro/stmmac/stmmac_main.c |  6 ++---
 drivers/net/ethernet/ti/am65-cpsw-nuss.c      |  9 ++++---
 drivers/net/ethernet/ti/icssg/icssg_common.c  |  5 ++--
 drivers/net/ethernet/ti/icssg/icssg_prueth.c  |  5 ++--
 drivers/net/ieee802154/at86rf230.c            |  4 ++--
 drivers/net/usb/cdc_ncm.c                     |  3 +--
 .../wireless/mediatek/mt76/mt76x02_usb_core.c |  4 ++--
 .../net/wireless/ralink/rt2x00/rt2x00dev.c    |  9 +++++--
 drivers/net/wireless/virtual/mac80211_hwsim.c |  6 ++---
 drivers/net/wwan/iosm/iosm_ipc_imem.c         | 24 ++++++++-----------
 net/can/bcm.c                                 | 16 +++++--------
 net/can/isotp.c                               | 10 ++++----
 net/can/j1939/bus.c                           |  4 ++--
 net/can/j1939/transport.c                     |  8 ++-----
 net/core/dev.c                                |  3 +--
 net/ipv4/tcp_timer.c                          | 10 ++++----
 net/mac802154/main.c                          |  4 ++--
 net/sched/act_gate.c                          |  3 +--
 net/sched/sch_api.c                           |  3 +--
 net/sched/sch_taprio.c                        |  6 ++---
 net/xfrm/xfrm_state.c                         |  4 ++--
 32 files changed, 84 insertions(+), 115 deletions(-)

-- 
2.39.5


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 01/24] netdev: Switch to use hrtimer_setup()
  2024-10-28  7:34 [PATCH 00/24] hrtimers: Switch to new hrtimer interface functions (3/5) Nam Cao
@ 2024-10-28  7:34 ` Nam Cao
  2024-10-28  7:34 ` [PATCH 02/24] net/sched: " Nam Cao
                   ` (22 subsequent siblings)
  23 siblings, 0 replies; 28+ messages in thread
From: Nam Cao @ 2024-10-28  7:34 UTC (permalink / raw)
  To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
	Andreas Hindborg, Alice Ryhl, Miguel Ojeda, Kees Cook,
	linux-kernel
  Cc: Nam Cao, Jakub Kicinski, Paolo Abeni

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.

Signed-off-by: Nam Cao <namcao@linutronix.de>
---
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
---
 net/core/dev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index cd479f5f22f6..83971c85466e 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -6645,8 +6645,7 @@ void netif_napi_add_weight(struct net_device *dev, struct napi_struct *napi,
 
 	INIT_LIST_HEAD(&napi->poll_list);
 	INIT_HLIST_NODE(&napi->napi_hash_node);
-	hrtimer_init(&napi->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_PINNED);
-	napi->timer.function = napi_watchdog;
+	hrtimer_setup(&napi->timer, napi_watchdog, CLOCK_MONOTONIC, HRTIMER_MODE_REL_PINNED);
 	init_gro_hash(napi);
 	napi->skb = NULL;
 	INIT_LIST_HEAD(&napi->rx_list);
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 02/24] net/sched: Switch to use hrtimer_setup()
  2024-10-28  7:34 [PATCH 00/24] hrtimers: Switch to new hrtimer interface functions (3/5) Nam Cao
  2024-10-28  7:34 ` [PATCH 01/24] netdev: Switch to use hrtimer_setup() Nam Cao
@ 2024-10-28  7:34 ` Nam Cao
  2024-10-28  7:34 ` [PATCH 03/24] mac802154: " Nam Cao
                   ` (21 subsequent siblings)
  23 siblings, 0 replies; 28+ messages in thread
From: Nam Cao @ 2024-10-28  7:34 UTC (permalink / raw)
  To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
	Andreas Hindborg, Alice Ryhl, Miguel Ojeda, Kees Cook,
	linux-kernel
  Cc: Nam Cao, Jakub Kicinski, Paolo Abeni

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.

Signed-off-by: Nam Cao <namcao@linutronix.de>
---
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
---
 net/sched/act_gate.c   | 3 +--
 net/sched/sch_api.c    | 3 +--
 net/sched/sch_taprio.c | 6 ++----
 3 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/net/sched/act_gate.c b/net/sched/act_gate.c
index 1dd74125398a..ba4bdb71f1f3 100644
--- a/net/sched/act_gate.c
+++ b/net/sched/act_gate.c
@@ -292,8 +292,7 @@ static void gate_setup_timer(struct tcf_gate *gact, u64 basetime,
 	gact->param.tcfg_basetime = basetime;
 	gact->param.tcfg_clockid = clockid;
 	gact->tk_offset = tko;
-	hrtimer_init(&gact->hitimer, clockid, HRTIMER_MODE_ABS_SOFT);
-	gact->hitimer.function = gate_timer_func;
+	hrtimer_setup(&gact->hitimer, gate_timer_func, clockid, HRTIMER_MODE_ABS_SOFT);
 }
 
 static int tcf_gate_init(struct net *net, struct nlattr *nla,
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index 74afc210527d..679d441e6074 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -620,8 +620,7 @@ static enum hrtimer_restart qdisc_watchdog(struct hrtimer *timer)
 void qdisc_watchdog_init_clockid(struct qdisc_watchdog *wd, struct Qdisc *qdisc,
 				 clockid_t clockid)
 {
-	hrtimer_init(&wd->timer, clockid, HRTIMER_MODE_ABS_PINNED);
-	wd->timer.function = qdisc_watchdog;
+	hrtimer_setup(&wd->timer, qdisc_watchdog, clockid, HRTIMER_MODE_ABS_PINNED);
 	wd->qdisc = qdisc;
 }
 EXPORT_SYMBOL(qdisc_watchdog_init_clockid);
diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c
index 8498d0606b24..9b8bc27e633d 100644
--- a/net/sched/sch_taprio.c
+++ b/net/sched/sch_taprio.c
@@ -1932,8 +1932,7 @@ static int taprio_change(struct Qdisc *sch, struct nlattr *opt,
 	if (!TXTIME_ASSIST_IS_ENABLED(q->flags) &&
 	    !FULL_OFFLOAD_IS_ENABLED(q->flags) &&
 	    !hrtimer_active(&q->advance_timer)) {
-		hrtimer_init(&q->advance_timer, q->clockid, HRTIMER_MODE_ABS);
-		q->advance_timer.function = advance_sched;
+		hrtimer_setup(&q->advance_timer, advance_sched, q->clockid, HRTIMER_MODE_ABS);
 	}
 
 	err = taprio_get_start_time(sch, new_admin, &start);
@@ -2055,8 +2054,7 @@ static int taprio_init(struct Qdisc *sch, struct nlattr *opt,
 
 	spin_lock_init(&q->current_entry_lock);
 
-	hrtimer_init(&q->advance_timer, CLOCK_TAI, HRTIMER_MODE_ABS);
-	q->advance_timer.function = advance_sched;
+	hrtimer_setup(&q->advance_timer, advance_sched, CLOCK_TAI, HRTIMER_MODE_ABS);
 
 	q->root = sch;
 
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 03/24] mac802154: Switch to use hrtimer_setup()
  2024-10-28  7:34 [PATCH 00/24] hrtimers: Switch to new hrtimer interface functions (3/5) Nam Cao
  2024-10-28  7:34 ` [PATCH 01/24] netdev: Switch to use hrtimer_setup() Nam Cao
  2024-10-28  7:34 ` [PATCH 02/24] net/sched: " Nam Cao
@ 2024-10-28  7:34 ` Nam Cao
  2024-10-28  7:34 ` [PATCH 04/24] tcp: " Nam Cao
                   ` (20 subsequent siblings)
  23 siblings, 0 replies; 28+ messages in thread
From: Nam Cao @ 2024-10-28  7:34 UTC (permalink / raw)
  To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
	Andreas Hindborg, Alice Ryhl, Miguel Ojeda, Kees Cook,
	linux-kernel
  Cc: Nam Cao, Jakub Kicinski, Paolo Abeni

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.

Signed-off-by: Nam Cao <namcao@linutronix.de>
---
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
---
 net/mac802154/main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/mac802154/main.c b/net/mac802154/main.c
index 21b7c3b280b4..ea1efef3572a 100644
--- a/net/mac802154/main.c
+++ b/net/mac802154/main.c
@@ -213,8 +213,8 @@ int ieee802154_register_hw(struct ieee802154_hw *hw)
 		goto out_wq;
 	}
 
-	hrtimer_init(&local->ifs_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	local->ifs_timer.function = ieee802154_xmit_ifs_timer;
+	hrtimer_setup(&local->ifs_timer, ieee802154_xmit_ifs_timer, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 
 	wpan_phy_set_dev(local->phy, local->hw.parent);
 
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 04/24] tcp: Switch to use hrtimer_setup()
  2024-10-28  7:34 [PATCH 00/24] hrtimers: Switch to new hrtimer interface functions (3/5) Nam Cao
                   ` (2 preceding siblings ...)
  2024-10-28  7:34 ` [PATCH 03/24] mac802154: " Nam Cao
@ 2024-10-28  7:34 ` Nam Cao
  2024-10-28  7:34 ` [PATCH 05/24] can: m_can: " Nam Cao
                   ` (19 subsequent siblings)
  23 siblings, 0 replies; 28+ messages in thread
From: Nam Cao @ 2024-10-28  7:34 UTC (permalink / raw)
  To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
	Andreas Hindborg, Alice Ryhl, Miguel Ojeda, Kees Cook,
	linux-kernel
  Cc: Nam Cao, Jakub Kicinski, Paolo Abeni

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.

Signed-off-by: Nam Cao <namcao@linutronix.de>
---
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
---
 net/ipv4/tcp_timer.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index 79064580c8c0..6fa99cac98c2 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -869,11 +869,9 @@ void tcp_init_xmit_timers(struct sock *sk)
 {
 	inet_csk_init_xmit_timers(sk, &tcp_write_timer, &tcp_delack_timer,
 				  &tcp_keepalive_timer);
-	hrtimer_init(&tcp_sk(sk)->pacing_timer, CLOCK_MONOTONIC,
-		     HRTIMER_MODE_ABS_PINNED_SOFT);
-	tcp_sk(sk)->pacing_timer.function = tcp_pace_kick;
+	hrtimer_setup(&tcp_sk(sk)->pacing_timer, tcp_pace_kick, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_ABS_PINNED_SOFT);
 
-	hrtimer_init(&tcp_sk(sk)->compressed_ack_timer, CLOCK_MONOTONIC,
-		     HRTIMER_MODE_REL_PINNED_SOFT);
-	tcp_sk(sk)->compressed_ack_timer.function = tcp_compressed_ack_kick;
+	hrtimer_setup(&tcp_sk(sk)->compressed_ack_timer, tcp_compressed_ack_kick, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL_PINNED_SOFT);
 }
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 05/24] can: m_can: Switch to use hrtimer_setup()
  2024-10-28  7:34 [PATCH 00/24] hrtimers: Switch to new hrtimer interface functions (3/5) Nam Cao
                   ` (3 preceding siblings ...)
  2024-10-28  7:34 ` [PATCH 04/24] tcp: " Nam Cao
@ 2024-10-28  7:34 ` Nam Cao
  2024-10-28 14:02   ` Marc Kleine-Budde
  2024-10-28  7:34 ` [PATCH 06/24] can: mcp251xfd: " Nam Cao
                   ` (18 subsequent siblings)
  23 siblings, 1 reply; 28+ messages in thread
From: Nam Cao @ 2024-10-28  7:34 UTC (permalink / raw)
  To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
	Andreas Hindborg, Alice Ryhl, Miguel Ojeda, Kees Cook,
	linux-kernel
  Cc: Nam Cao, Marc Kleine-Budde, Jakub Kicinski, Paolo Abeni

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.

Signed-off-by: Nam Cao <namcao@linutronix.de>
---
Cc: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
---
 drivers/net/can/m_can/m_can.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index a978b960f1f1..183f6eceb7e9 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -2383,12 +2383,11 @@ int m_can_class_register(struct m_can_classdev *cdev)
 
 	if (!cdev->net->irq) {
 		dev_dbg(cdev->dev, "Polling enabled, initialize hrtimer");
-		hrtimer_init(&cdev->hrtimer, CLOCK_MONOTONIC,
-			     HRTIMER_MODE_REL_PINNED);
-		cdev->hrtimer.function = &hrtimer_callback;
+		hrtimer_setup(&cdev->hrtimer, &hrtimer_callback, CLOCK_MONOTONIC,
+			      HRTIMER_MODE_REL_PINNED);
 	} else {
-		hrtimer_init(&cdev->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-		cdev->hrtimer.function = m_can_coalescing_timer;
+		hrtimer_setup(&cdev->hrtimer, m_can_coalescing_timer, CLOCK_MONOTONIC,
+			      HRTIMER_MODE_REL);
 	}
 
 	ret = m_can_dev_setup(cdev);
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 06/24] can: mcp251xfd: Switch to use hrtimer_setup()
  2024-10-28  7:34 [PATCH 00/24] hrtimers: Switch to new hrtimer interface functions (3/5) Nam Cao
                   ` (4 preceding siblings ...)
  2024-10-28  7:34 ` [PATCH 05/24] can: m_can: " Nam Cao
@ 2024-10-28  7:34 ` Nam Cao
  2024-10-28 14:02   ` Marc Kleine-Budde
  2024-10-28  7:34 ` [PATCH 07/24] can: " Nam Cao
                   ` (17 subsequent siblings)
  23 siblings, 1 reply; 28+ messages in thread
From: Nam Cao @ 2024-10-28  7:34 UTC (permalink / raw)
  To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
	Andreas Hindborg, Alice Ryhl, Miguel Ojeda, Kees Cook,
	linux-kernel
  Cc: Nam Cao, Marc Kleine-Budde, Jakub Kicinski, Paolo Abeni

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.

Signed-off-by: Nam Cao <namcao@linutronix.de>
---
Cc: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
---
 drivers/net/can/spi/mcp251xfd/mcp251xfd-ring.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/can/spi/mcp251xfd/mcp251xfd-ring.c b/drivers/net/can/spi/mcp251xfd/mcp251xfd-ring.c
index 83c18035b2a2..de2ae204beaa 100644
--- a/drivers/net/can/spi/mcp251xfd/mcp251xfd-ring.c
+++ b/drivers/net/can/spi/mcp251xfd/mcp251xfd-ring.c
@@ -539,11 +539,11 @@ int mcp251xfd_ring_alloc(struct mcp251xfd_priv *priv)
 	}
 	priv->rx_ring_num = i;
 
-	hrtimer_init(&priv->rx_irq_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	priv->rx_irq_timer.function = mcp251xfd_rx_irq_timer;
+	hrtimer_setup(&priv->rx_irq_timer, mcp251xfd_rx_irq_timer, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 
-	hrtimer_init(&priv->tx_irq_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	priv->tx_irq_timer.function = mcp251xfd_tx_irq_timer;
+	hrtimer_setup(&priv->tx_irq_timer, mcp251xfd_tx_irq_timer, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 
 	return 0;
 }
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 07/24] can: Switch to use hrtimer_setup()
  2024-10-28  7:34 [PATCH 00/24] hrtimers: Switch to new hrtimer interface functions (3/5) Nam Cao
                   ` (5 preceding siblings ...)
  2024-10-28  7:34 ` [PATCH 06/24] can: mcp251xfd: " Nam Cao
@ 2024-10-28  7:34 ` Nam Cao
  2024-10-28 14:03   ` Marc Kleine-Budde
  2024-10-28  7:34 ` [PATCH 08/24] net: ethernet: ti: " Nam Cao
                   ` (16 subsequent siblings)
  23 siblings, 1 reply; 28+ messages in thread
From: Nam Cao @ 2024-10-28  7:34 UTC (permalink / raw)
  To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
	Andreas Hindborg, Alice Ryhl, Miguel Ojeda, Kees Cook,
	linux-kernel
  Cc: Nam Cao, Marc Kleine-Budde, Jakub Kicinski, Paolo Abeni

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.

Signed-off-by: Nam Cao <namcao@linutronix.de>
---
Cc: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
---
 net/can/bcm.c             | 16 ++++++----------
 net/can/isotp.c           | 10 ++++------
 net/can/j1939/bus.c       |  4 ++--
 net/can/j1939/transport.c |  8 ++------
 4 files changed, 14 insertions(+), 24 deletions(-)

diff --git a/net/can/bcm.c b/net/can/bcm.c
index 792528f7bce2..2048cbbed138 100644
--- a/net/can/bcm.c
+++ b/net/can/bcm.c
@@ -1012,9 +1012,8 @@ static int bcm_tx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
 		op->ifindex = ifindex;
 
 		/* initialize uninitialized (kzalloc) structure */
-		hrtimer_init(&op->timer, CLOCK_MONOTONIC,
-			     HRTIMER_MODE_REL_SOFT);
-		op->timer.function = bcm_tx_timeout_handler;
+		hrtimer_setup(&op->timer, bcm_tx_timeout_handler, CLOCK_MONOTONIC,
+			      HRTIMER_MODE_REL_SOFT);
 
 		/* add this bcm_op to the list of the tx_ops */
 		list_add(&op->list, &bo->tx_ops);
@@ -1189,13 +1188,10 @@ static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
 		op->rx_ifindex = ifindex;
 
 		/* initialize uninitialized (kzalloc) structure */
-		hrtimer_init(&op->timer, CLOCK_MONOTONIC,
-			     HRTIMER_MODE_REL_SOFT);
-		op->timer.function = bcm_rx_timeout_handler;
-
-		hrtimer_init(&op->thrtimer, CLOCK_MONOTONIC,
-			     HRTIMER_MODE_REL_SOFT);
-		op->thrtimer.function = bcm_rx_thr_handler;
+		hrtimer_setup(&op->timer, bcm_rx_timeout_handler, CLOCK_MONOTONIC,
+			      HRTIMER_MODE_REL_SOFT);
+		hrtimer_setup(&op->thrtimer, bcm_rx_thr_handler, CLOCK_MONOTONIC,
+			      HRTIMER_MODE_REL_SOFT);
 
 		/* add this bcm_op to the list of the rx_ops */
 		list_add(&op->list, &bo->rx_ops);
diff --git a/net/can/isotp.c b/net/can/isotp.c
index 16046931542a..442c343afe1f 100644
--- a/net/can/isotp.c
+++ b/net/can/isotp.c
@@ -1634,12 +1634,10 @@ static int isotp_init(struct sock *sk)
 	so->rx.buflen = ARRAY_SIZE(so->rx.sbuf);
 	so->tx.buflen = ARRAY_SIZE(so->tx.sbuf);
 
-	hrtimer_init(&so->rxtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_SOFT);
-	so->rxtimer.function = isotp_rx_timer_handler;
-	hrtimer_init(&so->txtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_SOFT);
-	so->txtimer.function = isotp_tx_timer_handler;
-	hrtimer_init(&so->txfrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_SOFT);
-	so->txfrtimer.function = isotp_txfr_timer_handler;
+	hrtimer_setup(&so->rxtimer, isotp_rx_timer_handler, CLOCK_MONOTONIC, HRTIMER_MODE_REL_SOFT);
+	hrtimer_setup(&so->txtimer, isotp_tx_timer_handler, CLOCK_MONOTONIC, HRTIMER_MODE_REL_SOFT);
+	hrtimer_setup(&so->txfrtimer, isotp_txfr_timer_handler, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL_SOFT);
 
 	init_waitqueue_head(&so->wait);
 	spin_lock_init(&so->rx_lock);
diff --git a/net/can/j1939/bus.c b/net/can/j1939/bus.c
index 486687901602..39844f14eed8 100644
--- a/net/can/j1939/bus.c
+++ b/net/can/j1939/bus.c
@@ -158,8 +158,8 @@ struct j1939_ecu *j1939_ecu_create_locked(struct j1939_priv *priv, name_t name)
 	ecu->addr = J1939_IDLE_ADDR;
 	ecu->name = name;
 
-	hrtimer_init(&ecu->ac_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_SOFT);
-	ecu->ac_timer.function = j1939_ecu_timer_handler;
+	hrtimer_setup(&ecu->ac_timer, j1939_ecu_timer_handler, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL_SOFT);
 	INIT_LIST_HEAD(&ecu->list);
 
 	j1939_priv_get(priv);
diff --git a/net/can/j1939/transport.c b/net/can/j1939/transport.c
index 319f47df3330..7f97e7f97799 100644
--- a/net/can/j1939/transport.c
+++ b/net/can/j1939/transport.c
@@ -1510,12 +1510,8 @@ static struct j1939_session *j1939_session_new(struct j1939_priv *priv,
 	skcb = j1939_skb_to_cb(skb);
 	memcpy(&session->skcb, skcb, sizeof(session->skcb));
 
-	hrtimer_init(&session->txtimer, CLOCK_MONOTONIC,
-		     HRTIMER_MODE_REL_SOFT);
-	session->txtimer.function = j1939_tp_txtimer;
-	hrtimer_init(&session->rxtimer, CLOCK_MONOTONIC,
-		     HRTIMER_MODE_REL_SOFT);
-	session->rxtimer.function = j1939_tp_rxtimer;
+	hrtimer_setup(&session->txtimer, j1939_tp_txtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_SOFT);
+	hrtimer_setup(&session->rxtimer, j1939_tp_rxtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_SOFT);
 
 	netdev_dbg(priv->ndev, "%s: 0x%p: sa: %02x, da: %02x\n",
 		   __func__, session, skcb->addr.sa, skcb->addr.da);
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 08/24] net: ethernet: ti: Switch to use hrtimer_setup()
  2024-10-28  7:34 [PATCH 00/24] hrtimers: Switch to new hrtimer interface functions (3/5) Nam Cao
                   ` (6 preceding siblings ...)
  2024-10-28  7:34 ` [PATCH 07/24] can: " Nam Cao
@ 2024-10-28  7:34 ` Nam Cao
  2024-10-28  7:34 ` [PATCH 09/24] net: ethernet: cortina: " Nam Cao
                   ` (15 subsequent siblings)
  23 siblings, 0 replies; 28+ messages in thread
From: Nam Cao @ 2024-10-28  7:34 UTC (permalink / raw)
  To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
	Andreas Hindborg, Alice Ryhl, Miguel Ojeda, Kees Cook,
	linux-kernel
  Cc: Nam Cao, Jakub Kicinski, Paolo Abeni

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.

Signed-off-by: Nam Cao <namcao@linutronix.de>
---
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
---
 drivers/net/ethernet/ti/am65-cpsw-nuss.c     | 9 ++++-----
 drivers/net/ethernet/ti/icssg/icssg_common.c | 5 ++---
 drivers/net/ethernet/ti/icssg/icssg_prueth.c | 5 ++---
 3 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
index cbe99017cbfa..ba5e32366fb8 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
@@ -2236,8 +2236,8 @@ static int am65_cpsw_nuss_ndev_add_tx_napi(struct am65_cpsw_common *common)
 
 		netif_napi_add_tx(common->dma_ndev, &tx_chn->napi_tx,
 				  am65_cpsw_nuss_tx_poll);
-		hrtimer_init(&tx_chn->tx_hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_PINNED);
-		tx_chn->tx_hrtimer.function = &am65_cpsw_nuss_tx_timer_callback;
+		hrtimer_setup(&tx_chn->tx_hrtimer, &am65_cpsw_nuss_tx_timer_callback,
+			      CLOCK_MONOTONIC, HRTIMER_MODE_REL_PINNED);
 
 		ret = devm_request_irq(dev, tx_chn->irq,
 				       am65_cpsw_nuss_tx_irq,
@@ -2485,9 +2485,8 @@ static int am65_cpsw_nuss_init_rx_chns(struct am65_cpsw_common *common)
 			 dev_name(dev), i);
 		netif_napi_add(common->dma_ndev, &flow->napi_rx,
 			       am65_cpsw_nuss_rx_poll);
-		hrtimer_init(&flow->rx_hrtimer, CLOCK_MONOTONIC,
-			     HRTIMER_MODE_REL_PINNED);
-		flow->rx_hrtimer.function = &am65_cpsw_nuss_rx_timer_callback;
+		hrtimer_setup(&flow->rx_hrtimer, &am65_cpsw_nuss_rx_timer_callback, CLOCK_MONOTONIC,
+			      HRTIMER_MODE_REL_PINNED);
 
 		ret = devm_request_irq(dev, flow->irq,
 				       am65_cpsw_nuss_rx_irq,
diff --git a/drivers/net/ethernet/ti/icssg/icssg_common.c b/drivers/net/ethernet/ti/icssg/icssg_common.c
index fdebeb2f84e0..16ca4b1fc01b 100644
--- a/drivers/net/ethernet/ti/icssg/icssg_common.c
+++ b/drivers/net/ethernet/ti/icssg/icssg_common.c
@@ -249,9 +249,8 @@ int prueth_ndev_add_tx_napi(struct prueth_emac *emac)
 		struct prueth_tx_chn *tx_chn = &emac->tx_chns[i];
 
 		netif_napi_add_tx(emac->ndev, &tx_chn->napi_tx, emac_napi_tx_poll);
-		hrtimer_init(&tx_chn->tx_hrtimer, CLOCK_MONOTONIC,
-			     HRTIMER_MODE_REL_PINNED);
-		tx_chn->tx_hrtimer.function = &emac_tx_timer_callback;
+		hrtimer_setup(&tx_chn->tx_hrtimer, &emac_tx_timer_callback, CLOCK_MONOTONIC,
+			      HRTIMER_MODE_REL_PINNED);
 		ret = request_irq(tx_chn->irq, prueth_tx_irq,
 				  IRQF_TRIGGER_HIGH, tx_chn->name,
 				  tx_chn);
diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.c b/drivers/net/ethernet/ti/icssg/icssg_prueth.c
index 5fd9902ab181..fe5c32be1ab3 100644
--- a/drivers/net/ethernet/ti/icssg/icssg_prueth.c
+++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.c
@@ -951,9 +951,8 @@ static int prueth_netdev_init(struct prueth *prueth,
 	ndev->hw_features |= NETIF_PRUETH_HSR_OFFLOAD_FEATURES;
 
 	netif_napi_add(ndev, &emac->napi_rx, icssg_napi_rx_poll);
-	hrtimer_init(&emac->rx_hrtimer, CLOCK_MONOTONIC,
-		     HRTIMER_MODE_REL_PINNED);
-	emac->rx_hrtimer.function = &emac_rx_timer_callback;
+	hrtimer_setup(&emac->rx_hrtimer, &emac_rx_timer_callback, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL_PINNED);
 	prueth->emac[mac] = emac;
 
 	return 0;
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 09/24] net: ethernet: cortina: Switch to use hrtimer_setup()
  2024-10-28  7:34 [PATCH 00/24] hrtimers: Switch to new hrtimer interface functions (3/5) Nam Cao
                   ` (7 preceding siblings ...)
  2024-10-28  7:34 ` [PATCH 08/24] net: ethernet: ti: " Nam Cao
@ 2024-10-28  7:34 ` Nam Cao
  2024-10-28  7:34 ` [PATCH 10/24] net: ethernet: ec_bhf: " Nam Cao
                   ` (14 subsequent siblings)
  23 siblings, 0 replies; 28+ messages in thread
From: Nam Cao @ 2024-10-28  7:34 UTC (permalink / raw)
  To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
	Andreas Hindborg, Alice Ryhl, Miguel Ojeda, Kees Cook,
	linux-kernel
  Cc: Nam Cao, Jakub Kicinski, Paolo Abeni

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.

Signed-off-by: Nam Cao <namcao@linutronix.de>
---
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
---
 drivers/net/ethernet/cortina/gemini.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c
index 73e1c71c5092..5347431a089f 100644
--- a/drivers/net/ethernet/cortina/gemini.c
+++ b/drivers/net/ethernet/cortina/gemini.c
@@ -1833,9 +1833,8 @@ static int gmac_open(struct net_device *netdev)
 	gmac_enable_tx_rx(netdev);
 	netif_tx_start_all_queues(netdev);
 
-	hrtimer_init(&port->rx_coalesce_timer, CLOCK_MONOTONIC,
-		     HRTIMER_MODE_REL);
-	port->rx_coalesce_timer.function = &gmac_coalesce_delay_expired;
+	hrtimer_setup(&port->rx_coalesce_timer, &gmac_coalesce_delay_expired, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 
 	netdev_dbg(netdev, "opened\n");
 
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 10/24] net: ethernet: ec_bhf: Switch to use hrtimer_setup()
  2024-10-28  7:34 [PATCH 00/24] hrtimers: Switch to new hrtimer interface functions (3/5) Nam Cao
                   ` (8 preceding siblings ...)
  2024-10-28  7:34 ` [PATCH 09/24] net: ethernet: cortina: " Nam Cao
@ 2024-10-28  7:34 ` Nam Cao
  2024-10-28  7:34 ` [PATCH 11/24] net: ethernet: hisilicon: " Nam Cao
                   ` (13 subsequent siblings)
  23 siblings, 0 replies; 28+ messages in thread
From: Nam Cao @ 2024-10-28  7:34 UTC (permalink / raw)
  To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
	Andreas Hindborg, Alice Ryhl, Miguel Ojeda, Kees Cook,
	linux-kernel
  Cc: Nam Cao, Jakub Kicinski, Paolo Abeni

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.

Signed-off-by: Nam Cao <namcao@linutronix.de>
---
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
---
 drivers/net/ethernet/ec_bhf.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/ec_bhf.c b/drivers/net/ethernet/ec_bhf.c
index 44af1d13d931..67275aa4f65b 100644
--- a/drivers/net/ethernet/ec_bhf.c
+++ b/drivers/net/ethernet/ec_bhf.c
@@ -416,8 +416,7 @@ static int ec_bhf_open(struct net_device *net_dev)
 
 	netif_start_queue(net_dev);
 
-	hrtimer_init(&priv->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	priv->hrtimer.function = ec_bhf_timer_fun;
+	hrtimer_setup(&priv->hrtimer, ec_bhf_timer_fun, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 	hrtimer_start(&priv->hrtimer, polling_frequency, HRTIMER_MODE_REL);
 
 	return 0;
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 11/24] net: ethernet: hisilicon: Switch to use hrtimer_setup()
  2024-10-28  7:34 [PATCH 00/24] hrtimers: Switch to new hrtimer interface functions (3/5) Nam Cao
                   ` (9 preceding siblings ...)
  2024-10-28  7:34 ` [PATCH 10/24] net: ethernet: ec_bhf: " Nam Cao
@ 2024-10-28  7:34 ` Nam Cao
  2024-10-28  7:34 ` [PATCH 12/24] net: sparx5: " Nam Cao
                   ` (12 subsequent siblings)
  23 siblings, 0 replies; 28+ messages in thread
From: Nam Cao @ 2024-10-28  7:34 UTC (permalink / raw)
  To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
	Andreas Hindborg, Alice Ryhl, Miguel Ojeda, Kees Cook,
	linux-kernel
  Cc: Nam Cao, Jakub Kicinski, Paolo Abeni

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.

Signed-off-by: Nam Cao <namcao@linutronix.de>
---
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
---
 drivers/net/ethernet/hisilicon/hip04_eth.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hip04_eth.c b/drivers/net/ethernet/hisilicon/hip04_eth.c
index beb815e5289b..bea8b79e69b2 100644
--- a/drivers/net/ethernet/hisilicon/hip04_eth.c
+++ b/drivers/net/ethernet/hisilicon/hip04_eth.c
@@ -934,8 +934,6 @@ static int hip04_mac_probe(struct platform_device *pdev)
 	priv->chan = arg.args[1] * RX_DESC_NUM;
 	priv->group = arg.args[2];
 
-	hrtimer_init(&priv->tx_coalesce_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-
 	/* BQL will try to keep the TX queue as short as possible, but it can't
 	 * be faster than tx_coalesce_usecs, so we need a fast timeout here,
 	 * but also long enough to gather up enough frames to ensure we don't
@@ -944,7 +942,7 @@ static int hip04_mac_probe(struct platform_device *pdev)
 	 */
 	priv->tx_coalesce_frames = TX_DESC_NUM * 3 / 4;
 	priv->tx_coalesce_usecs = 200;
-	priv->tx_coalesce_timer.function = tx_done;
+	hrtimer_setup(&priv->tx_coalesce_timer, tx_done, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 
 	priv->map = syscon_node_to_regmap(arg.np);
 	of_node_put(arg.np);
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 12/24] net: sparx5: Switch to use hrtimer_setup()
  2024-10-28  7:34 [PATCH 00/24] hrtimers: Switch to new hrtimer interface functions (3/5) Nam Cao
                   ` (10 preceding siblings ...)
  2024-10-28  7:34 ` [PATCH 11/24] net: ethernet: hisilicon: " Nam Cao
@ 2024-10-28  7:34 ` Nam Cao
  2024-10-28  7:34 ` [PATCH 13/24] net: ieee802154: at86rf230: " Nam Cao
                   ` (11 subsequent siblings)
  23 siblings, 0 replies; 28+ messages in thread
From: Nam Cao @ 2024-10-28  7:34 UTC (permalink / raw)
  To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
	Andreas Hindborg, Alice Ryhl, Miguel Ojeda, Kees Cook,
	linux-kernel
  Cc: Nam Cao, Jakub Kicinski, Paolo Abeni

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.

Signed-off-by: Nam Cao <namcao@linutronix.de>
---
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
---
 drivers/net/ethernet/microchip/sparx5/sparx5_packet.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_packet.c b/drivers/net/ethernet/microchip/sparx5/sparx5_packet.c
index f3f5fb420468..89e25292d8f9 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_packet.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_packet.c
@@ -356,6 +356,6 @@ irqreturn_t sparx5_xtr_handler(int irq, void *_sparx5)
 
 void sparx5_port_inj_timer_setup(struct sparx5_port *port)
 {
-	hrtimer_init(&port->inj_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	port->inj_timer.function = sparx5_injection_timeout;
+	hrtimer_setup(&port->inj_timer, sparx5_injection_timeout, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 }
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 13/24] net: ieee802154: at86rf230: Switch to use hrtimer_setup()
  2024-10-28  7:34 [PATCH 00/24] hrtimers: Switch to new hrtimer interface functions (3/5) Nam Cao
                   ` (11 preceding siblings ...)
  2024-10-28  7:34 ` [PATCH 12/24] net: sparx5: " Nam Cao
@ 2024-10-28  7:34 ` Nam Cao
  2024-10-28  7:34 ` [PATCH 14/24] net: mvpp2: " Nam Cao
                   ` (10 subsequent siblings)
  23 siblings, 0 replies; 28+ messages in thread
From: Nam Cao @ 2024-10-28  7:34 UTC (permalink / raw)
  To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
	Andreas Hindborg, Alice Ryhl, Miguel Ojeda, Kees Cook,
	linux-kernel
  Cc: Nam Cao, Jakub Kicinski, Paolo Abeni

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.

Signed-off-by: Nam Cao <namcao@linutronix.de>
---
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
---
 drivers/net/ieee802154/at86rf230.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c
index f632b0cfd5ae..fd91f8a45bce 100644
--- a/drivers/net/ieee802154/at86rf230.c
+++ b/drivers/net/ieee802154/at86rf230.c
@@ -776,8 +776,8 @@ at86rf230_setup_spi_messages(struct at86rf230_local *lp,
 	state->trx.tx_buf = state->buf;
 	state->trx.rx_buf = state->buf;
 	spi_message_add_tail(&state->trx, &state->msg);
-	hrtimer_init(&state->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	state->timer.function = at86rf230_async_state_timer;
+	hrtimer_setup(&state->timer, at86rf230_async_state_timer, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 }
 
 static irqreturn_t at86rf230_isr(int irq, void *data)
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 14/24] net: mvpp2: Switch to use hrtimer_setup()
  2024-10-28  7:34 [PATCH 00/24] hrtimers: Switch to new hrtimer interface functions (3/5) Nam Cao
                   ` (12 preceding siblings ...)
  2024-10-28  7:34 ` [PATCH 13/24] net: ieee802154: at86rf230: " Nam Cao
@ 2024-10-28  7:34 ` Nam Cao
  2024-10-28  7:34 ` [PATCH 15/24] net: qualcomm: rmnet: " Nam Cao
                   ` (9 subsequent siblings)
  23 siblings, 0 replies; 28+ messages in thread
From: Nam Cao @ 2024-10-28  7:34 UTC (permalink / raw)
  To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
	Andreas Hindborg, Alice Ryhl, Miguel Ojeda, Kees Cook,
	linux-kernel
  Cc: Nam Cao, Jakub Kicinski, Paolo Abeni

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.

Signed-off-by: Nam Cao <namcao@linutronix.de>
---
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
---
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
index 3880dcc0418b..03038402957e 100644
--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
+++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
@@ -6914,9 +6914,8 @@ static int mvpp2_port_probe(struct platform_device *pdev,
 		for (thread = 0; thread < priv->nthreads; thread++) {
 			port_pcpu = per_cpu_ptr(port->pcpu, thread);
 
-			hrtimer_init(&port_pcpu->tx_done_timer, CLOCK_MONOTONIC,
-				     HRTIMER_MODE_REL_PINNED_SOFT);
-			port_pcpu->tx_done_timer.function = mvpp2_hr_timer_cb;
+			hrtimer_setup(&port_pcpu->tx_done_timer, mvpp2_hr_timer_cb, CLOCK_MONOTONIC,
+				      HRTIMER_MODE_REL_PINNED_SOFT);
 			port_pcpu->timer_scheduled = false;
 			port_pcpu->dev = dev;
 		}
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 15/24] net: qualcomm: rmnet: Switch to use hrtimer_setup()
  2024-10-28  7:34 [PATCH 00/24] hrtimers: Switch to new hrtimer interface functions (3/5) Nam Cao
                   ` (13 preceding siblings ...)
  2024-10-28  7:34 ` [PATCH 14/24] net: mvpp2: " Nam Cao
@ 2024-10-28  7:34 ` Nam Cao
  2024-10-28  7:34 ` [PATCH 16/24] net: stmmac: " Nam Cao
                   ` (8 subsequent siblings)
  23 siblings, 0 replies; 28+ messages in thread
From: Nam Cao @ 2024-10-28  7:34 UTC (permalink / raw)
  To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
	Andreas Hindborg, Alice Ryhl, Miguel Ojeda, Kees Cook,
	linux-kernel
  Cc: Nam Cao, Jakub Kicinski, Paolo Abeni

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.

Signed-off-by: Nam Cao <namcao@linutronix.de>
---
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
---
 drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c
index a5e3d1a88305..8b4640c5d61e 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c
@@ -686,8 +686,8 @@ void rmnet_map_update_ul_agg_config(struct rmnet_port *port, u32 size,
 
 void rmnet_map_tx_aggregate_init(struct rmnet_port *port)
 {
-	hrtimer_init(&port->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	port->hrtimer.function = rmnet_map_flush_tx_packet_queue;
+	hrtimer_setup(&port->hrtimer, rmnet_map_flush_tx_packet_queue, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 	spin_lock_init(&port->agg_lock);
 	rmnet_map_update_ul_agg_config(port, 4096, 1, 800);
 	INIT_WORK(&port->agg_wq, rmnet_map_flush_tx_packet_work);
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 16/24] net: stmmac: Switch to use hrtimer_setup()
  2024-10-28  7:34 [PATCH 00/24] hrtimers: Switch to new hrtimer interface functions (3/5) Nam Cao
                   ` (14 preceding siblings ...)
  2024-10-28  7:34 ` [PATCH 15/24] net: qualcomm: rmnet: " Nam Cao
@ 2024-10-28  7:34 ` Nam Cao
  2024-10-28  7:34 ` [PATCH 17/24] net: fec: " Nam Cao
                   ` (7 subsequent siblings)
  23 siblings, 0 replies; 28+ messages in thread
From: Nam Cao @ 2024-10-28  7:34 UTC (permalink / raw)
  To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
	Andreas Hindborg, Alice Ryhl, Miguel Ojeda, Kees Cook,
	linux-kernel
  Cc: Nam Cao, Jakub Kicinski, Paolo Abeni

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.

Signed-off-by: Nam Cao <namcao@linutronix.de>
---
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index e2140482270a..61ed82561168 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -3148,8 +3148,7 @@ static void stmmac_init_coalesce(struct stmmac_priv *priv)
 		priv->tx_coal_frames[chan] = STMMAC_TX_FRAMES;
 		priv->tx_coal_timer[chan] = STMMAC_COAL_TX_TIMER;
 
-		hrtimer_init(&tx_q->txtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-		tx_q->txtimer.function = stmmac_tx_timer;
+		hrtimer_setup(&tx_q->txtimer, stmmac_tx_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 	}
 
 	for (chan = 0; chan < rx_channel_count; chan++)
@@ -6967,8 +6966,7 @@ int stmmac_xdp_open(struct net_device *dev)
 		stmmac_set_tx_tail_ptr(priv, priv->ioaddr,
 				       tx_q->tx_tail_addr, chan);
 
-		hrtimer_init(&tx_q->txtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-		tx_q->txtimer.function = stmmac_tx_timer;
+		hrtimer_setup(&tx_q->txtimer, stmmac_tx_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 	}
 
 	/* Enable the MAC Rx/Tx */
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 17/24] net: fec: Switch to use hrtimer_setup()
  2024-10-28  7:34 [PATCH 00/24] hrtimers: Switch to new hrtimer interface functions (3/5) Nam Cao
                   ` (15 preceding siblings ...)
  2024-10-28  7:34 ` [PATCH 16/24] net: stmmac: " Nam Cao
@ 2024-10-28  7:34 ` Nam Cao
  2024-10-28  7:34 ` [PATCH 18/24] net: wwan: iosm: " Nam Cao
                   ` (6 subsequent siblings)
  23 siblings, 0 replies; 28+ messages in thread
From: Nam Cao @ 2024-10-28  7:34 UTC (permalink / raw)
  To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
	Andreas Hindborg, Alice Ryhl, Miguel Ojeda, Kees Cook,
	linux-kernel
  Cc: Nam Cao, Jakub Kicinski, Paolo Abeni

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.

Signed-off-by: Nam Cao <namcao@linutronix.de>
---
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
---
 drivers/net/ethernet/freescale/fec_ptp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec_ptp.c b/drivers/net/ethernet/freescale/fec_ptp.c
index 4cffda363a14..b357967d56b6 100644
--- a/drivers/net/ethernet/freescale/fec_ptp.c
+++ b/drivers/net/ethernet/freescale/fec_ptp.c
@@ -738,8 +738,8 @@ void fec_ptp_init(struct platform_device *pdev, int irq_idx)
 
 	INIT_DELAYED_WORK(&fep->time_keep, fec_time_keep);
 
-	hrtimer_init(&fep->perout_timer, CLOCK_REALTIME, HRTIMER_MODE_REL);
-	fep->perout_timer.function = fec_ptp_pps_perout_handler;
+	hrtimer_setup(&fep->perout_timer, fec_ptp_pps_perout_handler, CLOCK_REALTIME,
+		      HRTIMER_MODE_REL);
 
 	irq = platform_get_irq_byname_optional(pdev, "pps");
 	if (irq < 0)
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 18/24] net: wwan: iosm: Switch to use hrtimer_setup()
  2024-10-28  7:34 [PATCH 00/24] hrtimers: Switch to new hrtimer interface functions (3/5) Nam Cao
                   ` (16 preceding siblings ...)
  2024-10-28  7:34 ` [PATCH 17/24] net: fec: " Nam Cao
@ 2024-10-28  7:34 ` Nam Cao
  2024-10-28  7:34 ` [PATCH 19/24] net/cdc_ncm: " Nam Cao
                   ` (5 subsequent siblings)
  23 siblings, 0 replies; 28+ messages in thread
From: Nam Cao @ 2024-10-28  7:34 UTC (permalink / raw)
  To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
	Andreas Hindborg, Alice Ryhl, Miguel Ojeda, Kees Cook,
	linux-kernel
  Cc: Nam Cao, Jakub Kicinski, Paolo Abeni

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.

Signed-off-by: Nam Cao <namcao@linutronix.de>
---
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
---
 drivers/net/wwan/iosm/iosm_ipc_imem.c | 24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/drivers/net/wwan/iosm/iosm_ipc_imem.c b/drivers/net/wwan/iosm/iosm_ipc_imem.c
index 829515a601b3..530a3ea47a1a 100644
--- a/drivers/net/wwan/iosm/iosm_ipc_imem.c
+++ b/drivers/net/wwan/iosm/iosm_ipc_imem.c
@@ -1381,24 +1381,20 @@ struct iosm_imem *ipc_imem_init(struct iosm_pcie *pcie, unsigned int device_id,
 	/* The phase is set to power off. */
 	ipc_imem->phase = IPC_P_OFF;
 
-	hrtimer_init(&ipc_imem->startup_timer, CLOCK_MONOTONIC,
-		     HRTIMER_MODE_REL);
-	ipc_imem->startup_timer.function = ipc_imem_startup_timer_cb;
+	hrtimer_setup(&ipc_imem->startup_timer, ipc_imem_startup_timer_cb, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 
-	hrtimer_init(&ipc_imem->tdupdate_timer, CLOCK_MONOTONIC,
-		     HRTIMER_MODE_REL);
-	ipc_imem->tdupdate_timer.function = ipc_imem_td_update_timer_cb;
+	hrtimer_setup(&ipc_imem->tdupdate_timer, ipc_imem_td_update_timer_cb, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 
-	hrtimer_init(&ipc_imem->fast_update_timer, CLOCK_MONOTONIC,
-		     HRTIMER_MODE_REL);
-	ipc_imem->fast_update_timer.function = ipc_imem_fast_update_timer_cb;
+	hrtimer_setup(&ipc_imem->fast_update_timer, ipc_imem_fast_update_timer_cb, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 
-	hrtimer_init(&ipc_imem->td_alloc_timer, CLOCK_MONOTONIC,
-		     HRTIMER_MODE_REL);
-	ipc_imem->td_alloc_timer.function = ipc_imem_td_alloc_timer_cb;
+	hrtimer_setup(&ipc_imem->td_alloc_timer, ipc_imem_td_alloc_timer_cb, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 
-	hrtimer_init(&ipc_imem->adb_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	ipc_imem->adb_timer.function = ipc_imem_adb_timer_cb;
+	hrtimer_setup(&ipc_imem->adb_timer, ipc_imem_adb_timer_cb, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 
 	if (ipc_imem_config(ipc_imem)) {
 		dev_err(ipc_imem->dev, "failed to initialize the imem");
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 19/24] net/cdc_ncm: Switch to use hrtimer_setup()
  2024-10-28  7:34 [PATCH 00/24] hrtimers: Switch to new hrtimer interface functions (3/5) Nam Cao
                   ` (17 preceding siblings ...)
  2024-10-28  7:34 ` [PATCH 18/24] net: wwan: iosm: " Nam Cao
@ 2024-10-28  7:34 ` Nam Cao
  2024-10-28  7:34 ` [PATCH 20/24] wifi: " Nam Cao
                   ` (4 subsequent siblings)
  23 siblings, 0 replies; 28+ messages in thread
From: Nam Cao @ 2024-10-28  7:34 UTC (permalink / raw)
  To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
	Andreas Hindborg, Alice Ryhl, Miguel Ojeda, Kees Cook,
	linux-kernel
  Cc: Nam Cao, Oliver Neukum, Jakub Kicinski, Paolo Abeni

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.

Signed-off-by: Nam Cao <namcao@linutronix.de>
---
Cc: Oliver Neukum <oliver@neukum.org>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
---
 drivers/net/usb/cdc_ncm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index d5c47a2a62dc..34e82f1e37d9 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -833,8 +833,7 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
 
 	ctx->dev = dev;
 
-	hrtimer_init(&ctx->tx_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	ctx->tx_timer.function = &cdc_ncm_tx_timer_cb;
+	hrtimer_setup(&ctx->tx_timer, &cdc_ncm_tx_timer_cb, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 	tasklet_setup(&ctx->bh, cdc_ncm_txpath_bh);
 	atomic_set(&ctx->stop, 0);
 	spin_lock_init(&ctx->mtx);
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 20/24] wifi: Switch to use hrtimer_setup()
  2024-10-28  7:34 [PATCH 00/24] hrtimers: Switch to new hrtimer interface functions (3/5) Nam Cao
                   ` (18 preceding siblings ...)
  2024-10-28  7:34 ` [PATCH 19/24] net/cdc_ncm: " Nam Cao
@ 2024-10-28  7:34 ` Nam Cao
  2024-10-28  7:34 ` [PATCH 21/24] wifi: rt2x00: " Nam Cao
                   ` (3 subsequent siblings)
  23 siblings, 0 replies; 28+ messages in thread
From: Nam Cao @ 2024-10-28  7:34 UTC (permalink / raw)
  To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
	Andreas Hindborg, Alice Ryhl, Miguel Ojeda, Kees Cook,
	linux-kernel
  Cc: Nam Cao, Kalle Valo

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.

Signed-off-by: Nam Cao <namcao@linutronix.de>
---
Cc: Kalle Valo <kvalo@kernel.org>
---
 drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c | 4 ++--
 drivers/net/wireless/virtual/mac80211_hwsim.c         | 6 ++----
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c b/drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c
index 0e1ede9314d8..4840d0b500b3 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c
@@ -264,8 +264,8 @@ void mt76x02u_init_beacon_config(struct mt76x02_dev *dev)
 	};
 	dev->beacon_ops = &beacon_ops;
 
-	hrtimer_init(&dev->pre_tbtt_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	dev->pre_tbtt_timer.function = mt76x02u_pre_tbtt_interrupt;
+	hrtimer_setup(&dev->pre_tbtt_timer, mt76x02u_pre_tbtt_interrupt, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 	INIT_WORK(&dev->pre_tbtt_work, mt76x02u_pre_tbtt_work);
 
 	mt76x02_init_beacon_config(dev);
diff --git a/drivers/net/wireless/virtual/mac80211_hwsim.c b/drivers/net/wireless/virtual/mac80211_hwsim.c
index f0e528abb1b4..3695f79fec95 100644
--- a/drivers/net/wireless/virtual/mac80211_hwsim.c
+++ b/drivers/net/wireless/virtual/mac80211_hwsim.c
@@ -5509,10 +5509,8 @@ static int mac80211_hwsim_new_radio(struct genl_info *info,
 	wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_CQM_RSSI_LIST);
 
 	for (i = 0; i < ARRAY_SIZE(data->link_data); i++) {
-		hrtimer_init(&data->link_data[i].beacon_timer, CLOCK_MONOTONIC,
-			     HRTIMER_MODE_ABS_SOFT);
-		data->link_data[i].beacon_timer.function =
-			mac80211_hwsim_beacon;
+		hrtimer_setup(&data->link_data[i].beacon_timer, mac80211_hwsim_beacon,
+			      CLOCK_MONOTONIC, HRTIMER_MODE_ABS_SOFT);
 		data->link_data[i].link_id = i;
 	}
 
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 21/24] wifi: rt2x00: Switch to use hrtimer_setup()
  2024-10-28  7:34 [PATCH 00/24] hrtimers: Switch to new hrtimer interface functions (3/5) Nam Cao
                   ` (19 preceding siblings ...)
  2024-10-28  7:34 ` [PATCH 20/24] wifi: " Nam Cao
@ 2024-10-28  7:34 ` Nam Cao
  2024-10-28  7:34 ` [PATCH 22/24] igc: " Nam Cao
                   ` (2 subsequent siblings)
  23 siblings, 0 replies; 28+ messages in thread
From: Nam Cao @ 2024-10-28  7:34 UTC (permalink / raw)
  To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
	Andreas Hindborg, Alice Ryhl, Miguel Ojeda, Kees Cook,
	linux-kernel
  Cc: Nam Cao, Kalle Valo

There is a new function hrtimer_setup() which will replace hrtimer_init()
and also set the timer callback function with additional sanity checks.

This driver calls hrtimer_init() in rt2x00dev.c, then set the hrtimer's
callback function in rt2800mmio.c and rt2800usb.c. Therefore, switching to
the new function is not a simple one-for-one replacement.

Because only usb/mmio variants of this driver use hrtimer, ideally all
hrtimer code should be moved in those specific parts. However, all usage of
hrtimer_cancel() should be moved as well, and that is not so obvious to do.

With the lack of hardware to verify any non-trivial changes, introduce a
dummy timer callback function and use hrtimer_setup() instead of
hrtimer_init().

Signed-off-by: Nam Cao <namcao@linutronix.de>
---
Cc: Kalle Valo <kvalo@kernel.org>
---
 drivers/net/wireless/ralink/rt2x00/rt2x00dev.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
index 9e7d9dbe954c..187701a8f8c8 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
@@ -1362,6 +1362,11 @@ static unsigned int rt2x00dev_extra_tx_headroom(struct rt2x00_dev *rt2x00dev)
 	return rt2x00dev->tx[0].winfo_size;
 }
 
+static enum hrtimer_restart rt2x00lib_dummy_timeout(struct hrtimer *timer)
+{
+	return HRTIMER_NORESTART;
+}
+
 /*
  * driver allocation handlers.
  */
@@ -1391,8 +1396,8 @@ int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev)
 	mutex_init(&rt2x00dev->conf_mutex);
 	INIT_LIST_HEAD(&rt2x00dev->bar_list);
 	spin_lock_init(&rt2x00dev->bar_list_lock);
-	hrtimer_init(&rt2x00dev->txstatus_timer, CLOCK_MONOTONIC,
-		     HRTIMER_MODE_REL);
+	hrtimer_setup(&rt2x00dev->txstatus_timer, rt2x00lib_dummy_timeout, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 
 	set_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags);
 
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 22/24] igc: Switch to use hrtimer_setup()
  2024-10-28  7:34 [PATCH 00/24] hrtimers: Switch to new hrtimer interface functions (3/5) Nam Cao
                   ` (20 preceding siblings ...)
  2024-10-28  7:34 ` [PATCH 21/24] wifi: rt2x00: " Nam Cao
@ 2024-10-28  7:34 ` Nam Cao
  2024-10-28  7:34 ` [PATCH 23/24] octeontx2-pf: " Nam Cao
  2024-10-28  7:34 ` [PATCH 24/24] xfrm: " Nam Cao
  23 siblings, 0 replies; 28+ messages in thread
From: Nam Cao @ 2024-10-28  7:34 UTC (permalink / raw)
  To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
	Andreas Hindborg, Alice Ryhl, Miguel Ojeda, Kees Cook,
	linux-kernel
  Cc: Nam Cao, Jakub Kicinski, Paolo Abeni

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.

Signed-off-by: Nam Cao <namcao@linutronix.de>
---
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
---
 drivers/net/ethernet/intel/igc/igc_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c
index 6e70bca15db1..dd5190a2a4f0 100644
--- a/drivers/net/ethernet/intel/igc/igc_main.c
+++ b/drivers/net/ethernet/intel/igc/igc_main.c
@@ -7103,8 +7103,8 @@ static int igc_probe(struct pci_dev *pdev,
 	INIT_WORK(&adapter->reset_task, igc_reset_task);
 	INIT_WORK(&adapter->watchdog_task, igc_watchdog_task);
 
-	hrtimer_init(&adapter->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	adapter->hrtimer.function = &igc_qbv_scheduling_timer;
+	hrtimer_setup(&adapter->hrtimer, &igc_qbv_scheduling_timer, CLOCK_MONOTONIC,
+		      HRTIMER_MODE_REL);
 
 	/* Initialize link properties that are user-changeable */
 	adapter->fc_autoneg = true;
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 23/24] octeontx2-pf: Switch to use hrtimer_setup()
  2024-10-28  7:34 [PATCH 00/24] hrtimers: Switch to new hrtimer interface functions (3/5) Nam Cao
                   ` (21 preceding siblings ...)
  2024-10-28  7:34 ` [PATCH 22/24] igc: " Nam Cao
@ 2024-10-28  7:34 ` Nam Cao
  2024-10-28  7:34 ` [PATCH 24/24] xfrm: " Nam Cao
  23 siblings, 0 replies; 28+ messages in thread
From: Nam Cao @ 2024-10-28  7:34 UTC (permalink / raw)
  To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
	Andreas Hindborg, Alice Ryhl, Miguel Ojeda, Kees Cook,
	linux-kernel
  Cc: Nam Cao, Jakub Kicinski, Paolo Abeni

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.

Signed-off-by: Nam Cao <namcao@linutronix.de>
---
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
---
 drivers/net/ethernet/marvell/octeontx2/af/ptp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/ptp.c b/drivers/net/ethernet/marvell/octeontx2/af/ptp.c
index bcc96eed2481..66749b3649c1 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/ptp.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/ptp.c
@@ -545,8 +545,7 @@ static int ptp_probe(struct pci_dev *pdev,
 	spin_lock_init(&ptp->ptp_lock);
 	if (cn10k_ptp_errata(ptp)) {
 		ptp->read_ptp_tstmp = &read_ptp_tstmp_sec_nsec;
-		hrtimer_init(&ptp->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-		ptp->hrtimer.function = ptp_reset_thresh;
+		hrtimer_setup(&ptp->hrtimer, ptp_reset_thresh, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 	} else {
 		ptp->read_ptp_tstmp = &read_ptp_tstmp_nsec;
 	}
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 24/24] xfrm: Switch to use hrtimer_setup()
  2024-10-28  7:34 [PATCH 00/24] hrtimers: Switch to new hrtimer interface functions (3/5) Nam Cao
                   ` (22 preceding siblings ...)
  2024-10-28  7:34 ` [PATCH 23/24] octeontx2-pf: " Nam Cao
@ 2024-10-28  7:34 ` Nam Cao
  23 siblings, 0 replies; 28+ messages in thread
From: Nam Cao @ 2024-10-28  7:34 UTC (permalink / raw)
  To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
	Andreas Hindborg, Alice Ryhl, Miguel Ojeda, Kees Cook,
	linux-kernel
  Cc: Nam Cao, Jakub Kicinski, Paolo Abeni

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.

Signed-off-by: Nam Cao <namcao@linutronix.de>
---
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
---
 net/xfrm/xfrm_state.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 37478d36a8df..ee0581d45d9c 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -669,8 +669,8 @@ struct xfrm_state *xfrm_state_alloc(struct net *net)
 		INIT_HLIST_NODE(&x->bysrc);
 		INIT_HLIST_NODE(&x->byspi);
 		INIT_HLIST_NODE(&x->byseq);
-		hrtimer_init(&x->mtimer, CLOCK_BOOTTIME, HRTIMER_MODE_ABS_SOFT);
-		x->mtimer.function = xfrm_timer_handler;
+		hrtimer_setup(&x->mtimer, xfrm_timer_handler, CLOCK_BOOTTIME,
+			      HRTIMER_MODE_ABS_SOFT);
 		timer_setup(&x->rtimer, xfrm_replay_timer_handler, 0);
 		x->curlft.add_time = ktime_get_real_seconds();
 		x->lft.soft_byte_limit = XFRM_INF;
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* Re: [PATCH 05/24] can: m_can: Switch to use hrtimer_setup()
  2024-10-28  7:34 ` [PATCH 05/24] can: m_can: " Nam Cao
@ 2024-10-28 14:02   ` Marc Kleine-Budde
  0 siblings, 0 replies; 28+ messages in thread
From: Marc Kleine-Budde @ 2024-10-28 14:02 UTC (permalink / raw)
  To: Nam Cao
  Cc: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
	Andreas Hindborg, Alice Ryhl, Miguel Ojeda, Kees Cook,
	linux-kernel, Jakub Kicinski, Paolo Abeni

[-- Attachment #1: Type: text/plain, Size: 724 bytes --]

On 28.10.2024 08:34:18, Nam Cao 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.
> 
> Signed-off-by: Nam Cao <namcao@linutronix.de>

Reviewed-by: Marc Kleine-Budde <mkl@pengutronix.de>

Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde          |
Embedded Linux                   | https://www.pengutronix.de |
Vertretung Nürnberg              | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-9   |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 06/24] can: mcp251xfd: Switch to use hrtimer_setup()
  2024-10-28  7:34 ` [PATCH 06/24] can: mcp251xfd: " Nam Cao
@ 2024-10-28 14:02   ` Marc Kleine-Budde
  0 siblings, 0 replies; 28+ messages in thread
From: Marc Kleine-Budde @ 2024-10-28 14:02 UTC (permalink / raw)
  To: Nam Cao
  Cc: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
	Andreas Hindborg, Alice Ryhl, Miguel Ojeda, Kees Cook,
	linux-kernel, Jakub Kicinski, Paolo Abeni

[-- Attachment #1: Type: text/plain, Size: 724 bytes --]

On 28.10.2024 08:34:19, Nam Cao 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.
> 
> Signed-off-by: Nam Cao <namcao@linutronix.de>

Reviewed-by: Marc Kleine-Budde <mkl@pengutronix.de>

Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde          |
Embedded Linux                   | https://www.pengutronix.de |
Vertretung Nürnberg              | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-9   |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 07/24] can: Switch to use hrtimer_setup()
  2024-10-28  7:34 ` [PATCH 07/24] can: " Nam Cao
@ 2024-10-28 14:03   ` Marc Kleine-Budde
  0 siblings, 0 replies; 28+ messages in thread
From: Marc Kleine-Budde @ 2024-10-28 14:03 UTC (permalink / raw)
  To: Nam Cao
  Cc: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
	Andreas Hindborg, Alice Ryhl, Miguel Ojeda, Kees Cook,
	linux-kernel, Jakub Kicinski, Paolo Abeni

[-- Attachment #1: Type: text/plain, Size: 724 bytes --]

On 28.10.2024 08:34:20, Nam Cao 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.
> 
> Signed-off-by: Nam Cao <namcao@linutronix.de>

Reviewed-by: Marc Kleine-Budde <mkl@pengutronix.de>

Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde          |
Embedded Linux                   | https://www.pengutronix.de |
Vertretung Nürnberg              | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-9   |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2024-10-28 14:03 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-28  7:34 [PATCH 00/24] hrtimers: Switch to new hrtimer interface functions (3/5) Nam Cao
2024-10-28  7:34 ` [PATCH 01/24] netdev: Switch to use hrtimer_setup() Nam Cao
2024-10-28  7:34 ` [PATCH 02/24] net/sched: " Nam Cao
2024-10-28  7:34 ` [PATCH 03/24] mac802154: " Nam Cao
2024-10-28  7:34 ` [PATCH 04/24] tcp: " Nam Cao
2024-10-28  7:34 ` [PATCH 05/24] can: m_can: " Nam Cao
2024-10-28 14:02   ` Marc Kleine-Budde
2024-10-28  7:34 ` [PATCH 06/24] can: mcp251xfd: " Nam Cao
2024-10-28 14:02   ` Marc Kleine-Budde
2024-10-28  7:34 ` [PATCH 07/24] can: " Nam Cao
2024-10-28 14:03   ` Marc Kleine-Budde
2024-10-28  7:34 ` [PATCH 08/24] net: ethernet: ti: " Nam Cao
2024-10-28  7:34 ` [PATCH 09/24] net: ethernet: cortina: " Nam Cao
2024-10-28  7:34 ` [PATCH 10/24] net: ethernet: ec_bhf: " Nam Cao
2024-10-28  7:34 ` [PATCH 11/24] net: ethernet: hisilicon: " Nam Cao
2024-10-28  7:34 ` [PATCH 12/24] net: sparx5: " Nam Cao
2024-10-28  7:34 ` [PATCH 13/24] net: ieee802154: at86rf230: " Nam Cao
2024-10-28  7:34 ` [PATCH 14/24] net: mvpp2: " Nam Cao
2024-10-28  7:34 ` [PATCH 15/24] net: qualcomm: rmnet: " Nam Cao
2024-10-28  7:34 ` [PATCH 16/24] net: stmmac: " Nam Cao
2024-10-28  7:34 ` [PATCH 17/24] net: fec: " Nam Cao
2024-10-28  7:34 ` [PATCH 18/24] net: wwan: iosm: " Nam Cao
2024-10-28  7:34 ` [PATCH 19/24] net/cdc_ncm: " Nam Cao
2024-10-28  7:34 ` [PATCH 20/24] wifi: " Nam Cao
2024-10-28  7:34 ` [PATCH 21/24] wifi: rt2x00: " Nam Cao
2024-10-28  7:34 ` [PATCH 22/24] igc: " Nam Cao
2024-10-28  7:34 ` [PATCH 23/24] octeontx2-pf: " Nam Cao
2024-10-28  7:34 ` [PATCH 24/24] xfrm: " Nam Cao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox