Skip to content

net: provide a devres variant of register_netdev()

Bartosz Golaszewski linux-arm-kernel linux-devicetree linux-mediatek lkml netdev 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest5 patches 1 replyIn review
  2. v15 patches 2 repliesSuperseded

Changes in v2 from the cover letter

- rebase on top of net-next after driver rename, no functional changes

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5Documentation: devres: add a missing section for networking helpersDocumentation/driver-api/driver-model/devres.rst+4 -00 replies
2/5net: move devres helpers into a separate source filenet/Makefile net/devres.c net/ethernet/eth.c+37 -290 replies
3/5net: devres: define a separate devres structure for devm_alloc_etherdev()net/devres.c+12 -80 replies
4/5net: devres: provide devm_register_netdev()Documentation/driver-api/driver-model/devres.rst include/linux/netdevice.h net/devres.c+58 -00 replies
5/5net: ethernet: mtk_star_emac: use devm_register_netdev()drivers/net/ethernet/mediatek/mtk_star_emac.c+1 -160 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/5] net: provide a devres variant of register_netdev()

From: Bartosz Golaszewski <[email protected]>

Using devres helpers allows to shrink the probing code, avoid memory leaks in error paths make sure the order in which resources are freed is the exact opposite of their allocation. This series proposes to add a devres variant of register_netdev() that will only work with net_device structures whose memory is also managed.

First we add the missing documentation entry for the only other networking devres helper: devm_alloc_etherdev().

Next we move devm_alloc_etherdev() into a separate source file.

We then use a proxy structure in devm_alloc_etherdev() to improve readability.

Last: we implement devm_register_netdev() and use it in mtk-eth-mac driver.

v1 -> v2:
- rebase on top of net-next after driver rename, no functional changes

Bartosz Golaszewski (5):
Documentation: devres: add a missing section for networking helpers
net: move devres helpers into a separate source file
net: devres: define a separate devres structure for
devm_alloc_etherdev()
net: devres: provide devm_register_netdev()
net: ethernet: mtk_star_emac: use devm_register_netdev()

 .../driver-api/driver-model/devres.rst        |  5 +
 drivers/net/ethernet/mediatek/mtk_star_emac.c | 17 +---
 include/linux/netdevice.h                     |  2 +
 net/Makefile                                  |  2 +-
 net/devres.c                                  | 95 +++++++++++++++++++
 net/ethernet/eth.c                            | 28 ------
 6 files changed, 104 insertions(+), 45 deletions(-)
 create mode 100644 net/devres.c
Signature · 1 line
2.25.0