[PATCH] PCI: mvebu: Use devm_add_action_or_reset()
Bjorn Helgaas
helgaas at kernel.org
Thu Jul 24 09:42:17 PDT 2025
On Sat, Jul 19, 2025 at 05:34:40AM +0100, Salah Triki wrote:
> Replace devm_add_action() with devm_add_action_or_reset() to make code
> cleaner.
>
> Signed-off-by: Salah Triki <salah.triki at gmail.com>
> ---
> drivers/pci/controller/pci-mvebu.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/pci/controller/pci-mvebu.c b/drivers/pci/controller/pci-mvebu.c
> index a4a2bac4f4b2..755651f33811 100644
> --- a/drivers/pci/controller/pci-mvebu.c
> +++ b/drivers/pci/controller/pci-mvebu.c
> @@ -1353,11 +1353,9 @@ static int mvebu_pcie_parse_port(struct mvebu_pcie *pcie,
> goto skip;
> }
>
> - ret = devm_add_action(dev, mvebu_pcie_port_clk_put, port);
> - if (ret < 0) {
> - clk_put(port->clk);
> + ret = devm_add_action_or_reset(dev, mvebu_pcie_port_clk_put, port);
> + if (ret < 0)
> goto err;
> - }
Looks OK to me (and already applied, so no action necessary).
But this is the only use of mvebu_pcie_port_clk_put(), which only does
the clk_put(), so I think we could also remove
mvebu_pcie_port_clk_put() completely and simply do this:
port->clk = of_clk_get_by_name(child, NULL);
...
ret = devm_add_action_or_reset(dev, clk_put, port->clk)
which would arguably make this more readable because clk_put()
corresponds with of_clk_get_by_name(), and it's clear that port->clk
is the target.
Also, and unrelated, the "err:" label only does a return, so I think
this function would be improved by removing the "err:" label and
replacing all the "goto err" cases with "return -ENOMEM" or whatever.
Bjorn
More information about the linux-arm-kernel
mailing list