I just stopped by the ugly variable name, ________addr.
(8 underscores!)
If this is just a matter of casting to (unsigned long), this variable
is unneeded since you can do like this:
({ \
__set_fixmap(idx, phys, flags); \
(unsigned long)(fix_to_virt(idx) + ((phys) & (PAGE_SIZE - 1))); \
})
However, I'd rather like to change it to an inline function since it
is more readable, and the parameter types are clearer.
Signed-off-by: Masahiro Yamada <[email protected]>
---
include/asm-generic/fixmap.h | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/include/asm-generic/fixmap.h b/include/asm-generic/fixmap.h
index 8cc7b09c1bc7..de4c36912529 100644
--- a/include/asm-generic/fixmap.h
+++ b/include/asm-generic/fixmap.h
@@ -70,14 +70,14 @@ static inline unsigned long virt_to_fix(const unsigned long vaddr)
__set_fixmap(idx, 0, FIXMAP_PAGE_CLEAR)
#endif
-/* Return a pointer with offset calculated */
-#define __set_fixmap_offset(idx, phys, flags) \
-({ \
- unsigned long ________addr; \
- __set_fixmap(idx, phys, flags); \
- ________addr = fix_to_virt(idx) + ((phys) & (PAGE_SIZE - 1)); \
- ________addr; \
-})
+/* Return a virtual address with offset calculated */
+static inline unsigned long __set_fixmap_offset(enum fixed_addresses idx,
+ phys_addr_t phys,
+ pgprot_t flags)
+{
+ __set_fixmap(idx, phys, flags);
+ return fix_to_virt(idx) + ((phys) & (PAGE_SIZE - 1));
+}
#define set_fixmap_offset(idx, phys) \
__set_fixmap_offset(idx, phys, FIXMAP_PAGE_NORMAL)
--
2.17.1
Hi Masahiro,
I love your patch! Perhaps something to improve:
[auto build test WARNING on mmotm/master]
[also build test WARNING on v5.4-rc6 next-20191108]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Masahiro-Yamada/mm-fixmap-convert-__set_fixmap_offset-to-an-inline-function/20191110-045158
base: git://git.cmpxchg.org/linux-mmotm.git master
config: powerpc-allnoconfig (attached as .config)
compiler: powerpc-linux-gcc (GCC) 7.4.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=powerpc
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <[email protected]>
All warnings (new ones prefixed by >>):
In file included from arch/powerpc/include/asm/fixmap.h:75:0,
from arch/powerpc/include/asm/book3s/32/pgtable.h:149,
from arch/powerpc/include/asm/book3s/pgtable.h:8,
from arch/powerpc/include/asm/pgtable.h:18,
from arch/powerpc/include/asm/kup.h:30,
from arch/powerpc/include/asm/uaccess.h:9,
from include/linux/uaccess.h:11,
from include/linux/crypto.h:21,
from include/crypto/hash.h:11,
from include/linux/uio.h:10,
from include/linux/socket.h:8,
from include/linux/compat.h:15,
from arch/powerpc/kernel/asm-offsets.c:14:
include/asm-generic/fixmap.h: In function '__set_fixmap_offset':
include/asm-generic/fixmap.h:78:2: error: implicit declaration of function '__set_fixmap'; did you mean 'set_fixmap'? [-Werror=implicit-function-declaration]
__set_fixmap(idx, phys, flags);
^~~~~~~~~~~~
set_fixmap
In file included from arch/powerpc/include/asm/book3s/32/pgtable.h:149:0,
from arch/powerpc/include/asm/book3s/pgtable.h:8,
from arch/powerpc/include/asm/pgtable.h:18,
from arch/powerpc/include/asm/kup.h:30,
from arch/powerpc/include/asm/uaccess.h:9,
from include/linux/uaccess.h:11,
from include/linux/crypto.h:21,
from include/crypto/hash.h:11,
from include/linux/uio.h:10,
from include/linux/socket.h:8,
from include/linux/compat.h:15,
from arch/powerpc/kernel/asm-offsets.c:14:
arch/powerpc/include/asm/fixmap.h: At top level:
>> arch/powerpc/include/asm/fixmap.h:77:20: warning: conflicting types for '__set_fixmap'
static inline void __set_fixmap(enum fixed_addresses idx,
^~~~~~~~~~~~
arch/powerpc/include/asm/fixmap.h:77:20: error: static declaration of '__set_fixmap' follows non-static declaration
In file included from arch/powerpc/include/asm/fixmap.h:75:0,
from arch/powerpc/include/asm/book3s/32/pgtable.h:149,
from arch/powerpc/include/asm/book3s/pgtable.h:8,
from arch/powerpc/include/asm/pgtable.h:18,
from arch/powerpc/include/asm/kup.h:30,
from arch/powerpc/include/asm/uaccess.h:9,
from include/linux/uaccess.h:11,
from include/linux/crypto.h:21,
from include/crypto/hash.h:11,
from include/linux/uio.h:10,
from include/linux/socket.h:8,
from include/linux/compat.h:15,
from arch/powerpc/kernel/asm-offsets.c:14:
include/asm-generic/fixmap.h:78:2: note: previous implicit declaration of '__set_fixmap' was here
__set_fixmap(idx, phys, flags);
^~~~~~~~~~~~
cc1: some warnings being treated as errors
make[2]: *** [arch/powerpc/kernel/asm-offsets.s] Error 1
make[2]: Target '__build' not remade because of errors.
make[1]: *** [prepare0] Error 2
make[1]: Target 'prepare' not remade because of errors.
make: *** [sub-make] Error 2
17 real 5 user 2 sys 44.62% cpu make prepare
vim +/__set_fixmap +77 arch/powerpc/include/asm/fixmap.h
2c419bdeca1d95 include/asm-powerpc/fixmap.h Kumar Gala 2008-04-23 76
4cfac2f9c7f116 arch/powerpc/include/asm/fixmap.h Christophe Leroy 2017-08-02 @77 static inline void __set_fixmap(enum fixed_addresses idx,
4cfac2f9c7f116 arch/powerpc/include/asm/fixmap.h Christophe Leroy 2017-08-02 78 phys_addr_t phys, pgprot_t flags)
4cfac2f9c7f116 arch/powerpc/include/asm/fixmap.h Christophe Leroy 2017-08-02 79 {
c766ee72235d09 arch/powerpc/include/asm/fixmap.h Christophe Leroy 2018-10-09 80 map_kernel_page(fix_to_virt(idx), phys, flags);
4cfac2f9c7f116 arch/powerpc/include/asm/fixmap.h Christophe Leroy 2017-08-02 81 }
4cfac2f9c7f116 arch/powerpc/include/asm/fixmap.h Christophe Leroy 2017-08-02 82
:::::: The code at line 77 was first introduced by commit
:::::: 4cfac2f9c7f116af8516d0b3d0e7383189eca376 powerpc/mm: Simplify __set_fixmap()
:::::: TO: Christophe Leroy <[email protected]>
:::::: CC: Michael Ellerman <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/[email protected] Intel Corporation
Hi Masahiro,
I love your patch! Yet something to improve:
[auto build test ERROR on mmotm/master]
[also build test ERROR on v5.4-rc6 next-20191108]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Masahiro-Yamada/mm-fixmap-convert-__set_fixmap_offset-to-an-inline-function/20191110-045158
base: git://git.cmpxchg.org/linux-mmotm.git master
config: powerpc-defconfig (attached as .config)
compiler: powerpc64-linux-gcc (GCC) 7.4.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=powerpc
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <[email protected]>
All errors (new ones prefixed by >>):
In file included from arch/powerpc/include/asm/fixmap.h:75:0,
from arch/powerpc/mm/mem.c:48:
include/asm-generic/fixmap.h: In function '__set_fixmap_offset':
include/asm-generic/fixmap.h:78:2: error: implicit declaration of function '__set_fixmap'; did you mean 'set_fixmap'? [-Werror=implicit-function-declaration]
__set_fixmap(idx, phys, flags);
^~~~~~~~~~~~
set_fixmap
In file included from arch/powerpc/mm/mem.c:48:0:
arch/powerpc/include/asm/fixmap.h: At top level:
arch/powerpc/include/asm/fixmap.h:77:20: error: conflicting types for '__set_fixmap' [-Werror]
static inline void __set_fixmap(enum fixed_addresses idx,
^~~~~~~~~~~~
>> arch/powerpc/include/asm/fixmap.h:77:20: error: static declaration of '__set_fixmap' follows non-static declaration
In file included from arch/powerpc/include/asm/fixmap.h:75:0,
from arch/powerpc/mm/mem.c:48:
include/asm-generic/fixmap.h:78:2: note: previous implicit declaration of '__set_fixmap' was here
__set_fixmap(idx, phys, flags);
^~~~~~~~~~~~
cc1: all warnings being treated as errors
vim +/__set_fixmap +77 arch/powerpc/include/asm/fixmap.h
2c419bdeca1d95 include/asm-powerpc/fixmap.h Kumar Gala 2008-04-23 76
4cfac2f9c7f116 arch/powerpc/include/asm/fixmap.h Christophe Leroy 2017-08-02 @77 static inline void __set_fixmap(enum fixed_addresses idx,
4cfac2f9c7f116 arch/powerpc/include/asm/fixmap.h Christophe Leroy 2017-08-02 78 phys_addr_t phys, pgprot_t flags)
4cfac2f9c7f116 arch/powerpc/include/asm/fixmap.h Christophe Leroy 2017-08-02 79 {
c766ee72235d09 arch/powerpc/include/asm/fixmap.h Christophe Leroy 2018-10-09 80 map_kernel_page(fix_to_virt(idx), phys, flags);
4cfac2f9c7f116 arch/powerpc/include/asm/fixmap.h Christophe Leroy 2017-08-02 81 }
4cfac2f9c7f116 arch/powerpc/include/asm/fixmap.h Christophe Leroy 2017-08-02 82
:::::: The code at line 77 was first introduced by commit
:::::: 4cfac2f9c7f116af8516d0b3d0e7383189eca376 powerpc/mm: Simplify __set_fixmap()
:::::: TO: Christophe Leroy <[email protected]>
:::::: CC: Michael Ellerman <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/[email protected] Intel Corporation
Hi Andrew,
On Fri, Nov 8, 2019 at 9:42 PM Masahiro Yamada
<[email protected]> wrote:
>
> I just stopped by the ugly variable name, ________addr.
> (8 underscores!)
>
> If this is just a matter of casting to (unsigned long), this variable
> is unneeded since you can do like this:
>
> ({ \
> __set_fixmap(idx, phys, flags); \
> (unsigned long)(fix_to_virt(idx) + ((phys) & (PAGE_SIZE - 1))); \
> })
>
> However, I'd rather like to change it to an inline function since it
> is more readable, and the parameter types are clearer.
>
> Signed-off-by: Masahiro Yamada <[email protected]>
Unfortunately, this patch broke building ppc, mips, etc.
(Not all arch implement __set_fixmap)
Could you drop it from your tree?
Thanks.
--
Best Regards
Masahiro Yamada