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

Sean Anderson seanga2 at gmail.com
Wed Jan 4 18:23:23 CET 2023


On 11/28/22 00:53, Samuel Holland wrote:
> This allows devm_clock_get(dev, NULL) to work and get the first clock,

nit: devm_clk_get

> 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;

Reviewed-by: Sean Anderson <seanga2 at gmail.com>


More information about the U-Boot mailing list