Re: [PATCH v9 5/6] pwm: bcm2835: Allow PWM driver to be used in atomic context

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Uwe,

On Mon, Dec 18, 2023 at 10:31:36AM +0100, Uwe Kleine-König wrote:
> On Mon, Dec 18, 2023 at 09:06:46AM +0000, Sean Young wrote:
> > +	pc->rate = clk_get_rate(pc->clk);
> > +	if (!pc->rate) {
> > +		clk_rate_exclusive_put(pc->clk);
> > +		return dev_err_probe(&pdev->dev, -EINVAL,
> > +				     "failed to get clock rate\n");
> > +	}
> > +
> >  	pc->chip.dev = &pdev->dev;
> >  	pc->chip.ops = &bcm2835_pwm_ops;
> > +	pc->chip.atomic = true;
> >  	pc->chip.npwm = 2;
> >  
> >  	platform_set_drvdata(pdev, pc);
> >  
> >  	ret = devm_pwmchip_add(&pdev->dev, &pc->chip);
> > -	if (ret < 0)
> > +	if (ret < 0) {
> > +		clk_rate_exclusive_put(pc->clk);
> >  		return dev_err_probe(&pdev->dev, ret,
> >  				     "failed to add pwmchip\n");
> > +	}
> > +
> > +	return 0;
> > +}
> > +
> > +static int bcm2835_pwm_remove(struct platform_device *pdev)
> > +{
> > +	struct bcm2835_pwm *pc = platform_get_drvdata(pdev);
> > +
> > +	clk_rate_exclusive_put(pc->clk);
> 
> The ugly thing here is that now clk_rate_exclusive_put() happens before
> pwmchip_remove().

Mixing devm with non-devm does lead to problems like this.

> Maybe register a devm cleanup which also gets rid of
> the two clk_rate_exclusive_put() in probe's error path?

That's good idea, I've done that in v10.

> 
> >  	return 0;
> >  }
> > @@ -197,6 +216,7 @@ static struct platform_driver bcm2835_pwm_driver = {
> >  		.pm = pm_ptr(&bcm2835_pwm_pm_ops),
> >  	},
> >  	.probe = bcm2835_pwm_probe,
> > +	.remove = bcm2835_pwm_remove,
> 
> Please use .remove_new

No longer needed in v10.


Sean




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux