]>
Commit | Line | Data |
---|---|---|
596791dc GKH |
1 | From 260b31643691e8a58683a4ccc3bdf7abfd86f54a Mon Sep 17 00:00:00 2001 |
2 | From: Arnd Bergmann <arnd@arndb.de> | |
3 | Date: Thu, 12 Nov 2015 15:14:23 +0100 | |
4 | Subject: mmc: dw_mmc: use resource_size_t to store physical address | |
5 | ||
6 | From: Arnd Bergmann <arnd@arndb.de> | |
7 | ||
8 | commit 260b31643691e8a58683a4ccc3bdf7abfd86f54a upstream. | |
9 | ||
10 | The dw_mmc driver stores the physical address of the MMIO registers | |
11 | in a pointer, which requires the use of type casts, and is actually | |
12 | broken if anyone ever has this device on a 32-bit SoC in registers | |
13 | above 4GB. Gcc warns about this possibility when the driver is built | |
14 | with ARM LPAE enabled: | |
15 | ||
16 | mmc/host/dw_mmc.c: In function 'dw_mci_edmac_start_dma': | |
17 | mmc/host/dw_mmc.c:702:17: warning: cast from pointer to integer of different size | |
18 | cfg.dst_addr = (dma_addr_t)(host->phy_regs + fifo_offset); | |
19 | ^ | |
20 | mmc/host/dw_mmc-pltfm.c: In function 'dw_mci_pltfm_register': | |
21 | mmc/host/dw_mmc-pltfm.c:63:19: warning: cast to pointer from integer of different size | |
22 | host->phy_regs = (void *)(regs->start); | |
23 | ||
24 | This changes the code to use resource_size_t, which gets rid of the | |
25 | warning, the bug and the useless casts. | |
26 | ||
27 | Signed-off-by: Arnd Bergmann <arnd@arndb.de> | |
28 | Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com> | |
29 | Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> | |
30 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
31 | ||
32 | --- | |
33 | drivers/mmc/host/dw_mmc-pltfm.c | 2 +- | |
34 | drivers/mmc/host/dw_mmc.c | 2 +- | |
35 | include/linux/mmc/dw_mmc.h | 2 +- | |
36 | 3 files changed, 3 insertions(+), 3 deletions(-) | |
37 | ||
38 | --- a/drivers/mmc/host/dw_mmc-pltfm.c | |
39 | +++ b/drivers/mmc/host/dw_mmc-pltfm.c | |
40 | @@ -60,7 +60,7 @@ int dw_mci_pltfm_register(struct platfor | |
41 | ||
42 | regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); | |
43 | /* Get registers' physical base address */ | |
44 | - host->phy_regs = (void *)(regs->start); | |
45 | + host->phy_regs = regs->start; | |
46 | host->regs = devm_ioremap_resource(&pdev->dev, regs); | |
47 | if (IS_ERR(host->regs)) | |
48 | return PTR_ERR(host->regs); | |
49 | --- a/drivers/mmc/host/dw_mmc.c | |
50 | +++ b/drivers/mmc/host/dw_mmc.c | |
51 | @@ -699,7 +699,7 @@ static int dw_mci_edmac_start_dma(struct | |
52 | int ret = 0; | |
53 | ||
54 | /* Set external dma config: burst size, burst width */ | |
55 | - cfg.dst_addr = (dma_addr_t)(host->phy_regs + fifo_offset); | |
56 | + cfg.dst_addr = host->phy_regs + fifo_offset; | |
57 | cfg.src_addr = cfg.dst_addr; | |
58 | cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; | |
59 | cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; | |
60 | --- a/include/linux/mmc/dw_mmc.h | |
61 | +++ b/include/linux/mmc/dw_mmc.h | |
62 | @@ -172,7 +172,7 @@ struct dw_mci { | |
63 | /* For edmac */ | |
64 | struct dw_mci_dma_slave *dms; | |
65 | /* Registers's physical base address */ | |
66 | - void *phy_regs; | |
67 | + resource_size_t phy_regs; | |
68 | ||
69 | u32 cmd_status; | |
70 | u32 data_status; |