]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
media: media/test_drivers: Replace open-coded parity calculation with parity8()
authorKuan-Wei Chiu <visitorckw@gmail.com>
Thu, 15 May 2025 08:07:48 +0000 (16:07 +0800)
committerHans Verkuil <hverkuil@xs4all.nl>
Tue, 17 Jun 2025 08:51:35 +0000 (10:51 +0200)
Refactor parity calculations to use the standard parity8() helper.
This change eliminates redundant implementations.

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>
Reviewed-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
drivers/media/test-drivers/vivid/vivid-vbi-gen.c

index 70a4024d461e3a263d8dcac39049d2c843d4cc81..e0f4151bda18a8ed86c7246d5adfbc096901c3ef 100644 (file)
@@ -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)