[PATCH 1/2] clk: Allow clk_get_by_name() with NULL name

Simon Glass sjg at chromium.org
Wed Jan 4 21:01:50 CET 2023


Hi Samuel,

On Sun, 27 Nov 2022 at 22:54, Samuel Holland <samuel at sholland.org> wrote:
>
> This allows devm_clock_get(dev, NULL) to work and get the first clock,
> which is common in code ported from Linux.
>
> Signed-off-by: Samuel Holland <samuel at sholland.org>
> ---
>
>  drivers/clk/clk-uclass.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
> index 2f9635524cf..bfacafb2eef 100644
> --- a/drivers/clk/clk-uclass.c
> +++ b/drivers/clk/clk-uclass.c
> @@ -399,13 +399,14 @@ int clk_get_by_name(struct udevice *dev, const char *name, struct clk *clk)
>
>  int clk_get_by_name_nodev(ofnode node, const char *name, struct clk *clk)
>  {
> -       int index;
> +       int index = 0;
>
>         debug("%s(node=%p, name=%s, clk=%p)\n", __func__,
>                 ofnode_get_name(node), name, clk);
>         clk->dev = NULL;
>
> -       index = ofnode_stringlist_search(node, "clock-names", name);
> +       if (name)
> +               index = ofnode_stringlist_search(node, "clock-names", name);
>         if (index < 0) {
>                 debug("fdt_stringlist_search() failed: %d\n", index);
>                 return index;
> --
> 2.37.4
>

Same comments as for the reset patch.

Regards,
Simon


More information about the U-Boot mailing list