From: "Shradha Todi" <shradha.t@samsung.com>
To: "'Dan Carpenter'" <dan.carpenter@linaro.org>
Cc: <linux-clk@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-pci@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-samsung-soc@vger.kernel.org>, <mturquette@baylibre.com>,
<sboyd@kernel.org>, <jingoohan1@gmail.com>,
<lpieralisi@kernel.org>, <kw@linux.com>, <robh@kernel.org>,
<bhelgaas@google.com>, <krzysztof.kozlowski@linaro.org>,
<alim.akhtar@samsung.com>, <linux@armlinux.org.uk>,
<m.szyprowski@samsung.com>, <manivannan.sadhasivam@linaro.org>,
<pankaj.dubey@samsung.com>, <gost.dev@samsung.com>
Subject: RE: [PATCH v6 1/2] clk: Provide managed helper to get and enable bulk clocks
Date: Wed, 6 Mar 2024 17:43:03 +0530 [thread overview]
Message-ID: <022301da6fbf$aae4f7e0$00aee7a0$@samsung.com> (raw)
In-Reply-To: <f00eed31-4baf-4d5c-934d-8223d1ab554d@moroto.mountain>
> -----Original Message-----
> From: Dan Carpenter <dan.carpenter@linaro.org>
> Sent: 05 March 2024 14:20
> To: Shradha Todi <shradha.t@samsung.com>
> Cc: linux-clk@vger.kernel.org; linux-kernel@vger.kernel.org; linux-
> pci@vger.kernel.org; linux-arm-kernel@lists.infradead.org; linux-samsung-
> soc@vger.kernel.org; mturquette@baylibre.com; sboyd@kernel.org;
> jingoohan1@gmail.com; lpieralisi@kernel.org; kw@linux.com; robh@kernel.org;
> bhelgaas@google.com; krzysztof.kozlowski@linaro.org;
> alim.akhtar@samsung.com; linux@armlinux.org.uk;
> m.szyprowski@samsung.com; manivannan.sadhasivam@linaro.org;
> pankaj.dubey@samsung.com; gost.dev@samsung.com
> Subject: Re: [PATCH v6 1/2] clk: Provide managed helper to get and enable bulk
> clocks
>
> On Tue, Feb 20, 2024 at 02:10:45PM +0530, Shradha Todi wrote:
> > +int __must_check devm_clk_bulk_get_all_enable(struct device *dev,
> > + struct clk_bulk_data **clks) {
> > + struct clk_bulk_devres *devres;
> > + int ret;
> > +
> > + devres = devres_alloc(devm_clk_bulk_release_all_enable,
> > + sizeof(*devres), GFP_KERNEL);
> > + if (!devres)
> > + return -ENOMEM;
> > +
> > + ret = clk_bulk_get_all(dev, &devres->clks);
> > + if (ret > 0) {
>
> I feel like this should be >= instead of >. There aren't any callers of this
function
> yet so we can't see what's in *clks at the start but it's easy to imagine a
situation
> where it's bad data.
>
Reference for this piece of code has been taken from devm_clk_bulk_get_all()
which
has multiple callers, so it's safe. If we make this >=, it will hold on to the
devres node
even though there are no clocks.
> > + *clks = devres->clks;
> > + devres->num_clks = ret;
> > + } else {
> > + devres_free(devres);
> > + return ret;
>
> When clk_bulk_get_all() returns zero then we return success here.
>
Yes, we are returning success in case there are no clocks as well. In case there
are no
clocks defined in the DT-node, then it is assumed that the driver does not need
any
clock manipulation for driver operation. So the intention here is to continue
without
throwing error.
> regards,
> dan carpenter
>
> > + }
> > +
> > + ret = clk_bulk_prepare_enable(devres->num_clks, *clks);
> > + if (!ret) {
> > + devres_add(dev, devres);
> > + } else {
> > + clk_bulk_put_all(devres->num_clks, devres->clks);
> > + devres_free(devres);
> > + }
> > +
> > + return ret;
> > +}
> > +EXPORT_SYMBOL_GPL(devm_clk_bulk_get_all_enable);
> > +
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2024-03-06 12:13 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20240220084109epcas5p3dc6b95a0ed69b63e93f4aa0a6fc919fe@epcas5p3.samsung.com>
2024-02-20 8:40 ` [PATCH v6 0/2] Add helper function to get and enable all bulk clocks Shradha Todi
2024-02-20 8:40 ` [PATCH v6 1/2] clk: Provide managed helper to get and enable " Shradha Todi
2024-02-22 5:15 ` Stephen Boyd
2024-03-05 8:50 ` Dan Carpenter
2024-03-06 12:13 ` Shradha Todi [this message]
2024-03-09 0:50 ` Stephen Boyd
2024-03-15 11:34 ` Shradha Todi
2024-03-15 17:39 ` Stephen Boyd
2024-02-20 8:40 ` [PATCH v6 2/2] PCI: exynos: Adapt to clk_bulk_* APIs Shradha Todi
2024-05-17 11:25 ` Krzysztof Wilczyński
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='022301da6fbf$aae4f7e0$00aee7a0$@samsung.com' \
--to=shradha.t@samsung.com \
--cc=alim.akhtar@samsung.com \
--cc=bhelgaas@google.com \
--cc=dan.carpenter@linaro.org \
--cc=gost.dev@samsung.com \
--cc=jingoohan1@gmail.com \
--cc=krzysztof.kozlowski@linaro.org \
--cc=kw@linux.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=lpieralisi@kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=manivannan.sadhasivam@linaro.org \
--cc=mturquette@baylibre.com \
--cc=pankaj.dubey@samsung.com \
--cc=robh@kernel.org \
--cc=sboyd@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).