Skip to contentSkip to conversation

dma: ste_dma40: fix unneeded variable warning

PATCH Applied Arnd Bergmann 5 participants 6 messages Jul 12, 2019 – Jul 22, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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
index 89d710899010..de8bfd9a76e9 100644
@@ -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
Reviewed-by on v1 1/1
#1 lore raw
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_unused to shut up the warning.

Might be worth mentioning that this warning will only appear when CONFIG_PM is unset (they are both used in d40_save_restore_registers).

#2 lore raw
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_unused to shut up the warning.

Thanks for the patch!

Quoted 3 lines

Might be worth mentioning that this warning will only appear when CONFIG_PM is unset (they are both used in d40_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
#3 lore raw
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_unused to shut up the warning.

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_PM is unset (they are both used in d40_save_restore_registers).

So would moving the definition into a
#ifdef CONFIG_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

Reviewed-by on v1 1/1
#4 lore raw
In reply to Arnd Bergmann
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_unused to shut up the warning.

Seems like a reasonable fix:

Yours,
Linus Walleij

maintainer Applied
#5 lore raw
In reply to Arnd Bergmann
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_unused to shut up the warning.

Applied, thanks

Signature · 1 line
~Vinod