mbox series

[net-next,v2,00/11] net: stmmac: introduce devres helpers for stmmac platform drivers

Message ID 20230623100417.93592-1-brgl@bgdev.pl (mailing list archive)
Headers show
Series net: stmmac: introduce devres helpers for stmmac platform drivers | expand

Message

Bartosz Golaszewski June 23, 2023, 10:04 a.m. UTC
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

The goal of this series is two-fold: to make the API for stmmac platforms more
logically correct (by providing functions that acquire resources with release
counterparts that undo only their actions and nothing more) and to provide
devres variants of commonly use registration functions that allows to
significantly simplify the platform drivers.

The current pattern for stmmac platform drivers is to call
stmmac_probe_config_dt(), possibly the platform's init() callback and then
call stmmac_drv_probe(). The resources allocated by these calls will then
be released by calling stmmac_pltfr_remove(). This goes against the commonly
accepted way of providing each function that allocated a resource with a
function that frees it.

First: provide wrappers around platform's init() and exit() callbacks that
allow users to skip checking if the callbacks exist manually.

Second: provide stmmac_pltfr_probe() which calls the platform init() callback
and then calls stmmac_drv_probe() together with a variant of
stmmac_pltfr_remove() that DOES NOT call stmmac_remove_config_dt(). For now
this variant is called stmmac_pltfr_remove_no_dt() but once all users of
the old stmmac_pltfr_remove() are converted to the devres helper, it will be
renamed back to stmmac_pltfr_remove() and the no_dt function removed.

Finally use the devres helpers in dwmac-qco-ethqos to show how much simplier
the driver's probe() becomes.

This series obviously just starts the conversion process and other platform
drivers will need to be converted once the helpers land in net/.

v1 -> v2:
- fix build for !CONFIG_OF

Bartosz Golaszewski (11):
  net: stmmac: platform: provide stmmac_pltfr_init()
  net: stmmac: dwmac-generic: use stmmac_pltfr_init()
  net: stmmac: platform: provide stmmac_pltfr_exit()
  net: stmmac: dwmac-generic: use stmmac_pltfr_exit()
  net: stmmac: platform: provide stmmac_pltfr_probe()
  net: stmmac: dwmac-generic: use stmmac_pltfr_probe()
  net: stmmac: platform: provide stmmac_pltfr_remove_no_dt()
  net: stmmac: platform: provide devm_stmmac_probe_config_dt()
  net: stmmac: dwmac-qco-ethqos: use devm_stmmac_probe_config_dt()
  net: stmmac: platform: provide devm_stmmac_pltfr_probe()
  net: stmmac: dwmac-qcom-ethqos: use devm_stmmac_pltfr_probe()

 .../ethernet/stmicro/stmmac/dwmac-generic.c   |  14 +-
 .../stmicro/stmmac/dwmac-qcom-ethqos.c        |  48 ++---
 .../ethernet/stmicro/stmmac/stmmac_platform.c | 164 +++++++++++++++++-
 .../ethernet/stmicro/stmmac/stmmac_platform.h |  14 ++
 4 files changed, 185 insertions(+), 55 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org June 24, 2023, 10:40 p.m. UTC | #1
Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Fri, 23 Jun 2023 12:04:06 +0200 you wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> 
> The goal of this series is two-fold: to make the API for stmmac platforms more
> logically correct (by providing functions that acquire resources with release
> counterparts that undo only their actions and nothing more) and to provide
> devres variants of commonly use registration functions that allows to
> significantly simplify the platform drivers.
> 
> [...]

Here is the summary with links:
  - [net-next,v2,01/11] net: stmmac: platform: provide stmmac_pltfr_init()
    https://git.kernel.org/netdev/net-next/c/97117eb51ec8
  - [net-next,v2,02/11] net: stmmac: dwmac-generic: use stmmac_pltfr_init()
    https://git.kernel.org/netdev/net-next/c/4450e7d4231a
  - [net-next,v2,03/11] net: stmmac: platform: provide stmmac_pltfr_exit()
    https://git.kernel.org/netdev/net-next/c/5b0acf8dd2c1
  - [net-next,v2,04/11] net: stmmac: dwmac-generic: use stmmac_pltfr_exit()
    https://git.kernel.org/netdev/net-next/c/40db9f1ddfcc
  - [net-next,v2,05/11] net: stmmac: platform: provide stmmac_pltfr_probe()
    https://git.kernel.org/netdev/net-next/c/3d5bf75d76ea
  - [net-next,v2,06/11] net: stmmac: dwmac-generic: use stmmac_pltfr_probe()
    https://git.kernel.org/netdev/net-next/c/0a68a59493e0
  - [net-next,v2,07/11] net: stmmac: platform: provide stmmac_pltfr_remove_no_dt()
    https://git.kernel.org/netdev/net-next/c/1be0c9d65e17
  - [net-next,v2,08/11] net: stmmac: platform: provide devm_stmmac_probe_config_dt()
    https://git.kernel.org/netdev/net-next/c/d74065427374
  - [net-next,v2,09/11] net: stmmac: dwmac-qco-ethqos: use devm_stmmac_probe_config_dt()
    https://git.kernel.org/netdev/net-next/c/061425d933ef
  - [net-next,v2,10/11] net: stmmac: platform: provide devm_stmmac_pltfr_probe()
    https://git.kernel.org/netdev/net-next/c/fc9ee2ac4f9c
  - [net-next,v2,11/11] net: stmmac: dwmac-qcom-ethqos: use devm_stmmac_pltfr_probe()
    https://git.kernel.org/netdev/net-next/c/4194f32a4b2b

You are awesome, thank you!