linux-i3c.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Wolfram Sang <wsa+renesas@sang-engineering.com>
To: David Laight <david.laight.linux@gmail.com>
Cc: linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org,
	linux-renesas-soc@vger.kernel.org,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	Guenter Roeck <linux@roeck-us.net>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Yury Norov <yury.norov@gmail.com>,
	Kuan-Wei Chiu <visitorckw@gmail.com>
Subject: Re: [PATCH RFT v2 1/5] bitops: add generic parity calculation for u8
Date: Thu, 2 Jan 2025 09:55:38 +0100	[thread overview]
Message-ID: <Z3ZUit3usbDSblTb@shikoro> (raw)
In-Reply-To: <20241229111129.2602d219@dsl-u17-10>


[-- Attachment #1.1: Type: text/plain, Size: 1095 bytes --]


> > +/**
> > + * parity8 - get the parity of an u8 value
> > + * @value: the value to be examined
> > + *
> > + * Determine the parity of the u8 argument.
> > + *
> > + * Returns:
> > + * 0 for even parity, 1 for odd parity
> 
> I think I'd return 0x80 for even and 0 for odd.

This would be a very non-intuitive result which makes code more
complicated to read. And increases chances that people get it wrong.

> That just need the 'magic constant' changing and masking with 0x80.

Not all users will have the parity in bit 7, some have it in bit 0, some
have it in a different register even. So, returning 0x80 would be a
micro-optimization for some cases in a code path which is not hot.

> Also rename to parity8_even() - since it returns non-zero for even parity.

The name has been agreed on with the maintainer of bitmap.h already.

> (and I'm sorry, but IMHO 0x80 is better than BIT(7))

No need to feel sorry, but it is really your HO. We have reasons for
switching from 0xXY to BIT() tree-wide. You might want to check commit
messages of such changes.


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

[-- Attachment #2: Type: text/plain, Size: 111 bytes --]

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

  reply	other threads:[~2025-01-10 11:19 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-29 10:12 [PATCH RFT v2 0/5] i3c: introduce and use generic parity helper Wolfram Sang
2024-12-29 10:12 ` [PATCH RFT v2 1/5] bitops: add generic parity calculation for u8 Wolfram Sang
2024-12-29 11:11   ` David Laight
2025-01-02  8:55     ` Wolfram Sang [this message]
2024-12-29 10:12 ` [PATCH RFT v2 2/5] hwmon: (spd5118) Use generic parity calculation Wolfram Sang
2024-12-29 10:12 ` [PATCH RFT v2 3/5] i3c: dw: use get_parity8 helper instead of open coding it Wolfram Sang
2024-12-29 10:12 ` [PATCH RFT v2 4/5] i3c: mipi-i3c-hci: " Wolfram Sang
2025-01-01 12:14   ` David Laight
2025-01-02  9:01     ` Wolfram Sang
2025-01-02 18:51       ` David Laight
2025-01-03 10:02         ` Wolfram Sang
2025-01-03 13:49           ` David Laight
2025-01-03 21:17             ` Wolfram Sang
2025-01-02 14:19   ` Jarkko Nikula
2025-01-02 14:46     ` Wolfram Sang
2024-12-29 10:12 ` [PATCH RFT v2 5/5] i3c: cdns: " Wolfram Sang
2024-12-29 10:49   ` Geert Uytterhoeven
2024-12-29 11:33     ` David Laight
2025-01-02  9:04     ` Wolfram Sang
2025-01-02  9:28       ` Geert Uytterhoeven
2025-01-02  9:34         ` Wolfram Sang
2025-01-03 22:08           ` Alexandre Belloni
2025-01-03 22:11 ` [PATCH RFT v2 0/5] i3c: introduce and use generic parity helper Alexandre Belloni
2025-01-03 22:16   ` Wolfram Sang
2025-01-05  3:38     ` Yury Norov
2025-01-05  9:35       ` 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=Z3ZUit3usbDSblTb@shikoro \
    --to=wsa+renesas@sang-engineering.com \
    --cc=david.laight.linux@gmail.com \
    --cc=geert+renesas@glider.be \
    --cc=linux-i3c@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).