diff mbox

[U-Boot] dm: ti_qspi: Fix conversion of address to a pointer

Message ID 1457176386-25658-1-git-send-email-lokeshvutla@ti.com
State Accepted
Commit e6601df8acf19a369b4c12ef16296f719dd237ca
Delegated to: Jagannadha Sutradharudu Teki
Headers show

Commit Message

Lokesh Vutla March 5, 2016, 11:13 a.m. UTC
TI QSPI driver directly typecasts fdt_addr_t to a pointer. This is
not strictly correct, as it gives a build warning when fdt_addr_t is u64.
So, use map_physmem for a proper typecasts.

This is inspired by commit 167efe01bc5a9 ("dm: ns16550: Use an address
instead of a pointer for the uart base")

Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
---
 drivers/spi/ti_qspi.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Comments

Jagan Teki March 5, 2016, 11:54 a.m. UTC | #1
On Saturday 05 March 2016 04:43 PM, Lokesh Vutla wrote:
> TI QSPI driver directly typecasts fdt_addr_t to a pointer. This is
> not strictly correct, as it gives a build warning when fdt_addr_t is u64.
> So, use map_physmem for a proper typecasts.
>
> This is inspired by commit 167efe01bc5a9 ("dm: ns16550: Use an address
> instead of a pointer for the uart base")
>
> Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>

Reviewed-by: Jagan Teki <jteki@openedev.com>

thanks!
--
Jagan.
Tom Rini March 7, 2016, 11:38 p.m. UTC | #2
On Sat, Mar 05, 2016 at 04:43:06PM +0530, Lokesh Vutla wrote:

> TI QSPI driver directly typecasts fdt_addr_t to a pointer. This is
> not strictly correct, as it gives a build warning when fdt_addr_t is u64.
> So, use map_physmem for a proper typecasts.
> 
> This is inspired by commit 167efe01bc5a9 ("dm: ns16550: Use an address
> instead of a pointer for the uart base")
> 
> Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>

Reviewed-by: Tom Rini <trini@konsulko.com>
Mugunthan V N March 8, 2016, 6:35 a.m. UTC | #3
On Saturday 05 March 2016 04:43 PM, Lokesh Vutla wrote:
> TI QSPI driver directly typecasts fdt_addr_t to a pointer. This is
> not strictly correct, as it gives a build warning when fdt_addr_t is u64.
> So, use map_physmem for a proper typecasts.
> 
> This is inspired by commit 167efe01bc5a9 ("dm: ns16550: Use an address
> instead of a pointer for the uart base")
> 
> Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>

Reviewed-by: Mugunthan V N <mugunthanvnm@ti.com>

Regards
Mugunthan V N
diff mbox

Patch

diff --git a/drivers/spi/ti_qspi.c b/drivers/spi/ti_qspi.c
index 409a5c4..e69ec0d 100644
--- a/drivers/spi/ti_qspi.c
+++ b/drivers/spi/ti_qspi.c
@@ -534,11 +534,15 @@  static int ti_qspi_ofdata_to_platdata(struct udevice *bus)
 	const void *blob = gd->fdt_blob;
 	int node = bus->of_offset;
 	fdt_addr_t addr;
+	void *mmap;
 
-	priv->base = (struct ti_qspi_regs *)dev_get_addr(bus);
-	priv->memory_map = (void *)dev_get_addr_index(bus, 1);
+	priv->base = map_physmem(dev_get_addr(bus), sizeof(struct ti_qspi_regs),
+				 MAP_NOCACHE);
+	priv->memory_map = map_physmem(dev_get_addr_index(bus, 1), 0,
+				       MAP_NOCACHE);
 	addr = dev_get_addr_index(bus, 2);
-	priv->ctrl_mod_mmap = (addr == FDT_ADDR_T_NONE) ? NULL : (void *)addr;
+	mmap = map_physmem(dev_get_addr_index(bus, 2), 0, MAP_NOCACHE);
+	priv->ctrl_mod_mmap = (addr == FDT_ADDR_T_NONE) ? NULL : mmap;
 
 	priv->max_hz = fdtdec_get_int(blob, node, "spi-max-frequency", -1);
 	if (priv->max_hz < 0) {