linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: s.hauer@pengutronix.de (Sascha Hauer)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/2] pwm: add Mediatek display PWM driver support
Date: Tue, 12 May 2015 15:00:05 +0200	[thread overview]
Message-ID: <20150512130005.GS6325@pengutronix.de> (raw)
In-Reply-To: <1431336382-13167-3-git-send-email-yh.huang@mediatek.com>

On Mon, May 11, 2015 at 05:26:22PM +0800, YH Huang wrote:
> +
> +static int mtk_disp_pwm_probe(struct platform_device *pdev)
> +{
> +	struct mtk_disp_pwm_chip *pwm;

The struct mtk_disp_pwm_chip * is named 'mpc' in the other functions.
For consistency reasons you should do that here aswell.

> +	struct resource *r;
> +	int ret;
> +
> +	pwm = devm_kzalloc(&pdev->dev, sizeof(*pwm), GFP_KERNEL);
> +	if (!pwm)
> +		return -ENOMEM;
> +
> +	pwm->dev = &pdev->dev;
> +
> +	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	pwm->mmio_base = devm_ioremap_resource(&pdev->dev, r);
> +	if (IS_ERR(pwm->mmio_base))
> +		return PTR_ERR(pwm->mmio_base);
> +
> +	pwm->clk_main = devm_clk_get(&pdev->dev, "main");
> +	if (IS_ERR(pwm->clk_main))
> +		return PTR_ERR(pwm->clk_main);
> +	pwm->clk_mm = devm_clk_get(&pdev->dev, "mm");
> +	if (IS_ERR(pwm->clk_mm))
> +		return PTR_ERR(pwm->clk_mm);
> +
> +	ret = clk_prepare_enable(pwm->clk_main);
> +	if (ret < 0)
> +		return ret;
> +	ret = clk_prepare_enable(pwm->clk_mm);
> +	if (ret < 0) {
> +		clk_disable_unprepare(pwm->clk_main);
> +		return ret;
> +	}
> +
> +	platform_set_drvdata(pdev, pwm);
> +
> +	pwm->chip.dev = &pdev->dev;
> +	pwm->chip.ops = &mtk_disp_pwm_ops;
> +	pwm->chip.base = -1;
> +	pwm->chip.npwm = NUM_PWM;
> +
> +	ret = pwmchip_add(&pwm->chip);
> +	if (ret < 0) {
> +		dev_err(&pdev->dev, "pwmchip_add() failed: %d\n", ret);
> +		return ret;

This error path leaves the clocks enabled.

> +	}
> +
> +	return 0;
> +}
> +
> +static int mtk_disp_pwm_remove(struct platform_device *pdev)
> +{
> +	struct mtk_disp_pwm_chip *pc = platform_get_drvdata(pdev);
> +
> +	if (WARN_ON(!pc))
> +		return -ENODEV;
> +
> +	clk_disable_unprepare(pc->clk_main);
> +	clk_disable_unprepare(pc->clk_mm);
> +
> +	return pwmchip_remove(&pc->chip);

You should first remove the pwmchip and disable the clocks afterwards.
Also note that this function can fail.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

  parent reply	other threads:[~2015-05-12 13:00 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-11  9:26 [PATCH 0/2] Add Mediatek display PWM driver YH Huang
2015-05-11  9:26 ` [PATCH 1/2] dt-bindings: pwm: add Mediatek display PWM bindings YH Huang
2015-05-11  9:26 ` [PATCH 2/2] pwm: add Mediatek display PWM driver support YH Huang
2015-05-12 12:37   ` Matthias Brugger
2015-05-12 12:44     ` Matthias Brugger
2015-05-14 14:45       ` YH Huang
2015-05-14 14:39     ` YH Huang
2015-05-12 13:00   ` Sascha Hauer [this message]
2015-05-14 14:52     ` YH Huang
2015-05-12 13:32   ` Thierry Reding
2015-05-12 14:34     ` Matthias Brugger
2015-05-14 15:39       ` YH Huang
2015-05-14 15:35     ` YH Huang
2015-05-18  3:42   ` Daniel Kurtz
2015-05-21  8:22     ` YH Huang
2015-05-26  6:05       ` Sascha Hauer
2015-05-26  8:29         ` Yingjoe Chen

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=20150512130005.GS6325@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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).