Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 260b3164 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Ulf Hansson
Browse files

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: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarJaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent 3bbb0dee
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ int dw_mci_pltfm_register(struct platform_device *pdev,

	regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	/* Get registers' physical base address */
	host->phy_regs = (void *)(regs->start);
	host->phy_regs = regs->start;
	host->regs = devm_ioremap_resource(&pdev->dev, regs);
	if (IS_ERR(host->regs))
		return PTR_ERR(host->regs);
+1 −1
Original line number Diff line number Diff line
@@ -699,7 +699,7 @@ static int dw_mci_edmac_start_dma(struct dw_mci *host,
	int ret = 0;

	/* Set external dma config: burst size, burst width */
	cfg.dst_addr = (dma_addr_t)(host->phy_regs + fifo_offset);
	cfg.dst_addr = host->phy_regs + fifo_offset;
	cfg.src_addr = cfg.dst_addr;
	cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
	cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
+1 −1
Original line number Diff line number Diff line
@@ -172,7 +172,7 @@ struct dw_mci {
	/* For edmac */
	struct dw_mci_dma_slave *dms;
	/* Registers's physical base address */
	void                    *phy_regs;
	resource_size_t		phy_regs;

	u32			cmd_status;
	u32			data_status;