Skip to content

Commit 9c94c14

Browse files
visitorckwIngo Molnar
authored andcommitted
x86/bootflag: Replace open-coded parity calculation with parity8()
Refactor parity calculations to use the standard parity8() helper. This change eliminates redundant implementations and improves code efficiency. [ ubizjak: Updated the patch to apply to the latest x86 tree. ] Co-developed-by: Yu-Chun Lin <eleanor15x@gmail.com> Signed-off-by: Yu-Chun Lin <eleanor15x@gmail.com> Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com> Signed-off-by: Uros Bizjak <ubizjak@gmail.com> Signed-off-by: Ingo Molnar <mingo@kernel.org> Cc: "H. Peter Anvin" <hpa@zytor.com> Link: https://lore.kernel.org/r/20250227125616.2253774-1-ubizjak@gmail.com
1 parent adf6819 commit 9c94c14

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

arch/x86/kernel/bootflag.c

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <linux/string.h>
99
#include <linux/spinlock.h>
1010
#include <linux/acpi.h>
11+
#include <linux/bitops.h>
1112
#include <asm/io.h>
1213

1314
#include <linux/mc146818rtc.h>
@@ -20,25 +21,12 @@
2021

2122
int sbf_port __initdata = -1; /* set via acpi_boot_init() */
2223

23-
static bool __init parity(u8 v)
24-
{
25-
int x = 0;
26-
int i;
27-
28-
for (i = 0; i < 8; i++) {
29-
x ^= (v & 1);
30-
v >>= 1;
31-
}
32-
33-
return !!x;
34-
}
35-
3624
static void __init sbf_write(u8 v)
3725
{
3826
unsigned long flags;
3927

4028
if (sbf_port != -1) {
41-
if (!parity(v))
29+
if (!parity8(v))
4230
v ^= SBF_PARITY;
4331

4432
printk(KERN_INFO "Simple Boot Flag at 0x%x set to 0x%x\n",
@@ -69,7 +57,7 @@ static bool __init sbf_value_valid(u8 v)
6957
{
7058
if (v & SBF_RESERVED) /* Reserved bits */
7159
return false;
72-
if (!parity(v))
60+
if (!parity8(v))
7361
return false;
7462

7563
return true;

0 commit comments

Comments
 (0)