devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: YH Huang <yh.huang@mediatek.com>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Matthias Brugger <matthias.bgg@gmail.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Thierry Reding <thierry.reding@gmail.com>,
	Rob Herring <robh+dt@kernel.org>, Pawel Moll <pawel.moll@arm.com>,
	linux-pwm@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	srv_heupstream@mediatek.com, linux-mediatek@lists.infradead.org,
	Sascha Hauer <kernel@pengutronix.de>,
	yh.huang@mediatek.com
Subject: Re: [PATCH 2/2] pwm: add Mediatek display PWM driver support
Date: Thu, 14 May 2015 22:52:03 +0800	[thread overview]
Message-ID: <1431615123.15140.36.camel@mtksdaap41> (raw)
In-Reply-To: <20150512130005.GS6325@pengutronix.de>

On Tue, 2015-05-12 at 15:00 +0200, Sascha Hauer wrote:
> 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.
> 

I miss it! Maybe 'mdpc' is a better name for mtk_disp_pwm_chip.

> > +	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.
> 

I forgot this one. I will fix it.

> > +	}
> > +
> > +	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.
> 

OK.

> Sascha
> 

Thank for your suggestion.

Regards,
YH Huang

  reply	other threads:[~2015-05-14 14:52 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
     [not found] ` <1431336382-13167-1-git-send-email-yh.huang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
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
     [not found]     ` <1431336382-13167-3-git-send-email-yh.huang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
2015-05-12 12:37       ` Matthias Brugger
2015-05-12 12:44         ` Matthias Brugger
     [not found]           ` <CABuKBeJc3Kvdoejyi0XFbQMU2saztzV5S7jiXCg-09juYeh4pg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-05-14 14:45             ` YH Huang
2015-05-14 14:39         ` YH Huang
2015-05-12 13:00       ` Sascha Hauer
2015-05-14 14:52         ` YH Huang [this message]
2015-05-12 13:32     ` Thierry Reding
     [not found]       ` <20150512133202.GA24684-AwZRO8vwLAwmlAP/+Wk3EA@public.gmane.org>
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
     [not found]           ` <20150526060533.GW6325-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
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=1431615123.15140.36.camel@mtksdaap41 \
    --to=yh.huang@mediatek.com \
    --cc=devicetree@vger.kernel.org \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=matthias.bgg@gmail.com \
    --cc=pawel.moll@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=srv_heupstream@mediatek.com \
    --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).