Re: [PATCH 0/4] log2: make is_power_of_2() more generic

2024-04-12 Thread Jani Nikula
On Wed, 05 Apr 2023, Steven Price wrote: > On 31/03/2023 09:31, Jani Nikula wrote: >> On Thu, 30 Mar 2023, Andrew Morton wrote: >>> On Thu, 30 Mar 2023 21:53:03 + David Laight >>> wrote: >>> > But wouldn't all these issues be addressed by simply doing > > #define

Re: [PATCH 0/4] log2: make is_power_of_2() more generic

2023-04-05 Thread Steven Price
On 31/03/2023 09:31, Jani Nikula wrote: > On Thu, 30 Mar 2023, Andrew Morton wrote: >> On Thu, 30 Mar 2023 21:53:03 + David Laight >> wrote: >> But wouldn't all these issues be addressed by simply doing #define is_power_of_2(n) (n != 0 && ((n & (n - 1)) == 0)) ?

Re: [PATCH 0/4] log2: make is_power_of_2() more generic

2023-03-31 Thread Jani Nikula
On Thu, 30 Mar 2023, Andrew Morton wrote: > On Thu, 30 Mar 2023 21:53:03 + David Laight > wrote: > >> > But wouldn't all these issues be addressed by simply doing >> > >> > #define is_power_of_2(n) (n != 0 && ((n & (n - 1)) == 0)) >> > >> > ? >> > >> > (With suitable tweaks to avoid

RE: [PATCH 0/4] log2: make is_power_of_2() more generic

2023-03-31 Thread David Laight
From: Andrew Morton > Sent: 30 March 2023 23:19 > > On Thu, 30 Mar 2023 21:53:03 + David Laight > wrote: > > > > But wouldn't all these issues be addressed by simply doing > > > > > > #define is_power_of_2(n) (n != 0 && ((n & (n - 1)) == 0)) > > > > > > ? > > > > > > (With suitable tweaks

Re: [PATCH 0/4] log2: make is_power_of_2() more generic

2023-03-30 Thread Andrew Morton
On Thu, 30 Mar 2023 21:53:03 + David Laight wrote: > > But wouldn't all these issues be addressed by simply doing > > > > #define is_power_of_2(n) (n != 0 && ((n & (n - 1)) == 0)) > > > > ? > > > > (With suitable tweaks to avoid evaluating `n' more than once) > > I think you need to use

RE: [PATCH 0/4] log2: make is_power_of_2() more generic

2023-03-30 Thread David Laight
From: Andrew Morton > Sent: 30 March 2023 20:51 > > On Thu, 30 Mar 2023 13:42:39 +0300 Jani Nikula wrote: > > > is_power_of_2() only works for types <= sizeof(unsigned long) and it's > > also not a constant expression. There are a number of places in kernel > > where is_power_of_2() is called

Re: [PATCH 0/4] log2: make is_power_of_2() more generic

2023-03-30 Thread Andrew Morton
On Thu, 30 Mar 2023 13:42:39 +0300 Jani Nikula wrote: > is_power_of_2() only works for types <= sizeof(unsigned long) and it's > also not a constant expression. There are a number of places in kernel > where is_power_of_2() is called on u64, which fails on 32-bit > builds. Try to remedy that.

Re: [PATCH 0/4] log2: make is_power_of_2() more generic

2023-03-30 Thread Christian König
Am 30.03.23 um 12:42 schrieb Jani Nikula: is_power_of_2() only works for types <= sizeof(unsigned long) and it's also not a constant expression. There are a number of places in kernel where is_power_of_2() is called on u64, which fails on 32-bit builds. Try to remedy that. While at it, make it a

[PATCH 0/4] log2: make is_power_of_2() more generic

2023-03-30 Thread Jani Nikula
is_power_of_2() only works for types <= sizeof(unsigned long) and it's also not a constant expression. There are a number of places in kernel where is_power_of_2() is called on u64, which fails on 32-bit builds. Try to remedy that. While at it, make it a constant expression when possible. I admit