[PATCH v2] pwm: atmel-tcb: Cache clock rates and mark chip as atomic
Uwe Kleine-König
ukleinek at kernel.org
Fri Apr 24 03:46:00 PDT 2026
Hello Sangyun,
On Wed, Apr 22, 2026 at 01:49:40PM +0900, Sangyun Kim wrote:
> > On Sun, Apr 19, 2026 at 05:08:38PM +0900, Sangyun Kim wrote:
> > > @@ -438,16 +441,33 @@ static int atmel_tcb_pwm_probe(struct platform_device *pdev)
> > > if (err)
> > > goto err_gclk;
> > >
> > > + err = clk_rate_exclusive_get(tcbpwmc->clk);
> > > + if (err)
> > > + goto err_disable_clk;
> > > +
> > > + err = clk_rate_exclusive_get(tcbpwmc->slow_clk);
> > > + if (err)
> > > + goto err_clk_unlock;
> > > +
> > > + tcbpwmc->rate = clk_get_rate(tcbpwmc->clk);
> > > + tcbpwmc->slow_rate = clk_get_rate(tcbpwmc->slow_clk);
> > > +
> >
> > Only one concern left: clk_get_rate() should only be called on enabled
> > clocks. I don't know the architecture details and how expensive it is to
> > have .clk enabled (or if it's enabled anyhow).
> >
> > If you're ok, I'd squash the following diff into your patch:
>
> That makes sense. clk_get_rate() should indeed only be used on enabled
> clocks, and your change is the simplest way to ensure correctness while
> respecting the clk API constraints. I’m happy with squashing your diff
> into my patch.
Just for the record: I did that, the result is already in Linus' tree
at https://git.kernel.org/linus/68637b68afcc3cb4d56aca14a3a1d1b47b879369
and will be part of v7.1-rc1.
Best regards
Uwe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20260424/5d4c59d3/attachment.sig>
More information about the linux-arm-kernel
mailing list