dma: ste_dma40: fix unneeded variable warning
Subsystems (2)
PATCH 1/1 dma: ste_dma40: fix unneeded variable warning
clang-9 points out that there are two variables that depending on the configuration may only be used in an ARRAY_SIZE() expression but not referenced:
drivers/dma/ste_dma40.c:145:12: error: variable 'd40_backup_regs' is not needed and will not be emitted [-Werror,-Wunneeded-internal-declaration]
static u32 d40_backup_regs[] = {
^drivers/dma/ste_dma40.c:214:12: error: variable 'd40_backup_regs_chan' is not needed and will not be emitted [-Werror,-Wunneeded-internal-declaration] static u32 d40_backup_regs_chan[] = {
Mark these __maybe_unused to shut up the warning.
--- drivers/dma/ste_dma40.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/dma/ste_dma40.c +2 -2
@@ -142,7 +142,7 @@ enum d40_events {* when the DMA hw is powered off. * TODO: Add save/restore of D40_DREG_GCC on dma40 v3 or later, if that works. */ -static u32 d40_backup_regs[] = { +static __maybe_unused u32 d40_backup_regs[] = {D40_DREG_LCPA ,D40_DREG_LCLA ,D40_DREG_PRMSE ,
@@ -211,7 +211,7 @@ static u32 d40_backup_regs_v4b[] = {#define BACKUP_REGS_SZ_V4B ARRAY_SIZE(d40_backup_regs_v4b) -static u32 d40_backup_regs_chan[] = { +static __maybe_unused u32 d40_backup_regs_chan[] = {D40_CHAN_REG_SSCFG ,D40_CHAN_REG_SSELT ,D40_CHAN_REG_SSPTR ,
Signature · 1 line
2.20.0
Quoted 5 lines · Arnd Bergmann
clang-9 points out that there are two variables that depending on the configuration may only be used in an
ARRAY_SIZE()expression but not referenced:
drivers/dma/ste_dma40.c:145:12: error: variable 'd40_backup_regs' is not needed and will not be emitted [-Werror,-Wunneeded-internal-declaration]
Quoted 8 lines
static u32 d40_backup_regs[] = { ^
drivers/dma/ste_dma40.c:214:12: error: variable 'd40_backup_regs_chan' is not needed and will not be emitted [-Werror,-Wunneeded-internal-declaration] static u32 d40_backup_regs_chan[] = {Mark these
__maybe_unusedto shut up the warning.Signed-off-by Arnd Bergmann <[email protected]>
Might be worth mentioning that this warning will only appear when CONFIG_PM is unset (they are both used in d40_save_restore_registers).
Quoted 12 lines · Nathan Chancellor
Quoted 10 lines · Arnd Bergmann
clang-9 points out that there are two variables that depending on the configuration may only be used in an
ARRAY_SIZE()expression but not referenced:
drivers/dma/ste_dma40.c:145:12: error: variable 'd40_backup_regs' is not needed and will not be emitted [-Werror,-Wunneeded-internal-declaration]static u32 d40_backup_regs[] = { ^
drivers/dma/ste_dma40.c:214:12: error: variable 'd40_backup_regs_chan' is not needed and will not be emitted [-Werror,-Wunneeded-internal-declaration] static u32 d40_backup_regs_chan[] = {
Quoted 3 lines
Quoted 3 lines
Mark these
__maybe_unusedto shut up the warning.Signed-off-by Arnd Bergmann <[email protected]>
Thanks for the patch!
Quoted 3 lines
Might be worth mentioning that this warning will only appear when
CONFIG_PMis unset (they are both used ind40_save_restore_registers).
So would moving the definition into a
#ifdef CONFIG_PM
#endif
block be better than __maybe_unused?
Signature · 2 lines
Thanks, ~Nick Desaulniers
Quoted 22 lines · Nick Desaulniers' via Clang Built Linux
Quoted 12 lines · Nathan Chancellor
Quoted 10 lines · Arnd Bergmann
clang-9 points out that there are two variables that depending on the configuration may only be used in an
ARRAY_SIZE()expression but not referenced:
drivers/dma/ste_dma40.c:145:12: error: variable 'd40_backup_regs' is not needed and will not be emitted [-Werror,-Wunneeded-internal-declaration]static u32 d40_backup_regs[] = { ^
drivers/dma/ste_dma40.c:214:12: error: variable 'd40_backup_regs_chan' is not needed and will not be emitted [-Werror,-Wunneeded-internal-declaration] static u32 d40_backup_regs_chan[] = {Quoted 3 lines
Quoted 3 lines
Mark these
__maybe_unusedto shut up the warning.Signed-off-by Arnd Bergmann <[email protected]>Thanks for the patch!
Quoted 1 line
Quoted 8 lines
Quoted 2 lines
Might be worth mentioning that this warning will only appear when
CONFIG_PMis unset (they are both used ind40_save_restore_registers).So would moving the definition into a
#ifdefCONFIG_PM
#endif
block be better than__maybe_unused?
That would not work here, since the driver still uses ARRAY_SIZE() on the variable.
Even more #ifdefs could solve that as well, but I don't want to spend too much effort on this driver since it has almost no users.
Arnd
Quoted 5 lines · Arnd Bergmann
clang-9 points out that there are two variables that depending on the configuration may only be used in an
ARRAY_SIZE()expression but not referenced:
drivers/dma/ste_dma40.c:145:12: error: variable 'd40_backup_regs' is not needed and will not be emitted [-Werror,-Wunneeded-internal-declaration]
Quoted 8 lines
static u32 d40_backup_regs[] = { ^
drivers/dma/ste_dma40.c:214:12: error: variable 'd40_backup_regs_chan' is not needed and will not be emitted [-Werror,-Wunneeded-internal-declaration] static u32 d40_backup_regs_chan[] = {Mark these
__maybe_unusedto shut up the warning.Signed-off-by Arnd Bergmann <[email protected]>
Seems like a reasonable fix:
Yours,
Linus Walleij
Quoted 11 lines · Arnd Bergmann
clang-9 points out that there are two variables that depending on the configuration may only be used in an
ARRAY_SIZE()expression but not referenced:
drivers/dma/ste_dma40.c:145:12: error: variable 'd40_backup_regs' is not needed and will not be emitted [-Werror,-Wunneeded-internal-declaration]static u32 d40_backup_regs[] = { ^
drivers/dma/ste_dma40.c:214:12: error: variable 'd40_backup_regs_chan' is not needed and will not be emitted [-Werror,-Wunneeded-internal-declaration] static u32 d40_backup_regs_chan[] = {Mark these
__maybe_unusedto shut up the warning.
Applied, thanks
Signature · 1 line
~Vinod