[PATCH v2 0/4] 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
Changes in v2: - Included header file instead of declaring prototype - Modified description to reflect the same - Instead of removing ret variable, take it and return incase of error. - Updated description as per this. - Changed subject from missing prototype to missing header - Moved include file in alphabetical order - Updated description
Algapally Santosh Sagar (4): xilinx: common: Include header file to fix warning gpio: zynqmp: Handle error from get_gpio_modepin xilinx: versal: Add missing header drivers: mmc: Change datatype of tuning_loop_counter to int
board/xilinx/common/board.c | 1 + board/xilinx/versal/board.c | 1 + drivers/gpio/zynqmp_gpio_modepin.c | 3 +++ drivers/mmc/zynq_sdhci.c | 2 +- 4 files changed, 6 insertions(+), 1 deletion(-)

From: Algapally Santosh Sagar santoshsagar.algapally@amd.com
Prototype is missing for board_get_usable_ram_top, which is pointed by below sparse warning. Include init.h header file to fix this.
warning: no previous prototype for 'board_get_usable_ram_top' [-Wmissing-prototypes].
Signed-off-by: Algapally Santosh Sagar santoshsagar.algapally@amd.com Signed-off-by: Ashok Reddy Soma ashok.reddy.soma@amd.com ---
Changes in v2: - Included header file instead of declaring prototype - Modified description to reflect the same
board/xilinx/common/board.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c index 59d87f2352..a5bd289776 100644 --- a/board/xilinx/common/board.c +++ b/board/xilinx/common/board.c @@ -9,6 +9,7 @@ #include <efi_loader.h> #include <env.h> #include <image.h> +#include <init.h> #include <lmb.h> #include <log.h> #include <asm/global_data.h>

From: Algapally Santosh Sagar santoshsagar.algapally@amd.com
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].
Return ret incase of error.
Signed-off-by: Algapally Santosh Sagar santoshsagar.algapally@amd.com Signed-off-by: Ashok Reddy Soma ashok.reddy.soma@amd.com ---
Changes in v2: - Instead of removing ret variable, take it and return incase of error. - Updated description as per this.
drivers/gpio/zynqmp_gpio_modepin.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/drivers/gpio/zynqmp_gpio_modepin.c b/drivers/gpio/zynqmp_gpio_modepin.c index 078fd83395..e9565ff543 100644 --- a/drivers/gpio/zynqmp_gpio_modepin.c +++ b/drivers/gpio/zynqmp_gpio_modepin.c @@ -48,6 +48,9 @@ static int modepin_gpio_set_value(struct udevice *dev, unsigned int offset, int ret;
ret = get_gpio_modepin(ret_payload); + if (ret) + return ret; + if (value) out_val = OUTVAL(offset) | ret_payload[1]; else

From: Algapally Santosh Sagar santoshsagar.algapally@amd.com
Add missing prototype to fix the sparse warning, warning: no previous prototype for 'do_go_exec' [-Wmissing-prototypes].
Signed-off-by: Algapally Santosh Sagar santoshsagar.algapally@amd.com Signed-off-by: Ashok Reddy Soma ashok.reddy.soma@amd.com ---
Changes in v2: - Changed subject from missing prototype to missing header - Moved include file in alphabetical order
board/xilinx/versal/board.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/board/xilinx/versal/board.c b/board/xilinx/versal/board.c index f9f5457ed2..4cdc2ecd1d 100644 --- a/board/xilinx/versal/board.c +++ b/board/xilinx/versal/board.c @@ -4,6 +4,7 @@ * Michal Simek michal.simek@xilinx.com */
+#include <command.h> #include <common.h> #include <cpu_func.h> #include <env.h>

From: Algapally Santosh Sagar santoshsagar.algapally@amd.com
tuning_loop_counter is of char type, which is not capable of handling the entire data range of this variable. This is pointed by below sparse warning. Change datatype to int to fix this. warning: comparison is always false due to limited range of data type.
Signed-off-by: Algapally Santosh Sagar santoshsagar.algapally@amd.com Signed-off-by: Ashok Reddy Soma ashok.reddy.soma@amd.com ---
Changes in v2: - Updated description
drivers/mmc/zynq_sdhci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mmc/zynq_sdhci.c b/drivers/mmc/zynq_sdhci.c index 7dcf6ad842..be4075c97a 100644 --- a/drivers/mmc/zynq_sdhci.c +++ b/drivers/mmc/zynq_sdhci.c @@ -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__);

On 1/20/23 06:36, Ashok Reddy Soma wrote:
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
Changes in v2:
- Included header file instead of declaring prototype
- Modified description to reflect the same
- Instead of removing ret variable, take it and return incase of error.
- Updated description as per this.
- Changed subject from missing prototype to missing header
- Moved include file in alphabetical order
- Updated description
Algapally Santosh Sagar (4): xilinx: common: Include header file to fix warning gpio: zynqmp: Handle error from get_gpio_modepin xilinx: versal: Add missing header drivers: mmc: Change datatype of tuning_loop_counter to int
board/xilinx/common/board.c | 1 + board/xilinx/versal/board.c | 1 + drivers/gpio/zynqmp_gpio_modepin.c | 3 +++ drivers/mmc/zynq_sdhci.c | 2 +- 4 files changed, 6 insertions(+), 1 deletion(-)
Applied all. M
participants (2)
-
Ashok Reddy Soma
-
Michal Simek