Re: [PATCH] clk: qcom: rcg2: compute 2d using duty fraction directly

From: Taniya Das
Date: Fri Dec 26 2025 - 13:00:43 EST




On 12/25/2025 3:25 AM, Stephen Boyd wrote:
> Quoting Bjorn Andersson (2025-12-22 09:09:54)
>> On Mon, Dec 22, 2025 at 10:38:14PM +0530, Taniya Das wrote:
>>> @@ -774,10 +774,8 @@ static int clk_rcg2_set_duty_cycle(struct clk_hw *hw, struct clk_duty *duty)
>>>
>>> n = (~(notn_m) + m) & mask;
>>>
>>> - duty_per = (duty->num * 100) / duty->den;
>>> -
>>> /* Calculate 2d value */
>>> - d = DIV_ROUND_CLOSEST(n * duty_per * 2, 100);
>>> + d = DIV_ROUND_CLOSEST(n * duty->num * 2, duty->den);
>>
>> This looks better/cleaner. But for my understanding, can you share some
>> example numbers that shows the problem?
>>
>
> Even better would be to add some KUnit tests for the qcom clk driver
> functions like this so we know they're still working.


Sure Stephen, let me take a look.

--
Thanks,
Taniya Das