From: Bjorn Helgaas <helgaas@kernel.org>
To: Salah Triki <salah.triki@gmail.com>
Cc: "Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
"Pali Rohár" <pali@kernel.org>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
"Manivannan Sadhasivam" <mani@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] PCI: mvebu: Use devm_add_action_or_reset()
Date: Thu, 24 Jul 2025 11:42:17 -0500 [thread overview]
Message-ID: <20250724164217.GA2942464@bhelgaas> (raw)
In-Reply-To: <aHsgYALHfQbrgq0t@pc>
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
next prev parent reply other threads:[~2025-07-24 19:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2025-07-25 3:57 ` Salah Triki
2025-07-25 10:13 ` Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250724164217.GA2942464@bhelgaas \
--to=helgaas@kernel.org \
--cc=bhelgaas@google.com \
--cc=kwilczynski@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=pali@kernel.org \
--cc=robh@kernel.org \
--cc=salah.triki@gmail.com \
--cc=thomas.petazzoni@bootlin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox