Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: Simplify __bswapdi2() and __bswapsi2()

Use macro definitions ___constant_swab64 and ___constant_swab32
to simplify __bswapdi2() and __bswapsi2().

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>

authored by

Tiezhu Yang and committed by
Thomas Bogendoerfer
8e6ec6ce 06689517

+4 -12
+2 -8
arch/mips/lib/bswapdi.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 #include <linux/export.h> 3 3 #include <linux/compiler.h> 4 + #include <uapi/linux/swab.h> 4 5 5 6 /* To silence -Wmissing-prototypes. */ 6 7 unsigned long long __bswapdi2(unsigned long long u); 7 8 8 9 unsigned long long notrace __bswapdi2(unsigned long long u) 9 10 { 10 - return (((u) & 0xff00000000000000ull) >> 56) | 11 - (((u) & 0x00ff000000000000ull) >> 40) | 12 - (((u) & 0x0000ff0000000000ull) >> 24) | 13 - (((u) & 0x000000ff00000000ull) >> 8) | 14 - (((u) & 0x00000000ff000000ull) << 8) | 15 - (((u) & 0x0000000000ff0000ull) << 24) | 16 - (((u) & 0x000000000000ff00ull) << 40) | 17 - (((u) & 0x00000000000000ffull) << 56); 11 + return ___constant_swab64(u); 18 12 } 19 13 EXPORT_SYMBOL(__bswapdi2);
+2 -4
arch/mips/lib/bswapsi.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 #include <linux/export.h> 3 3 #include <linux/compiler.h> 4 + #include <uapi/linux/swab.h> 4 5 5 6 /* To silence -Wmissing-prototypes. */ 6 7 unsigned int __bswapsi2(unsigned int u); 7 8 8 9 unsigned int notrace __bswapsi2(unsigned int u) 9 10 { 10 - return (((u) & 0xff000000) >> 24) | 11 - (((u) & 0x00ff0000) >> 8) | 12 - (((u) & 0x0000ff00) << 8) | 13 - (((u) & 0x000000ff) << 24); 11 + return ___constant_swab32(u); 14 12 } 15 13 EXPORT_SYMBOL(__bswapsi2);