Skip to contentSkip to conversation

serial: max3100: Replace open-coded parity calculation with parity8()

PATCH New Kuan-Wei Chiu 1 participant 1 message May 15, 2025 TTY layer and serial drivers

lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 serial: max3100: Replace open-coded parity calculation with parity8()

Refactor parity calculations to use the standard parity8() helper. This change eliminates redundant implementations.

---
Changes in v5:
- Dropped changes to bitops.h
- Switched to using existing parity8()
- Split parity8() conversion patch out of the series

 drivers/tty/serial/max3100.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/tty/serial/max3100.c +2 -1
index f2dd83692b2c..d28a2ebfa29f 100644
@@ -16,6 +16,7 @@
 /* 4 MAX3100s should be enough for everyone */
 #define MAX_MAX3100 4
 
+#include <linux/bitops.h>
 #include <linux/container_of.h>
 #include <linux/delay.h>
 #include <linux/device.h>
@@ -133,7 +134,7 @@ static int max3100_do_parity(struct max3100_port *s, u16 c)
 	else
 		c &= 0xff;
 
-	parity = parity ^ (hweight8(c) & 1);
+	parity = parity ^ parity8(c);
 	return parity;
 }
 
Signature · 1 line
2.34.1