From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Bart Tanghe <bart.tanghe@thomasmore.be>, thierry.reding@gmail.com
Cc: matt.porter@linaro.org, linux-rpi-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org
Subject: Re: [resend rfc v4]pwm: add BCM2835 PWM driver
Date: Mon, 29 Sep 2014 17:21:27 +0200 [thread overview]
Message-ID: <542978F7.5030405@pengutronix.de> (raw)
In-Reply-To: <1412001619-30001-1-git-send-email-bart.tanghe@thomasmore.be>
[-- Attachment #1: Type: text/plain, Size: 2500 bytes --]
On 09/29/2014 04:40 PM, Bart Tanghe wrote:
> +static int bcm2835_pwm_probe(struct platform_device *pdev)
> +{
> + struct bcm2835_pwm *pwm;
> + int ret;
> + struct resource *r;
> + struct clk *clk;
> +
> + pwm = devm_kzalloc(&pdev->dev, sizeof(*pwm), GFP_KERNEL);
> + if (!pwm)
> + return -ENOMEM;
> +
> + pwm->dev = &pdev->dev;
> +
> + clk = clk_get(&pdev->dev, NULL);
Better use devm_, as you don't free the clock in case of an error and
during remove()
> + if (IS_ERR(clk)) {
> + dev_err(&pdev->dev, "no clock found: %ld\n", PTR_ERR(clk));
> + return PTR_ERR(clk);
> + }
> +
> + pwm->clk = clk;
> + clk_prepare_enable(pwm->clk);
Please check the return value of clk_prepare_enable()
> + pwm->scaler = NSEC_PER_SEC / clk_get_rate(clk);
> +
> + r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + pwm->base = devm_ioremap_resource(&pdev->dev, r);
> + if (IS_ERR(pwm->base))
> + return PTR_ERR(pwm->base);
> +
> + pwm->chip.dev = &pdev->dev;
> + pwm->chip.ops = &bcm2835_pwm_ops;
> + pwm->chip.npwm = 2;
> +
> + ret = pwmchip_add(&pwm->chip);
> + if (ret < 0) {
> + dev_err(&pdev->dev, "pwmchip_add() failed: %d\n", ret);
> + return -1;
Please propagate the error vlaue:
return ret;
> + }
> + platform_set_drvdata(pdev, pwm);
Better do this before pwmchip_add()
> + return 0;
> +}
> +
> +static int bcm2835_pwm_remove(struct platform_device *pdev)
> +{
> + struct bcm2835_pwm *pc = platform_get_drvdata(pdev);
> + clk_disable_unprepare(pc->clk);
> + return pwmchip_remove(&pc->chip);
> +}
> +
> +static const struct of_device_id bcm2835_pwm_of_match[] = {
> + { .compatible = "brcm,bcm2835-pwm", },
> + { /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, bcm2835_pwm_of_match);
> +
> +static struct platform_driver bcm2835_pwm_driver = {
> + .driver = {
> + .name = "bcm2835-pwm",
> + .of_match_table = bcm2835_pwm_of_match,
> + },
> + .probe = bcm2835_pwm_probe,
> + .remove = bcm2835_pwm_remove,
> +};
> +module_platform_driver(bcm2835_pwm_driver);
> +
> +MODULE_AUTHOR("Bart Tanghe <bart.tanghe@thomasmore.be");
> +MODULE_DESCRIPTION("Broadcom BCM2835 PWM driver");
> +MODULE_LICENSE("GPL v2");
regards,
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
next prev parent reply other threads:[~2014-09-29 15:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-29 14:40 [resend rfc v4]pwm: add BCM2835 PWM driver Bart Tanghe
2014-09-29 15:21 ` Marc Kleine-Budde [this message]
2014-09-30 4:34 ` Stephen Warren
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=542978F7.5030405@pengutronix.de \
--to=mkl@pengutronix.de \
--cc=bart.tanghe@thomasmore.be \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=matt.porter@linaro.org \
--cc=thierry.reding@gmail.com \
/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 NNTP newsgroup(s).