Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] dma: ste_dma40: fix unneeded variable warning
@ 2019-07-12  9:13 Arnd Bergmann
  2019-07-12 17:39 ` Nathan Chancellor
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Arnd Bergmann @ 2019-07-12  9:13 UTC (permalink / raw)
  To: Linus Walleij, Vinod Koul
  Cc: dmaengine, clang-built-linux, linux-arm-kernel, Arnd Bergmann,
	linux-kernel

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(-)

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,
-- 
2.20.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] dma: ste_dma40: fix unneeded variable warning
  2019-07-12  9:13 [PATCH] dma: ste_dma40: fix unneeded variable warning Arnd Bergmann
@ 2019-07-12 17:39 ` Nathan Chancellor
  2019-07-12 19:16   ` Nick Desaulniers
  2019-07-17 16:44 ` Linus Walleij
  2019-07-22 14:24 ` Vinod Koul
  2 siblings, 1 reply; 6+ messages in thread
From: Nathan Chancellor @ 2019-07-12 17:39 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Linus Walleij, linux-kernel, clang-built-linux, Vinod Koul,
	dmaengine, linux-arm-kernel

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>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] dma: ste_dma40: fix unneeded variable warning
  2019-07-12 17:39 ` Nathan Chancellor
@ 2019-07-12 19:16   ` Nick Desaulniers
  2019-07-12 20:32     ` Arnd Bergmann
  0 siblings, 1 reply; 6+ messages in thread
From: Nick Desaulniers @ 2019-07-12 19:16 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Arnd Bergmann, Linus Walleij, LKML, clang-built-linux,
	Vinod Koul, dmaengine, Linux ARM

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?

-- 
Thanks,
~Nick Desaulniers

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] dma: ste_dma40: fix unneeded variable warning
  2019-07-12 19:16   ` Nick Desaulniers
@ 2019-07-12 20:32     ` Arnd Bergmann
  0 siblings, 0 replies; 6+ messages in thread
From: Arnd Bergmann @ 2019-07-12 20:32 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Linus Walleij, LKML, clang-built-linux, Vinod Koul, dmaengine,
	Nathan Chancellor, Linux ARM

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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] dma: ste_dma40: fix unneeded variable warning
  2019-07-12  9:13 [PATCH] dma: ste_dma40: fix unneeded variable warning Arnd Bergmann
  2019-07-12 17:39 ` Nathan Chancellor
@ 2019-07-17 16:44 ` Linus Walleij
  2019-07-22 14:24 ` Vinod Koul
  2 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2019-07-17 16:44 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: dmaengine, clang-built-linux, Vinod Koul, linux-kernel, Linux ARM

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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] dma: ste_dma40: fix unneeded variable warning
  2019-07-12  9:13 [PATCH] dma: ste_dma40: fix unneeded variable warning Arnd Bergmann
  2019-07-12 17:39 ` Nathan Chancellor
  2019-07-17 16:44 ` Linus Walleij
@ 2019-07-22 14:24 ` Vinod Koul
  2 siblings, 0 replies; 6+ messages in thread
From: Vinod Koul @ 2019-07-22 14:24 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: dmaengine, clang-built-linux, Linus Walleij, linux-kernel,
	linux-arm-kernel

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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, back to index

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-12  9:13 [PATCH] dma: ste_dma40: fix unneeded variable warning Arnd Bergmann
2019-07-12 17:39 ` Nathan Chancellor
2019-07-12 19:16   ` Nick Desaulniers
2019-07-12 20:32     ` Arnd Bergmann
2019-07-17 16:44 ` Linus Walleij
2019-07-22 14:24 ` Vinod Koul

Linux-ARM-Kernel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-arm-kernel/0 linux-arm-kernel/git/0.git
	git clone --mirror https://lore.kernel.org/linux-arm-kernel/1 linux-arm-kernel/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-arm-kernel linux-arm-kernel/ https://lore.kernel.org/linux-arm-kernel \
		linux-arm-kernel@lists.infradead.org infradead-linux-arm-kernel@archiver.kernel.org
	public-inbox-index linux-arm-kernel


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-arm-kernel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox