All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wolfram Sang <wsa+renesas@sang-engineering.com>
To: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: linux-renesas-soc@vger.kernel.org,
	Yury Norov <yury.norov@gmail.com>,
	Guenter Roeck <linux@roeck-us.net>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Kuan-Wei Chiu <visitorckw@gmail.com>
Subject: Re: [PATCH RFT 1/5] bitops: add generic parity calculation for u8
Date: Sun, 22 Dec 2024 14:00:22 +0100	[thread overview]
Message-ID: <Z2gNZtuDSwpwK3T-@ninjato> (raw)
In-Reply-To: <CAKwiHFiamZ7FgS3wbyLHo6n6R136LrLVCsih0w+spG55BPxy8g@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1366 bytes --]

Hi Rasmus,

thanks for the review!

> I know it's prototypical bikeshedding, but what's with the "get_"
> prefix? Certainly the purpose of any pure function is to "get" the
> result of some computation. We don't have "get_strlen()".

Hmmm, can be argued.

The reason I chose the naming was that the open coded implementations
were sometimes either returning the current parity or returning the bit
which you need to enforce a certain parity. And this was never obvious
from their names. Sometimes it was not even clear if the returned bit
was for odd or even parity, just for "their" parity whatever it was.

So, with "get_" I wanted to ensure that people can read from the name,
that this is about the current parity and one has to draw conclusions
from there. But maybe the kdoc documentation is good enough for this?

> Please either just "parity8", or if you want to emphasize that this
> belongs in the bit-munging family, "bit_parity8".

I'd go for 'parity8' then.

> > + *     if (get_parity8(val) == 0)
> > + *             val |= BIT(7);
> 
> Shouldn't that be ^= in general? Of course in some particular
> application one may have constructed the value in the lower 7 bits and
> "know" that bit 7 is currently clear.

Yeah, that is my use case. True, your example is more generic. Will fix.

All the best,

   Wolfram


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2024-12-22 13:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-20 11:29 [PATCH RFT 0/5] i3c: introduce and use generic parity helper Wolfram Sang
2024-12-20 11:29 ` Wolfram Sang
2024-12-20 11:29 ` [PATCH RFT 1/5] bitops: add generic parity calculation for u8 Wolfram Sang
2024-12-20 11:50   ` Rasmus Villemoes
2024-12-22 13:00     ` Wolfram Sang [this message]
2024-12-20 11:29 ` [PATCH RFT 2/5] hwmon: (spd5118) Use generic parity calculation Wolfram Sang
2024-12-20 15:23   ` Guenter Roeck
2024-12-20 11:29 ` [PATCH RFT 3/5] i3c: dw: use get_parity8 helper instead of open coding it Wolfram Sang
2024-12-20 11:29   ` Wolfram Sang
2024-12-20 11:29 ` [PATCH RFT 4/5] i3c: mipi-i3c-hci: " Wolfram Sang
2024-12-20 11:29   ` Wolfram Sang
2024-12-20 11:29 ` [PATCH RFT 5/5] i3c: cdns: " Wolfram Sang
2024-12-20 11:29   ` Wolfram Sang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z2gNZtuDSwpwK3T-@ninjato \
    --to=wsa+renesas@sang-engineering.com \
    --cc=geert+renesas@glider.be \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=linux@roeck-us.net \
    --cc=visitorckw@gmail.com \
    --cc=yury.norov@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.