[PATCH] clk: clk_set_parent: skip any operation if current and new parents are equal

Michael Grzeschik mgr at pengutronix.de
Mon Oct 6 13:53:02 PDT 2025


On Mon, Oct 06, 2025 at 01:43:47PM +0200, Ahmad Fatoum wrote:
>On 10/3/25 12:37 PM, Michael Grzeschik wrote:
>> Signed-off-by: Michael Grzeschik <m.grzeschik at pengutronix.de>
>
>While I agree this makes sense, I appreciate some background. Did you
>run into problems? Or is it just something you noticed while reading the
>code? A prime location for that background would be the empty commit
>message ;)

Yes this happend when using the video drivers. Somehow some drivers
tried to reparent the video_pll to the same parent that it already had.

clk: failed to reparent video_pll to osc_24m: -22
clk: failed to reparent video_pll to osc_24m: -22

I did not check which one it was. Since this call came twice, it looked
right to me to fix this on this obvious location.

Michael

>> ---
>>  drivers/clk/clk.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
>> index 89a007a12c5..ac5b83cf8b4 100644
>> --- a/drivers/clk/clk.c
>> +++ b/drivers/clk/clk.c
>> @@ -302,6 +302,9 @@ int clk_set_parent(struct clk *clk, struct clk *newparent)
>>  	if (IS_ERR(newparent))
>>  		return PTR_ERR(newparent);
>>
>> +	if (newparent == curparent)
>> +		return 0;
>> +
>>  	if (!clk->num_parents)
>>  		return -EINVAL;
>>  	if (!clk->ops->set_parent)
>
>-- 
>Pengutronix e.K.                  |                             |
>Steuerwalder Str. 21              | http://www.pengutronix.de/  |
>31137 Hildesheim, Germany         | Phone: +49-5121-206917-0    |
>Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |
>
>

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/barebox/attachments/20251006/a68ff16f/attachment.sig>


More information about the barebox mailing list