Linux-PWM Archive mirror
 help / color / mirror / Atom feed
From: Sean Young <sean@mess.org>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: linux-media@vger.kernel.org, linux-pwm@vger.kernel.org,
	Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>,
	Thierry Reding <thierry.reding@gmail.com>,
	Florian Fainelli <florian.fainelli@broadcom.com>,
	Ray Jui <rjui@broadcom.com>,
	Scott Branden <sbranden@broadcom.com>,
	Broadcom internal kernel review list
	<bcm-kernel-feedback-list@broadcom.com>,
	linux-rpi-kernel@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v9 5/6] pwm: bcm2835: Allow PWM driver to be used in atomic context
Date: Tue, 19 Dec 2023 17:04:24 +0000	[thread overview]
Message-ID: <ZYHNGMabe8xBigyN@gofer.mess.org> (raw)
In-Reply-To: <eicw7ppqj5dubskhmeh7iwdaoixv27qw2zqaljkddt2rwosogt@6aftnwt6p5ek>

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

  reply	other threads:[~2023-12-19 17:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-18  9:06 [PATCH v9 0/6] Improve pwm-ir-tx precision Sean Young
2023-12-18  9:06 ` [PATCH v9 1/6] pwm: Rename pwm_apply_state() to pwm_apply_might_sleep() Sean Young
2023-12-18  9:06 ` [PATCH v9 2/6] pwm: Replace ENOTSUPP with EOPNOTSUPP Sean Young
2023-12-18  9:06 ` [PATCH v9 3/6] pwm: renesas: Remove unused include Sean Young
2023-12-18  9:06 ` [PATCH v9 4/6] pwm: Make it possible to apply PWM changes in atomic context Sean Young
2023-12-18  9:06 ` [PATCH v9 5/6] pwm: bcm2835: Allow PWM driver to be used " Sean Young
2023-12-18  9:31   ` Uwe Kleine-König
2023-12-19 17:04     ` Sean Young [this message]
2023-12-18  9:06 ` [PATCH v9 6/6] media: pwm-ir-tx: Trigger edges from hrtimer interrupt context Sean Young

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZYHNGMabe8xBigyN@gofer.mess.org \
    --to=sean@mess.org \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=florian.fainelli@broadcom.com \
    --cc=ivo.g.dimitrov.75@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=rjui@broadcom.com \
    --cc=sbranden@broadcom.com \
    --cc=thierry.reding@gmail.com \
    --cc=u.kleine-koenig@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).