Skip to content

Commit

Permalink
mmc: sdhci-of-at91: use sdhci_pltfm_init for private allocation
Browse files Browse the repository at this point in the history
Commit 0e74823 ("mmc: sdhci: Add size for caller in init+register")
allows users of sdhci_pltfm to allocate private space in calls to
sdhci_pltfm_init+sdhci_pltfm_register. This patch migrates the
sdhci-of-at91 driver to this allocation.

Signed-off-by: Jisheng Zhang <[email protected]>
Acked-by: Arnd Bergmann <[email protected]>
Acked-by: Ludovic Desroches <[email protected]>
Acked-by: Adrian Hunter <[email protected]>
Signed-off-by: Ulf Hansson <[email protected]>
  • Loading branch information
Jisheng Zhang authored and storulf committed Feb 29, 2016
1 parent 8921141 commit 10f1c13
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions drivers/mmc/host/sdhci-of-at91.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ static int sdhci_at91_runtime_suspend(struct device *dev)
{
struct sdhci_host *host = dev_get_drvdata(dev);
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
struct sdhci_at91_priv *priv = pltfm_host->priv;
struct sdhci_at91_priv *priv = sdhci_pltfm_priv(pltfm_host);
int ret;

ret = sdhci_runtime_suspend_host(host);
Expand All @@ -74,7 +74,7 @@ static int sdhci_at91_runtime_resume(struct device *dev)
{
struct sdhci_host *host = dev_get_drvdata(dev);
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
struct sdhci_at91_priv *priv = pltfm_host->priv;
struct sdhci_at91_priv *priv = sdhci_pltfm_priv(pltfm_host);
int ret;

ret = clk_prepare_enable(priv->mainck);
Expand Down Expand Up @@ -124,11 +124,12 @@ static int sdhci_at91_probe(struct platform_device *pdev)
return -EINVAL;
soc_data = match->data;

priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
if (!priv) {
dev_err(&pdev->dev, "unable to allocate private data\n");
return -ENOMEM;
}
host = sdhci_pltfm_init(pdev, soc_data, sizeof(*priv));
if (IS_ERR(host))
return PTR_ERR(host);

pltfm_host = sdhci_priv(host);
priv = sdhci_pltfm_priv(pltfm_host);

priv->mainck = devm_clk_get(&pdev->dev, "baseclk");
if (IS_ERR(priv->mainck)) {
Expand All @@ -148,10 +149,6 @@ static int sdhci_at91_probe(struct platform_device *pdev)
return PTR_ERR(priv->gck);
}

host = sdhci_pltfm_init(pdev, soc_data, 0);
if (IS_ERR(host))
return PTR_ERR(host);

/*
* The mult clock is provided by as a generated clock by the PMC
* controller. In order to set the rate of gck, we have to get the
Expand Down Expand Up @@ -191,9 +188,6 @@ static int sdhci_at91_probe(struct platform_device *pdev)
clk_prepare_enable(priv->mainck);
clk_prepare_enable(priv->gck);

pltfm_host = sdhci_priv(host);
pltfm_host->priv = priv;

ret = mmc_of_parse(host->mmc);
if (ret)
goto clocks_disable_unprepare;
Expand Down Expand Up @@ -231,17 +225,20 @@ static int sdhci_at91_remove(struct platform_device *pdev)
{
struct sdhci_host *host = platform_get_drvdata(pdev);
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
struct sdhci_at91_priv *priv = pltfm_host->priv;
struct sdhci_at91_priv *priv = sdhci_pltfm_priv(pltfm_host);
struct clk *gck = priv->gck;
struct clk *hclock = priv->hclock;
struct clk *mainck = priv->mainck;

pm_runtime_get_sync(&pdev->dev);
pm_runtime_disable(&pdev->dev);
pm_runtime_put_noidle(&pdev->dev);

sdhci_pltfm_unregister(pdev);

clk_disable_unprepare(priv->gck);
clk_disable_unprepare(priv->hclock);
clk_disable_unprepare(priv->mainck);
clk_disable_unprepare(gck);
clk_disable_unprepare(hclock);
clk_disable_unprepare(mainck);

return 0;
}
Expand Down

0 comments on commit 10f1c13

Please sign in to comment.