lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241009181725.47ff98b8@kmaincent-XPS-13-7390>
Date: Wed, 9 Oct 2024 18:17:25 +0200
From: Kory Maincent <kory.maincent@...tlin.com>
To: Oleksij Rempel <o.rempel@...gutronix.de>
Cc: "David S. Miller" <davem@...emloft.net>, Eric Dumazet
 <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, Paolo Abeni
 <pabeni@...hat.com>, Jonathan Corbet <corbet@....net>, Donald Hunter
 <donald.hunter@...il.com>, Thomas Petazzoni <thomas.petazzoni@...tlin.com>,
 linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
 linux-doc@...r.kernel.org, Kyle Swenson <kyle.swenson@....tech>, Dent
 Project <dentproject@...uxfoundation.org>, kernel@...gutronix.de
Subject: Re: [PATCH net-next 04/12] net: pse-pd: tps23881: Add support for
 power limit and measurement features

On Wed, 9 Oct 2024 17:16:20 +0200
Oleksij Rempel <o.rempel@...gutronix.de> wrote:

> > > This is a common pattern in this driver, we read and write two registers
> > > in one run and then calculate bit offset for the channel, can you please
> > > move it in to separate function. This can be done in a separate patch if
> > > you like.  
> > 
> > The pattern is common but the operations are always different so I didn't
> > found a clean way of doing it.
> > Here is a listing of it:
> > 	if (chan < 4)
> > 		class = ret >> 4;
> > 	else
> > 		class = ret >> 12;
> > 
> > 	if (chan < 4)
> > 		val = (ret & 0xff00) | pol;
> > 	else
> > 		val = (ret & 0xff) | (pol << 8);  
> > 
> >         if (chan < 4)
> > val = (u16)(ret | BIT(chan));                                   
> >         else
> > val = (u16)(ret | BIT(chan + 4));
> > 
> > 	if (chan < 4)
> > 		mW = (ret & 0xff) * TPS23881_MW_STEP;
> > 	else
> > 		mW = (ret >> 8) * TPS23881_MW_STEP;
> > 
> > 
> > Any idea?
> >   
> 
> something like this:

Oh thanks, you rock!!
Indeed this should work, thanks for sorting this out.

Regards,
-- 
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ