]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.4.22/mmc-dw_mmc-use-resource_size_t-to-store-physical-address.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.4.22 / mmc-dw_mmc-use-resource_size_t-to-store-physical-address.patch
CommitLineData
596791dc
GKH
1From 260b31643691e8a58683a4ccc3bdf7abfd86f54a Mon Sep 17 00:00:00 2001
2From: Arnd Bergmann <arnd@arndb.de>
3Date: Thu, 12 Nov 2015 15:14:23 +0100
4Subject: mmc: dw_mmc: use resource_size_t to store physical address
5
6From: Arnd Bergmann <arnd@arndb.de>
7
8commit 260b31643691e8a58683a4ccc3bdf7abfd86f54a upstream.
9
10The dw_mmc driver stores the physical address of the MMIO registers
11in a pointer, which requires the use of type casts, and is actually
12broken if anyone ever has this device on a 32-bit SoC in registers
13above 4GB. Gcc warns about this possibility when the driver is built
14with ARM LPAE enabled:
15
16mmc/host/dw_mmc.c: In function 'dw_mci_edmac_start_dma':
17mmc/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 ^
20mmc/host/dw_mmc-pltfm.c: In function 'dw_mci_pltfm_register':
21mmc/host/dw_mmc-pltfm.c:63:19: warning: cast to pointer from integer of different size
22 host->phy_regs = (void *)(regs->start);
23
24This changes the code to use resource_size_t, which gets rid of the
25warning, the bug and the useless casts.
26
27Signed-off-by: Arnd Bergmann <arnd@arndb.de>
28Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
29Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
30Signed-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;