Re: [PATCH 2/2] pwm: Add support for Xilinx AXI Timer

From: Sean Anderson
Date: Tue May 04 2021 - 11:03:45 EST


On 5/4/21 10:46 AM, Sean Anderson wrote:
> On 5/4/21 4:51 AM, Uwe Kleine-König wrote:
> >> +static int xilinx_pwm_remove(struct platform_device *pdev)
> >> +{
> >> + struct xilinx_pwm_device *pwm = platform_get_drvdata(pdev);
> >> + bool enabled = xilinx_pwm_is_enabled(readl(pwm->regs + TCSR0),
> >> + readl(pwm->regs + TCSR1));
> >> +
> >> + if (enabled)
> >> + clk_rate_exclusive_put(pwm->clk);
> >
> > This looks wrong. You should rely on the consumer that they disable the
> > PWM.
>
> What about a PWM regulator with always-on?
>
> This is mostly to match the exclusive_get in probe, in case there are
> misbehaving consumers.

Since we always get the rate exclusively, we must always put the rate
exclusively here. So if the PWM is probed, but no one ever does anything
with it (and therefore no one turns it off), we must release the
exclusive rate in remove.

--Sean