Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

Shawn Guo 842afc02 913413c3

+13 -9
+13 -9
drivers/mmc/host/sdhci-esdhc-imx.c
··· 45 45 struct pltfm_imx_data { 46 46 int flags; 47 47 u32 scratchpad; 48 + struct esdhc_platform_data boarddata; 48 49 }; 49 50 50 51 static inline void esdhc_clrset_le(struct sdhci_host *host, u32 mask, u32 val, int reg) ··· 58 57 59 58 static u32 esdhc_readl_le(struct sdhci_host *host, int reg) 60 59 { 61 - struct esdhc_platform_data *boarddata = 62 - host->mmc->parent->platform_data; 60 + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 61 + struct pltfm_imx_data *imx_data = pltfm_host->priv; 62 + struct esdhc_platform_data *boarddata = &imx_data->boarddata; 63 63 64 64 /* fake CARD_PRESENT flag */ 65 65 u32 val = readl(host->ioaddr + reg); ··· 82 80 { 83 81 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 84 82 struct pltfm_imx_data *imx_data = pltfm_host->priv; 85 - struct esdhc_platform_data *boarddata = 86 - host->mmc->parent->platform_data; 83 + struct esdhc_platform_data *boarddata = &imx_data->boarddata; 87 84 88 85 if (unlikely((reg == SDHCI_INT_ENABLE || reg == SDHCI_SIGNAL_ENABLE) 89 86 && (boarddata->cd_type == ESDHC_CD_GPIO))) ··· 199 198 200 199 static unsigned int esdhc_pltfm_get_ro(struct sdhci_host *host) 201 200 { 202 - struct esdhc_platform_data *boarddata = 203 - host->mmc->parent->platform_data; 201 + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 202 + struct pltfm_imx_data *imx_data = pltfm_host->priv; 203 + struct esdhc_platform_data *boarddata = &imx_data->boarddata; 204 204 205 205 switch (boarddata->wp_type) { 206 206 case ESDHC_WP_GPIO: ··· 283 281 if (!(cpu_is_mx25() || cpu_is_mx35() || cpu_is_mx51())) 284 282 imx_data->flags |= ESDHC_FLAG_MULTIBLK_NO_INT; 285 283 286 - boarddata = host->mmc->parent->platform_data; 287 - if (!boarddata) { 284 + if (!host->mmc->parent->platform_data) { 288 285 dev_err(mmc_dev(host->mmc), "no board data!\n"); 289 286 err = -EINVAL; 290 287 goto no_board_data; 291 288 } 289 + imx_data->boarddata = *((struct esdhc_platform_data *) 290 + host->mmc->parent->platform_data); 291 + boarddata = &imx_data->boarddata; 292 292 293 293 /* write_protect */ 294 294 if (boarddata->wp_type == ESDHC_WP_GPIO) { ··· 367 363 { 368 364 struct sdhci_host *host = platform_get_drvdata(pdev); 369 365 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 370 - struct esdhc_platform_data *boarddata = host->mmc->parent->platform_data; 371 366 struct pltfm_imx_data *imx_data = pltfm_host->priv; 367 + struct esdhc_platform_data *boarddata = &imx_data->boarddata; 372 368 int dead = (readl(host->ioaddr + SDHCI_INT_STATUS) == 0xffffffff); 373 369 374 370 sdhci_remove_host(host, dead);