[PATCH 04/22] clk: bind clk to new parent device

Claudiu.Beznea at microchip.com Claudiu.Beznea at microchip.com
Tue Aug 4 09:24:59 CEST 2020



On 04.08.2020 05:00, Simon Glass wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> On Wed, 29 Jul 2020 at 08:51, Claudiu Beznea
> <claudiu.beznea at microchip.com> wrote:
>>
>> Clock re-parenting is not binding the clock's device to its new
>> parent device, it only calls the clock's ops->set_parent() API. The
>> changes in this commit re-parent the clock device to its new parent
>> so that subsequent operations like clk_get_parent() to point to the
>> proper parent.
>>
>> Signed-off-by: Claudiu Beznea <claudiu.beznea at microchip.com>
>> ---
>>  drivers/clk/clk-uclass.c | 11 ++++++++++-
>>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> Reviewed-by: Simon Glass <sjg at chromium.org>
> 
> But please add a sandbox test.

Sure!

> 
> 
>>
>> diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
>> index aa1f11a27c41..b390a6b01c06 100644
>> --- a/drivers/clk/clk-uclass.c
>> +++ b/drivers/clk/clk-uclass.c
>> @@ -14,6 +14,7 @@
>>  #include <errno.h>
>>  #include <log.h>
>>  #include <malloc.h>
>> +#include <dm/device-internal.h>
>>  #include <dm/devres.h>
>>  #include <dm/read.h>
>>  #include <linux/bug.h>
>> @@ -511,6 +512,7 @@ ulong clk_set_rate(struct clk *clk, ulong rate)
>>  int clk_set_parent(struct clk *clk, struct clk *parent)
>>  {
>>         const struct clk_ops *ops;
>> +       int ret;
>>
>>         debug("%s(clk=%p, parent=%p)\n", __func__, clk, parent);
>>         if (!clk_valid(clk))
>> @@ -520,7 +522,14 @@ int clk_set_parent(struct clk *clk, struct clk *parent)
>>         if (!ops->set_parent)
>>                 return -ENOSYS;
>>
>> -       return ops->set_parent(clk, parent);
>> +       ret = ops->set_parent(clk, parent);
>> +       if (ret)
>> +               return ret;
>> +
>> +       if (CONFIG_IS_ENABLED(CLK_CCF))
>> +               ret = device_reparent(clk->dev, parent->dev);
>> +
>> +       return ret;
>>  }
>>
>>  int clk_enable(struct clk *clk)
>> --
>> 2.7.4
>>


More information about the U-Boot mailing list