Skip to content

Commit 260b316

Browse files
arndbstorulf
authored andcommitted
mmc: dw_mmc: use resource_size_t to store physical address
The dw_mmc driver stores the physical address of the MMIO registers in a pointer, which requires the use of type casts, and is actually broken if anyone ever has this device on a 32-bit SoC in registers above 4GB. Gcc warns about this possibility when the driver is built with ARM LPAE enabled: mmc/host/dw_mmc.c: In function 'dw_mci_edmac_start_dma': mmc/host/dw_mmc.c:702:17: warning: cast from pointer to integer of different size cfg.dst_addr = (dma_addr_t)(host->phy_regs + fifo_offset); ^ mmc/host/dw_mmc-pltfm.c: In function 'dw_mci_pltfm_register': mmc/host/dw_mmc-pltfm.c:63:19: warning: cast to pointer from integer of different size host->phy_regs = (void *)(regs->start); This changes the code to use resource_size_t, which gets rid of the warning, the bug and the useless casts. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent 3bbb0de commit 260b316

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

drivers/mmc/host/dw_mmc-pltfm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ int dw_mci_pltfm_register(struct platform_device *pdev,
6060

6161
regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
6262
/* Get registers' physical base address */
63-
host->phy_regs = (void *)(regs->start);
63+
host->phy_regs = regs->start;
6464
host->regs = devm_ioremap_resource(&pdev->dev, regs);
6565
if (IS_ERR(host->regs))
6666
return PTR_ERR(host->regs);

drivers/mmc/host/dw_mmc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ static int dw_mci_edmac_start_dma(struct dw_mci *host,
699699
int ret = 0;
700700

701701
/* Set external dma config: burst size, burst width */
702-
cfg.dst_addr = (dma_addr_t)(host->phy_regs + fifo_offset);
702+
cfg.dst_addr = host->phy_regs + fifo_offset;
703703
cfg.src_addr = cfg.dst_addr;
704704
cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
705705
cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;

include/linux/mmc/dw_mmc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ struct dw_mci {
172172
/* For edmac */
173173
struct dw_mci_dma_slave *dms;
174174
/* Registers's physical base address */
175-
void *phy_regs;
175+
resource_size_t phy_regs;
176176

177177
u32 cmd_status;
178178
u32 data_status;

0 commit comments

Comments
 (0)