diff mbox series

dma: ste_dma40: fix unneeded variable warning

Message ID 20190712091357.744515-1-arnd@arndb.de
State Accepted
Commit 5d6fb560729a5d5554e23db8d00eb57cd0021083
Headers show
Series dma: ste_dma40: fix unneeded variable warning | expand

Commit Message

Arnd Bergmann July 12, 2019, 9:13 a.m. UTC
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.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>

---
 drivers/dma/ste_dma40.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

-- 
2.20.0

Comments

Nathan Chancellor July 12, 2019, 5:39 p.m. UTC | #1
On Fri, Jul 12, 2019 at 11:13:30AM +0200, Arnd Bergmann wrote:
> 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.

> 

> Signed-off-by: Arnd Bergmann <arnd@arndb.de>


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

Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
Arnd Bergmann July 12, 2019, 8:32 p.m. UTC | #2
On Fri, Jul 12, 2019 at 9:17 PM 'Nick Desaulniers' via Clang Built
Linux <clang-built-linux@googlegroups.com> wrote:
>

> On Fri, Jul 12, 2019 at 10:39 AM Nathan Chancellor

> <natechancellor@gmail.com> wrote:

> >

> > On Fri, Jul 12, 2019 at 11:13:30AM +0200, Arnd Bergmann wrote:

> > > 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.

> > >

> > > Signed-off-by: Arnd Bergmann <arnd@arndb.de>

>

> Thanks for the patch!

>

> >

> > 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
Linus Walleij July 17, 2019, 4:44 p.m. UTC | #3
On Fri, Jul 12, 2019 at 11:14 AM Arnd Bergmann <arnd@arndb.de> wrote:

> 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.

>

> Signed-off-by: Arnd Bergmann <arnd@arndb.de>


Seems like a reasonable fix:
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>


Yours,
Linus Walleij
Vinod Koul July 22, 2019, 2:24 p.m. UTC | #4
On 12-07-19, 11:13, Arnd Bergmann wrote:
> 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

-- 
~Vinod
diff mbox series

Patch

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index 89d710899010..de8bfd9a76e9 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -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,