Re: [PATCH v6 2/3] pwm: sophgo: add driver for Sophgo SG2042 PWM
From: Uwe Kleine-König
Date: Wed Jan 22 2025 - 05:03:35 EST
Hello,
On Wed, Jan 22, 2025 at 04:58:26PM +0800, Chen Wang wrote:
> On 2025/1/21 19:14, Uwe Kleine-König wrote:
> > On Wed, Dec 04, 2024 at 11:17:18AM +0800, Chen Wang wrote:
> > > + ret = devm_clk_rate_exclusive_get(dev, clk);
> > > + if (ret)
> > > + return dev_err_probe(dev, ret, "failed to get exclusive rate\n");
> > > +
> > > + ddata->clk_rate_hz = clk_get_rate(clk);
> > > + if (!ddata->clk_rate_hz || ddata->clk_rate_hz > NSEC_PER_SEC)
> >
> > Please add a comment about why you check for > NSEC_PER_SEC.
>
> Seems no need to check this (> NSEC_PER_SEC ), I will remove it in next
> version.
The rational is usually that
mul_u64_u64_div_u64(ddata->clk_rate_hz, state->period, NSEC_PER_SEC)
cannot overflow. Your driver relies on that, too. (Which somewhat
proves that a comment is indeed necessary :-)
Best regards
Uwe
Attachment:
signature.asc
Description: PGP signature