Re: [PATCH v4 03/13] media: pci: cx18-av-vbi: Replace open-coded parity calculation with parity_odd()

Hans Verkuil <[email protected]>
Newsgroups dev.linux.lists.brcm80211,org.freedesktop.lists.dri-devel,org.infradead.lists.linux-i3c,org.infradead.lists.linux-mtd,org.kernel.vger.bpf,org.kernel.vger.linux-hwmon,org.kernel.vger.linux-input,org.kernel.vger.linux-kernel,org.kernel.vger.linux-media,org.kernel.vger.linux-serial,org.kernel.vger.linux-wireless,org.kernel.vger.netdev
Message-ID <[email protected]>
On 09/04/2025 20:59, Kuan-Wei Chiu wrote:
> On Wed, Apr 09, 2025 at 08:43:09PM +0200, Arend van Spriel wrote:
>> On 4/9/2025 5:43 PM, Kuan-Wei Chiu wrote:
>>> Refactor parity calculations to use the standard parity_odd() helper.
>>> This change eliminates redundant implementations.
>>>
>>> Co-developed-by: Yu-Chun Lin <[email protected]>
>>> Signed-off-by: Yu-Chun Lin <[email protected]>
>>> Signed-off-by: Kuan-Wei Chiu <[email protected]>
>>> ---
>>>   drivers/media/pci/cx18/cx18-av-vbi.c | 12 ++----------
>>>   1 file changed, 2 insertions(+), 10 deletions(-)
>>>
>>> diff --git a/drivers/media/pci/cx18/cx18-av-vbi.c b/drivers/media/pci/cx18/cx18-av-vbi.c
>>> index 65281d40c681..15b515b95956 100644
>>> --- a/drivers/media/pci/cx18/cx18-av-vbi.c
>>> +++ b/drivers/media/pci/cx18/cx18-av-vbi.c
>>
>> [...]
>>
>>> @@ -278,7 +270,7 @@ int cx18_av_decode_vbi_line(struct v4l2_subdev *sd,
>>>   		break;
>>>   	case 6:
>>>   		sdid = V4L2_SLICED_CAPTION_525;
>>> -		err = !odd_parity(p[0]) || !odd_parity(p[1]);
>>> +		err = !parity_odd(p[0]) || !parity_odd(p[1]);
>>
>> No need to call parity_odd() twice here. Instead you could do:
>>
>> 		err = !parity_odd(p[0] ^ p[1]);

I prefer the original approach, it is easier to understand. Performance
is not an issue here, clarity of the code is more important.

So for this patch (i.e. this v4 version):

Reviewed-by: Hans Verkuil <[email protected]>

>>
>> This is orthogonal to the change to parity_odd() though. More specific to
>> the new parity_odd() you can now do following as parity_odd() argument is
>> u64:
>>
>> 		err = !parity_odd(*(u16 *)p);
>>
>>
> Thanks for the feedback!
> Would you prefer this change to be part of the parity() conversion
> patch, or in a separate one?

Just leave it as-is, as mentioned above.

Regards,

	Hans

> 
> Regards,
> Kuan-Wei
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.