Skip to contentSkip to conversation

media: media/test_drivers: Replace open-coded parity calculation with parity8()

PATCH New Kuan-Wei Chiu 1 participant 1 message May 15, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 media: media/test_drivers: 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/media/test-drivers/vivid/vivid-vbi-gen.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/media/test-drivers/vivid/vivid-vbi-gen.c +2 -6
index 70a4024d461e..e0f4151bda18 100644
@@ -5,6 +5,7 @@
  * Copyright 2014 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
  */
 
+#include <linux/bitops.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/ktime.h>
@@ -165,12 +166,7 @@ static const u8 vivid_cc_sequence2[30] = {
 
 static u8 calc_parity(u8 val)
 {
-	unsigned i;
-	unsigned tot = 0;
-
-	for (i = 0; i < 7; i++)
-		tot += (val & (1 << i)) ? 1 : 0;
-	return val | ((tot & 1) ? 0 : 0x80);
+	return val | (parity8(val) ? 0 : 0x80);
 }
 
 static void vivid_vbi_gen_set_time_of_day(u8 *packet)
Signature · 1 line
2.34.1