Skip to contentSkip to conversation

Fix sparse warnings

PATCH Superseded Ashok Reddy Soma 2 participants 10 messages Jan 6, 2023

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover Fix sparse warnings

Run and fix sparse warnings in below files
-drivers/mmc/zynq_sdhci.c
-board/xilinx/common/board.h
-drivers/gpio/zynqmp_gpio_modepin.c
-board/xilinx/versal/board.c

Algapally Santosh Sagar (4):
xilinx: common: Add missing prototype for board_get_usable_ram_top
gpio: zynqmp: Remove unused variable ret
xilinx: versal: Add missing prototype
drivers: mmc: Change datatype to fix a warning

 board/xilinx/common/board.h        | 4 ++++
 board/xilinx/versal/board.c        | 1 +
 drivers/gpio/zynqmp_gpio_modepin.c | 3 +--
 drivers/mmc/zynq_sdhci.c           | 2 +-
 4 files changed, 7 insertions(+), 3 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/4 xilinx: common: Add missing prototype for board_get_usable_ram_top

From: Algapally Santosh Sagar <[email protected]>

Add missing prototype to fix the sparse warning, warning: no previous prototype for 'board_get_usable_ram_top' [-Wmissing-prototypes].

---

 board/xilinx/common/board.h | 4 ++++
 1 file changed, 4 insertions(+)
board/xilinx/common/board.h +4 -0
index 69e642429b..ef7f3f3dce 100644
@@ -11,4 +11,8 @@ int board_late_init_xilinx(void);
 
 int xilinx_read_eeprom(void);
 
+#if defined(CONFIG_LMB)
+phys_size_t board_get_usable_ram_top(phys_size_t total_size);
+#endif
+
 #endif /* BOARD_XILINX_COMMON_BOARD_H */
Signature · 1 line
2.17.1
maintainer
#2 lore raw

Re: [PATCH 1/4] xilinx: common: Add missing prototype for board_get_usable_ram_top

Quoted 17 lines · Ashok Reddy Soma

From: Algapally Santosh Sagar <[email protected]>

Add missing prototype to fix the sparse warning, warning: no previous prototype for 'board_get_usable_ram_top' [-Wmissing-prototypes].

---

  board/xilinx/common/board.h | 4 ++++
  1 file changed, 4 insertions(+)
board/xilinx/common/board.h +0 -0
index 69e642429b..ef7f3f3dce 100644

board/xilinx/common/board.h int board_late_init_xilinx(void); · line 15

Quoted 5 lines
board/xilinx/common/board.h +2 -0
@@ -11,4 +11,8 @@ int board_late_init_xilinx(void);
 
  int xilinx_read_eeprom(void);
 
+#if defined(CONFIG_LMB)
+phys_size_t board_get_usable_ram_top(phys_size_t total_size);

it is already in include/init.h.

M

#3 lore raw

PATCH 2/4 gpio: zynqmp: Remove unused variable ret

In reply to Ashok Reddy Soma

From: Algapally Santosh Sagar <[email protected]>

There is a unused variable ret, due to which we are getting sparse warning as below.
warning: variable 'ret' set but not used [-Wunused-but-set-variable].

Remove variable ret.

---

 drivers/gpio/zynqmp_gpio_modepin.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpio/zynqmp_gpio_modepin.c +1 -2
index 078fd83395..52eda9ceb4 100644
@@ -45,9 +45,8 @@ static int modepin_gpio_set_value(struct udevice *dev, unsigned int offset,
 {
 	u32 ret_payload[PAYLOAD_ARG_CNT];
 	u32 out_val = 0;
-	int ret;
 
-	ret = get_gpio_modepin(ret_payload);
+	get_gpio_modepin(ret_payload);
 	if (value)
 		out_val = OUTVAL(offset) | ret_payload[1];
 	else
Signature · 1 line
2.17.1
maintainer
#4 lore raw

Re: [PATCH 2/4] gpio: zynqmp: Remove unused variable ret

Quoted 20 lines · Ashok Reddy Soma

From: Algapally Santosh Sagar <[email protected]>

There is a unused variable ret, due to which we are getting sparse warning as below.
warning: variable 'ret' set but not used [-Wunused-but-set-variable].

Remove variable ret.

---

  drivers/gpio/zynqmp_gpio_modepin.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpio/zynqmp_gpio_modepin.c +0 -0
index 078fd83395..52eda9ceb4 100644

drivers/gpio/zynqmp_gpio_modepin.c static int modepin_gpio_set_value(struct udevice *dev, unsigned int offset, · line 49

Quoted 7 lines
drivers/gpio/zynqmp_gpio_modepin.c +1 -2
@@ -45,9 +45,8 @@ static int modepin_gpio_set_value(struct udevice *dev, unsigned int offset,
  {
  	u32 ret_payload[PAYLOAD_ARG_CNT];
  	u32 out_val = 0;
-	int ret;
 
-	ret = get_gpio_modepin(ret_payload);
+	get_gpio_modepin(ret_payload);

:-) what about return error if get_gpio_modepin fails?

M

Quoted 3 lines
drivers/gpio/zynqmp_gpio_modepin.c +0 -0
  	if (value)
  		out_val = OUTVAL(offset) | ret_payload[1];
  	else
#5 lore raw

PATCH 3/4 xilinx: versal: Add missing prototype

In reply to Ashok Reddy Soma

From: Algapally Santosh Sagar <[email protected]>

Add missing prototype to fix the sparse warning, warning: no previous prototype for 'do_go_exec' [-Wmissing-prototypes].

---

 board/xilinx/versal/board.c | 1 +
 1 file changed, 1 insertion(+)
board/xilinx/versal/board.c +1 -0
index f9f5457ed2..d8562ce47a 100644
@@ -22,6 +22,7 @@
 #include <dm/uclass.h>
 #include <versalpl.h>
 #include "../common/board.h"
+#include <command.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
Signature · 1 line
2.17.1
maintainer
#6 lore raw

Re: [PATCH 3/4] xilinx: versal: Add missing prototype

Add missing header in subject?

Quoted 17 lines · Ashok Reddy Soma

From: Algapally Santosh Sagar <[email protected]>

Add missing prototype to fix the sparse warning, warning: no previous prototype for 'do_go_exec' [-Wmissing-prototypes].

---

  board/xilinx/versal/board.c | 1 +
  1 file changed, 1 insertion(+)
board/xilinx/versal/board.c +0 -0
index f9f5457ed2..d8562ce47a 100644

board/xilinx/versal/board.c line 25

Quoted 4 lines
board/xilinx/versal/board.c +1 -0
@@ -22,6 +22,7 @@
  #include <dm/uclass.h>
  #include <versalpl.h>
  #include "../common/board.h"
+#include <command.h>

alphabetic order please.

M

Quoted 3 lines
board/xilinx/versal/board.c +0 -0
  DECLARE_GLOBAL_DATA_PTR;
 
#7 lore raw

PATCH 4/4 drivers: mmc: Change datatype to fix a warning

In reply to Ashok Reddy Soma

From: Algapally Santosh Sagar <[email protected]>

tuning_loop_counter is of char type. Change to int to fix below warning.
warning: comparison is always false due to limited range of data type.

---

 drivers/mmc/zynq_sdhci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/zynq_sdhci.c +1 -1
index 7dcf6ad842..be4075c97a 100644
@@ -249,7 +249,7 @@ static int arasan_sdhci_execute_tuning(struct mmc *mmc, u8 opcode)
 	u32 ctrl;
 	struct sdhci_host *host;
 	struct arasan_sdhci_priv *priv = dev_get_priv(mmc->dev);
-	char tuning_loop_counter = SDHCI_TUNING_LOOP_COUNT;
+	int tuning_loop_counter = SDHCI_TUNING_LOOP_COUNT;
 
 	dev_dbg(mmc->dev, "%s\n", __func__);
 
Signature · 1 line
2.17.1
maintainer
#8 lore raw

Re: [PATCH 4/4] drivers: mmc: Change datatype to fix a warning

mmc: zynq_sdhci: Fix wrong tuning_loop_counter datatype

Quoted 4 lines · Ashok Reddy Soma

From: Algapally Santosh Sagar <[email protected]>

tuning_loop_counter is of char type. Change to int to fix below warning.
warning: comparison is always false due to limited range of data type.

Conceptually description should be done a way that you say I fixed this issue because datatype wasn't correct. And this was reported by spare.

And you are doing it because it is not correct not because there is a warning. Warning just points to it.

M

Quoted 21 lines

---

  drivers/mmc/zynq_sdhci.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/zynq_sdhci.c +1 -1
index 7dcf6ad842..be4075c97a 100644
@@ -249,7 +249,7 @@ static int arasan_sdhci_execute_tuning(struct mmc *mmc, u8 opcode)
  	u32 ctrl;
  	struct sdhci_host *host;
  	struct arasan_sdhci_priv *priv = dev_get_priv(mmc->dev);
-	char tuning_loop_counter = SDHCI_TUNING_LOOP_COUNT;
+	int tuning_loop_counter = SDHCI_TUNING_LOOP_COUNT;
 
  	dev_dbg(mmc->dev, "%s\n", __func__);
 
maintainer
#9 lore raw
In reply to Ashok Reddy Soma
Quoted 13 lines · Ashok Reddy Soma

Run and fix sparse warnings in below files
-drivers/mmc/zynq_sdhci.c
-board/xilinx/common/board.h
-drivers/gpio/zynqmp_gpio_modepin.c
-board/xilinx/versal/board.c

Algapally Santosh Sagar (4):
xilinx: common: Add missing prototype for board_get_usable_ram_top
gpio: zynqmp: Remove unused variable ret
xilinx: versal: Add missing prototype
drivers: mmc: Change datatype to fix a warning

Quoted 6 lines
  board/xilinx/common/board.h        | 4 ++++
  board/xilinx/versal/board.c        | 1 +
  drivers/gpio/zynqmp_gpio_modepin.c | 3 +--
  drivers/mmc/zynq_sdhci.c           | 2 +-
  4 files changed, 7 insertions(+), 3 deletions(-)

Please do it against upstream.

M