Commit 5c59065b authored by Masahiro Yamada's avatar Masahiro Yamada Committed by Ulf Hansson

mmc: sdhci-pltfm: call platform_get_irq() before sdhci_alloc_host()

Swap the call order of sdhci_alloc_host() and platform_get_irq().
It makes sdhci_alloc_host() the last function that can fail in the
sdhci_pltfm_init().  So, we can drop the sdhci_free_host() call from
the failure path.
Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent 378382b8
...@@ -120,7 +120,7 @@ struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev, ...@@ -120,7 +120,7 @@ struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev,
struct sdhci_host *host; struct sdhci_host *host;
struct resource *iomem; struct resource *iomem;
void __iomem *ioaddr; void __iomem *ioaddr;
int ret; int irq, ret;
iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0); iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
ioaddr = devm_ioremap_resource(&pdev->dev, iomem); ioaddr = devm_ioremap_resource(&pdev->dev, iomem);
...@@ -129,6 +129,13 @@ struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev, ...@@ -129,6 +129,13 @@ struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev,
goto err; goto err;
} }
irq = platform_get_irq(pdev, 0);
if (irq < 0) {
dev_err(&pdev->dev, "failed to get IRQ number\n");
ret = irq;
goto err;
}
host = sdhci_alloc_host(&pdev->dev, host = sdhci_alloc_host(&pdev->dev,
sizeof(struct sdhci_pltfm_host) + priv_size); sizeof(struct sdhci_pltfm_host) + priv_size);
...@@ -138,6 +145,7 @@ struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev, ...@@ -138,6 +145,7 @@ struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev,
} }
host->ioaddr = ioaddr; host->ioaddr = ioaddr;
host->irq = irq;
host->hw_name = dev_name(&pdev->dev); host->hw_name = dev_name(&pdev->dev);
if (pdata && pdata->ops) if (pdata && pdata->ops)
host->ops = pdata->ops; host->ops = pdata->ops;
...@@ -148,13 +156,6 @@ struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev, ...@@ -148,13 +156,6 @@ struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev,
host->quirks2 = pdata->quirks2; host->quirks2 = pdata->quirks2;
} }
host->irq = platform_get_irq(pdev, 0);
if (host->irq < 0) {
dev_err(&pdev->dev, "failed to get IRQ number\n");
ret = host->irq;
goto err_request;
}
/* /*
* Some platforms need to probe the controller to be able to * Some platforms need to probe the controller to be able to
* determine which caps should be used. * determine which caps should be used.
...@@ -165,9 +166,6 @@ struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev, ...@@ -165,9 +166,6 @@ struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev,
platform_set_drvdata(pdev, host); platform_set_drvdata(pdev, host);
return host; return host;
err_request:
sdhci_free_host(host);
err: err:
dev_err(&pdev->dev, "%s failed %d\n", __func__, ret); dev_err(&pdev->dev, "%s failed %d\n", __func__, ret);
return ERR_PTR(ret); return ERR_PTR(ret);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment