]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
can: Switch to use hrtimer_setup()
authorNam Cao <namcao@linutronix.de>
Wed, 5 Feb 2025 10:43:27 +0000 (11:43 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Tue, 18 Feb 2025 09:35:45 +0000 (10:35 +0100)
hrtimer_setup() takes the callback function pointer as argument and
initializes the timer completely.

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

Most of this patch is generated by Coccinelle. Except for the TX thrtimer
in bcm_tx_setup() because this timer is not used and the callback function
is never set. For this particular case, set the callback to
hrtimer_dummy_timeout()

Signed-off-by: Nam Cao <namcao@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Marc Kleine-Budde <mkl@pengutronix.de>
Link: https://lore.kernel.org/all/a3a6be42c818722ad41758457408a32163bfd9a0.1738746872.git.namcao@linutronix.de
include/linux/hrtimer.h
kernel/time/hrtimer.c
net/can/bcm.c
net/can/isotp.c
net/can/j1939/bus.c
net/can/j1939/transport.c

index f7bfdcf0dda3f12dd7216ff51471f32647c70ab5..acae379541c52565367918644892a58a8f15b683 100644 (file)
@@ -223,6 +223,11 @@ static inline void hrtimer_cancel_wait_running(struct hrtimer *timer)
 }
 #endif
 
+static inline enum hrtimer_restart hrtimer_dummy_timeout(struct hrtimer *unused)
+{
+       return HRTIMER_NORESTART;
+}
+
 /* Exported timer functions: */
 
 /* Initialize timers: */
index deb1aa32814e3bbea57d0a6a23986a625c6e13d1..47df6f50e12cfd32b3d653c76ecff01109f5554f 100644 (file)
@@ -1597,11 +1597,6 @@ static inline int hrtimer_clockid_to_base(clockid_t clock_id)
        return HRTIMER_BASE_MONOTONIC;
 }
 
-static enum hrtimer_restart hrtimer_dummy_timeout(struct hrtimer *unused)
-{
-       return HRTIMER_NORESTART;
-}
-
 static void __hrtimer_init(struct hrtimer *timer, clockid_t clock_id,
                           enum hrtimer_mode mode)
 {
index 217049fa496e9db80bf0ffaf97d66ac731042ee6..526cb6cd901fbcb0c1507d35aaf1116333859018 100644 (file)
@@ -1011,13 +1011,12 @@ 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);
 
                /* currently unused in tx_ops */
-               hrtimer_init(&op->thrtimer, CLOCK_MONOTONIC,
-                            HRTIMER_MODE_REL_SOFT);
+               hrtimer_setup(&op->thrtimer, hrtimer_dummy_timeout, CLOCK_MONOTONIC,
+                             HRTIMER_MODE_REL_SOFT);
 
                /* add this bcm_op to the list of the tx_ops */
                list_add(&op->list, &bo->tx_ops);
@@ -1192,13 +1191,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);
index 16046931542a57cbf1e35c5d0c402db00cff1bd2..442c343afe1f75ab5d7fe42fb46b6924d1cbf1c2 100644 (file)
@@ -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);
index 486687901602112db6a6de166b85f116c7a19e59..39844f14eed86290dacb3cf17ed2141f1d0062fd 100644 (file)
@@ -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);
index 9b72d118d756dda5ddd79ac22361beab3f377ffc..fbf5c8001c9df3d2192e2f334b5361648d207fa9 100644 (file)
@@ -1511,12 +1511,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);