Re: [PATCH v2] pwm: atmel-tcb: Cache clock rates and mark chip as atomic

Uwe Kleine-König
2026-04-24T10:46:02Z

[-- Attachment #1: Type: text/plain, Size: 1370 bytes --]

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.