PCI: mvebu: Use devm_add_action_or_reset()
Subsystems (3)
PATCH 1/1 PCI: mvebu: Use devm_add_action_or_reset()
Replace devm_add_action() with devm_add_action_or_reset() to make code cleaner.
--- drivers/pci/controller/pci-mvebu.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/pci/controller/pci-mvebu.c +2 -4
@@ -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 ;
Signature · 1 line
2.43.0
Manivannan Sadhasivam
AppliedQuoted 4 lines · Salah Triki
Replace
devm_add_action()withdevm_add_action_or_reset()to make code cleaner.
Applied, thanks!
[1/1] PCI: mvebu: Use devm_add_action_or_reset()
commit: c79a7ca8fb72a17db03e916438c44d9afc98998f
Best regards,
Signature · 1 line
Manivannan Sadhasivam <[email protected]>
Quoted 13 lines · Salah Triki
Replace
devm_add_action()withdevm_add_action_or_reset()to make code cleaner.Signed-off-by Salah Triki <[email protected]>--- drivers/pci/controller/pci-mvebu.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/pci/controller/pci-mvebu.c +0
-0
drivers/pci/controller/pci-mvebu.c static int mvebu_pcie_parse_port(struct mvebu_pcie *pcie, · line 1360
Quoted 10 lines
drivers/pci/controller/pci-mvebu.c +2
-4@@ -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
Quoted 4 lines · Bjorn Helgaas
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
Quoted 10 lines · On Fri, 25 Jul 2025 04:57:05 +0100 Salah Triki <[email protected]> wrote:
Quoted 4 lines · Bjorn Helgaas
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 ofclk_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.
Quoted 4 lines
Best regards,
Salah Triki