[PATCH 00/24] hrtimers: Switch to new hrtimer interface functions (3/5)

Nam Cao posted 24 patches 4 weeks ago
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(-)
[PATCH 00/24] hrtimers: Switch to new hrtimer interface functions (3/5)
Posted by Nam Cao 4 weeks ago
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