]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
media: saa7115: Replace open-coded parity calculation with parity8()
authorKuan-Wei Chiu <visitorckw@gmail.com>
Thu, 15 May 2025 08:11:09 +0000 (16:11 +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/i2c/saa7115.c

index a1c71187e773ffd74cb0c0cf57247d65352d507f..b8b8f206ec3a6501d8d7ded98be43a24a0031649 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "saa711x_regs.h"
 
+#include <linux/bitops.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/slab.h>
@@ -664,15 +665,6 @@ static const unsigned char saa7115_init_misc[] = {
        0x00, 0x00
 };
 
-static int saa711x_odd_parity(u8 c)
-{
-       c ^= (c >> 4);
-       c ^= (c >> 2);
-       c ^= (c >> 1);
-
-       return c & 1;
-}
-
 static int saa711x_decode_vps(u8 *dst, u8 *p)
 {
        static const u8 biphase_tbl[] = {
@@ -1227,7 +1219,7 @@ static int saa711x_decode_vbi_line(struct v4l2_subdev *sd, struct v4l2_decode_vb
                vbi->type = V4L2_SLICED_TELETEXT_B;
                break;
        case 4:
-               if (!saa711x_odd_parity(p[0]) || !saa711x_odd_parity(p[1]))
+               if (!parity8(p[0]) || !parity8(p[1]))
                        return 0;
                vbi->type = V4L2_SLICED_CAPTION_525;
                break;