Re: [PATCH v2 2/7] pwm: Add Rust driver for T-HEAD TH1520 SoC
From: Michal Wilczynski
Date: Wed Jun 11 2025 - 17:16:14 EST
On 6/11/25 22:04, Michal Wilczynski wrote:
>
>
> On 6/11/25 08:58, Uwe Kleine-König wrote:
>> Hello,
>>
>>
>> What does .unwrap_or(0) do? You need to round up in this mul_div
>> operation.
Yeah and I'm thinking that the helper needs to be updated or new one
added like mul_div_round_up, to do the rounding
>
> The .unwrap_or(0) is to handle the case where the mul_div helper returns
> None, which can happen if the divisor (rate_hz) is zero. In that case,
> the period becomes 0. The mul_div helper is introduced in this commit
> [1].
>
> [1] - https://lore.kernel.org/all/20250609-math-rust-v1-v1-1-285fac00031f@xxxxxxxxxxx/
>
Best regards,
--
Michal Wilczynski <m.wilczynski@xxxxxxxxxxx>