* [PATCH] PCI: mvebu: Use devm_add_action_or_reset() @ 2025-07-19 4:34 Salah Triki 2025-07-23 16:40 ` Manivannan Sadhasivam 2025-07-24 16:42 ` Bjorn Helgaas 0 siblings, 2 replies; 5+ messages in thread From: Salah Triki @ 2025-07-19 4:34 UTC (permalink / raw) To: Thomas Petazzoni, Pali Rohár, Lorenzo Pieralisi, Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, linux-pci, linux-arm-kernel, linux-kernel Cc: salah.triki 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 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] PCI: mvebu: Use devm_add_action_or_reset() 2025-07-19 4:34 [PATCH] PCI: mvebu: Use devm_add_action_or_reset() Salah Triki @ 2025-07-23 16:40 ` Manivannan Sadhasivam 2025-07-24 16:42 ` Bjorn Helgaas 1 sibling, 0 replies; 5+ messages in thread From: Manivannan Sadhasivam @ 2025-07-23 16:40 UTC (permalink / raw) To: Thomas Petazzoni, Pali Rohár, Lorenzo Pieralisi, Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas, linux-pci, linux-arm-kernel, linux-kernel, 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> ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] PCI: mvebu: Use devm_add_action_or_reset() 2025-07-19 4:34 [PATCH] PCI: mvebu: Use devm_add_action_or_reset() Salah Triki 2025-07-23 16:40 ` Manivannan Sadhasivam @ 2025-07-24 16:42 ` Bjorn Helgaas 2025-07-25 3:57 ` Salah Triki 1 sibling, 1 reply; 5+ messages in thread From: Bjorn Helgaas @ 2025-07-24 16:42 UTC (permalink / raw) To: Salah Triki Cc: Thomas Petazzoni, Pali Rohár, Lorenzo Pieralisi, Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, linux-pci, linux-arm-kernel, linux-kernel 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] PCI: mvebu: Use devm_add_action_or_reset() 2025-07-24 16:42 ` Bjorn Helgaas @ 2025-07-25 3:57 ` Salah Triki 2025-07-25 10:13 ` Jonathan Cameron 0 siblings, 1 reply; 5+ messages in thread From: Salah Triki @ 2025-07-25 3:57 UTC (permalink / raw) To: Bjorn Helgaas Cc: Thomas Petazzoni, Pali Rohár, Lorenzo Pieralisi, Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, linux-pci, linux-arm-kernel, linux-kernel 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] PCI: mvebu: Use devm_add_action_or_reset() 2025-07-25 3:57 ` Salah Triki @ 2025-07-25 10:13 ` Jonathan Cameron 0 siblings, 0 replies; 5+ messages in thread From: Jonathan Cameron @ 2025-07-25 10:13 UTC (permalink / raw) To: Salah Triki Cc: Bjorn Helgaas, Thomas Petazzoni, Pali Rohár, Lorenzo Pieralisi, Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, linux-pci, linux-arm-kernel, linux-kernel 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 > ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-07-25 10:13 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-07-19 4:34 [PATCH] PCI: mvebu: Use devm_add_action_or_reset() Salah Triki 2025-07-23 16:40 ` Manivannan Sadhasivam 2025-07-24 16:42 ` Bjorn Helgaas 2025-07-25 3:57 ` Salah Triki 2025-07-25 10:13 ` Jonathan Cameron
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).