From: Simon Horman <horms@verge.net.au>
To: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Cc: linux-mmc@vger.kernel.org, linux-sh@vger.kernel.org,
Magnus Damm <magnus.damm@gmail.com>, Chris Ball <cjb@laptop.org>,
Mark Brown <broonie@opensource.wolfsonmicro.com>
Subject: Re: [PATCH 1/5 v4] mmc: sh_mmcif: simplify and use meaningful label names in error-handling
Date: Wed, 20 Jun 2012 05:02:14 +0000 [thread overview]
Message-ID: <20120620050214.GD20030@verge.net.au> (raw)
In-Reply-To: <Pine.LNX.4.64.1206131532490.17854@axis700.grange>
On Wed, Jun 13, 2012 at 03:37:15PM +0200, Guennadi Liakhovetski wrote:
> A check for NULL platform data can be conveniently made in the very
> beginning of probing. Replace numbered error-handling labels in .probe()
> with meaningful names to make any future reorganisation simpler.
>
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Reviewed-by: Simon Horman <horms@verge.net.au>
> ---
> drivers/mmc/host/sh_mmcif.c | 41 ++++++++++++++++++++---------------------
> 1 files changed, 20 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c
> index e32da11..d6ffb05 100644
> --- a/drivers/mmc/host/sh_mmcif.c
> +++ b/drivers/mmc/host/sh_mmcif.c
> @@ -1241,11 +1241,16 @@ static int __devinit sh_mmcif_probe(struct platform_device *pdev)
> int ret = 0, irq[2];
> struct mmc_host *mmc;
> struct sh_mmcif_host *host;
> - struct sh_mmcif_plat_data *pd;
> + struct sh_mmcif_plat_data *pd = pdev->dev.platform_data;
> struct resource *res;
> void __iomem *reg;
> char clk_name[8];
>
> + if (!pd) {
> + dev_err(&pdev->dev, "sh_mmcif plat data error.\n");
> + return -ENXIO;
> + }
> +
> irq[0] = platform_get_irq(pdev, 0);
> irq[1] = platform_get_irq(pdev, 1);
> if (irq[0] < 0 || irq[1] < 0) {
> @@ -1262,16 +1267,11 @@ static int __devinit sh_mmcif_probe(struct platform_device *pdev)
> dev_err(&pdev->dev, "ioremap error.\n");
> return -ENOMEM;
> }
> - pd = pdev->dev.platform_data;
> - if (!pd) {
> - dev_err(&pdev->dev, "sh_mmcif plat data error.\n");
> - ret = -ENXIO;
> - goto clean_up;
> - }
> +
> mmc = mmc_alloc_host(sizeof(struct sh_mmcif_host), &pdev->dev);
> if (!mmc) {
> ret = -ENOMEM;
> - goto clean_up;
> + goto ealloch;
> }
> host = mmc_priv(mmc);
> host->mmc = mmc;
> @@ -1283,7 +1283,7 @@ static int __devinit sh_mmcif_probe(struct platform_device *pdev)
> if (IS_ERR(host->hclk)) {
> dev_err(&pdev->dev, "cannot get clock \"%s\"\n", clk_name);
> ret = PTR_ERR(host->hclk);
> - goto clean_up1;
> + goto eclkget;
> }
> clk_enable(host->hclk);
> host->clk = clk_get_rate(host->hclk);
> @@ -1313,7 +1313,7 @@ static int __devinit sh_mmcif_probe(struct platform_device *pdev)
>
> ret = pm_runtime_resume(&pdev->dev);
> if (ret < 0)
> - goto clean_up2;
> + goto eresume;
>
> INIT_DELAYED_WORK(&host->timeout_work, mmcif_timeout_work);
>
> @@ -1322,17 +1322,17 @@ static int __devinit sh_mmcif_probe(struct platform_device *pdev)
> ret = request_threaded_irq(irq[0], sh_mmcif_intr, sh_mmcif_irqt, 0, "sh_mmc:error", host);
> if (ret) {
> dev_err(&pdev->dev, "request_irq error (sh_mmc:error)\n");
> - goto clean_up3;
> + goto ereqirq0;
> }
> ret = request_threaded_irq(irq[1], sh_mmcif_intr, sh_mmcif_irqt, 0, "sh_mmc:int", host);
> if (ret) {
> dev_err(&pdev->dev, "request_irq error (sh_mmc:int)\n");
> - goto clean_up4;
> + goto ereqirq1;
> }
>
> ret = mmc_add_host(mmc);
> if (ret < 0)
> - goto clean_up5;
> + goto emmcaddh;
>
> dev_pm_qos_expose_latency_limit(&pdev->dev, 100);
>
> @@ -1341,20 +1341,19 @@ static int __devinit sh_mmcif_probe(struct platform_device *pdev)
> sh_mmcif_readl(host->addr, MMCIF_CE_VERSION) & 0x0000ffff);
> return ret;
>
> -clean_up5:
> +emmcaddh:
> free_irq(irq[1], host);
> -clean_up4:
> +ereqirq1:
> free_irq(irq[0], host);
> -clean_up3:
> +ereqirq0:
> pm_runtime_suspend(&pdev->dev);
> -clean_up2:
> +eresume:
> pm_runtime_disable(&pdev->dev);
> clk_disable(host->hclk);
> -clean_up1:
> +eclkget:
> mmc_free_host(mmc);
> -clean_up:
> - if (reg)
> - iounmap(reg);
It looks like this if (reg) was redundant: reg was always non-NULL if
this path is executed. Good riddance :)
> +ealloch:
> + iounmap(reg);
> return ret;
> }
next prev parent reply other threads:[~2012-06-20 5:02 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-13 13:37 [PATCH 0/5 v4] mmc: sh_mmcif: clock and power updates Guennadi Liakhovetski
2012-06-13 13:37 ` [PATCH 1/5 v4] mmc: sh_mmcif: simplify and use meaningful label names in error-handling Guennadi Liakhovetski
2012-06-20 5:02 ` Simon Horman [this message]
2012-06-13 13:37 ` [PATCH 2/5 v4] mmc: sh_mmcif: fix clock management Guennadi Liakhovetski
2012-06-20 5:18 ` Simon Horman
2012-06-20 6:41 ` Guennadi Liakhovetski
2012-06-20 6:58 ` Simon Horman
2012-06-13 13:37 ` [PATCH 3/5 v4] mmc: sh_mmcif: re-read the clock frequency every time the clock is turned on Guennadi Liakhovetski
2012-06-20 5:23 ` Simon Horman
2012-06-13 13:37 ` [PATCH 4/5 v4] mmc: sh_mmcif: remove redundant .down_pwr() callback Guennadi Liakhovetski
2012-06-20 4:58 ` Simon Horman
2012-06-20 6:19 ` Guennadi Liakhovetski
2012-06-20 6:57 ` Simon Horman
2012-06-13 13:37 ` [PATCH 5/5 v4] mmc: sh_mmcif: add regulator support Guennadi Liakhovetski
2012-06-17 17:23 ` Mark Brown
2012-06-20 5:12 ` Simon Horman
2012-06-20 6:38 ` Guennadi Liakhovetski
2012-06-20 6:58 ` Simon Horman
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=20120620050214.GD20030@verge.net.au \
--to=horms@verge.net.au \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=cjb@laptop.org \
--cc=g.liakhovetski@gmx.de \
--cc=linux-mmc@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=magnus.damm@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).