Skip to contentSkip to conversation

spi: cadence_qspi: Change to use devfdt_get_addr_index()

PATCH New Ley Foon Tan 5 participants 11 messages May 7, 2018 – Jun 1, 2018 SPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spi: cadence_qspi: Change to use devfdt_get_addr_index()

Change to use devfdt_get_addr_index() function to get fdt address.

Original code has compilation warning below:

drivers/spi/cadence_qspi.c: In function ‘cadence_spi_ofdata_to_platdata’:
drivers/spi/cadence_qspi.c:297:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]

  plat->regbase = (void *)data[0];
                  ^
drivers/spi/cadence_qspi.c:298:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
  plat->ahbbase = (void *)data[2];
                  ^
---
 drivers/spi/cadence_qspi.c |   13 ++-----------
 1 files changed, 2 insertions(+), 11 deletions(-)
drivers/spi/cadence_qspi.c +2 -11
index 7b312f8..f80d073 100644
@@ -284,18 +284,9 @@ static int cadence_spi_ofdata_to_platdata(struct udevice *bus)
 	const void *blob = gd->fdt_blob;
 	int node = dev_of_offset(bus);
 	int subnode;
-	u32 data[4];
-	int ret;
 
-	/* 2 base addresses are needed, lets get them from the DT */
-	ret = fdtdec_get_int_array(blob, node, "reg", data, ARRAY_SIZE(data));
-	if (ret) {
-		printf("Error: Can't get base addresses (ret=%d)!\n", ret);
-		return -ENODEV;
-	}
-
-	plat->regbase = (void *)data[0];
-	plat->ahbbase = (void *)data[2];
+	plat->regbase = (void *)devfdt_get_addr_index(bus, 0);
+	plat->ahbbase = (void *)devfdt_get_addr_index(bus, 1);
 	plat->is_decoded_cs = fdtdec_get_bool(blob, node, "cdns,is-decoded-cs");
 	plat->fifo_depth = fdtdec_get_uint(blob, node, "cdns,fifo-depth", 128);
 	plat->fifo_width = fdtdec_get_uint(blob, node, "cdns,fifo-width", 4);
Signature · 1 line
1.7.1
#1 lore raw

PATCH 1/1 spi: cadence_qspi: Fix compilation warning

Cast data_bytes to integer.

Compilation warning as below:

In file included from include/linux/bug.h:7:0,
from include/common.h:26,
from drivers/spi/cadence_qspi.c:8:
drivers/spi/cadence_qspi.c: In function ‘cadence_spi_xfer’:
drivers/spi/cadence_qspi.c:211:8: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘size_t {aka long unsigned int}’ [-Wformat=]

  debug("%s: len=%d [bytes]\n", __func__, data_bytes);
        ^
include/linux/printk.h:37:21: note: in definition of macro ‘pr_fmt’
 #define pr_fmt(fmt) fmt
                     ^~~

include/log.h:142:2: note: in expansion of macro ‘debug_cond’
debug_cond(_DEBUG, fmt, ##args)
^~~~~~~~~~
drivers/spi/cadence_qspi.c:211:2: note: in expansion of macro ‘debug’
debug("%s: len=%d [bytes]\n", __func__, data_bytes);

---
 drivers/spi/cadence_qspi.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/spi/cadence_qspi.c +1 -1
index f80d073..dc4b5a4 100644
@@ -208,7 +208,7 @@ static int cadence_spi_xfer(struct udevice *dev, unsigned int bitlen,
 	} else {
 		data_bytes = bitlen / 8;
 	}
-	debug("%s: len=%d [bytes]\n", __func__, data_bytes);
+	debug("%s: len=%d [bytes]\n", __func__, (int)data_bytes);
 
 	/* Set Chip select */
 	cadence_qspi_apb_chipselect(base, spi_chip_select(dev),
Signature · 1 line
1.7.1
#4 lore raw

PATCH 1/1 spi: cadence_qspi: Fix warning cast from pointer to integer of different size

In reply to Ley Foon Tan

Cast to ulong data type.

Compilation warning as below:

CC spl/drivers/spi/cadence_qspi_apb.o
LD spl/lib/built-in.o
drivers/spi/cadence_qspi_apb.c: In function ‘cadence_qspi_apb_indirect_write_setup’:
drivers/spi/cadence_qspi_apb.c:696:18: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

          cmdlen, (unsigned int)cmdbuf);
---
 drivers/spi/cadence_qspi_apb.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/spi/cadence_qspi_apb.c +2 -2
index aa3a9ff..5bef0ae 100644
@@ -692,8 +692,8 @@ int cadence_qspi_apb_indirect_write_setup(struct cadence_spi_platdata *plat,
 	unsigned int addr_bytes = cmdlen > 4 ? 4 : 3;
 
 	if (cmdlen < 4 || cmdbuf == NULL) {
-		printf("QSPI: iInvalid input argument, len %d cmdbuf 0x%08x\n",
-		       cmdlen, (unsigned int)cmdbuf);
+		printf("QSPI: Invalid input argument, len %d cmdbuf 0x%08lx\n",
+		       cmdlen, (unsigned long)cmdbuf);
 		return -EINVAL;
 	}
 	/* Setup the indirect trigger address */
Signature · 1 line
1.7.1
#7 lore raw

PATCH 1/1 spi: cadence_qspi: Change to use devfdt_get_addr_index()

In reply to Ley Foon Tan
Quoted 10 lines · Ley Foon Tan

Change to use devfdt_get_addr_index() function to get fdt address.

Original code has compilation warning below:

drivers/spi/cadence_qspi.c: In function ‘cadence_spi_ofdata_to_platdata’:
drivers/spi/cadence_qspi.c:297:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]

  plat->regbase = (void *)data[0];
                  ^

drivers/spi/cadence_qspi.c:298:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
plat->ahbbase = (void *)data[2];

was this a coverage-tool check, I didn't see any warning with arm compiler? make socfpga_arria5_defconfig && make

#8 lore raw

PATCH 1/1 spi: cadence_qspi: Change to use devfdt_get_addr_index()

Quoted 12 lines · Jagan Teki
Quoted 10 lines · Ley Foon Tan

Change to use devfdt_get_addr_index() function to get fdt address.

Original code has compilation warning below:

drivers/spi/cadence_qspi.c: In function ‘cadence_spi_ofdata_to_platdata’:
drivers/spi/cadence_qspi.c:297:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]

  plat->regbase = (void *)data[0];
                  ^

drivers/spi/cadence_qspi.c:298:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
plat->ahbbase = (void *)data[2];

Quoted 2 lines

was this a coverage-tool check, I didn't see any warning with arm compiler? make socfpga_arria5_defconfig && make

This error came up if compile with ARM 64bit (aarch64-linux-gnu-).

Regards
Ley Foon

#9 lore raw

PATCH 1/1 spi: cadence_qspi: Change to use devfdt_get_addr_index()

In reply to Ley Foon Tan
Quoted 4 lines · Ley Foon Tan

Change to use devfdt_get_addr_index() function to get fdt address.

Original code has compilation warning below:

Quoted 8 lines

drivers/spi/cadence_qspi.c: In function ‘cadence_spi_ofdata_to_platdata’:
drivers/spi/cadence_qspi.c:297:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]

  plat->regbase = (void *)data[0];
                  ^
drivers/spi/cadence_qspi.c:298:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
  plat->ahbbase = (void *)data[2];
                  ^
Quoted 30 lines
---
 drivers/spi/cadence_qspi.c |   13 ++-----------
 1 files changed, 2 insertions(+), 11 deletions(-)
drivers/spi/cadence_qspi.c +2 -11
index 7b312f8..f80d073 100644
@@ -284,18 +284,9 @@ static int cadence_spi_ofdata_to_platdata(struct udevice *bus)
 	const void *blob = gd->fdt_blob;
 	int node = dev_of_offset(bus);
 	int subnode;
-	u32 data[4];
-	int ret;
 
-	/* 2 base addresses are needed, lets get them from the DT */
-	ret = fdtdec_get_int_array(blob, node, "reg", data, ARRAY_SIZE(data));
-	if (ret) {
-		printf("Error: Can't get base addresses (ret=%d)!\n", ret);
-		return -ENODEV;
-	}
-
-	plat->regbase = (void *)data[0];
-	plat->ahbbase = (void *)data[2];
+	plat->regbase = (void *)devfdt_get_addr_index(bus, 0);
+	plat->ahbbase = (void *)devfdt_get_addr_index(bus, 1);
 	plat->is_decoded_cs = fdtdec_get_bool(blob, node, "cdns,is-decoded-cs");
 	plat->fifo_depth = fdtdec_get_uint(blob, node, "cdns,fifo-depth", 128);
 	plat->fifo_width = fdtdec_get_uint(blob, node, "cdns,fifo-width", 4);
Signature · 2 lines
Best regards,
Marek Vasut
#2 lore raw

PATCH 1/1 spi: cadence_qspi: Fix compilation warning

In reply to Ley Foon Tan
Quoted 30 lines · Ley Foon Tan

Cast data_bytes to integer.

Compilation warning as below:

In file included from include/linux/bug.h:7:0,
from include/common.h:26,
from drivers/spi/cadence_qspi.c:8:
drivers/spi/cadence_qspi.c: In function ‘cadence_spi_xfer’:
drivers/spi/cadence_qspi.c:211:8: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘size_t {aka long unsigned int}’ [-Wformat=]

  debug("%s: len=%d [bytes]\n", __func__, data_bytes);
        ^
include/linux/printk.h:37:21: note: in definition of macro ‘pr_fmt’
 #define pr_fmt(fmt) fmt
                     ^~~

include/log.h:142:2: note: in expansion of macro ‘debug_cond’
debug_cond(_DEBUG, fmt, ##args)
^~~~~~~~~~
drivers/spi/cadence_qspi.c:211:2: note: in expansion of macro ‘debug’
debug("%s: len=%d [bytes]\n", __func__, data_bytes);

---
 drivers/spi/cadence_qspi.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/spi/cadence_qspi.c +0 -0
index f80d073..dc4b5a4 100644

drivers/spi/cadence_qspi.c static int cadence_spi_xfer(struct udevice *dev, unsigned int bitlen, · line 211

Quoted 5 lines
drivers/spi/cadence_qspi.c +1 -1
@@ -208,7 +208,7 @@ static int cadence_spi_xfer(struct udevice *dev, unsigned int bitlen,
 	} else {
 		data_bytes = bitlen / 8;
 	}
-	debug("%s: len=%d [bytes]\n", __func__, data_bytes);
+	debug("%s: len=%d [bytes]\n", __func__, (int)data_bytes);

This should probably be %lu instead of the cast.

Quoted 3 lines
drivers/spi/cadence_qspi.c +0 -0
 	/* Set Chip select */
 	cadence_qspi_apb_chipselect(base, spi_chip_select(dev),
 
Signature · 2 lines
Best regards,
Marek Vasut
#5 lore raw

PATCH 1/1 spi: cadence_qspi: Fix warning cast from pointer to integer of different size

In reply to Ley Foon Tan
Quoted 20 lines · Ley Foon Tan

Cast to ulong data type.

Compilation warning as below:

CC spl/drivers/spi/cadence_qspi_apb.o
LD spl/lib/built-in.o
drivers/spi/cadence_qspi_apb.c: In function ‘cadence_qspi_apb_indirect_write_setup’:
drivers/spi/cadence_qspi_apb.c:696:18: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

          cmdlen, (unsigned int)cmdbuf);
---
 drivers/spi/cadence_qspi_apb.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/spi/cadence_qspi_apb.c +0 -0
index aa3a9ff..5bef0ae 100644

drivers/spi/cadence_qspi_apb.c int cadence_qspi_apb_indirect_write_setup(struct cadence_spi_platdata *plat, · line 696

Quoted 7 lines
drivers/spi/cadence_qspi_apb.c +2 -2
@@ -692,8 +692,8 @@ int cadence_qspi_apb_indirect_write_setup(struct cadence_spi_platdata *plat,
 	unsigned int addr_bytes = cmdlen > 4 ? 4 : 3;
 
 	if (cmdlen < 4 || cmdbuf == NULL) {
-		printf("QSPI: iInvalid input argument, len %d cmdbuf 0x%08x\n",
-		       cmdlen, (unsigned int)cmdbuf);
+		printf("QSPI: Invalid input argument, len %d cmdbuf 0x%08lx\n",
+		       cmdlen, (unsigned long)cmdbuf);

%p ?

Quoted 4 lines
drivers/spi/cadence_qspi_apb.c +0 -0
 		return -EINVAL;
 	}
 	/* Setup the indirect trigger address */
Signature · 2 lines
Best regards,
Marek Vasut
#3 lore raw

PATCH 1/1 spi: cadence_qspi: Fix compilation warning

In reply to Marek Vasut
Quoted 26 lines · Marek Vasut
Quoted 25 lines · Ley Foon Tan

Cast data_bytes to integer.

Compilation warning as below:

In file included from include/linux/bug.h:7:0,
from include/common.h:26,
from drivers/spi/cadence_qspi.c:8:
drivers/spi/cadence_qspi.c: In function ‘cadence_spi_xfer’:
drivers/spi/cadence_qspi.c:211:8: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘size_t {aka long unsigned int}’ [-Wformat=]

  debug("%s: len=%d [bytes]\n", __func__, data_bytes);
        ^
include/linux/printk.h:37:21: note: in definition of macro ‘pr_fmt’
 #define pr_fmt(fmt) fmt
                     ^~~

include/log.h:142:2: note: in expansion of macro ‘debug_cond’
debug_cond(_DEBUG, fmt, ##args)
^~~~~~~~~~
drivers/spi/cadence_qspi.c:211:2: note: in expansion of macro ‘debug’
debug("%s: len=%d [bytes]\n", __func__, data_bytes);

---
 drivers/spi/cadence_qspi.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Quoted 12 lines

drivers/spi/cadence_qspi.c static int cadence_spi_xfer(struct udevice *dev, unsigned int bitlen, · line 211

Quoted 10 lines
drivers/spi/cadence_qspi.c +1 -1
index f80d073..dc4b5a4 100644
@@ -208,7 +208,7 @@ static int cadence_spi_xfer(struct udevice *dev, unsigned int bitlen,
      } else {
              data_bytes = bitlen / 8;
      }
-     debug("%s: len=%d [bytes]\n", __func__, data_bytes);
+     debug("%s: len=%d [bytes]\n", __func__, (int)data_bytes);

This should probably be %lu instead of the cast.

Okay.

Quoted 5 lines

drivers/spi/cadence_qspi.c static int cadence_spi_xfer(struct udevice *dev, unsigned int bitlen,

Quoted 4 lines
drivers/spi/cadence_qspi.c +0 -0
      /* Set Chip select */
      cadence_qspi_apb_chipselect(base, spi_chip_select(dev),
 

Regards
Ley Foon

#6 lore raw

PATCH 1/1 spi: cadence_qspi: Fix warning cast from pointer to integer of different size

In reply to Marek Vasut
Quoted 23 lines · Marek Vasut
Quoted 22 lines · Ley Foon Tan

Cast to ulong data type.

Compilation warning as below:

CC spl/drivers/spi/cadence_qspi_apb.o
LD spl/lib/built-in.o
drivers/spi/cadence_qspi_apb.c: In function ‘cadence_qspi_apb_indirect_write_setup’:
drivers/spi/cadence_qspi_apb.c:696:18: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

          cmdlen, (unsigned int)cmdbuf);
---
 drivers/spi/cadence_qspi_apb.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/spi/cadence_qspi_apb.c +0 -0
index aa3a9ff..5bef0ae 100644
@@ -692,8 +692,8 @@ int cadence_qspi_apb_indirect_write_setup(struct cadence_spi_platdata *plat,
      unsigned int addr_bytes = cmdlen > 4 ? 4 : 3;
 
Quoted 7 lines

drivers/spi/cadence_qspi_apb.c int cadence_qspi_apb_indirect_write_setup(struct cadence_spi_platdata *plat, · line 696

Quoted 5 lines
drivers/spi/cadence_qspi_apb.c +2 -2
      if (cmdlen < 4 || cmdbuf == NULL) {
-             printf("QSPI: iInvalid input argument, len %d cmdbuf 0x%08x\n",
-                    cmdlen, (unsigned int)cmdbuf);
+             printf("QSPI: Invalid input argument, len %d cmdbuf 0x%08lx\n",
+                    cmdlen, (unsigned long)cmdbuf);

%p ?

Yes, can use %p.

Quoted 7 lines

drivers/spi/cadence_qspi_apb.c int cadence_qspi_apb_indirect_write_setup(struct cadence_spi_platdata *plat, · line 699

Quoted 5 lines
drivers/spi/cadence_qspi_apb.c +0 -0
              return -EINVAL;
      }
      /* Setup the indirect trigger address */

Regards
Ley Foon

#10 lore raw

PATCH 1/1 spi: cadence_qspi: Change to use devfdt_get_addr_index()

In reply to Ley Foon Tan
Quoted 6 lines · Ley Foon Tan

Change to use devfdt_get_addr_index() function to get fdt address.

Original code has compilation warning below:

drivers/spi/cadence_qspi.c: In function ‘cadence_spi_ofdata_to_platdata’:
drivers/spi/cadence_qspi.c:297:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]

Quoted 7 lines
  plat->regbase = (void *)data[0];
                  ^
drivers/spi/cadence_qspi.c:298:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
  plat->ahbbase = (void *)data[2];
                  ^

---

Applied to u-boot-spi/master