[PATCH v3 1/1] int_sqrt() adjustments

2019-01-27 Thread Florian La Roche
Add __attribute_const__ and adjust to use (signed) int for the right param of "<<". Change the return value of int_sqrt() from "unsigned long" to u32 to be the same as int_sqrt64() and adjust some calling functions. Signed-off-by: Florian La Roche ---

Re: [PATCH v2 1/1] int_sqrt() adjustments

2019-01-27 Thread Florian La Roche
Hello Joe, sending in a new patch with u32 as return value and some adjusted callers of int_sqrt(). best regards, Florian La Roche

Re: [PATCH v2 1/1] int_sqrt() adjustments

2019-01-27 Thread Joe Perches
On Sun, 2019-01-27 at 21:32 +0100, Florian La Roche wrote: > Add __attribute_const__ and use normal ints for the right param of "<<". [] > diff --git a/include/linux/kernel.h b/include/linux/kernel.h [] > @@ -513,10 +513,10 @@ extern int __kernel_text_address(unsigned long addr); > extern int

[PATCH v2 1/1] int_sqrt() adjustments

2019-01-27 Thread Florian La Roche
Add __attribute_const__ and use normal ints for the right param of "<<". Signed-off-by: Florian La Roche --- include/linux/kernel.h | 4 ++-- lib/int_sqrt.c | 8 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/linux/kernel.h b/include/linux/kernel.h index

Re: [PATCH 1/1] int_sqrt() adjustments

2019-01-27 Thread Linus Torvalds
On Sun, Jan 27, 2019 at 9:06 AM Florian La Roche wrote: > > > - m = 1UL << (__fls(x) & ~1UL); > + m = 1UL << ((int)__fls(x) & ~1); No need to add the cast. It doesn't do anything and just makes the code uglier. The type of a shift operator is the type of the left side of the shift

[PATCH 1/1] int_sqrt() adjustments

2019-01-27 Thread Florian La Roche
From: Florian La Roche int_sqrt() and int_sqrt64(): Add __attribute_const__ and adjust to use (signed) int for the right param of "<<". Signed-off-by: Florian La Roche --- include/linux/kernel.h | 4 ++-- lib/int_sqrt.c | 8 2 files changed, 6 insertions(+), 6 deletions(-)

Re: int_sqrt() adjustments

2019-01-26 Thread Florian La Roche
Hello all, The first part of this patch is wrong: it changes from an unsigned long param to __fls() to an unsigned int param in fls(). One option would be to add another implementation of flsl() or given the minimalistic usage of int_sqrt() in the kernel to keep the current code with __fls() and

Re: int_sqrt() adjustments

2019-01-24 Thread Linus Torvalds
On Fri, Jan 25, 2019 at 7:58 AM Florian La Roche wrote: > > __fls() is returning an unsigned long, but fls() and fls64() are > both returning a (signed) int. > As we need a signed int as right operand of "<<" (as Linus pointed out), It's not that the "signed" part is all that important, it's

int_sqrt() adjustments

2019-01-24 Thread Florian La Roche
__fls() is returning an unsigned long, but fls() and fls64() are both returning a (signed) int. As we need a signed int as right operand of "<<" (as Linus pointed out), change __fls() to fls() for 32bit and also adjust masking the lowest bit to be a signed int. Now the 32bit and the 64bit

int_sqrt() adjustments

2019-01-24 Thread Florian La Roche
__fls() is returning an unsigned long, but fls() and fls64() are both returning a (signed) int. As we need a signed int as right operand of "<<" (as Linus pointed out), change __fls() to fls() for 32bit and also adjust masking the lowest bit to be a signed int. Now the 32bit and the 64bit