From 3c471c35812bc7863509dda1aedad08d35b48896 Mon Sep 17 00:00:00 2001 From: Yann Gautier Date: Fri, 9 Nov 2018 18:21:51 +0100 Subject: [PATCH 1/4] psci: put __dead2 attribute after void in plat_psci_ops These warnings were issued by sparse: plat/st/stm32mp1/stm32mp1_pm.c:365:36: warning: incorrect type in initializer (different modifiers) expected void ( *[noreturn] pwr_domain_pwr_down_wfi )( ... ) got void ( [noreturn] * )( ... ) plat/st/stm32mp1/stm32mp1_pm.c:366:23: warning: incorrect type in initializer (different modifiers) expected void ( *[noreturn] system_off )( ... ) got void ( [noreturn] * )( ... ) plat/st/stm32mp1/stm32mp1_pm.c:367:25: warning: incorrect type in initializer (different modifiers) expected void ( *[noreturn] system_reset )( ... ) got void ( [noreturn] * )( ... ) This cannot be changed the other way in all platforms pm drivers or else there is a compilation error: plat/st/stm32mp1/stm32mp1_pm.c:234:1: error: attributes should be specified before the declarator in a function definition Signed-off-by: Yann Gautier --- include/lib/psci/psci.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/lib/psci/psci.h b/include/lib/psci/psci.h index b27e48153..b7febc38f 100644 --- a/include/lib/psci/psci.h +++ b/include/lib/psci/psci.h @@ -302,10 +302,10 @@ typedef struct plat_psci_ops { void (*pwr_domain_on_finish)(const psci_power_state_t *target_state); void (*pwr_domain_suspend_finish)( const psci_power_state_t *target_state); - void (*pwr_domain_pwr_down_wfi)( - const psci_power_state_t *target_state) __dead2; - void (*system_off)(void) __dead2; - void (*system_reset)(void) __dead2; + void __dead2 (*pwr_domain_pwr_down_wfi)( + const psci_power_state_t *target_state); + void __dead2 (*system_off)(void); + void __dead2 (*system_reset)(void); int (*validate_power_state)(unsigned int power_state, psci_power_state_t *req_state); int (*validate_ns_entrypoint)(uintptr_t ns_entrypoint); From 4cb17707b5c83e47477d743cb1129fc0c75a15c1 Mon Sep 17 00:00:00 2001 From: Yann Gautier Date: Fri, 9 Nov 2018 18:21:04 +0100 Subject: [PATCH 2/4] drivers: partition: correct some static analysis tools issues cppcheck: [drivers/partition/gpt.c:19] -> [drivers/partition/gpt.c:19]: (warning) Either the condition 'str_in!=((void*)0)' is redundant or there is possible null pointer dereference: name. sparse: drivers/partition/gpt.c:39:9: warning: Using plain integer as NULL pointer Signed-off-by: Yann Gautier --- drivers/partition/gpt.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/partition/gpt.c b/drivers/partition/gpt.c index 9cc917d33..0c51e62a8 100644 --- a/drivers/partition/gpt.c +++ b/drivers/partition/gpt.c @@ -13,10 +13,14 @@ static int unicode_to_ascii(unsigned short *str_in, unsigned char *str_out) { - uint8_t *name = (uint8_t *)str_in; + uint8_t *name; int i; - assert((str_in != NULL) && (str_out != NULL) && (name[0] != '\0')); + assert((str_in != NULL) && (str_out != NULL)); + + name = (uint8_t *)str_in; + + assert(name[0] != '\0'); /* check whether the unicode string is valid */ for (i = 1; i < (EFI_NAMELEN << 1); i += 2) { @@ -36,7 +40,7 @@ int parse_gpt_entry(gpt_entry_t *gpt_entry, partition_entry_t *entry) { int result; - assert((gpt_entry != 0) && (entry != 0)); + assert((gpt_entry != NULL) && (entry != NULL)); if ((gpt_entry->first_lba == 0) && (gpt_entry->last_lba == 0)) { return -EINVAL; From 3e6fab43085b0f3ecb05339d81edad86dd091a52 Mon Sep 17 00:00:00 2001 From: Yann Gautier Date: Fri, 9 Nov 2018 15:57:18 +0100 Subject: [PATCH 3/4] stm32mp1: correct some static analysis tools issues These issues wer found by sparse: drivers/st/clk/stm32mp1_clk.c:1524:19: warning: incorrect type in assignment (different base types) expected restricted fdt32_t const [usertype] *pkcs_cell got unsigned int const [usertype] * plat/st/stm32mp1/plat_image_load.c:13:6: warning: symbol 'plat_flush_next_bl_params' was not declared. Should it be static? plat/st/stm32mp1/plat_image_load.c:21:16: warning: symbol 'plat_get_bl_image_load_info' was not declared. Should it be static? plat/st/stm32mp1/plat_image_load.c:29:13: warning: symbol 'plat_get_next_bl_params' was not declared. Should it be static? plat/st/stm32mp1/bl2_io_storage.c:40:10: warning: symbol 'block_buffer' was not declared. Should it be static? Signed-off-by: Yann Gautier --- drivers/st/clk/stm32mp1_clk.c | 4 ++-- drivers/st/clk/stm32mp1_clkfunc.c | 6 +++--- include/drivers/st/stm32mp1_clkfunc.h | 3 ++- plat/st/stm32mp1/bl2_io_storage.c | 2 +- plat/st/stm32mp1/plat_image_load.c | 1 + 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/st/clk/stm32mp1_clk.c b/drivers/st/clk/stm32mp1_clk.c index f0bf363e2..b8457cb37 100644 --- a/drivers/st/clk/stm32mp1_clk.c +++ b/drivers/st/clk/stm32mp1_clk.c @@ -1323,7 +1323,7 @@ int stm32mp1_clk_init(void) int ret, len; enum stm32mp1_pll_id i; bool lse_css = false; - const uint32_t *pkcs_cell; + const fdt32_t *pkcs_cell; /* Check status field to disable security */ if (!fdt_get_rcc_secure_status()) { @@ -1529,7 +1529,7 @@ int stm32mp1_clk_init(void) priv->pkcs_usb_value = 0; for (j = 0; j < ((uint32_t)len / sizeof(uint32_t)); j++) { - uint32_t pkcs = (uint32_t)fdt32_to_cpu(pkcs_cell[j]); + uint32_t pkcs = fdt32_to_cpu(pkcs_cell[j]); if (pkcs == (uint32_t)CLK_CKPER_DISABLED) { ckper_disabled = true; diff --git a/drivers/st/clk/stm32mp1_clkfunc.c b/drivers/st/clk/stm32mp1_clkfunc.c index d4c69cb4e..078d803e7 100644 --- a/drivers/st/clk/stm32mp1_clkfunc.c +++ b/drivers/st/clk/stm32mp1_clkfunc.c @@ -265,11 +265,11 @@ int fdt_rcc_subnode_offset(const char *name) * This function gets the pointer to a rcc-clk property from its name. * It reads the values indicated inside the device tree. * Length of the property is stored in the second parameter. - * Returns pointer if success, and NULL value else. + * Returns pointer on success, and NULL value on failure. ******************************************************************************/ -const uint32_t *fdt_rcc_read_prop(const char *prop_name, int *lenp) +const fdt32_t *fdt_rcc_read_prop(const char *prop_name, int *lenp) { - const uint32_t *cuint; + const fdt32_t *cuint; int node, len; void *fdt; diff --git a/include/drivers/st/stm32mp1_clkfunc.h b/include/drivers/st/stm32mp1_clkfunc.h index b11ccf860..2467af9bb 100644 --- a/include/drivers/st/stm32mp1_clkfunc.h +++ b/include/drivers/st/stm32mp1_clkfunc.h @@ -7,6 +7,7 @@ #ifndef STM32MP1_CLKFUNC_H #define STM32MP1_CLKFUNC_H +#include #include enum stm32mp_osc_id { @@ -33,7 +34,7 @@ uint32_t fdt_rcc_read_addr(void); int fdt_rcc_read_uint32_array(const char *prop_name, uint32_t *array, uint32_t count); int fdt_rcc_subnode_offset(const char *name); -const uint32_t *fdt_rcc_read_prop(const char *prop_name, int *lenp); +const fdt32_t *fdt_rcc_read_prop(const char *prop_name, int *lenp); bool fdt_get_rcc_secure_status(void); uintptr_t fdt_get_stgen_base(void); diff --git a/plat/st/stm32mp1/bl2_io_storage.c b/plat/st/stm32mp1/bl2_io_storage.c index 9a023124c..fdbd4bfd0 100644 --- a/plat/st/stm32mp1/bl2_io_storage.c +++ b/plat/st/stm32mp1/bl2_io_storage.c @@ -37,7 +37,7 @@ static io_block_spec_t gpt_block_spec = { .length = 34 * MMC_BLOCK_SIZE, /* Size of GPT table */ }; -uint32_t block_buffer[MMC_BLOCK_SIZE] __aligned(MMC_BLOCK_SIZE); +static uint32_t block_buffer[MMC_BLOCK_SIZE] __aligned(MMC_BLOCK_SIZE); static const io_block_dev_spec_t mmc_block_dev_spec = { /* It's used as temp buffer in block driver */ diff --git a/plat/st/stm32mp1/plat_image_load.c b/plat/st/stm32mp1/plat_image_load.c index 3c6d677a0..d5b328e3c 100644 --- a/plat/st/stm32mp1/plat_image_load.c +++ b/plat/st/stm32mp1/plat_image_load.c @@ -5,6 +5,7 @@ */ #include +#include /******************************************************************************* * This function flushes the data structures so that they are visible From 7227d89215d29992a9999cb8af5fa36f99eeb5c2 Mon Sep 17 00:00:00 2001 From: Yann Gautier Date: Fri, 9 Nov 2018 17:47:34 +0100 Subject: [PATCH 4/4] stm32mp1: remove duplicate function declaration It is already in include/drivers/st/stm32mp1_ddr_helpers.h. Signed-off-by: Yann Gautier --- include/drivers/st/stm32mp1_ddr_regs.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/drivers/st/stm32mp1_ddr_regs.h b/include/drivers/st/stm32mp1_ddr_regs.h index 9598d9ba5..288e072d2 100644 --- a/include/drivers/st/stm32mp1_ddr_regs.h +++ b/include/drivers/st/stm32mp1_ddr_regs.h @@ -408,6 +408,4 @@ struct stm32mp1_ddrphy { #define DDRPHYC_DXNDLLCR_SDPHASE_MASK GENMASK(17, 14) #define DDRPHYC_DXNDLLCR_SDPHASE_SHIFT 14 -void ddr_enable_clock(void); - #endif /* STM32MP1_DDR_REGS_H */