[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250429142932.718a8415@kmaincent-XPS-13-7390>
Date: Tue, 29 Apr 2025 14:29:32 +0200
From: Kory Maincent <kory.maincent@...tlin.com>
To: Paolo Abeni <pabeni@...hat.com>
Cc: Andrew Lunn <andrew@...n.ch>, Oleksij Rempel <o.rempel@...gutronix.de>,
"David S. Miller" <davem@...emloft.net>, Eric Dumazet
<edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, Jonathan Corbet
<corbet@....net>, Donald Hunter <donald.hunter@...il.com>, Rob Herring
<robh@...nel.org>, Andrew Lunn <andrew+netdev@...n.ch>, Simon Horman
<horms@...nel.org>, Heiner Kallweit <hkallweit1@...il.com>, Russell King
<linux@...linux.org.uk>, Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor
Dooley <conor+dt@...nel.org>, Liam Girdwood <lgirdwood@...il.com>, Mark
Brown <broonie@...nel.org>, Thomas Petazzoni
<thomas.petazzoni@...tlin.com>, netdev@...r.kernel.org,
linux-doc@...r.kernel.org, Kyle Swenson <kyle.swenson@....tech>, Dent
Project <dentproject@...uxfoundation.org>, kernel@...gutronix.de, Maxime
Chevallier <maxime.chevallier@...tlin.com>, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next v9 03/13] net: pse-pd: tps23881: Add support
for PSE events and interrupts
On Tue, 29 Apr 2025 11:07:04 +0200
Paolo Abeni <pabeni@...hat.com> wrote:
> On 4/22/25 4:56 PM, Kory Maincent wrote:
> > +/* Convert interrupt events to 0xff to be aligned with the chan
> > + * number.
> > + */
> > +static u8 tps23881_irq_export_chans_helper(u16 reg_val, u8 field_offset)
> > +{
> > + u8 val;
> > +
> > + val = (reg_val >> (4 + field_offset) & 0xf0) |
> > + (reg_val >> field_offset & 0x0f);
>
> I'm probably low on coffee but I don't see why the above could not be
> replaced with:
>
> return reg_val >> field_offset;
>
> (given that the return type is u8)
Shift takes precedence to bit operation.
So the calculation is like:
val = ((reg_val >> (4 + field_offset)) & 0xf0) |
((reg_val >> field_offset) & 0x0f)
Supposing reg_val = 0xabcd;
- If field_offset = 0, we return 0xbd;
- If field_offset = 4, we return 0xac
Regards
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
Powered by blists - more mailing lists