[U-Boot] [PATCH v1 1/7] clk: clk-uclass: Assign clk->dev before call .of_xlate

Stephen Warren swarren at wwwdotorg.org
Tue Sep 13 20:56:54 CEST 2016


On 09/12/2016 07:54 PM, Wenyou Yang wrote:
> In order to make clk->dev available in ops->of_xlate() to get the
> clock ID from the 'reg' property of the clock node, assign the
> clk->dev before calling ops->of_xlate().

It does seem reasonable to me to allow using the same of_xlate 
implementation across multiple similar-but-different clock providers, 
and this change is required to allow that. I note that the reset and 
power domain uclasses already work this way. So, from that perspective, 
you get an ack.

> diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c

> @@ -80,6 +80,9 @@ int clk_get_by_index(struct udevice *dev, int index, struct clk *clk)
>  		      __func__, ret);
>  		return ret;
>  	}
> +
> +	clk->dev = dev_clk;

That assignment also happens in clk_request() itself. I'm tempted to say 
that we should modify clk_request() to remove the dev parameter, and 
remove the assignment of clk->dev. clk_request()'s documentation says:

>  * @clock:      A pointer to a clock struct to initialize. The caller must
>  *              have already initialized any field in this struct which the
>  *              clock provider uses to identify the clock.

... and since clk->dev is a field that is used to identify the clock, it 
really should be set already, thus removing the need for this function 
to set clk->dev.

However, I suppose we can clean that up later, so,
Acked-by: Stephen Warren <swarren at nvidia.com>


More information about the U-Boot mailing list