linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Boyd <sboyd@kernel.org>
To: "Alim Akhtar" <alim.akhtar@samsung.com>,
	"AngeloGioacchino Del Regno"
	<angelogioacchino.delregno@collabora.com>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Cristian Ciocaltea" <cristian.ciocaltea@collabora.com>,
	"Jingoo Han" <jingoohan1@gmail.com>,
	"Krzysztof Kozlowski" <krzk@kernel.org>,
	"Krzysztof Wilczyński" <kw@linux.com>,
	"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
	"Manivannan Sadhasivam" <manivannan.sadhasivam@linaro.org>,
	"Matthias Brugger" <matthias.bgg@gmail.com>,
	"Michael Turquette" <mturquette@baylibre.com>,
	"Rob Herring" <robh@kernel.org>,
	"Russell King" <linux@armlinux.org.uk>
Cc: kernel@collabora.com, linux-clk@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org, linux-pci@vger.kernel.org,
	linux-samsung-soc@vger.kernel.org
Subject: Re: [PATCH v2 1/4] clk: Provide devm_clk_bulk_get_all_enabled() helper
Date: Thu, 17 Oct 2024 12:45:10 -0700	[thread overview]
Message-ID: <347771679b3ac765de3f79c26f3d3595.sboyd@kernel.org> (raw)
In-Reply-To: <20240926-clk_bulk_ena_fix-v2-1-9c767510fbb5@collabora.com>

Quoting Cristian Ciocaltea (2024-09-26 03:43:20)
> Commit 265b07df758a ("clk: Provide managed helper to get and enable bulk
> clocks") added devm_clk_bulk_get_all_enable() function, but missed to
> return the number of clocks stored in the clk_bulk_data table referenced
> by the clks argument.  Without knowing the number, it's not possible to
> iterate these clocks when needed, hence the argument is useless and
> could have been simply removed.
> 
> Introduce devm_clk_bulk_get_all_enabled() variant, which is consistent
> with devm_clk_bulk_get_all() in terms of the returned value:
> 
>  > 0 if one or more clocks have been stored
>  = 0 if there are no clocks
>  < 0 if an error occurred
> 
> Moreover, the naming is consistent with devm_clk_get_enabled(), i.e. use
> the past form of 'enable'.
> 
> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
> ---
>  drivers/clk/clk-devres.c | 34 ++++++++++++++++++++++++++++++++++
>  include/linux/clk.h      | 24 ++++++++++++++++++++++++
>  2 files changed, 58 insertions(+)
> 
> diff --git a/drivers/clk/clk-devres.c b/drivers/clk/clk-devres.c
> index 82ae1f26e634..4203aaaa7544 100644
> --- a/drivers/clk/clk-devres.c
> +++ b/drivers/clk/clk-devres.c
> @@ -250,6 +250,40 @@ int __must_check devm_clk_bulk_get_all_enable(struct device *dev,
>  }
>  EXPORT_SYMBOL_GPL(devm_clk_bulk_get_all_enable);
>  
> +int __must_check devm_clk_bulk_get_all_enabled(struct device *dev,

I'm not super excited about the one letter difference in the function
name as that's likely to lead to confusion for someone.

> +                                              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)
> +               goto err_free_devres;
> +
> +       *clks = devres->clks;
> +       devres->num_clks = ret;
> +
> +       ret = clk_bulk_prepare_enable(devres->num_clks, *clks);
> +       if (ret) {
> +               clk_bulk_put_all(devres->num_clks, devres->clks);
> +               goto err_free_devres;
> +       }
> +
> +       devres_add(dev, devres);
> +
> +       return devres->num_clks;
> +
> +err_free_devres:
> +       devres_free(devres);
> +       return ret;
> +}
> +EXPORT_SYMBOL_GPL(devm_clk_bulk_get_all_enabled);

Instead of duplicating can you make devm_clk_bulk_get_all_enable() use
the devm_clk_bulk_get_all_enabled() function but not return the number
of clks all in this patch? It will make the diff much more readable that
way.

  reply	other threads:[~2024-10-17 19:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-26 10:43 [PATCH v2 0/4] Provide devm_clk_bulk_get_all_enabled() helper Cristian Ciocaltea
2024-09-26 10:43 ` [PATCH v2 1/4] clk: " Cristian Ciocaltea
2024-10-17 19:45   ` Stephen Boyd [this message]
2024-10-17 23:23     ` Cristian Ciocaltea
2024-09-26 10:43 ` [PATCH v2 2/4] soc: mediatek: pwrap: Switch to devm_clk_bulk_get_all_enabled() Cristian Ciocaltea
2024-09-26 10:43 ` [PATCH v2 3/4] PCI: exynos: " Cristian Ciocaltea
2024-09-26 10:43 ` [PATCH v2 4/4] clk: Drop obsolete devm_clk_bulk_get_all_enable() helper Cristian Ciocaltea
2024-10-16  9:28 ` [PATCH v2 0/4] Provide devm_clk_bulk_get_all_enabled() helper Cristian Ciocaltea
2024-10-16 16:07   ` Sebastian Reichel

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=347771679b3ac765de3f79c26f3d3595.sboyd@kernel.org \
    --to=sboyd@kernel.org \
    --cc=alim.akhtar@samsung.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=bhelgaas@google.com \
    --cc=cristian.ciocaltea@collabora.com \
    --cc=jingoohan1@gmail.com \
    --cc=kernel@collabora.com \
    --cc=krzk@kernel.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-mediatek@lists.infradead.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=lpieralisi@kernel.org \
    --cc=manivannan.sadhasivam@linaro.org \
    --cc=matthias.bgg@gmail.com \
    --cc=mturquette@baylibre.com \
    --cc=robh@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).