Skip to content

Commit 8e6ec6c

Browse files
seehearfeeltsbogend
authored andcommitted
MIPS: Simplify __bswapdi2() and __bswapsi2()
Use macro definitions ___constant_swab64 and ___constant_swab32 to simplify __bswapdi2() and __bswapsi2(). Signed-off-by: Tiezhu Yang <[email protected]> Signed-off-by: Thomas Bogendoerfer <[email protected]>
1 parent 0668951 commit 8e6ec6c

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

arch/mips/lib/bswapdi.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
// SPDX-License-Identifier: GPL-2.0
22
#include <linux/export.h>
33
#include <linux/compiler.h>
4+
#include <uapi/linux/swab.h>
45

56
/* To silence -Wmissing-prototypes. */
67
unsigned long long __bswapdi2(unsigned long long u);
78

89
unsigned long long notrace __bswapdi2(unsigned long long u)
910
{
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);
1812
}
1913
EXPORT_SYMBOL(__bswapdi2);

arch/mips/lib/bswapsi.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
// SPDX-License-Identifier: GPL-2.0
22
#include <linux/export.h>
33
#include <linux/compiler.h>
4+
#include <uapi/linux/swab.h>
45

56
/* To silence -Wmissing-prototypes. */
67
unsigned int __bswapsi2(unsigned int u);
78

89
unsigned int notrace __bswapsi2(unsigned int u)
910
{
10-
return (((u) & 0xff000000) >> 24) |
11-
(((u) & 0x00ff0000) >> 8) |
12-
(((u) & 0x0000ff00) << 8) |
13-
(((u) & 0x000000ff) << 24);
11+
return ___constant_swab32(u);
1412
}
1513
EXPORT_SYMBOL(__bswapsi2);

0 commit comments

Comments
 (0)