aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Guo <shawn.guo@linaro.org>2011-07-06 10:57:48 -0400
committerShawn Guo <shawn.guo@linaro.org>2011-07-26 21:31:21 -0400
commit842afc02cf04f0474392b4c5efd808996a804fa6 (patch)
treefb144a2ee86fca78029c171b3f30753785aeb61e
parent913413c307c919f8b21edccea23a9fd9d9d49a64 (diff)
mmc: sdhci-esdhc-imx: do not reference platform data after probe
The patch copies platform data into pltfm_imx_data and reference the data there than platform data after probe. This work is inspired by Grant Likely and Troy Kisky. Signed-off-by: Shawn Guo <shawn.guo@linaro.org> Cc: Troy Kisky <troy.kisky@boundarydevices.com> Cc: Grant Likely <grant.likely@secretlab.ca> Cc: Wolfram Sang <w.sang@pengutronix.de> Cc: Chris Ball <cjb@laptop.org> Acked-by: Grant Likely <grant.likely@secretlab.ca> Acked-by: Chris Ball <cjb@laptop.org>
-rw-r--r--drivers/mmc/host/sdhci-esdhc-imx.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index 4269bb498ff0..58fc6533d250 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -45,6 +45,7 @@
45struct pltfm_imx_data { 45struct pltfm_imx_data {
46 int flags; 46 int flags;
47 u32 scratchpad; 47 u32 scratchpad;
48 struct esdhc_platform_data boarddata;
48}; 49};
49 50
50static inline void esdhc_clrset_le(struct sdhci_host *host, u32 mask, u32 val, int reg) 51static inline void esdhc_clrset_le(struct sdhci_host *host, u32 mask, u32 val, int reg)
@@ -57,8 +58,9 @@ static inline void esdhc_clrset_le(struct sdhci_host *host, u32 mask, u32 val, i
57 58
58static u32 esdhc_readl_le(struct sdhci_host *host, int reg) 59static u32 esdhc_readl_le(struct sdhci_host *host, int reg)
59{ 60{
60 struct esdhc_platform_data *boarddata = 61 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
61 host->mmc->parent->platform_data; 62 struct pltfm_imx_data *imx_data = pltfm_host->priv;
63 struct esdhc_platform_data *boarddata = &imx_data->boarddata;
62 64
63 /* fake CARD_PRESENT flag */ 65 /* fake CARD_PRESENT flag */
64 u32 val = readl(host->ioaddr + reg); 66 u32 val = readl(host->ioaddr + reg);
@@ -80,8 +82,7 @@ static void esdhc_writel_le(struct sdhci_host *host, u32 val, int reg)
80{ 82{
81 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 83 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
82 struct pltfm_imx_data *imx_data = pltfm_host->priv; 84 struct pltfm_imx_data *imx_data = pltfm_host->priv;
83 struct esdhc_platform_data *boarddata = 85 struct esdhc_platform_data *boarddata = &imx_data->boarddata;
84 host->mmc->parent->platform_data;
85 86
86 if (unlikely((reg == SDHCI_INT_ENABLE || reg == SDHCI_SIGNAL_ENABLE) 87 if (unlikely((reg == SDHCI_INT_ENABLE || reg == SDHCI_SIGNAL_ENABLE)
87 && (boarddata->cd_type == ESDHC_CD_GPIO))) 88 && (boarddata->cd_type == ESDHC_CD_GPIO)))
@@ -198,8 +199,9 @@ static unsigned int esdhc_pltfm_get_min_clock(struct sdhci_host *host)
198 199
199static unsigned int esdhc_pltfm_get_ro(struct sdhci_host *host) 200static unsigned int esdhc_pltfm_get_ro(struct sdhci_host *host)
200{ 201{
201 struct esdhc_platform_data *boarddata = 202 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
202 host->mmc->parent->platform_data; 203 struct pltfm_imx_data *imx_data = pltfm_host->priv;
204 struct esdhc_platform_data *boarddata = &imx_data->boarddata;
203 205
204 switch (boarddata->wp_type) { 206 switch (boarddata->wp_type) {
205 case ESDHC_WP_GPIO: 207 case ESDHC_WP_GPIO:
@@ -281,12 +283,14 @@ static int __devinit sdhci_esdhc_imx_probe(struct platform_device *pdev)
281 if (!(cpu_is_mx25() || cpu_is_mx35() || cpu_is_mx51())) 283 if (!(cpu_is_mx25() || cpu_is_mx35() || cpu_is_mx51()))
282 imx_data->flags |= ESDHC_FLAG_MULTIBLK_NO_INT; 284 imx_data->flags |= ESDHC_FLAG_MULTIBLK_NO_INT;
283 285
284 boarddata = host->mmc->parent->platform_data; 286 if (!host->mmc->parent->platform_data) {
285 if (!boarddata) {
286 dev_err(mmc_dev(host->mmc), "no board data!\n"); 287 dev_err(mmc_dev(host->mmc), "no board data!\n");
287 err = -EINVAL; 288 err = -EINVAL;
288 goto no_board_data; 289 goto no_board_data;
289 } 290 }
291 imx_data->boarddata = *((struct esdhc_platform_data *)
292 host->mmc->parent->platform_data);
293 boarddata = &imx_data->boarddata;
290 294
291 /* write_protect */ 295 /* write_protect */
292 if (boarddata->wp_type == ESDHC_WP_GPIO) { 296 if (boarddata->wp_type == ESDHC_WP_GPIO) {
@@ -363,8 +367,8 @@ static int __devexit sdhci_esdhc_imx_remove(struct platform_device *pdev)
363{ 367{
364 struct sdhci_host *host = platform_get_drvdata(pdev); 368 struct sdhci_host *host = platform_get_drvdata(pdev);
365 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 369 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
366 struct esdhc_platform_data *boarddata = host->mmc->parent->platform_data;
367 struct pltfm_imx_data *imx_data = pltfm_host->priv; 370 struct pltfm_imx_data *imx_data = pltfm_host->priv;
371 struct esdhc_platform_data *boarddata = &imx_data->boarddata;
368 int dead = (readl(host->ioaddr + SDHCI_INT_STATUS) == 0xffffffff); 372 int dead = (readl(host->ioaddr + SDHCI_INT_STATUS) == 0xffffffff);
369 373
370 sdhci_remove_host(host, dead); 374 sdhci_remove_host(host, dead);