Hello, your second reply is nearly identical to the first. It would be helpful to only write new stuff in new mail. I think there is only a single new paragraph that I will reply to here. On Mon, May 03, 2021 at 05:57:23AM +0000, Billy Tsai wrote: > On 2021/4/27, 4:44 AM,Uwe Kleine-Königwrote: > > Also please round down in the division to never provide a duty_cycle > > bigger than the requested vaule. Also you have to use the actually used > > period as divider, not state->period. > > I don’t think that I should use the actually used period as divider. > The state->duty_cycle is relative with state->period, not the actual period > if I use the actual period the precision of the duty cycle may lose. The strategy you should implement in .apply() is: Pick the biggest period that is not bigger than the requested period. With that period pick the biggest duty_cycle that is not bigger than the requested duty_cycle. As the actual period might be smaller than state->period, dividing by the latter yields a result that might be too small. See commit 8035e6c66a5e98f098edf7441667de74affb4e78 (currently in next) for a similar example. Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ |