Commit 1638d98052e0d03e46d504b21ec1b88ecfcd87aa

Authored by Masahiro Yamada
Committed by Simon Glass
1 parent 9c38c07008

sandbox: change local_irq_save() to macro

local_irq_save() should be a macro, not a function
because local_irq_save() saves flag to the given argument.

GCC is silent about this issue, but Clang warns:

In file included from lib/asm-offsets.c:15:
In file included from include/common.h:20:
In file included from include/linux/bitops.h:110:
arch/sandbox/include/asm/bitops.h:59:17:
 warning: variable 'flags' is uninitialized when used here
      [-Wuninitialized]
        local_irq_save(flags);
                       ^~~~~

That change causes another warning:

In file included from include/linux/bitops.h:110:0,
                 from include/common.h:20,
                 from lib/asm-offsets.c:15:
arch/sandbox/include/asm/bitops.h: In function ‘test_and_set_bit’:
arch/sandbox/include/asm/bitops.h:56:16: warning: unused variable ‘flags’ [-Wunused-variable]

So, flags should be set to __always_unused.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Jeroen Hofstee <jeroen@myspectrum.nl>
Acked-by: Simon Glass <sjg@chromium.org>
Acked-by: Jeroen Hofstee <jeroen@myspectrum.nl>

Showing 2 changed files with 4 additions and 6 deletions Side-by-side Diff

arch/sandbox/include/asm/bitops.h
... ... @@ -17,6 +17,7 @@
17 17 #ifndef __ASM_SANDBOX_BITOPS_H
18 18 #define __ASM_SANDBOX_BITOPS_H
19 19  
  20 +#include <linux/compiler.h>
20 21 #include <asm/system.h>
21 22  
22 23 #ifdef __KERNEL__
... ... @@ -53,7 +54,7 @@
53 54  
54 55 static inline int test_and_set_bit(int nr, void *addr)
55 56 {
56   - unsigned long flags;
  57 + unsigned long __always_unused flags;
57 58 int out;
58 59  
59 60 local_irq_save(flags);
... ... @@ -75,7 +76,7 @@
75 76  
76 77 static inline int test_and_clear_bit(int nr, void *addr)
77 78 {
78   - unsigned long flags;
  79 + unsigned long __always_unused flags;
79 80 int out;
80 81  
81 82 local_irq_save(flags);
arch/sandbox/include/asm/system.h
... ... @@ -8,10 +8,7 @@
8 8 #define __ASM_SANDBOX_SYSTEM_H
9 9  
10 10 /* Define this as nops for sandbox architecture */
11   -static inline void local_irq_save(unsigned flags __attribute__((unused)))
12   -{
13   -}
14   -
  11 +#define local_irq_save(x)
15 12 #define local_irq_enable()
16 13 #define local_irq_disable()
17 14 #define local_save_flags(x)