drivers/pci/controller/pci-mvebu.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
Replace devm_add_action() with devm_add_action_or_reset() to make code
cleaner.
Signed-off-by: Salah Triki <salah.triki@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;
- }
return 1;
--
2.43.0
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@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
On Thu, Jul 24, 2025 at 11:42:17AM -0500, Bjorn Helgaas wrote: > On Sat, Jul 19, 2025 at 05:34:40AM +0100, Salah Triki wrote: > > ret = devm_add_action_or_reset(dev, clk_put, port->clk) > The second argument of devm_add_action_or_reset() is of type void (*)(void *) and the argument of clk_put() is of type struct clk *, so I think a cast is needed: ret = devm_add_action_or_reset(dev, (void (*)(void *)) clk_put, port->clk) Best regards, Salah Triki
On Fri, 25 Jul 2025 04:57:05 +0100 Salah Triki <salah.triki@gmail.com> wrote: > On Thu, Jul 24, 2025 at 11:42:17AM -0500, Bjorn Helgaas wrote: > > On Sat, Jul 19, 2025 at 05:34:40AM +0100, Salah Triki wrote: > > > > ret = devm_add_action_or_reset(dev, clk_put, port->clk) > > > The second argument of devm_add_action_or_reset() is of type void (*)(void *) > and the argument of clk_put() is of type struct clk *, so I think a cast is > needed: > > ret = devm_add_action_or_reset(dev, (void (*)(void *)) clk_put, port->clk) Can you use devm_get_clk_from_child() here? If not add a similar variant. > > Best regards, > Salah Triki >
On Sat, 19 Jul 2025 05:34:40 +0100, Salah Triki wrote: > Replace devm_add_action() with devm_add_action_or_reset() to make code > cleaner. > > Applied, thanks! [1/1] PCI: mvebu: Use devm_add_action_or_reset() commit: c79a7ca8fb72a17db03e916438c44d9afc98998f Best regards, -- Manivannan Sadhasivam <mani@kernel.org>
© 2016 - 2025 Red Hat, Inc.