From: Kuan-Wei Chiu Date: Thu, 15 May 2025 08:07:48 +0000 (+0800) Subject: media: media/test_drivers: Replace open-coded parity calculation with parity8() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=47e0452b40af6bf821a96e34d95fd5915fe4c7a6;p=thirdparty%2Flinux.git 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. Co-developed-by: Yu-Chun Lin Signed-off-by: Yu-Chun Lin Signed-off-by: Kuan-Wei Chiu Reviewed-by: Hans Verkuil Signed-off-by: Hans Verkuil --- diff --git a/drivers/media/test-drivers/vivid/vivid-vbi-gen.c b/drivers/media/test-drivers/vivid/vivid-vbi-gen.c index 70a4024d461e3..e0f4151bda18a 100644 --- a/drivers/media/test-drivers/vivid/vivid-vbi-gen.c +++ b/drivers/media/test-drivers/vivid/vivid-vbi-gen.c @@ -5,6 +5,7 @@ * Copyright 2014 Cisco Systems, Inc. and/or its affiliates. All rights reserved. */ +#include #include #include #include @@ -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)