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

mmc: sdhci: Add size for caller in init+register

Add a param to allow users of sdhci_pltfm to allocate private space
in calls to sdhci_pltfm_init+sdhci_pltfm_register. This is implemented
in the same way as sdhci does for its users.
None of the users have been migrated yet and are passing in zero to
retain their private allocation.

- todo: migrate clients to using allocation this way
- todo: remove priv variable once migration is complete

Also removed unused variable in sdhci_pltfm_init fn

Signed-off-by: Christian Daudt <csd@broadcom.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Chris Ball <cjb@laptop.org>

authored by

Christian Daudt and committed by
Chris Ball
0e748234 7396e318

+29 -19
+1 -1
drivers/mmc/host/sdhci-bcm2835.c
··· 148 148 struct sdhci_pltfm_host *pltfm_host; 149 149 int ret; 150 150 151 - host = sdhci_pltfm_init(pdev, &bcm2835_sdhci_pdata); 151 + host = sdhci_pltfm_init(pdev, &bcm2835_sdhci_pdata, 0); 152 152 if (IS_ERR(host)) 153 153 return PTR_ERR(host); 154 154
+1 -1
drivers/mmc/host/sdhci-cns3xxx.c
··· 96 96 97 97 static int sdhci_cns3xxx_probe(struct platform_device *pdev) 98 98 { 99 - return sdhci_pltfm_register(pdev, &sdhci_cns3xxx_pdata); 99 + return sdhci_pltfm_register(pdev, &sdhci_cns3xxx_pdata, 0); 100 100 } 101 101 102 102 static int sdhci_cns3xxx_remove(struct platform_device *pdev)
+1 -1
drivers/mmc/host/sdhci-dove.c
··· 130 130 gpio_direction_input(priv->gpio_cd); 131 131 } 132 132 133 - host = sdhci_pltfm_init(pdev, &sdhci_dove_pdata); 133 + host = sdhci_pltfm_init(pdev, &sdhci_dove_pdata, 0); 134 134 if (IS_ERR(host)) { 135 135 ret = PTR_ERR(host); 136 136 goto err_sdhci_pltfm_init;
+1 -1
drivers/mmc/host/sdhci-esdhc-imx.c
··· 503 503 int err; 504 504 struct pltfm_imx_data *imx_data; 505 505 506 - host = sdhci_pltfm_init(pdev, &sdhci_esdhc_imx_pdata); 506 + host = sdhci_pltfm_init(pdev, &sdhci_esdhc_imx_pdata, 0); 507 507 if (IS_ERR(host)) 508 508 return PTR_ERR(host); 509 509
+1 -1
drivers/mmc/host/sdhci-of-esdhc.c
··· 262 262 263 263 static int sdhci_esdhc_probe(struct platform_device *pdev) 264 264 { 265 - return sdhci_pltfm_register(pdev, &sdhci_esdhc_pdata); 265 + return sdhci_pltfm_register(pdev, &sdhci_esdhc_pdata, 0); 266 266 } 267 267 268 268 static int sdhci_esdhc_remove(struct platform_device *pdev)
+1 -1
drivers/mmc/host/sdhci-of-hlwd.c
··· 68 68 69 69 static int sdhci_hlwd_probe(struct platform_device *pdev) 70 70 { 71 - return sdhci_pltfm_register(pdev, &sdhci_hlwd_pdata); 71 + return sdhci_pltfm_register(pdev, &sdhci_hlwd_pdata, 0); 72 72 } 73 73 74 74 static int sdhci_hlwd_remove(struct platform_device *pdev)
+9 -8
drivers/mmc/host/sdhci-pltfm.c
··· 115 115 EXPORT_SYMBOL_GPL(sdhci_get_of_property); 116 116 117 117 struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev, 118 - const struct sdhci_pltfm_data *pdata) 118 + const struct sdhci_pltfm_data *pdata, 119 + size_t priv_size) 119 120 { 120 121 struct sdhci_host *host; 121 - struct sdhci_pltfm_host *pltfm_host; 122 122 struct device_node *np = pdev->dev.of_node; 123 123 struct resource *iomem; 124 124 int ret; ··· 134 134 135 135 /* Some PCI-based MFD need the parent here */ 136 136 if (pdev->dev.parent != &platform_bus && !np) 137 - host = sdhci_alloc_host(pdev->dev.parent, sizeof(*pltfm_host)); 137 + host = sdhci_alloc_host(pdev->dev.parent, 138 + sizeof(struct sdhci_pltfm_host) + priv_size); 138 139 else 139 - host = sdhci_alloc_host(&pdev->dev, sizeof(*pltfm_host)); 140 + host = sdhci_alloc_host(&pdev->dev, 141 + sizeof(struct sdhci_pltfm_host) + priv_size); 140 142 141 143 if (IS_ERR(host)) { 142 144 ret = PTR_ERR(host); 143 145 goto err; 144 146 } 145 - 146 - pltfm_host = sdhci_priv(host); 147 147 148 148 host->hw_name = dev_name(&pdev->dev); 149 149 if (pdata && pdata->ops) ··· 204 204 EXPORT_SYMBOL_GPL(sdhci_pltfm_free); 205 205 206 206 int sdhci_pltfm_register(struct platform_device *pdev, 207 - const struct sdhci_pltfm_data *pdata) 207 + const struct sdhci_pltfm_data *pdata, 208 + size_t priv_size) 208 209 { 209 210 struct sdhci_host *host; 210 211 int ret = 0; 211 212 212 - host = sdhci_pltfm_init(pdev, pdata); 213 + host = sdhci_pltfm_init(pdev, pdata, priv_size); 213 214 if (IS_ERR(host)) 214 215 return PTR_ERR(host); 215 216
+11 -2
drivers/mmc/host/sdhci-pltfm.h
··· 28 28 /* migrate from sdhci_of_host */ 29 29 unsigned int clock; 30 30 u16 xfer_mode_shadow; 31 + 32 + unsigned long private[0] ____cacheline_aligned; 31 33 }; 32 34 33 35 #ifdef CONFIG_MMC_SDHCI_BIG_ENDIAN_32BIT_BYTE_SWAPPER ··· 94 92 extern void sdhci_get_of_property(struct platform_device *pdev); 95 93 96 94 extern struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev, 97 - const struct sdhci_pltfm_data *pdata); 95 + const struct sdhci_pltfm_data *pdata, 96 + size_t priv_size); 98 97 extern void sdhci_pltfm_free(struct platform_device *pdev); 99 98 100 99 extern int sdhci_pltfm_register(struct platform_device *pdev, 101 - const struct sdhci_pltfm_data *pdata); 100 + const struct sdhci_pltfm_data *pdata, 101 + size_t priv_size); 102 102 extern int sdhci_pltfm_unregister(struct platform_device *pdev); 103 103 104 104 extern unsigned int sdhci_pltfm_clk_get_max_clock(struct sdhci_host *host); 105 + 106 + static inline void *sdhci_pltfm_priv(struct sdhci_pltfm_host *host) 107 + { 108 + return (void *)host->private; 109 + } 105 110 106 111 #ifdef CONFIG_PM 107 112 extern const struct dev_pm_ops sdhci_pltfm_pmops;
+1 -1
drivers/mmc/host/sdhci-pxav2.c
··· 175 175 if (!pxa) 176 176 return -ENOMEM; 177 177 178 - host = sdhci_pltfm_init(pdev, NULL); 178 + host = sdhci_pltfm_init(pdev, NULL, 0); 179 179 if (IS_ERR(host)) { 180 180 kfree(pxa); 181 181 return PTR_ERR(host);
+1 -1
drivers/mmc/host/sdhci-pxav3.c
··· 230 230 if (!pxa) 231 231 return -ENOMEM; 232 232 233 - host = sdhci_pltfm_init(pdev, &sdhci_pxav3_pdata); 233 + host = sdhci_pltfm_init(pdev, &sdhci_pxav3_pdata, 0); 234 234 if (IS_ERR(host)) { 235 235 kfree(pxa); 236 236 return PTR_ERR(host);
+1 -1
drivers/mmc/host/sdhci-tegra.c
··· 231 231 return -EINVAL; 232 232 soc_data = match->data; 233 233 234 - host = sdhci_pltfm_init(pdev, soc_data->pdata); 234 + host = sdhci_pltfm_init(pdev, soc_data->pdata, 0); 235 235 if (IS_ERR(host)) 236 236 return PTR_ERR(host); 237 237 pltfm_host = sdhci_priv(host);